Skip to content

Commit 7b79cc9

Browse files
authored
[SYCL][E2E] Fix multiple test suite discovery (#14534)
Since #9078 (itself a fix for #8854), the SYCL E2E lit config would change the working directory and never set it back. This impeded LIT's ability to discover tests and test suites, when tasked with sourcing multiple. For example: llvm-lit sycl/test/A sycl/test/B LIT would discover test 'A' by appending its relative path to the CWD (e.g., `root/sycl/test/A`) and load up the SYCL E2E lit.cfg. This would change directory into the SYCL build directory. When discovering test 'B' it would append its relative path to the SYCL binary dir and fail to find it (e.g., `root/build/tools/sycl/test-e2e/sycl/test/B`). This would also have the effect of loading the SYCL E2E LIT config a second time, even though it was already loaded. With this change, we maintain the CWD but open the temp files using absolute paths. This allows us to run multiple tests from multiple different paths at the same time, even ones from different suites: llvm-lit sycl/test/A clang/test/B llvm/test/C Running multiple individual SYCL tests on the same command line will also only load the SYCL config the once.
1 parent f51e43b commit 7b79cc9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

sycl/test-e2e/lit.cfg.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,13 @@
190190

191191
if lit_config.params.get("enable-perf-tests", False):
192192
config.available_features.add("enable-perf-tests")
193-
# Make sure that any dynamic checks below are done in the build directory and
194-
# not where the sources are located. This is important for the in-tree
195-
# configuration (as opposite to the standalone one).
196-
os.chdir(config.sycl_obj_root)
193+
194+
195+
# Use this to make sure that any dynamic checks below are done in the build
196+
# directory and not where the sources are located. This is important for the
197+
# in-tree configuration (as opposite to the standalone one).
198+
def open_check_file(file_name):
199+
return open(os.path.join(config.sycl_obj_root, file_name), "w")
197200

198201
# check if compiler supports CL command line options
199202
cl_options = False
@@ -204,7 +207,7 @@
204207

205208
# Check for Level Zero SDK
206209
check_l0_file = "l0_include.cpp"
207-
with open(check_l0_file, "w") as fp:
210+
with open_check_file(check_l0_file) as fp:
208211
print(
209212
textwrap.dedent(
210213
"""
@@ -254,7 +257,7 @@
254257

255258
# Check for sycl-preview library
256259
check_preview_breaking_changes_file = "preview_breaking_changes_link.cpp"
257-
with open(check_preview_breaking_changes_file, "w") as fp:
260+
with open_check_file(check_preview_breaking_changes_file) as fp:
258261
print(
259262
textwrap.dedent(
260263
"""
@@ -278,7 +281,7 @@
278281

279282
# Check for CUDA SDK
280283
check_cuda_file = "cuda_include.cpp"
281-
with open(check_cuda_file, "w") as fp:
284+
with open_check_file(check_cuda_file) as fp:
282285
print(
283286
textwrap.dedent(
284287
"""
@@ -637,7 +640,7 @@
637640
# be ill-formed (compilation stops with non-zero exit code) if the feature
638641
# test macro for kernel fusion is not defined.
639642
check_fusion_file = "check_fusion.cpp"
640-
with open(check_fusion_file, "w") as ff:
643+
with open_check_file(check_fusion_file) as ff:
641644
ff.write("#include <sycl/sycl.hpp>\n")
642645
ff.write("#ifndef SYCL_EXT_CODEPLAY_KERNEL_FUSION\n")
643646
ff.write('#error "Feature test for fusion failed"\n')

0 commit comments

Comments
 (0)