Skip to content

Commit ca04d12

Browse files
authored
[ATfE] Extend xfails to exclude tests, and exclude test-hello-raw (#617)
The test-hello-raw picolibc test expects qemu to send data on the serial port, which the downstream test runner scripts do not currently support. While this test can be set to be expected to fail, the test will wait the full timeout duration so it would be better to skip it until the test runner can be updated. The lit test driver already supports removing tests from the available set through the --filter-out option, so this patch extends the existing xfail mechanism to also allow for excluding tests through this argument. Unlike the xfail/xfail-not options, this expects a regular expression, but simply or'ing the filenames is sufficient. Since skipping the test reduces test coverage, the --show-excluded option is also enabled by default so that it is clear in the logs when a test is removed.
1 parent 1e02cd0 commit ca04d12

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

arm-software/embedded/arm-runtimes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if(ENABLE_LIBC_TESTS OR ENABLE_COMPILER_RT_TESTS OR ENABLE_LIBCXX_TESTS)
171171
endif()
172172

173173
set(external_lit_path "${LLVM_BINARY_DIR}/bin/llvm-lit")
174-
set(default_lit_args "-sv --show-xfail --show-unsupported")
174+
set(default_lit_args "-sv --show-xfail --show-unsupported --show-excluded")
175175
if (MSVC OR XCODE)
176176
set(default_lit_args "${default_lit_args} --no-progress-bar")
177177
endif()

arm-software/embedded/arm-runtimes/test-support/xfails.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import argparse
1212
import os
13+
import re
1314
import subprocess
1415

1516
from enum import Enum
@@ -21,6 +22,7 @@ class NewResult(Enum):
2122

2223
XFAILED = "FAILED" # Replace a failure with an expected failure.
2324
PASSED = "PASSED" # Replace an unexpected pass with a pass.
25+
EXCLUDE = "EXCLUDE" # Exclude a test, so that it is not run at all.
2426

2527

2628
class XFail(NamedTuple):
@@ -456,10 +458,26 @@ def check_r52_warning():
456458
],
457459
description="push_back crashes on a basic_string with an oversized value type",
458460
),
461+
XFail(
462+
name="picolibc_serial_test",
463+
testnames=[
464+
"test-hello-raw.test",
465+
],
466+
result=NewResult.EXCLUDE,
467+
project="picolibc",
468+
variants=[
469+
"aarch64a_exn_rtti_unaligned",
470+
"aarch64a_soft_nofp",
471+
"aarch64a_soft_nofp_exn_rtti",
472+
"aarch64a_unaligned",
473+
],
474+
description="The test expects serial port activity to end the test and times out without it.",
475+
),
459476
]
460477

461478
tests_to_xfail = []
462479
tests_to_upass = []
480+
tests_to_exclude = []
463481

464482
for xfail in xfails:
465483
if args.project != xfail.project:
@@ -478,25 +496,33 @@ def check_r52_warning():
478496
tests_to_xfail.extend(xfail.testnames)
479497
elif xfail.result == NewResult.PASSED:
480498
tests_to_upass.extend(xfail.testnames)
481-
# TODO: allow tests to be skipped and not run at all.
482-
# This can be done through the LIT_FILTER environment variable.
483-
# Unlike the xfail variables, this takes a regex, so an expression
484-
# will need to be constructed to cover the tests.
499+
elif xfail.result == NewResult.EXCLUDE:
500+
tests_to_exclude.extend(xfail.testnames)
485501

486502
tests_to_xfail.sort()
487503
tests_to_upass.sort()
504+
tests_to_exclude.sort()
488505

489506
if args.output_args:
490507
os.makedirs(os.path.dirname(args.output_args), exist_ok=True)
491508
with open(args.output_args, "w", encoding="utf-8") as f:
492509
if len(tests_to_xfail) > 0:
510+
# --xfail and --xfail-not expect a comma separated list of test names.
493511
f.write("--xfail=")
494512
f.write(";".join(tests_to_xfail))
495513
f.write("\n")
496514
if len(tests_to_upass) > 0:
497515
f.write("--xfail-not=")
498516
f.write(";".join(tests_to_upass))
499517
f.write("\n")
518+
if len(tests_to_exclude) > 0:
519+
# --filter-out expects a regular expression to match any test names.
520+
escaped_testnames = [
521+
re.escape(testname) for testname in tests_to_exclude
522+
]
523+
f.write("--filter-out=")
524+
f.write("|".join(escaped_testnames))
525+
f.write("\n")
500526
print(f"xfail list written to {args.output_args}")
501527
else:
502528
if len(tests_to_xfail) > 0:
@@ -507,6 +533,10 @@ def check_r52_warning():
507533
print("xfail removed from tests:")
508534
for testname in tests_to_upass:
509535
print(testname)
536+
if len(tests_to_exclude) > 0:
537+
print("excluded tests:")
538+
for testname in tests_to_exclude:
539+
print(testname)
510540

511541

512542
if __name__ == "__main__":

0 commit comments

Comments
 (0)