From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [Semihosting Tests PATCH 3/3] add SYS_GET_CMDLINE test
Date: Mon, 13 May 2024 12:35:13 +0100 [thread overview]
Message-ID: <20240513113513.640007-4-alex.bennee@linaro.org> (raw)
In-Reply-To: <20240513113513.640007-1-alex.bennee@linaro.org>
We actually had the stubs to implement this. The main pain is getting
the binary name into the program so we can validate the result.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
Makefile | 22 +++++++++++-----------
usertest.c | 24 ++++++++++++++++++++++++
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index 59fd831..f77665f 100644
--- a/Makefile
+++ b/Makefile
@@ -85,37 +85,37 @@ systest-srcs = start.S string.c $(usertest-srcs)
microbit-systest-srcs = start-microbit.S string.c $(usertest-srcs)
usertest-a32: $(usertest-srcs)
- $(A32GCC) --static -o $@ $^
+ $(A32GCC) -DBINARY_NAME="\"$@\"" --static -o $@ $^
usertest-t32: $(usertest-srcs)
- $(T32GCC) --static -o $@ $^
+ $(T32GCC) -DBINARY_NAME="\"$@\"" --static -o $@ $^
usertest-a32-hlt: $(usertest-srcs)
- $(A32GCC) -DUSE_HLT --static -o $@ $^
+ $(A32GCC) -DBINARY_NAME="\"$@\"" -DUSE_HLT --static -o $@ $^
usertest-t32-hlt: $(usertest-srcs)
- $(T32GCC) -DUSE_HLT --static -o $@ $^
+ $(T32GCC) -DBINARY_NAME="\"$@\"" -DUSE_HLT --static -o $@ $^
usertest-a64: $(usertest-srcs)
- $(A64GCC) --static -o $@ $^
+ $(A64GCC) -DBINARY_NAME="\"$@\"" --static -o $@ $^
systest-a32.axf: $(systest-srcs)
- $(A32GCC) -o $@ $^ $(A32LINKOPTS)
+ $(A32GCC) -DBINARY_NAME="\"$@\"" -o $@ $^ $(A32LINKOPTS)
systest-t32.axf: $(systest-srcs)
- $(T32GCC) -o $@ $^ $(A32LINKOPTS)
+ $(T32GCC) -DBINARY_NAME="\"$@\"" -o $@ $^ $(A32LINKOPTS)
systest-a32-hlt.axf: $(systest-srcs)
- $(A32GCC) -DUSE_HLT -o $@ $^ $(A32LINKOPTS)
+ $(A32GCC) -DBINARY_NAME="\"$@\"" -DUSE_HLT -o $@ $^ $(A32LINKOPTS)
systest-t32-hlt.axf: $(systest-srcs)
- $(T32GCC) -DUSE_HLT -o $@ $^ $(A32LINKOPTS)
+ $(T32GCC) -DBINARY_NAME="\"$@\"" -DUSE_HLT -o $@ $^ $(A32LINKOPTS)
systest-t32-bkpt.axf: $(microbit-systest-srcs)
- $(V7MGCC) -DUSE_BKPT -o $@ $^ $(AV7MLINKOPTS)
+ $(V7MGCC) -DBINARY_NAME="\"$@\"" -DUSE_BKPT -o $@ $^ $(AV7MLINKOPTS)
systest-a64.axf: $(systest-srcs)
- $(A64GCC) -nostdlib -o $@ $^ $(A64LINKOPTS)
+ $(A64GCC) -DBINARY_NAME="\"$@\"" -nostdlib -o $@ $^ $(A64LINKOPTS)
run-usertest-a32: usertest-a32
$(QEMU_ARM) usertest-a32
diff --git a/usertest.c b/usertest.c
index 5df95f3..268a9d9 100644
--- a/usertest.c
+++ b/usertest.c
@@ -315,6 +315,26 @@ static int test_feature_detect(void)
return 0;
}
+static int test_cmdline(void)
+{
+ char cmdline[256];
+ int actual;
+ const char *s, *c;
+
+ if (semi_get_cmdline(&cmdline[0], sizeof(cmdline), &actual)) {
+ semi_write0("FAIL could recover command line\n");
+ return 1;
+ }
+
+ if (strcmp(&cmdline[0], BINARY_NAME) != 0) {
+ semi_write0("FAIL unexpected command line:");
+ semi_write0(&cmdline[0]);
+ }
+
+ semi_write0("PASS command line test\n");
+ return 0;
+}
+
int main(void)
{
void *bufp;
@@ -366,6 +386,10 @@ int main(void)
return 1;
}
+ if (test_cmdline()) {
+ return 1;
+ }
+
semi_write0("ALL TESTS PASSED\n");
/* If we have EXIT_EXTENDED then use it */
--
2.39.2
next prev parent reply other threads:[~2024-05-13 11:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-13 11:35 [Semihosting Tests PATCH 0/3] add SYS_GET_CMDLINE test Alex Bennée
2024-05-13 11:35 ` [Semihosting Tests PATCH 1/3] .editorconfig: add code conventions for tooling Alex Bennée
2024-05-20 15:06 ` Peter Maydell
2024-05-13 11:35 ` [Semihosting Tests PATCH 2/3] update includes for bare metal compiling Alex Bennée
2024-05-20 15:07 ` Peter Maydell
2024-05-13 11:35 ` Alex Bennée [this message]
2024-05-13 12:36 ` [Semihosting Tests PATCH 3/3] add SYS_GET_CMDLINE test Alex Bennée
2024-05-20 15:17 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240513113513.640007-4-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).