build, docs: Replace python-based with cmake-based .ns3rc files

This commit is contained in:
Gabriel Ferreira
2022-07-21 22:15:19 -03:00
parent 4e03143b2e
commit 3e43ef1742
8 changed files with 350 additions and 190 deletions

View File

@@ -55,6 +55,9 @@ Changes from ns-3.36 to ns-3.37
* Replaced `./ns3 --check-profile` with `./ns3 show profile`. * Replaced `./ns3 --check-profile` with `./ns3 show profile`.
* Replaced `./ns3 --check-version` with `./ns3 show version`. * Replaced `./ns3 --check-version` with `./ns3 show version`.
* Added the `build_exec` macro to declare new executables. * Added the `build_exec` macro to declare new executables.
* Replaced Python-based .ns3rc with a CMake-based version.
* Deprecated .ns3rc files will be updated to the new CMake-based format and a backup will be placed alongside it.
### Changed behavior ### Changed behavior

View File

@@ -109,12 +109,15 @@ subdirlist(libs_to_build ${CMAKE_CURRENT_SOURCE_DIR}/src)
subdirlist(contrib_libs_to_build ${CMAKE_CURRENT_SOURCE_DIR}/contrib) subdirlist(contrib_libs_to_build ${CMAKE_CURRENT_SOURCE_DIR}/contrib)
# Before filtering, we need to load settings from .ns3rc # Before filtering, we need to load settings from .ns3rc
parse_ns3rc(ns3rc_enabled_modules ns3rc_examples_enabled ns3rc_tests_enabled) parse_ns3rc(
ns3rc_enabled_modules ns3rc_disabled_modules ns3rc_examples_enabled
ns3rc_tests_enabled
)
# After scanning modules, we can filter enabled and disabled ones # After scanning modules, we can filter enabled and disabled ones
filter_enabled_and_disabled_modules( filter_enabled_and_disabled_modules(
libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES
ns3rc_enabled_modules ns3rc_enabled_modules ns3rc_disabled_modules
) )
# ############################################################################## # ##############################################################################

View File

@@ -0,0 +1,21 @@
# A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also.
#
# All modules can be enabled by emptying the list.
set(ns3rc_enabled_modules @ns3rc_enabled_modules@)
# A list of the modules that will be disabled when ns-3 is run.
# Modules that depend on the listed modules will be disabled also.
#
# If the list is empty, no module will be disabled.
set(ns3rc_disabled_modules @ns3rc_disabled_modules@)
# Set this equal to ON if you want examples to be run.
set(ns3rc_examples_enabled @ns3rc_examples_enabled@)
# Set this equal to ON if you want tests to be run.
set(ns3rc_tests_enabled @ns3rc_tests_enabled@)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)

View File

