Skip to content

Commit b886cbb

Browse files
authored
[SYCL][E2E] Check for run-time features when in build-only (#17988)
Currently when we check `REQUIRES`/`UNSUPPORTED` statements in `build-only` mode we throw an error if any feature that is not in `build_specific_features` evaluates to true. Since this is error will only trigger when a test queries for one of these features, it can be easy to miss adding new build-specific features to this list (see #17985, and #17363). This pr changes this check to be done for all features when in `build-only`, not just those queried by a test. If any available feature does not appear in `build_specific_features` then an error is thrown.
1 parent 4157f90 commit b886cbb

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

sycl/test-e2e/E2EExpr.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ class E2EExpr(BooleanExpression):
3636
"vulkan",
3737
"hip_options",
3838
"cuda_options",
39+
"host=None",
40+
"target=None",
41+
"shell",
42+
"non-root-user",
43+
"llvm-spirv",
44+
"llvm-link",
3945
"true",
4046
"false",
4147
"pdtracker",
48+
"ze_debug",
4249
}
4350

4451
def __init__(self, string, variables, build_only_mode, final_unknown_value):
@@ -66,14 +73,10 @@ def evaluate(string, variables, build_only_mode, final_unknown_value=True):
6673
def parseMATCH(self):
6774
token = self.token
6875
BooleanExpression.parseMATCH(self)
69-
if token not in self.build_specific_features and self.build_only_mode:
76+
if token not in E2EExpr.build_specific_features and self.build_only_mode:
7077
self.unknown = True
7178
else:
7279
self.unknown = False
73-
if self.value and self.unknown:
74-
raise ValueError(
75-
'Runtime feature "' + token + '" evaluated to True in build-only'
76-
)
7780

7881
def parseAND(self):
7982
self.parseNOT()
@@ -113,6 +116,18 @@ def parseAll(self):
113116
self.expect(BooleanExpression.END)
114117
return self.final_unknown_value if self.unknown else self.value
115118

119+
@staticmethod
120+
def check_build_features(variables):
121+
rt_features = [x for x in variables if x not in E2EExpr.build_specific_features]
122+
if rt_features:
123+
raise ValueError(
124+
"Runtime features: "
125+
+ str(rt_features)
126+
+ " evaluated to True in build-only\n"
127+
+ "If this is a new build specific feature append it to:"
128+
+ "`build_specific_features` in `sycl/test-e2e/E2EExpr.py`"
129+
)
130+
116131

117132
import unittest
118133

@@ -165,11 +180,12 @@ def test_basic(self):
165180
self.assertFalse(
166181
UnsupportedBuildEval("linux && (vulkan && rt_feature)", {"linux"})
167182
)
168-
# runtime feature is present in build-only
183+
# Check that no runtime features are present in build-only
169184
with self.assertRaises(ValueError):
170-
RequiresBuildEval("rt_feature", {"rt_feature"})
185+
E2EExpr.check_build_features({"rt-feature"})
171186
with self.assertRaises(ValueError):
172-
UnsupportedBuildEval("rt_feature", {"rt_feature"})
187+
E2EExpr.check_build_features({"build-only", "rt-feature"})
188+
E2EExpr.check_build_features({"build-mode"})
173189

174190

175191
if __name__ == "__main__":

sycl/test-e2e/lit.cfg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,12 @@ def get_sycl_ls_verbose(sycl_device, env):
11021102
clangxx += config.cxx_flags
11031103
config.substitutions.append(("%clangxx", clangxx))
11041104

1105+
# Check that no runtime features are available when in build-only
1106+
from E2EExpr import E2EExpr
1107+
1108+
if config.test_mode == "build-only":
1109+
E2EExpr.check_build_features(config.available_features)
1110+
11051111
if lit_config.params.get("print_features", False):
11061112
lit_config.note(
11071113
"Global features: {}".format(" ".join(sorted(config.available_features)))

0 commit comments

Comments
 (0)