2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 01:49:48 +00:00

[#3732] Meson: Add gtest.cc compiler check to detect crashes

This commit is contained in:
Andrei Pavel 2025-04-22 23:08:26 +03:00
parent 53342bf8ca
commit 80fc384e21
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
2 changed files with 28 additions and 5 deletions

12
compiler-checks/gtest.cc Normal file
View File

@ -0,0 +1,12 @@
#include <gtest/gtest.h>
// musl's mallocng memory allocator stupidly crash for test names that are
// lengthier than 16 characters. Hence the long test name.
TEST(Fixture, testWithLongLongLongName) {
EXPECT_LT(1, 2);
}
int main() {
testing::InitGoogleTest();
return RUN_ALL_TESTS();
}

View File

@ -244,11 +244,22 @@ if netconf_opt.enabled() and NETCONF_DEP.get_variable(
error('Dependency not found: NETCONF.')
endif
GTEST_DEP = dependency(
'gtest',
fallback: ['gtest', 'gtest_dep'],
required: TESTS_OPT.enabled() or FUZZ_OPT.enabled(),
)
# Google Test
GTEST_DEP = dependency('gtest', required: TESTS_OPT.enabled() or FUZZ_OPT.enabled())
if GTEST_DEP.found()
result = cpp.run(
fs.read('compiler-checks/gtest.cc'),
name: 'Check if a simple GTest test runs.',
dependencies: [GTEST_DEP],
)
if result.returncode() != 0
GTEST_DEP = disabler()
gtest_subproject = subproject('gtest', required: false)
if gtest_subproject.found()
GTEST_DEP = gtest_subproject.get_variable('gtest_dep')
endif
endif
endif
# Crypto
if crypto_opt == 'botan'