From 0f998f6b05e044d2c2a0c99f24f4cd97f263f478 Mon Sep 17 00:00:00 2001 From: zhkag Date: Sat, 10 Jun 2023 12:32:34 +0800 Subject: [PATCH] =?UTF-8?q?[simulator]=20=E6=A8=A1=E6=8B=9F=E5=99=A8?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=20utest=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A1=86=E6=9E=B6=20(#7644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Man, Jianting (Meco) <920369182@qq.com> --- bsp/simulator/.config | 2 +- bsp/simulator/gcc_elf64.ld | 6 ++++++ bsp/simulator/rtconfig.h | 2 +- components/utilities/utest/utest.c | 16 ++++++++-------- src/kservice.c | 5 +++++ 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)