Skip to content

Commit 4349471

Browse files
committed
resolves config file location relative to the test's own location
1 parent 3eb1d6c commit 4349471

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

test/python/dtl_config.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,30 @@
33
# This program is free software you can redistribute it and/or modify it
44
# under the terms of the license (GNU LGPL) which comes with this package.
55

6+
import os
67
import sys
78
import multiprocessing
89
from simgrid import Engine, this_actor
910
from fsmod import FileSystem, OneDiskStorage
1011
from dtlmod import DTL, Stream, Transport, Engine as DTLEngine
1112

13+
# Locate DTL-config.json relative to this script rather than to the current working directory, so the test can be
14+
# launched from anywhere. CMake stages the file under <build>/config_files/test/ (canonical, used by CI); the second
15+
# candidate is the source-tree location (test/DTL-config.json) so the test also works when run from the sources.
16+
_HERE = os.path.dirname(os.path.abspath(__file__))
17+
_CONFIG_CANDIDATES = [
18+
os.path.join(_HERE, "..", "..", "config_files", "test", "DTL-config.json"),
19+
os.path.join(_HERE, "..", "DTL-config.json"),
20+
]
21+
22+
23+
def config_file_path():
24+
for candidate in _CONFIG_CANDIDATES:
25+
if os.path.exists(candidate):
26+
return candidate
27+
raise FileNotFoundError("DTL-config.json not found in any of: " + ", ".join(_CONFIG_CANDIDATES))
28+
29+
1230
def setup_platform():
1331
e = Engine(sys.argv)
1432
e.set_log_control("no_loc")
@@ -24,7 +42,7 @@ def setup_platform():
2442
FileSystem.register_file_system(root, fs)
2543
fs.mount_partition("/scratch/", local_storage, "100MB")
2644

27-
DTL.create("../../config_files/test/DTL-config.json")
45+
DTL.create(config_file_path())
2846
return e, host
2947

3048
def run_test_config_file():

0 commit comments

Comments
 (0)