Skip to content

Commit f740cb5

Browse files
committed
qemu: quit simulation when tests are completed
This allows CI to unblock and proceed to check results. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 49464c7 commit f740cb5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

app/boards/qemu_xtensa_dc233c.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ CONFIG_IPC_MAJOR_4=y
33
CONFIG_ZTEST=y
44
CONFIG_MM_DRV=y
55
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
6+
7+
# Ensure the kernel can exit QEMU on shutdown/panic
8+
CONFIG_REBOOT=y

app/boards/qemu_xtensa_dc233c_mmu.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ CONFIG_ZTEST=y
55
CONFIG_TEST_USERSPACE=y
66
CONFIG_MM_DRV=y
77
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
8+
9+
# Ensure the kernel can exit QEMU on shutdown/panic
10+
CONFIG_REBOOT=y

app/src/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <zephyr/kernel.h>
88
#include <sof/boot_test.h>
99
#include <zephyr/logging/log.h>
10+
1011
LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
1112

1213
/* define qemu boot tests if any qemu target is defined, add targets to end */
@@ -56,12 +57,28 @@ static int sof_app_main(void)
5657
return 0;
5758
}
5859

60+
#if CONFIG_SOF_BOOT_TEST && defined(QEMU_BOOT_TESTS)
61+
/* cleanly exit qemu so CI can continue and check test results */
62+
static inline void qemu_xtensa_exit(int status) {
63+
register int syscall_id __asm__ ("a2") = 1; /* SYS_exit is 1 */
64+
register int exit_status __asm__ ("a3") = status;
65+
66+
__asm__ __volatile__ (
67+
"simcall\n"
68+
:
69+
: "r" (syscall_id), "r" (exit_status)
70+
: "memory"
71+
);
72+
}
73+
#endif
74+
5975
#if CONFIG_ZTEST
6076
void test_main(void)
6177
{
6278
sof_app_main();
6379
#if CONFIG_SOF_BOOT_TEST && defined(QEMU_BOOT_TESTS)
6480
sof_run_boot_tests();
81+
qemu_xtensa_exit(0);
6582
#endif
6683
}
6784
#else

0 commit comments

Comments
 (0)