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>
---
v3
- include aarch64 version
v4
- use common semicall.h, test thumb & arm
---
tests/tcg/arm/semiconsole.c | 27 +++++++++++++++++++++++++++
tests/tcg/aarch64/Makefile.target | 7 +++++++
tests/tcg/arm/Makefile.target | 19 +++++++++++++++++++
3 files changed, 53 insertions(+)
create mode 100644 tests/tcg/arm/semiconsole.c
diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c
new file mode 100644
index 00000000000..6ef0bd24500
--- /dev/null
+++ b/tests/tcg/arm/semiconsole.c
@@ -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;
+}
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 96d2321045a..4281c766419 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -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-semiconsole-with-%:
+ $(call skip-test, $<, "MANUAL ONLY")
+
TESTS += $(AARCH64_TESTS)
diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
index 41aa26f4e17..a104ca30281 100644
--- a/tests/tcg/arm/Makefile.target
+++ b/tests/tcg/arm/Makefile.target
@@ -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-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-semiconsole-arm-with-%:
+ $(call skip-test, $<, "MANUAL ONLY")
+
TESTS += $(ARM_TESTS)
# On ARM Linux only supports 4k pages
--
2.20.1
Alex Bennée <alex.bennee@linaro.org> writes:
> 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>
>
> ---
> v3
> - include aarch64 version
> v4
> - use common semicall.h, test thumb & arm
> ---
> tests/tcg/arm/semiconsole.c | 27 +++++++++++++++++++++++++++
> tests/tcg/aarch64/Makefile.target | 7 +++++++
> tests/tcg/arm/Makefile.target | 19 +++++++++++++++++++
> 3 files changed, 53 insertions(+)
> create mode 100644 tests/tcg/arm/semiconsole.c
>
> diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c
> new file mode 100644
> index 00000000000..6ef0bd24500
> --- /dev/null
> +++ b/tests/tcg/arm/semiconsole.c
> @@ -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;
> +}
> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
> index 96d2321045a..4281c766419 100644
> --- a/tests/tcg/aarch64/Makefile.target
> +++ b/tests/tcg/aarch64/Makefile.target
> @@ -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-semiconsole-with-%:
this should be run-plugin-semiconsole-with-%
<snip>
> +run-semiconsole-with-%:
<snip>
> +run-semiconsole-arm-with-%:
ditto for these
--
Alex Bennée
On 1/9/20 6:55 AM, Alex Bennée wrote:
>
> Alex Bennée <alex.bennee@linaro.org> writes:
>
>> 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>
>>
>> ---
>> v3
>> - include aarch64 version
>> v4
>> - use common semicall.h, test thumb & arm
>> ---
>> tests/tcg/arm/semiconsole.c | 27 +++++++++++++++++++++++++++
>> tests/tcg/aarch64/Makefile.target | 7 +++++++
>> tests/tcg/arm/Makefile.target | 19 +++++++++++++++++++
>> 3 files changed, 53 insertions(+)
>> create mode 100644 tests/tcg/arm/semiconsole.c
>>
>> diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c
>> new file mode 100644
>> index 00000000000..6ef0bd24500
>> --- /dev/null
>> +++ b/tests/tcg/arm/semiconsole.c
>> @@ -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;
>> +}
>> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
>> index 96d2321045a..4281c766419 100644
>> --- a/tests/tcg/aarch64/Makefile.target
>> +++ b/tests/tcg/aarch64/Makefile.target
>> @@ -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-semiconsole-with-%:
>
> this should be run-plugin-semiconsole-with-%
>
> <snip>
>> +run-semiconsole-with-%:
> <snip>
>> +run-semiconsole-arm-with-%:
>
> ditto for these
With these,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
© 2016 - 2026 Red Hat, Inc.