aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/multiarch
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2021-03-23 16:52:51 +0000
committerAlex Bennée <alex.bennee@linaro.org>2021-03-24 14:25:03 +0000
commit3539d84df15a29bb72d6d1eb2c39908681056d51 (patch)
treeec2ef5bf72a0e89d954ee249c805c310537e0666 /tests/tcg/multiarch
parent320d0bca94b4650c8fe6b02c6f24ad461f47eed8 (diff)
semihosting: move semihosting tests to multiarch
It may be arm-compat-semihosting but more than one architecture uses it so lets move the tests into the multiarch area. We gate it on the feature and split the semicall.h header between the arches. Also clean-up a bit of the Makefile messing about to one common set of runners. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210323165308.15244-6-alex.bennee@linaro.org>
Diffstat (limited to 'tests/tcg/multiarch')
-rw-r--r--tests/tcg/multiarch/Makefile.target31
-rw-r--r--tests/tcg/multiarch/arm-compat-semi/semiconsole.c29
-rw-r--r--tests/tcg/multiarch/arm-compat-semi/semihosting.c29
3 files changed, 89 insertions, 0 deletions
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
index abbdb2e126..a3a751723d 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -69,6 +69,37 @@ run-gdbstub-%:
endif
EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read
+# ARM Compatible Semi Hosting Tests
+#
+# Despite having ARM in the name we actually have several
+# architectures that implement it. We gate the tests on the feature
+# appearing in config.
+#
+ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y)
+VPATH += $(MULTIARCH_SRC)/arm-compat-semi
+
+# Add -I path back to TARGET_NAME for semicall.h
+semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
+
+run-semihosting: semihosting
+ $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)")
+
+run-plugin-semihosting-with-%:
+ $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
+ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
+ $(call strip-plugin,$<) 2> $<.err, \
+ "$< on $(TARGET_NAME) with $*")
+
+semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
+
+run-semiconsole: semiconsole
+ $(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-with-%:
+ $(call skip-test, $<, "MANUAL ONLY")
+
+TESTS += semihosting semiconsole
+endif
# Update TESTS
TESTS += $(MULTIARCH_TESTS)
diff --git a/tests/tcg/multiarch/arm-compat-semi/semiconsole.c b/tests/tcg/multiarch/arm-compat-semi/semiconsole.c
new file mode 100644
index 0000000000..1d82efc589
--- /dev/null
+++ b/tests/tcg/multiarch/arm-compat-semi/semiconsole.c
@@ -0,0 +1,29 @@
+/*
+ * linux-user semihosting console
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <alex.bennee@linaro.org>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define SYS_READC 0x07
+
+#include <stdio.h>
+#include <stdint.h>
+#include "semicall.h"
+
+int main(void)
+{
+ char c;
+
+ printf("Semihosting Console Test\n");
+ printf("hit X to exit:");
+
+ do {
+ c = __semi_call(SYS_READC, 0);
+ printf("got '%c'\n", c);
+ } while (c != 'X');
+
+ return 0;
+}
diff --git a/tests/tcg/multiarch/arm-compat-semi/semihosting.c b/tests/tcg/multiarch/arm-compat-semi/semihosting.c
new file mode 100644
index 0000000000..b3fd16cd12
--- /dev/null
+++ b/tests/tcg/multiarch/arm-compat-semi/semihosting.c
@@ -0,0 +1,29 @@
+/*
+ * linux-user semihosting checks
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <alex.bennee@linaro.org>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define SYS_WRITE0 0x04
+#define SYS_REPORTEXC 0x18
+
+#include <stdint.h>
+#include "semicall.h"
+
+int main(int argc, char *argv[argc])
+{
+#if UINTPTR_MAX == UINT32_MAX
+ uintptr_t exit_code = 0x20026;
+#else
+ uintptr_t exit_block[2] = {0x20026, 0};
+ uintptr_t exit_code = (uintptr_t) &exit_block;
+#endif
+
+ __semi_call(SYS_WRITE0, (uintptr_t) "Hello World");
+ __semi_call(SYS_REPORTEXC, exit_code);
+ /* if we get here we failed */
+ return -1;
+}