Skip to content

Commit

Permalink
[SYCL][E2E] Fix multiple test suite discovery (#14534)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
frasercrmck authored Jul 11, 2024
1 parent f51e43b commit 7b79cc9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@

if lit_config.params.get("enable-perf-tests", False):
config.available_features.add("enable-perf-tests")
# Make sure that any dynamic checks below are done in the build directory and
# not where the sources are located. This is important for the in-tree
# configuration (as opposite to the standalone one).
os.chdir(config.sycl_obj_root)


# Use this to make sure that any dynamic checks below are done in the build
# directory and not where the sources are located. This is important for the
# in-tree configuration (as opposite to the standalone one).
def open_check_file(file_name):
return open(os.path.join(config.sycl_obj_root, file_name), "w")

# check if compiler supports CL command line options
cl_options = False
Expand All @@ -204,7 +207,7 @@

# Check for Level Zero SDK
check_l0_file = "l0_include.cpp"
with open(check_l0_file, "w") as fp:
with open_check_file(check_l0_file) as fp:
print(
textwrap.dedent(
"""
Expand Down Expand Up @@ -254,7 +257,7 @@

# Check for sycl-preview library
check_preview_breaking_changes_file = "preview_breaking_changes_link.cpp"
with open(check_preview_breaking_changes_file, "w") as fp:
with open_check_file(check_preview_breaking_changes_file) as fp:
print(
textwrap.dedent(
"""
Expand All @@ -278,7 +281,7 @@

# Check for CUDA SDK
check_cuda_file = "cuda_include.cpp"
with open(check_cuda_file, "w") as fp:
with open_check_file(check_cuda_file) as fp:
print(
textwrap.dedent(
"""
Expand Down Expand Up @@ -637,7 +640,7 @@
# be ill-formed (compilation stops with non-zero exit code) if the feature
# test macro for kernel fusion is not defined.
check_fusion_file = "check_fusion.cpp"
with open(check_fusion_file, "w") as ff:
with open_check_file(check_fusion_file) as ff:
ff.write("#include <sycl/sycl.hpp>\n")
ff.write("#ifndef SYCL_EXT_CODEPLAY_KERNEL_FUSION\n")
ff.write('#error "Feature test for fusion failed"\n')
Expand Down

0 comments on commit 7b79cc9

Please sign in to comment.