Skip to content

Commit

Permalink
Prevent copying cmake-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pagmatt committed Jan 27, 2023
1 parent ba896e3 commit eff5f24
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
42 changes: 26 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ def get_build_program(ns_3_dir):
if os.path.exists(os.path.join(ns_3_dir, "ns3")):
return "./ns3"
else:
return "./waf"
return "python3 ./waf"

@pytest.fixture(scope='function')
def ns_3(tmpdir):
# Copy the test ns-3 installation in the temporary directory
ns_3_tempdir = tmpdir.join('ns-3')
shutil.copytree(ns_3_test, str(ns_3_tempdir), symlinks=True)
shutil.copytree(ns_3_test, str(ns_3_tempdir), symlinks=True,
# Do not copy cmake's cache, as it is directory-dependant
ignore=shutil.ignore_patterns("cmake-cache"))
return ns_3_tempdir


Expand All @@ -39,15 +41,15 @@ def ns_3_compiled(tmpdir):
build_program = get_build_program(ns_3_tempdir)

# Relocate build by running the same command in the new directory
if subprocess.call(['python3', build_program, 'configure', '--disable-gtk',
if subprocess.call([build_program, 'configure', '--disable-gtk',
'--build-profile=optimized',
'--out=build/optimized'],
cwd=ns_3_tempdir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
raise Exception("Configuration failed")

if subprocess.call(['python3', build_program, 'build'],
if subprocess.call([build_program, 'build'],
cwd=ns_3_tempdir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
Expand All @@ -60,20 +62,22 @@ def ns_3_compiled(tmpdir):
def ns_3_compiled_debug(tmpdir):
# Copy the test ns-3 installation in the temporary directory
ns_3_tempdir = str(tmpdir.join('ns-3-compiled-debug'))
shutil.copytree(ns_3_test_compiled_debug, ns_3_tempdir, symlinks=True)
shutil.copytree(ns_3_test_compiled_debug, ns_3_tempdir, symlinks=True,
# Do not copy cmake's cache, as it is directory-dependant
ignore=shutil.ignore_patterns("cmake-cache"))

build_program = get_build_program(ns_3_tempdir)

# Relocate build by running the same command in the new directory
if subprocess.call(['python3', build_program, 'configure', '--disable-gtk',
if subprocess.call([build_program, 'configure', '--disable-gtk',
'--build-profile=debug',
'--out=build'],
cwd=ns_3_tempdir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
raise Exception("Configuration failed")

if subprocess.call(['python3', build_program, 'build'],
if subprocess.call([build_program, 'build'],
cwd=ns_3_tempdir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
Expand Down Expand Up @@ -151,51 +155,57 @@ def get_and_compile_ns_3():

# Copy folder to compile in optimized mode
if not os.path.exists(ns_3_test_compiled):
shutil.copytree(ns_3_test, ns_3_test_compiled, symlinks=True)
shutil.copytree(ns_3_test, ns_3_test_compiled, symlinks=True,
# Do not copy cmake's cache, as it is directory-dependant
ignore=shutil.ignore_patterns("cmake-cache"))

# Copy folder to compile in debug mode
if not os.path.exists(ns_3_test_compiled_debug):
shutil.copytree(ns_3_test, ns_3_test_compiled_debug, symlinks=True)
shutil.copytree(ns_3_test, ns_3_test_compiled_debug, symlinks=True,
# Do not copy cmake's cache, as it is directory-dependant
ignore=shutil.ignore_patterns("cmake-cache"))

# Copy folder to run examples
if not os.path.exists(ns_3_examples):
shutil.copytree(ns_3_test, ns_3_examples, symlinks=True)
shutil.copytree(ns_3_test, ns_3_examples, symlinks=True,
# Do not copy cmake's cache, as it is directory-dependant
ignore=shutil.ignore_patterns("cmake-cache"))

build_program = get_build_program(ns_3_test_compiled)

if subprocess.call(['python3', build_program, 'configure', '--disable-gtk',
if subprocess.call([build_program, 'configure', '--disable-gtk',
'--build-profile=optimized',
'--out=build/optimized'],
cwd=ns_3_test_compiled,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT) != 0:
raise Exception("Optimized test configuration failed.")

if subprocess.call(['python3', build_program, 'build'],
if subprocess.call([build_program, 'build'],
cwd=ns_3_test_compiled,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
raise Exception("Optimized test build failed.")

build_program = get_build_program(ns_3_test_compiled_debug)

if subprocess.call(['python3', build_program, 'configure', '--disable-gtk',
if subprocess.call([build_program, 'configure', '--disable-gtk',
'--build-profile=debug',
'--out=build'],
cwd=ns_3_test_compiled_debug,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT) != 0:
raise Exception("Debug test configuration failed.")

if subprocess.call(['python3', build_program, 'build'],
if subprocess.call([build_program, 'build'],
cwd=ns_3_test_compiled,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
raise Exception("Debug test build failed.")

build_program = get_build_program(ns_3_examples)

if subprocess.call(['python3', build_program, 'configure', '--disable-gtk',
if subprocess.call([build_program, 'configure', '--disable-gtk',
'--build-profile=optimized',
'--out=build/optimized'],
cwd=ns_3_examples,
Expand All @@ -204,7 +214,7 @@ def get_and_compile_ns_3():

raise Exception("Examples configuration failed.")

if subprocess.call(['python3', build_program, 'build'],
if subprocess.call([build_program, 'build'],
cwd=ns_3_test_compiled,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) > 0:
Expand Down
1 change: 1 addition & 0 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_load_campaign(manager, config, parameter_combination):
del config['campaign_dir']
assert loaded_manager.db.get_config() == config
# This campaign should not be able to run simulations
#TODO: Why, no runner ? Also how can the two configs be equal ?
with pytest.raises(Exception):
loaded_manager.run_simulations([parameter_combination])

Expand Down

0 comments on commit eff5f24

Please sign in to comment.