@@ -1628,8 +1628,14 @@ function(recursive_dependency module_name)
endforeach() endforeach()
endfunction() endfunction()
macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build macro(
NS3_ENABLED_MODULES NS3_DISABLED_MODULES ns3rc_enabled_modules filter_enabled_and_disabled_modules
libs_to_build
contrib_libs_to_build
NS3_ENABLED_MODULES
NS3_DISABLED_MODULES
ns3rc_enabled_modules
ns3rc_disabled_modules
) )
mark_as_advanced(ns3-all-enabled-modules) mark_as_advanced(ns3-all-enabled-modules)
@@ -1676,7 +1682,14 @@ macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build
endif() endif()
endif() endif()
if(${NS3_DISABLED_MODULES}) if(${NS3_DISABLED_MODULES} OR ${ns3rc_disabled_modules})
# List of disabled modules passed by the command line overwrites list read
# from ns3rc
if(${NS3_DISABLED_MODULES})
set(ns3rc_disabled_modules ${${NS3_DISABLED_MODULES}})
endif()
set(all_libs ${${libs_to_build}};${${contrib_libs_to_build}}) set(all_libs ${${libs_to_build}};${${contrib_libs_to_build}})
# We then use the recursive dependency finding to get all dependencies of # We then use the recursive dependency finding to get all dependencies of
@@ -1689,7 +1702,7 @@ macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build
endforeach() endforeach()
# Now we can begin removing libraries that require disabled dependencies # Now we can begin removing libraries that require disabled dependencies
set(disabled_libs "${${NS3_DISABLED_MODULES}}") set(disabled_libs "${${ns3rc_disabled_modules}}")
foreach(libo ${all_libs}) foreach(libo ${all_libs})
foreach(lib ${all_libs}) foreach(lib ${all_libs})
foreach(disabled_lib ${disabled_libs}) foreach(disabled_lib ${disabled_libs})
@@ -1735,61 +1748,98 @@ macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build
endmacro() endmacro()
# Parse .ns3rc # Parse .ns3rc
function(parse_ns3rc enabled_modules examples_enabled tests_enabled) macro(parse_ns3rc enabled_modules disabled_modules examples_enabled
set(ns3rc ${PROJECT_SOURCE_DIR}/.ns3rc) tests_enabled
# Set parent scope variables with default values (all modules, no examples nor )
# tests) # Try to find .ns3rc
set(${enabled_modules} "" PARENT_SCOPE) find_file(NS3RC .ns3rc PATHS /etc $ENV{HOME} $ENV{USERPROFILE}
set(${examples_enabled} "FALSE" PARENT_SCOPE) ${PROJECT_SOURCE_DIR} NO_CACHE
set(${tests_enabled} "FALSE" PARENT_SCOPE) )
if(EXISTS ${ns3rc})
# If ns3rc exists in ns-3-dev, read it
file(READ ${ns3rc} ns3rc_contents)
# Match modules_enabled list # Set variables with default values (all modules, no examples nor tests)
if(ns3rc_contents MATCHES "modules_enabled.*\\[(.*).*\\]") set(${enabled_modules} "")
set(${enabled_modules} ${CMAKE_MATCH_1}) set(${disabled_modules} "")
if(${enabled_modules} MATCHES "all_modules") set(${examples_enabled} "FALSE")
# If all modules, just clean the filter and all modules will get built set(${tests_enabled} "FALSE")
# by default
set(${enabled_modules})
else()
# If modules are listed, remove quotes and replace commas with
# semicolons transforming a string into a cmake list
string(REPLACE "," ";" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "'" "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "\"" "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE " " "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "\n" ";" ${enabled_modules} "${${enabled_modules}}")
list(SORT ${enabled_modules})
# Remove possibly empty entry if(NOT (${NS3RC} STREQUAL "NS3RC-NOTFOUND"))
list(REMOVE_ITEM ${enabled_modules} "") message(${HIGHLIGHTED_STATUS}
foreach(element ${${enabled_modules}}) "Configuration file .ns3rc being used : ${NS3RC}"
# Inspect each element for comments )
if(${element} MATCHES "#.*") file(READ ${NS3RC} ns3rc_contents)
list(REMOVE_ITEM ${enabled_modules} ${element}) # Check if ns3rc file is CMake or Python based and act accordingly
endif() if(ns3rc_contents MATCHES "ns3rc_*")
endforeach() include(${NS3RC})
endif() else()
parse_python_ns3rc(
"${ns3rc_contents}" ${enabled_modules} ${examples_enabled}
${tests_enabled} ${NS3RC}
)
endif() endif()
# Match examples_enabled flag
if(ns3rc_contents MATCHES "examples_enabled = (True|False)")
set(${examples_enabled} ${CMAKE_MATCH_1})
endif()
# Match tests_enabled flag
if(ns3rc_contents MATCHES "tests_enabled = (True|False)")
set(${tests_enabled} ${CMAKE_MATCH_1})
endif()
# Save variables to parent scope
set(${enabled_modules} "${${enabled_modules}}" PARENT_SCOPE)
set(${examples_enabled} "${${examples_enabled}}" PARENT_SCOPE)
set(${tests_enabled} "${${tests_enabled}}" PARENT_SCOPE)
endif() endif()
endfunction(parse_ns3rc) endmacro(parse_ns3rc)
function(parse_python_ns3rc ns3rc_contents enabled_modules examples_enabled
tests_enabled ns3rc_location
)
# Save .ns3rc backup
file(WRITE ${ns3rc_location}.backup ${ns3rc_contents})
# Match modules_enabled list
if(ns3rc_contents MATCHES "modules_enabled.*\\[(.*).*\\]")
set(${enabled_modules} ${CMAKE_MATCH_1})
if(${enabled_modules} MATCHES "all_modules")
# If all modules, just clean the filter and all modules will get built by
# default
set(${enabled_modules})
else()
# If modules are listed, remove quotes and replace commas with semicolons
# transforming a string into a cmake list
string(REPLACE "," ";" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "'" "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "\"" "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE " " "" ${enabled_modules} "${${enabled_modules}}")
string(REPLACE "\n" ";" ${enabled_modules} "${${enabled_modules}}")
list(SORT ${enabled_modules})
# Remove possibly empty entry
list(REMOVE_ITEM ${enabled_modules} "")
foreach(element ${${enabled_modules}})
# Inspect each element for comments
if(${element} MATCHES "#.*")
list(REMOVE_ITEM ${enabled_modules} ${element})
endif()
endforeach()
endif()
endif()
string(REPLACE "True" "ON" ns3rc_contents ${ns3rc_contents})
string(REPLACE "False" "OFF" ns3rc_contents ${ns3rc_contents})
# Match examples_enabled flag
if(ns3rc_contents MATCHES "examples_enabled = (ON|OFF)")
set(${examples_enabled} ${CMAKE_MATCH_1})
endif()
# Match tests_enabled flag
if(ns3rc_contents MATCHES "tests_enabled = (ON|OFF)")
set(${tests_enabled} ${CMAKE_MATCH_1})
endif()
# Save variables to parent scope
set(${enabled_modules} "${${enabled_modules}}" PARENT_SCOPE)
set(${examples_enabled} "${${examples_enabled}}" PARENT_SCOPE)
set(${tests_enabled} "${${tests_enabled}}" PARENT_SCOPE)
# Save updated .ns3rc file
message(
${HIGHLIGHTED_STATUS}
"The python-based .ns3rc file format is deprecated and was updated to the CMake format"
)
configure_file(
${PROJECT_SOURCE_DIR}/build-support/.ns3rc-template ${ns3rc_location} @ONLY
)
endfunction(parse_python_ns3rc)
function(log_find_searched_paths) function(log_find_searched_paths)
# Parse arguments # Parse arguments

View File

@@ -91,39 +91,55 @@ Assuming that you are in the top level |ns3| directory, you can get a copy of th
The .ns3rc file should now be in your top level |ns3| directory, and it contains the following: The .ns3rc file should now be in your top level |ns3| directory, and it contains the following:
.. sourcecode:: python .. sourcecode:: cmake
#! /usr/bin/env python # A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also.
#
# All modules can be enabled by emptying the list.
set(ns3rc_enabled_modules)
# A list of the modules that will be enabled when ns-3 is run. # A list of the modules that will be disabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also. # Modules that depend on the listed modules will be disabled also.
# #
# All modules can be enabled by choosing 'all_modules'. # If the list is empty, no module will be disabled.
modules_enabled = ['all_modules'] set(ns3rc_disabled_modules)
# Set this equal to true if you want examples to be run. # Set this equal to ON if you want examples to be run.
examples_enabled = False set(ns3rc_examples_enabled OFF)
# Set this equal to true if you want tests to be run. # Set this equal to ON if you want tests to be run.
tests_enabled = False set(ns3rc_tests_enabled OFF)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)
Use your favorite editor to modify the .ns3rc file to only enable the core module with examples and tests like this: Use your favorite editor to modify the .ns3rc file to only enable the core module with examples and tests like this:
.. sourcecode:: python .. sourcecode:: cmake
#! /usr/bin/env python # A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also.
#
# All modules can be enabled by emptying the list.
set(ns3rc_enabled_modules core)
# A list of the modules that will be enabled when ns-3 is run. # A list of the modules that will be disabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also. # Modules that depend on the listed modules will be disabled also.
# #
# All modules can be enabled by choosing 'all_modules'. # If the list is empty, no module will be disabled.
modules_enabled = ['core'] set(ns3rc_disabled_modules)
# Set this equal to true if you want examples to be run. # Set this equal to ON if you want examples to be run.
examples_enabled = True set(ns3rc_examples_enabled ON)
# Set this equal to true if you want tests to be run. # Set this equal to ON if you want tests to be run.
tests_enabled = True set(ns3rc_tests_enabled ON)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)
Only the core module will be enabled now if you try these commands: :: Only the core module will be enabled now if you try these commands: ::

View File

@@ -98,21 +98,29 @@ Assuming that you are in the top level |ns3| directory, you can get a copy of th
The .ns3rc file should now be in your top level |ns3| directory, and it contains the following: The .ns3rc file should now be in your top level |ns3| directory, and it contains the following:
.. sourcecode:: python .. sourcecode:: cmake
#! /usr/bin/env python # A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also.
#
# All modules can be enabled by emptying the list.
set(ns3rc_enabled_modules)
# A list of the modules that will be enabled when ns-3 is run. # A list of the modules that will be disabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also. # Modules that depend on the listed modules will be disabled also.
# #
# All modules can be enabled by choosing 'all_modules'. # If the list is empty, no module will be disabled.
modules_enabled = ['all_modules'] set(ns3rc_disabled_modules)
# Set this equal to true if you want examples to be run. # Set this equal to ON if you want examples to be run.
examples_enabled = False set(ns3rc_examples_enabled OFF)
# Set this equal to true if you want tests to be run. # Set this equal to ON if you want tests to be run.
tests_enabled = False set(ns3rc_tests_enabled OFF)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)
From the top level |ns3| directory, you can build |ns3| without any From the top level |ns3| directory, you can build |ns3| without any
examples or tests simply by doing: :: examples or tests simply by doing: ::
@@ -128,23 +136,31 @@ Running test.py now will cause no examples or tests to be run:
If you would like build |ns3| with examples and tests, use your If you would like build |ns3| with examples and tests, use your
favorite editor to change the values in the .ns3rc file for favorite editor to change the values in the .ns3rc file for
examples_enabled and tests_enabled file to be True: ns3rc_examples_enabled and ns3rc_tests_enabled file to be True:
.. sourcecode:: python .. sourcecode:: cmake
#! /usr/bin/env python # A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also.
#
# All modules can be enabled by emptying the list.
set(ns3rc_enabled_modules)
# A list of the modules that will be enabled when ns-3 is run. # A list of the modules that will be disabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also. # Modules that depend on the listed modules will be disabled also.
# #
# All modules can be enabled by choosing 'all_modules'. # If the list is empty, no module will be disabled.
modules_enabled = ['all_modules'] set(ns3rc_disabled_modules)
# Set this equal to true if you want examples to be run. # Set this equal to ON if you want examples to be run.
examples_enabled = True set(ns3rc_examples_enabled ON)
# Set this equal to true if you want tests to be run. # Set this equal to ON if you want tests to be run.
tests_enabled = True set(ns3rc_tests_enabled ON)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)
From the top level |ns3| directory, you can build |ns3| with examples From the top level |ns3| directory, you can build |ns3| with examples
and tests simply by doing: :: and tests simply by doing: ::

