tests/tcg: add user version of dumb-as-bricks semiconsole test
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 19 Dec 2019 12:13:44 +0000 (12:13 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Thu, 9 Jan 2020 11:41:29 +0000 (11:41 +0000)
There are linux-user users of semihosting so we'd better check things
work for them as well.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
tests/tcg/aarch64/Makefile.target
tests/tcg/arm/Makefile.target
tests/tcg/arm/semiconsole.c [new file with mode: 0644]

index 96d2321045a482c40d6de8b5a8ef311438b181c5..df3fe8032c3a697617a91d6947f709c7a68d5fea 100644 (file)
@@ -32,4 +32,11 @@ run-plugin-semihosting-with-%:
                 $(call strip-plugin,$<) 2> $<.err, \
                "$< on $(TARGET_NAME) with $*")
 
+AARCH64_TESTS += semiconsole
+run-semiconsole: semiconsole
+       $(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-with-%:
+       $(call skip-test, $<, "MANUAL ONLY")
+
 TESTS += $(AARCH64_TESTS)
index 41aa26f4e170733f90fda57d08796fb1275e3bed..11c39c601ea538d2a2d211103dbb078aed6af02f 100644 (file)
@@ -49,6 +49,25 @@ run-plugin-semihosting-with-%:
                 $(call strip-plugin,$<) 2> $<.err, \
                "$< on $(TARGET_NAME) with $*")
 
+ARM_TESTS += semiconsole semiconsole-arm
+
+semiconsole: CFLAGS += -mthumb
+run-semiconsole: semiconsole
+       $(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-with-%:
+       $(call skip-test, $<, "MANUAL ONLY")
+
+semiconsole-arm: CFLAGS += -marm
+semiconsole-arm: semiconsole.c
+       $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+
+run-semiconsole-arm: semiconsole-arm
+       $(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-arm-with-%:
+       $(call skip-test, $<, "MANUAL ONLY")
+
 TESTS += $(ARM_TESTS)
 
 # On ARM Linux only supports 4k pages
diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c
new file mode 100644 (file)
index 0000000..6ef0bd2
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * linux-user semihosting console
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <alex.bennee@linaro.org>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#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;
+}