summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhkag <[email protected]>2023-06-10 12:32:34 +0800
committerGitHub <[email protected]>2023-06-10 12:32:34 +0800
commit0f998f6b05e044d2c2a0c99f24f4cd97f263f478 (patch)
tree8211353b2dfe888d9a1c8f5355cc415bdad5c37c
parentd0c6d6f4a48b67fde477c743bec1a68198e882f3 (diff)
[simulator] 模拟器可以使用 utest 测试框架 (#7644)
Co-authored-by: Man, Jianting (Meco) <[email protected]>
-rw-r--r--bsp/simulator/.config2
-rw-r--r--bsp/simulator/gcc_elf64.ld6
-rwxr-xr-xbsp/simulator/rtconfig.h2
-rw-r--r--components/utilities/utest/utest.c16
-rw-r--r--src/kservice.c5
5 files changed, 21 insertions, 10 deletions
diff --git a/bsp/simulator/.config b/bsp/simulator/.config
index 3064f55a14..1cbd646211 100644
--- a/bsp/simulator/.config
+++ b/bsp/simulator/.config
@@ -77,7 +77,7 @@ CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_DM is not set
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y
-CONFIG_RT_CONSOLEBUF_SIZE=128
+CONFIG_RT_CONSOLEBUF_SIZE=256
CONFIG_RT_CONSOLE_DEVICE_NAME="console"
CONFIG_RT_VER_NUM=0x50001
# CONFIG_RT_USING_STDC_ATOMIC is not set
diff --git a/bsp/simulator/gcc_elf64.ld b/bsp/simulator/gcc_elf64.ld
index 26adaa86af..ad1ecac006 100644
--- a/bsp/simulator/gcc_elf64.ld
+++ b/bsp/simulator/gcc_elf64.ld
@@ -66,6 +66,12 @@ SECTIONS
/* setction information for finsh shell begin */
. = ALIGN(8);
+ UtestTcTab : {
+ __rt_utest_tc_tab_start = .;
+ KEEP(*(UtestTcTab))
+ __rt_utest_tc_tab_end = .;
+ }
+ . = ALIGN(8);
FSymTab : {
__fsymtab_start = .;
KEEP(*(FSymTab))
diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h
index a2b2cd15f9..034a402a5c 100755
--- a/bsp/simulator/rtconfig.h
+++ b/bsp/simulator/rtconfig.h
@@ -42,7 +42,7 @@
#define RT_USING_DEVICE
#define RT_USING_CONSOLE
-#define RT_CONSOLEBUF_SIZE 128
+#define RT_CONSOLEBUF_SIZE 256
#define RT_CONSOLE_DEVICE_NAME "console"
#define RT_VER_NUM 0x50001
diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c
index 3c91fa8166..6b480dd1e1 100644
--- a/components/utilities/utest/utest.c
+++ b/components/utilities/utest/utest.c
@@ -88,19 +88,19 @@ int utest_init(void)
#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
tc_table = (utest_tc_export_t)__section_begin("UtestTcTab");
tc_num = (utest_tc_export_t)__section_end("UtestTcTab") - tc_table;
-#elif defined (__GNUC__) /* for GCC Compiler */
+#else
+ unsigned int *ptr_begin, *ptr_end;
+#if defined(__GNUC__)
extern const int __rt_utest_tc_tab_start;
extern const int __rt_utest_tc_tab_end;
- tc_table = (utest_tc_export_t)&__rt_utest_tc_tab_start;
- tc_num = (utest_tc_export_t) &__rt_utest_tc_tab_end - tc_table;
+ ptr_begin = (unsigned int *)&__rt_utest_tc_tab_start;
+ ptr_end = (unsigned int *)&__rt_utest_tc_tab_end;
#elif defined(_MSC_VER)
- unsigned int* ptr_begin, * ptr_end;
-
- ptr_begin = (unsigned int*)&__tc_export_begin;
+ ptr_begin = (unsigned int *)&__tc_export_begin;
+ ptr_end = (unsigned int *)&__tc_export_end;
ptr_begin += (sizeof(struct utest_tc_export) / sizeof(unsigned int));
+#endif
while (*ptr_begin == 0) ptr_begin++;
-
- ptr_end = (unsigned int*)&__tc_export_end;
ptr_end--;
while (*ptr_end == 0) ptr_end--;
/* copy tc_table from rodata section to ram */
diff --git a/src/kservice.c b/src/kservice.c
index 4f44183707..dddcdf6df3 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -1574,8 +1574,13 @@ rt_inline void _heap_unlock(rt_base_t level)
#ifdef RT_USING_UTESTCASES
/* export to utest to observe the inner statements */
+#ifdef _MSC_VER
+#define rt_heap_lock() _heap_lock()
+#define rt_heap_unlock() _heap_unlock()
+#else
rt_base_t rt_heap_lock(void) __attribute__((alias("_heap_lock")));
void rt_heap_unlock(rt_base_t level) __attribute__((alias("_heap_unlock")));
+#endif /* _MSC_VER */
#endif
#if defined(RT_USING_SMALL_MEM_AS_HEAP)