Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 44 additions & 27 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@
lit_config.note("\tUnset " + var)
llvm_config.with_environment(var, "")


# Temporarily modify environment to be the same that we use when running tests
class test_env:
def __enter__(self):
self.old_environ = dict(os.environ)
os.environ.clear()
os.environ.update(config.environment)

def __exit__(self, exc_type, exc_value, exc_traceback):
os.environ.clear()
os.environ.update(self.old_environ)


config.substitutions.append(("%sycl_libs_dir", config.sycl_libs_dir))
if platform.system() == "Windows":
config.substitutions.append(
Expand Down Expand Up @@ -263,10 +276,11 @@ def open_check_file(file_name):

# check if compiler supports CL command line options
cl_options = False
sp = subprocess.getstatusoutput(config.dpcpp_compiler + " /help")
if sp[0] == 0:
cl_options = True
config.available_features.add("cl_options")
with test_env():
sp = subprocess.getstatusoutput(config.dpcpp_compiler + " /help")
if sp[0] == 0:
cl_options = True
config.available_features.add("cl_options")

# check if the compiler was built in NDEBUG configuration
has_ndebug = False
Expand Down Expand Up @@ -321,14 +335,15 @@ def open_check_file(file_name):

config.substitutions.append(("%level_zero_options", level_zero_options))

sp = subprocess.getstatusoutput(
config.dpcpp_compiler + " -fsycl " + check_l0_file + level_zero_options
)
if sp[0] == 0:
config.available_features.add("level_zero_dev_kit")
config.substitutions.append(("%level_zero_options", level_zero_options))
else:
config.substitutions.append(("%level_zero_options", ""))
with test_env():
sp = subprocess.getstatusoutput(
config.dpcpp_compiler + " -fsycl " + check_l0_file + level_zero_options
)
if sp[0] == 0:
config.available_features.add("level_zero_dev_kit")
config.substitutions.append(("%level_zero_options", level_zero_options))
else:
config.substitutions.append(("%level_zero_options", ""))

if lit_config.params.get("test-preview-mode", False):
config.available_features.add("preview-mode")
Expand All @@ -349,13 +364,14 @@ def open_check_file(file_name):
file=fp,
)

sp = subprocess.getstatusoutput(
config.dpcpp_compiler
+ " -fsycl -fpreview-breaking-changes "
+ check_preview_breaking_changes_file
)
if sp[0] == 0:
config.available_features.add("preview-breaking-changes-supported")
with test_env():
sp = subprocess.getstatusoutput(
config.dpcpp_compiler
+ " -fsycl -fpreview-breaking-changes "
+ check_preview_breaking_changes_file
)
if sp[0] == 0:
config.available_features.add("preview-breaking-changes-supported")

# Check if clang is built with ZSTD and compression support.
fPIC_opt = "-fPIC" if platform.system() != "Windows" else ""
Expand Down Expand Up @@ -418,14 +434,15 @@ def open_check_file(file_name):

config.substitutions.append(("%cuda_options", cuda_options))

sp = subprocess.getstatusoutput(
config.dpcpp_compiler + " -fsycl " + check_cuda_file + cuda_options
)
if sp[0] == 0:
config.available_features.add("cuda_dev_kit")
config.substitutions.append(("%cuda_options", cuda_options))
else:
config.substitutions.append(("%cuda_options", ""))
with test_env():
sp = subprocess.getstatusoutput(
config.dpcpp_compiler + " -fsycl " + check_cuda_file + cuda_options
)
if sp[0] == 0:
config.available_features.add("cuda_dev_kit")
config.substitutions.append(("%cuda_options", cuda_options))
else:
config.substitutions.append(("%cuda_options", ""))

# Check for OpenCL ICD
if config.opencl_libs_dir:
Expand Down