Skip to content

Commit 327f60c

Browse files
authored
Permit FVP tests to return a useful exit status. (#576)
This allows picolibc tests to mark themselves as "skipped" by returning the special exit code 77. Previously that didn't work in an FVP test run, so those tests are marked as failed rather than skipped. In particular, test-sprintf-percent-n was affected, because we build picolibc in a mode that doesn't support printf("%n"), and that test knew it and was trying to return "skipped". Background: Fast Models does support the SYS_EXIT_EXTENDED semihosting request, which allows specifying an exit status. But it doesn't support the ":semihosting-features" pseudo-file that advertises support for non-default semihosting features including that one. So picolibc wrongly believes that SYS_EXIT_EXTENDED doesn't work, and doesn't try it. This commit works around that lack of support by simply creating a _real_ file called ":semihosting-features" in the directory where the model will run. Then picolibc does find it, and learns from it that it's allowed to SYS_EXIT_EXTENDED. This makes test-sprintf-percent-n stop failing. It also means we can remove the semihost-exit-extended test from the list of tests specially disabled on FVP runs, because now it works.
1 parent d0b2af2 commit 327f60c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arm-runtimes/test-support/picolibc-test-wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
]
4141

4242
disabled_tests_fvp = [
43-
# SDDKW-53824: ":semihosting-features" pseudo-file not implemented.
44-
"test/semihost/semihost-exit-extended",
4543
# SDDKW-25808: SYS_SEEK returns wrong value.
4644
"test/semihost/semihost-seek",
4745
"test/test-fread-fwrite",

arm-runtimes/test-support/run_fvp.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ def run_fvp(
6767
if verbose:
6868
print("running: {}".format(shlex.join(command)))
6969

70+
# SDDKW-53824: the ":semihosting-features" pseudo-file isn't simulated
71+
# by these models. To work around that, we create one ourselves in the
72+
# test process's working directory, containing the single feature flag
73+
# SH_EXT_EXIT_EXTENDED, meaning that the SYS_EXIT_EXTENDED semihosting
74+
# request will work. This permits the test program's exit status to be
75+
# propagated to the exit status of the FVP, so that tests returning 77
76+
# for "test skipped" can be automatically detected.
77+
with open(
78+
path.join(working_directory, ":semihosting-features"), "wb"
79+
) as fh:
80+
fh.write(b"SHFB\x01")
81+
7082
result = subprocess.run(
7183
command,
7284
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)