build: do not build the test object library when tests are disabled

This commit is contained in:
Gabriel Ferreira
2023-04-01 17:02:06 -03:00
parent 13a42a5a9a
commit 71c1fba5a0
2 changed files with 18 additions and 5 deletions

View File

@@ -410,6 +410,8 @@ macro(process_options)
if(${NS3_TESTS} OR ${ns3rc_tests_enabled})
set(ENABLE_TESTS ON)
enable_testing()
else()
list(REMOVE_ITEM libs_to_build test)
endif()
set(profiles_without_suffixes release)
@@ -1929,10 +1931,6 @@ macro(
unset(dependencies)
unset(contrib_dependencies)
endforeach()
if(core IN_LIST ${libs_to_build})
list(APPEND ${libs_to_build} test) # include test module
endif()
endif()
if(${NS3_DISABLED_MODULES} OR ${ns3rc_disabled_modules})

View File

@@ -970,7 +970,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase):
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertIn("ns3-lte", enabled_modules)
self.assertTrue(get_test_enabled())
self.assertGreaterEqual(len(get_programs_list()), len(self.ns3_executables))
self.assertLessEqual(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with the wifi module, enabling examples and disabling tests
with open(ns3rc_script, "w") as f:
@@ -1839,6 +1839,21 @@ class NS3ConfigureTestCase(NS3BaseTestCase):
except DockerException as e:
self.assertTrue(False, "Precompiled headers should have been enabled")
def test_24_CheckTestSettings(self):
"""!
Check for regressions in test object build.
@return None
"""
return_code, stdout, stderr = run_ns3('configure')
self.assertEqual(return_code, 0)
test_module_cache = os.path.join(ns3_path, "cmake-cache", "src", "test")
self.assertFalse(os.path.exists(test_module_cache))
return_code, stdout, stderr = run_ns3('configure --enable-tests')
self.assertEqual(return_code, 0)
self.assertTrue(os.path.exists(test_module_cache))
class NS3BuildBaseTestCase(NS3BaseTestCase):
"""!