diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 4d949853ae56e..77589fac7579f 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -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 @@ -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( """ @@ -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( """ @@ -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( """ @@ -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 \n") ff.write("#ifndef SYCL_EXT_CODEPLAY_KERNEL_FUSION\n") ff.write('#error "Feature test for fusion failed"\n')