* [tools] Add `--add-rtconfig` args for scons when you want to add macro definitions build time.

* [utilities][utest] Add VS simulator support.
This commit is contained in:
朱天龙 (Armink) 2023-04-22 21:49:20 +08:00 committed by GitHub
parent 4f1c3a1472
commit 69e6c3017b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 1 deletions

View File

@ -51,6 +51,18 @@ static struct utest local_utest = {UTEST_PASSED, 0, 0};
#if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */
#pragma section="UtestTcTab"
#elif defined(_MSC_VER)
#pragma section("UtestTcTab$a", read)
__declspec(allocate("UtestTcTab$a")) const struct utest_tc_export __tc_export_begin =
{
"__start",
};
#pragma section("UtestTcTab$z", read)
__declspec(allocate("UtestTcTab$z")) const struct utest_tc_export __tc_export_end =
{
"__end",
};
#endif
#define TC_FAIL_LIST_SIZE (RT_ALIGN(tc_num, 8) / 8)
@ -81,6 +93,28 @@ int utest_init(void)
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;
#elif defined(_MSC_VER)
unsigned int* ptr_begin, * ptr_end;
ptr_begin = (unsigned int*)&__tc_export_begin;
ptr_begin += (sizeof(struct utest_tc_export) / sizeof(unsigned int));
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 */
for (unsigned int *ptr = ptr_begin; ptr < ptr_end;)
{
if (!tc_table)
tc_table = (utest_tc_export_t)rt_malloc(sizeof(struct utest_tc_export));
else
tc_table = (utest_tc_export_t)rt_realloc(tc_table, (tc_num + 1)* sizeof(struct utest_tc_export));
RT_ASSERT(tc_table);
tc_table[tc_num++] = *((utest_tc_export_t)ptr);
ptr += (sizeof(struct utest_tc_export) / sizeof(unsigned int));
while (*ptr == 0) ptr++;
}
#endif
LOG_I("utest is initialize success.");

View File

@ -136,9 +136,23 @@ utest_t utest_handle_get(void);
* @return None
*
*/
#ifdef _MSC_VER
#pragma section("UtestTcTab$f",read)
#define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \
__declspec(allocate("UtestTcTab$f")) \
static const struct utest_tc_export _utest_testcase = \
{ \
name, \
timeout, \
init, \
testcase, \
cleanup \
}
#pragma comment(linker, "/merge:UtestTcTab=tctext")
#else
#define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \
rt_used static const struct utest_tc_export _utest_testcase \
rt_section("UtestTcTab") = \
rt_section("UtestTcTab") = \
{ \
name, \
timeout, \
@ -146,6 +160,7 @@ utest_t utest_handle_get(void);
testcase, \
cleanup \
}
#endif /* _MSC_VER */
/**
* UTEST_UNIT_RUN