Skip to content

Commit 503dec7

Browse files
committed
testing/esp: enable test_semihost_args for riscv
1 parent 8206d5a commit 503dec7

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

testing/esp/test_apps/gen_ut_app/main/semihost_tests.c

+11-18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
#include "esp_vfs_semihost.h"
1010

11+
#if CONFIG_IDF_TARGET_ARCH_XTENSA
12+
#include "xtensa/semihosting.h"
13+
#else
14+
#include "riscv/semihosting.h"
15+
#endif
16+
1117
#include "esp_log.h"
1218
const static char *TAG = "semihost_test";
1319

@@ -16,8 +22,6 @@ const static char *TAG = "semihost_test";
1622
#define ESP_ENOTSUP_UNIX 95
1723
#define ESP_ENOTSUP_DARWIN 45
1824

19-
#define SYSCALL_INSTR "break 1,14\n"
20-
2125
#define SYS_OPEN 0x01
2226
#define SYS_CLOSE 0x02
2327
#define SYS_WRITE 0x05
@@ -71,16 +75,6 @@ static inline bool esp_cpu_in_ocd_debug_mode(void) //check
7175
return esp_cpu_dbgr_is_attached();
7276
}
7377

74-
static inline long semihosting_call_noerrno_generic(long id, long *data)
75-
{
76-
register long a2 asm ("a2") = id;
77-
register long a3 asm ("a3") = (long)data;
78-
__asm__ __volatile__ (
79-
"break 1, 14\n"
80-
: "+r"(a2) : "r"(a3)
81-
: "memory");
82-
return a2;
83-
}
8478
static inline int generic_syscall(int sys_nr, int arg1, int arg2, int arg3, int arg4,
8579
int *ret_errno)
8680
{
@@ -94,10 +88,10 @@ static inline int generic_syscall(int sys_nr, int arg1, int arg2, int arg3, int
9488
long data[] = {arg1, arg2, arg3, arg4};
9589
ESP_LOGI(TAG, "CPU[%d]: -> syscall 0x%x, args: 0x%x, 0x%x, 0x%x, 0x%x", core_id, sys_nr, arg1, arg2, arg3, arg4);
9690

97-
long ret = semihosting_call_noerrno_generic(sys_nr, data);
91+
long ret = semihosting_call_noerrno(sys_nr, data);
9892
if (ret == -1) {
9993
const int semihosting_sys_errno = SYS_ERRNO;
100-
*ret_errno = (int) semihosting_call_noerrno_generic(semihosting_sys_errno, NULL);
94+
*ret_errno = (int) semihosting_call_noerrno(semihosting_sys_errno, NULL);
10195
}
10296
ESP_LOGI(TAG, "CPU[%d]: -> syscall 0x%x, args: 0x%x, 0x%x, 0x%x, 0x%x, ret: 0x%x, errno: 0x%x", core_id, sys_nr, arg1, arg2, arg3, arg4, (int)ret, (int)*ret_errno);
10397
return ret;
@@ -112,10 +106,13 @@ static inline int semihosting_wrong_args(int wrong_arg)
112106
char fname[32];
113107
snprintf(fname, sizeof(fname) - 1, "/test_read.%d", core_id);
114108

109+
#if CONFIG_IDF_TARGET_ARCH_XTENSA
110+
/* Invalid opcode halts the execution for RISC-V targets OCD-1113 */
115111
ESP_LOGI(TAG, "CPU[%d]:------ wrong SYSCALL -------", core_id);
116112
syscall_ret = generic_syscall(wrong_arg, 0, 0, 0, 0, &test_errno);
117113
assert(syscall_ret == -1);
118114
assert((test_errno == ESP_ENOTSUP_WIN) || (test_errno == ESP_ENOTSUP_UNIX) || (test_errno == ESP_ENOTSUP_DARWIN));
115+
#endif
119116

120117
/**** SYS_DRVINFO ****/
121118
ESP_LOGI(TAG, "CPU[%d]:------ SYS_DRVINFO test -------", core_id);
@@ -794,7 +791,6 @@ static void semihost_task(void *pvParameter)
794791
done();
795792
}
796793

797-
#if CONFIG_IDF_TARGET_ARCH_XTENSA
798794
TEST_DECL(semihost_args, "test_semihost.SemihostTests*.test_semihost_args")
799795
{
800796
int ret;
@@ -839,7 +835,6 @@ TEST_DECL(semihost_args, "test_semihost.SemihostTests*.test_semihost_args")
839835
}
840836
done();
841837
}
842-
#endif /* CONFIG_IDF_TARGET_ARCH_XTENSA */
843838

844839
TEST_DECL(semihost_rw, "test_semihost.SemihostTests*.test_semihost_rw")
845840
{
@@ -959,7 +954,6 @@ ut_result_t semihost_test_do(int test_num)
959954
xTaskCreatePinnedToCore(TEST_ENTRY(gdb_consoleio), "gdb_consoleio_task", 4096, NULL, 5, NULL, 0);
960955
} else if (TEST_ID_MATCH(TEST_ID_PATTERN(semihost_rw), test_num)) {
961956
xTaskCreatePinnedToCore(TEST_ENTRY(semihost_rw), "semihost_task", 4096, NULL, 5, NULL, 0);
962-
#if CONFIG_IDF_TARGET_ARCH_XTENSA
963957
} else if (TEST_ID_MATCH(TEST_ID_PATTERN(semihost_args), test_num)) {
964958
/*
965959
* *** About the test ***
@@ -981,7 +975,6 @@ ut_result_t semihost_test_do(int test_num)
981975
* - Close the file
982976
*/
983977
xTaskCreatePinnedToCore(TEST_ENTRY(semihost_args), "semihost_args_task0", 8000, NULL, 5, NULL, 0);
984-
#endif /* CONFIG_IDF_TARGET_ARCH_XTENSA */
985978
/*
986979
* *** About the tests ***
987980
*

testing/esp/test_semihost.py

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def test_semihost_rw(self):
166166
get_logger().info('Compare files [%s, %s]', self.fout_names[i], self.fin_names[i])
167167
self.assertTrue(filecmp.cmp(self.fout_names[i], self.fin_names[i]))
168168

169-
@only_for_arch(['xtensa'])
170169
def test_semihost_args(self):
171170
"""
172171
This test checks that semihosting syscalls working properly with wrong argumented functions

0 commit comments

Comments
 (0)