View File

@@ -1,13 +1,21 @@
#! /usr/bin/env python
# A list of the modules that will be enabled when ns-3 is run. # A list of the modules that will be enabled when ns-3 is run.
# Modules that depend on the listed modules will be enabled also. # Modules that depend on the listed modules will be enabled also.
# #
# All modules can be enabled by choosing 'all_modules'. # All modules can be enabled by emptying the list.
modules_enabled = ['all_modules'] set(ns3rc_enabled_modules)
# Set this equal to true if you want examples to be run. # A list of the modules that will be disabled when ns-3 is run.
examples_enabled = False # Modules that depend on the listed modules will be disabled also.
#
# If the list is empty, no module will be disabled.
set(ns3rc_disabled_modules)
# Set this equal to true if you want tests to be run. # Set this equal to ON if you want examples to be run.
tests_enabled = False set(ns3rc_examples_enabled OFF)
# Set this equal to ON if you want tests to be run.
set(ns3rc_tests_enabled OFF)
# Override other ns-3 settings by setting their values below
# Note: command-line settings will also be overridden.
#set(NS3_LOG ON)

View File

@@ -834,101 +834,144 @@ class NS3ConfigureTestCase(NS3BaseTestCase):
Test loading settings from the ns3rc config file Test loading settings from the ns3rc config file
@return None @return None
""" """
ns3rc_template = "# ! /usr/bin/env python\
\
# A list of the modules that will be enabled when ns-3 is run.\
# Modules that depend on the listed modules will be enabled also.\
#\
# All modules can be enabled by choosing 'all_modules'.\
modules_enabled = [{modules}]\
\
# Set this equal to true if you want examples to be run.\
examples_enabled = {examples}\
\
# Set this equal to true if you want tests to be run.\
tests_enabled = {tests}\
"
# Now we repeat the command line tests but with the ns3rc file. class ns3rc_str:
with open(ns3rc_script, "w") as f: ## python-based ns3rc template # noqa
f.write(ns3rc_template.format(modules="'lte'", examples="False", tests="True")) ns3rc_python_template = "# ! /usr/bin/env python\
\
# A list of the modules that will be enabled when ns-3 is run.\
# Modules that depend on the listed modules will be enabled also.\
#\
# All modules can be enabled by choosing 'all_modules'.\
modules_enabled = [{modules}]\
\
# Set this equal to true if you want examples to be run.\
examples_enabled = {examples}\
\
# Set this equal to true if you want tests to be run.\
tests_enabled = {tests}\
"
# Reconfigure. ## cmake-based ns3rc template # noqa
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"") ns3rc_cmake_template = "set(ns3rc_tests_enabled {tests})\
self.config_ok(return_code, stdout) \nset(ns3rc_examples_enabled {examples})\
\nset(ns3rc_enabled_modules {modules})\
"
# Check. ## map ns3rc templates to types # noqa
enabled_modules = get_enabled_modules() ns3rc_templates = {
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) "python": ns3rc_python_template,
self.assertIn("ns3-lte", enabled_modules) "cmake": ns3rc_cmake_template
self.assertTrue(get_test_enabled()) }
self.assertEqual(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with the wifi module, enabling examples and disabling tests def __init__(self, ns3rc_type):
with open(ns3rc_script, "w") as f: self.type = ns3rc_type
f.write(ns3rc_template.format(modules="'wifi'", examples="True", tests="False"))
# Reconfigure def format(self, **args):
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"") # Convert arguments from python-based ns3rc format to CMake
self.config_ok(return_code, stdout) if self.type == "cmake":
args["modules"] = args["modules"].replace("'", "").replace("\"", "").replace(",", " ")
args["examples"] = "ON" if args["examples"] == "True" else "OFF"
args["tests"] = "ON" if args["tests"] == "True" else "OFF"
# Check formatted_string = ns3rc_str.ns3rc_templates[self.type].format(**args)
enabled_modules = get_enabled_modules()
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertIn("ns3-wifi", enabled_modules)
self.assertFalse(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with multiple modules # Return formatted string
with open(ns3rc_script, "w") as f: return formatted_string
f.write(ns3rc_template.format(modules="'core','network'", examples="True", tests="False"))
# Reconfigure @staticmethod
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"") def types():
self.config_ok(return_code, stdout) return ns3rc_str.ns3rc_templates.keys()
# Check for ns3rc_type in ns3rc_str.types():
enabled_modules = get_enabled_modules() # Replace default format method from string with a custom one
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) ns3rc_template = ns3rc_str(ns3rc_type)
self.assertIn("ns3-core", enabled_modules)
self.assertIn("ns3-network", enabled_modules)
self.assertFalse(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with multiple modules, # Now we repeat the command line tests but with the ns3rc file.
# in various different ways and with comments with open(ns3rc_script, "w") as f:
with open(ns3rc_script, "w") as f: f.write(ns3rc_template.format(modules="'lte'", examples="False", tests="True"))
f.write(ns3rc_template.format(modules="""'core', #comment
'lte',
#comment2,
#comment3
'network', 'internet','wimax'""", examples="True", tests="True"))
# Reconfigure # Reconfigure.
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"") return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"")
self.config_ok(return_code, stdout) self.config_ok(return_code, stdout)
# Check # Check.
enabled_modules = get_enabled_modules() enabled_modules = get_enabled_modules()
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertIn("ns3-core", enabled_modules) self.assertIn("ns3-lte", enabled_modules)
self.assertIn("ns3-internet", enabled_modules) self.assertTrue(get_test_enabled())
self.assertIn("ns3-lte", enabled_modules) self.assertEqual(len(get_programs_list()), len(self.ns3_executables))
self.assertIn("ns3-wimax", enabled_modules)
self.assertTrue(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Then we roll back by removing the ns3rc config file # Replace the ns3rc file with the wifi module, enabling examples and disabling tests
os.remove(ns3rc_script) with open(ns3rc_script, "w") as f:
f.write(ns3rc_template.format(modules="'wifi'", examples="True", tests="False"))
# Reconfigure # Reconfigure
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"") return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"")
self.config_ok(return_code, stdout) self.config_ok(return_code, stdout)
# Check # Check
self.assertEqual(len(get_enabled_modules()), len(self.ns3_modules)) enabled_modules = get_enabled_modules()
self.assertFalse(get_test_enabled()) self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertEqual(len(get_programs_list()), len(self.ns3_executables)) self.assertIn("ns3-wifi", enabled_modules)
self.assertFalse(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with multiple modules
with open(ns3rc_script, "w") as f:
f.write(ns3rc_template.format(modules="'core','network'", examples="True", tests="False"))
# Reconfigure
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"")
self.config_ok(return_code, stdout)
# Check
enabled_modules = get_enabled_modules()
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertIn("ns3-core", enabled_modules)
self.assertIn("ns3-network", enabled_modules)
self.assertFalse(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Replace the ns3rc file with multiple modules,
# in various different ways and with comments
with open(ns3rc_script, "w") as f:
if ns3rc_type == "python":
f.write(ns3rc_template.format(modules="""'core', #comment
'lte',
#comment2,
#comment3
'network', 'internet','wimax'""", examples="True", tests="True"))
else:
f.write(ns3rc_template.format(modules="'core', 'lte', 'network', 'internet', 'wimax'",
examples="True",
tests="True")
)
# Reconfigure
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"")
self.config_ok(return_code, stdout)
# Check
enabled_modules = get_enabled_modules()
self.assertLess(len(get_enabled_modules()), len(self.ns3_modules))
self.assertIn("ns3-core", enabled_modules)
self.assertIn("ns3-internet", enabled_modules)
self.assertIn("ns3-lte", enabled_modules)
self.assertIn("ns3-wimax", enabled_modules)
self.assertTrue(get_test_enabled())
self.assertGreater(len(get_programs_list()), len(self.ns3_executables))
# Then we roll back by removing the ns3rc config file
os.remove(ns3rc_script)
# Reconfigure
return_code, stdout, stderr = run_ns3("configure -G \"Unix Makefiles\"")
self.config_ok(return_code, stdout)
# Check
self.assertEqual(len(get_enabled_modules()), len(self.ns3_modules))
self.assertFalse(get_test_enabled())
self.assertEqual(len(get_programs_list()), len(self.ns3_executables))
def test_08_DryRun(self): def test_08_DryRun(self):
"""! """!