diff --git a/tests/conftest.py b/tests/conftest.py index e48f381..fd233fb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,7 +42,7 @@ def ns_3_compiled(tmpdir): # Relocate build by running the same command in the new directory if subprocess.call([build_program, 'configure', '--disable-gtk', - '--build-profile=optimized', '--enable-modules=core', + '--build-profile=optimized', '--enable-modules=core', '--enable-examples', '--out=build/optimized'], cwd=ns_3_tempdir, stdout=subprocess.DEVNULL, @@ -70,7 +70,7 @@ def ns_3_compiled_debug(tmpdir): # Relocate build by running the same command in the new directory if subprocess.call([build_program, 'configure', '--disable-gtk', - '--build-profile=debug', '--enable-modules=core', + '--build-profile=debug', '--enable-modules=core', '--enable-examples', '--out=build'], cwd=ns_3_tempdir, stdout=subprocess.DEVNULL, @@ -85,6 +85,26 @@ def ns_3_compiled_debug(tmpdir): return ns_3_tempdir +@pytest.fixture(scope='function') +def ns_3_compiled_examples(): + # Configure and build WAF-based ns-3 + build_program = get_build_program(ns_3_examples) + + if subprocess.call([build_program, 'configure', '--disable-gtk', + '--build-profile=optimized', '--enable-modules=core', + '--out=build/optimized'], + cwd=ns_3_examples, + stdout=subprocess.DEVNULL, + stderr=subprocess.STDOUT) != 0: + raise Exception("Examples configuration failed.") + + if subprocess.call([build_program, 'build'], + cwd=ns_3_examples, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) > 0: + raise Exception("Examples build failed.") + + return ns_3_examples @pytest.fixture(scope='function') def config(tmpdir, ns_3_compiled): diff --git a/tests/test_runner.py b/tests/test_runner.py index 9c9e2db..18d3672 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -6,11 +6,21 @@ # Runner creation # ################### +""" +First param: Runner type +Second param: Whether to use optimized build +Third param: Whether to use the CMake-version of ns-3 +""" +@pytest.fixture(scope='function', params=[['ParallelRunner', True, True], + ['ParallelRunner', True, False]]) +def runner(ns_3_compiled, ns_3_compiled_debug, ns_3_compiled_examples, config, request): + ns_3_folder = ns_3_compiled + if request.param[1] is False: + ns_3_folder = ns_3_compiled_debug + if request.param[2] is True: + assert(request.param[1] is True) + ns_3_folder = ns_3_compiled_examples -@pytest.fixture(scope='function', params=[['ParallelRunner', True], - ['ParallelRunner', False]]) -def runner(ns_3_compiled, ns_3_compiled_debug, config, request): - ns_3_folder = ns_3_compiled if request.param[1] is True else ns_3_compiled_debug if request.param[0] == 'SimulationRunner': return SimulationRunner(ns_3_folder, config['script'], optimized=request.param[1]) @@ -18,7 +28,6 @@ def runner(ns_3_compiled, ns_3_compiled_debug, config, request): return ParallelRunner(ns_3_folder, config['script'], optimized=request.param[1]) - def test_get_available_parameters(runner, config): # Try getting the available parameters of the script assert runner.get_available_parameters() == config['params'] @@ -26,13 +35,15 @@ def test_get_available_parameters(runner, config): @pytest.mark.parametrize('runner', [ - ['SimulationRunner', True], - ['ParallelRunner', True], + ['SimulationRunner', True, True], + ['ParallelRunner', True, True], + ['ParallelRunner', True, False], ], indirect=True) def test_run_simulations(runner, config, parameter_combination): - # Make sure that simulations run without any issue + # Make sure that simulations run without any issue, + # with CMake optimized and debug builds, and Waf optimized builds data_dir = os.path.join(config['campaign_dir'], 'data') list(runner.run_simulations([parameter_combination], data_dir))