@@ -29,6 +29,8 @@ class LibcxxTestFormat(object):
29
29
FOO.pass.cpp - Executable test which should compile, run, and exit with
30
30
code 0.
31
31
FOO.fail.cpp - Negative test case which is expected to fail compilation.
32
+ FOO.runfail.cpp - Negative test case which is expected to compile, run,
33
+ and exit with non-zero exit code.
32
34
FOO.sh.cpp - A test that uses LIT's ShTest format.
33
35
"""
34
36
@@ -88,6 +90,7 @@ def _execute(self, test, lit_config):
88
90
is_sh_test = name_root .endswith ('.sh' )
89
91
is_pass_test = name .endswith ('.pass.cpp' ) or name .endswith ('.pass.mm' )
90
92
is_fail_test = name .endswith ('.fail.cpp' ) or name .endswith ('.fail.mm' )
93
+ is_runfail_test = name .endswith ('.runfail.cpp' ) or name .endswith ('.runfail.mm' )
91
94
is_objcxx_test = name .endswith ('.mm' )
92
95
is_objcxx_arc_test = name .endswith ('.arc.pass.mm' ) or \
93
96
name .endswith ('.arc.fail.mm' )
@@ -166,6 +169,10 @@ def _execute(self, test, lit_config):
166
169
elif is_pass_test :
167
170
return self ._evaluate_pass_test (test , tmpBase , lit_config ,
168
171
test_cxx , parsers )
172
+ elif is_runfail_test :
173
+ return self ._evaluate_pass_test (test , tmpBase , lit_config ,
174
+ test_cxx , parsers ,
175
+ run_should_pass = False )
169
176
else :
170
177
# No other test type is supported
171
178
assert False
@@ -174,7 +181,7 @@ def _clean(self, exec_path): # pylint: disable=no-self-use
174
181
libcudacxx .util .cleanFile (exec_path )
175
182
176
183
def _evaluate_pass_test (self , test , tmpBase , lit_config ,
177
- test_cxx , parsers ):
184
+ test_cxx , parsers , run_should_pass = True ):
178
185
execDir = os .path .dirname (test .getExecPath ())
179
186
source_path = test .getSourcePath ()
180
187
exec_path = tmpBase + '.exe'
@@ -210,14 +217,18 @@ def _evaluate_pass_test(self, test, tmpBase, lit_config,
210
217
env )
211
218
report = "Compiled With: '%s'\n " % ' ' .join (compile_cmd )
212
219
report += libcudacxx .util .makeReport (cmd , out , err , rc )
213
- if rc == 0 :
220
+ result_expected = (rc == 0 ) == run_should_pass
221
+ if result_expected :
214
222
res = lit .Test .PASS if retry_count == 0 else lit .Test .FLAKYPASS
215
223
return lit .Test .Result (res , report )
216
224
# Rarely devices are unavailable, so just restart the test to avoid false negatives.
217
225
elif rc != 0 and "cudaErrorDevicesUnavailable" in out and max_retry <= 5 :
218
226
max_retry += 1
219
- elif rc != 0 and retry_count + 1 >= max_retry :
220
- report += "Compiled test failed unexpectedly!"
227
+ elif retry_count + 1 == max_retry :
228
+ if run_should_pass :
229
+ report += "Compiled test failed unexpectedly!"
230
+ else :
231
+ report += "Compiled test succeeded unexpectedly!"
221
232
return lit .Test .Result (lit .Test .FAIL , report )
222
233
223
234
assert False # Unreachable
0 commit comments