diff options
| author | Lim-LinYuanbo <[email protected]> | 2021-09-08 22:45:31 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-09-08 22:45:31 +0800 |
| commit | b404f69f851817c62697074ffb363294b91585c6 (patch) | |
| tree | f5f31152993843a5e07559a6b7b0caddcc9ebd0a /components/utilities | |
| parent | 49fcf9f4cd436d30d2df8c4e24b751194c32f43b (diff) | |
| parent | 7fa1c819ee852937705d948a58f0218c422ea6b1 (diff) | |
Merge branch 'master' into master
Diffstat (limited to 'components/utilities')
| -rw-r--r-- | components/utilities/ulog/ulog.c | 4 | ||||
| -rw-r--r-- | components/utilities/utest/utest.c | 40 |
2 files changed, 42 insertions, 2 deletions
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index c36fc6ff26..89ba58cf48 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -1075,7 +1075,7 @@ const char *ulog_global_filter_kw_get(void) return ulog.filter.keyword; } -#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) +#ifdef(RT_USING_FINSH) #include <finsh.h> static void _print_lvl_info(void) @@ -1250,7 +1250,7 @@ static void ulog_filter(uint8_t argc, char **argv) } } MSH_CMD_EXPORT(ulog_filter, Show ulog filter settings); -#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */ +#endif defined(RT_USING_FINSH) #endif /* ULOG_USING_FILTER */ rt_err_t ulog_backend_register(ulog_backend_t backend, const char *name, rt_bool_t support_color) diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 325823de8a..7103efb89c 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -46,12 +46,17 @@ static rt_uint8_t utest_log_lv = UTEST_LOG_ALL; static utest_tc_export_t tc_table = RT_NULL; static rt_size_t tc_num; static rt_uint32_t tc_loop; +static rt_uint8_t *tc_fail_list; static struct utest local_utest = {UTEST_PASSED, 0, 0}; #if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */ #pragma section="UtestTcTab" #endif +#define TC_FAIL_LIST_SIZE (RT_ALIGN(tc_num, 8) / 8) +#define TC_FAIL_LIST_MARK_FAILED(index) (tc_fail_list[index / 8] |= (1UL << (index % 8))) +#define TC_FAIL_LIST_IS_FAILED(index) (tc_fail_list[index / 8] & (1UL << (index % 8))) + void utest_log_lv_set(rt_uint8_t lv) { if (lv == UTEST_LOG_ALL || lv == UTEST_LOG_ASSERT) @@ -80,6 +85,14 @@ int utest_init(void) LOG_I("utest is initialize success."); LOG_I("total utest testcase num: (%d)", tc_num); + if (tc_num > 0) + { + tc_fail_list = rt_malloc(TC_FAIL_LIST_SIZE); + if(!tc_fail_list) + { + LOG_E("no memory, tc_fail_list init failed!"); + } + } return tc_num; } INIT_COMPONENT_EXPORT(utest_init); @@ -147,6 +160,8 @@ static void utest_run(const char *utest_name) rt_size_t i; rt_uint32_t index; rt_bool_t is_find; + rt_uint32_t tc_fail_num = 0; + rt_uint32_t tc_run_num = 0; rt_thread_mdelay(1000); @@ -154,6 +169,14 @@ static void utest_run(const char *utest_name) { i = 0; is_find = RT_FALSE; + + tc_fail_num = 0; + tc_run_num = 0; + if (tc_fail_list) + { + memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE); + } + LOG_I("[==========] [ utest ] loop %d/%d", index + 1, tc_loop); LOG_I("[==========] [ utest ] started"); while(i < tc_num) @@ -192,6 +215,8 @@ static void utest_run(const char *utest_name) } else { + TC_FAIL_LIST_MARK_FAILED(i); + tc_fail_num ++; LOG_E("[ FAILED ] [ result ] testcase (%s)", tc_table[i].name); } } @@ -212,6 +237,7 @@ static void utest_run(const char *utest_name) __tc_continue: LOG_I("[----------] [ testcase ] (%s) finished", tc_table[i].name); + tc_run_num ++; i++; } @@ -223,6 +249,20 @@ static void utest_run(const char *utest_name) } LOG_I("[==========] [ utest ] finished"); + LOG_I("[==========] [ utest ] %d tests from %d testcase ran.", tc_run_num, tc_num); + LOG_I("[ PASSED ] [ result ] %d tests.", tc_run_num - tc_fail_num); + + if(tc_fail_list && (tc_fail_num > 0)) + { + LOG_E("[ FAILED ] [ result ] %d tests, listed below:", tc_fail_num); + for(i = 0; i < tc_num; i ++) + { + if (TC_FAIL_LIST_IS_FAILED(i)) + { + LOG_E("[ FAILED ] [ result ] %s", tc_table[i].name); + } + } + } } } |
