Skip to content

Commit 0f998f6

Browse files
zhkagmysterywolf
andauthored
[simulator] 模拟器可以使用 utest 测试框架 (#7644)
Co-authored-by: Man, Jianting (Meco) <[email protected]>
1 parent d0c6d6f commit 0f998f6

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

bsp/simulator/.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CONFIG_RT_USING_DEVICE=y
7777
# CONFIG_RT_USING_DM is not set
7878
# CONFIG_RT_USING_INTERRUPT_INFO is not set
7979
CONFIG_RT_USING_CONSOLE=y
80-
CONFIG_RT_CONSOLEBUF_SIZE=128
80+
CONFIG_RT_CONSOLEBUF_SIZE=256
8181
CONFIG_RT_CONSOLE_DEVICE_NAME="console"
8282
CONFIG_RT_VER_NUM=0x50001
8383
# CONFIG_RT_USING_STDC_ATOMIC is not set

bsp/simulator/gcc_elf64.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ SECTIONS
6666

6767
/* setction information for finsh shell begin */
6868
. = ALIGN(8);
69+
UtestTcTab : {
70+
__rt_utest_tc_tab_start = .;
71+
KEEP(*(UtestTcTab))
72+
__rt_utest_tc_tab_end = .;
73+
}
74+
. = ALIGN(8);
6975
FSymTab : {
7076
__fsymtab_start = .;
7177
KEEP(*(FSymTab))

bsp/simulator/rtconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#define RT_USING_DEVICE
4444
#define RT_USING_CONSOLE
45-
#define RT_CONSOLEBUF_SIZE 128
45+
#define RT_CONSOLEBUF_SIZE 256
4646
#define RT_CONSOLE_DEVICE_NAME "console"
4747
#define RT_VER_NUM 0x50001
4848

components/utilities/utest/utest.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ int utest_init(void)
8888
#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
8989
tc_table = (utest_tc_export_t)__section_begin("UtestTcTab");
9090
tc_num = (utest_tc_export_t)__section_end("UtestTcTab") - tc_table;
91-
#elif defined (__GNUC__) /* for GCC Compiler */
91+
#else
92+
unsigned int *ptr_begin, *ptr_end;
93+
#if defined(__GNUC__)
9294
extern const int __rt_utest_tc_tab_start;
9395
extern const int __rt_utest_tc_tab_end;
94-
tc_table = (utest_tc_export_t)&__rt_utest_tc_tab_start;
95-
tc_num = (utest_tc_export_t) &__rt_utest_tc_tab_end - tc_table;
96+
ptr_begin = (unsigned int *)&__rt_utest_tc_tab_start;
97+
ptr_end = (unsigned int *)&__rt_utest_tc_tab_end;
9698
#elif defined(_MSC_VER)
97-
unsigned int* ptr_begin, * ptr_end;
98-
99-
ptr_begin = (unsigned int*)&__tc_export_begin;
99+
ptr_begin = (unsigned int *)&__tc_export_begin;
100+
ptr_end = (unsigned int *)&__tc_export_end;
100101
ptr_begin += (sizeof(struct utest_tc_export) / sizeof(unsigned int));
102+
#endif
101103
while (*ptr_begin == 0) ptr_begin++;
102-
103-
ptr_end = (unsigned int*)&__tc_export_end;
104104
ptr_end--;
105105
while (*ptr_end == 0) ptr_end--;
106106
/* copy tc_table from rodata section to ram */

src/kservice.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,13 @@ rt_inline void _heap_unlock(rt_base_t level)
15741574

15751575
#ifdef RT_USING_UTESTCASES
15761576
/* export to utest to observe the inner statements */
1577+
#ifdef _MSC_VER
1578+
#define rt_heap_lock() _heap_lock()
1579+
#define rt_heap_unlock() _heap_unlock()
1580+
#else
15771581
rt_base_t rt_heap_lock(void) __attribute__((alias("_heap_lock")));
15781582
void rt_heap_unlock(rt_base_t level) __attribute__((alias("_heap_unlock")));
1583+
#endif /* _MSC_VER */
15791584
#endif
15801585

15811586
#if defined(RT_USING_SMALL_MEM_AS_HEAP)

0 commit comments

Comments
 (0)