Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wwsmg1
rt-thread
提交
4af99b0d
R
rt-thread
项目概览
wwsmg1
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4af99b0d
编写于
8月 17, 2021
作者:
G
guozhanxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[add] utest add fail_list.
上级
196f340e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
0 deletion
+37
-0
components/utilities/utest/utest.c
components/utilities/utest/utest.c
+37
-0
未找到文件。
components/utilities/utest/utest.c
浏览文件 @
4af99b0d
...
...
@@ -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[RT_ALIGN(index, 8) / 8] |= (1UL << (index % 8)))
#define TC_FAIL_LIST_IS_FAILED(index) (tc_fail_list[RT_ALIGN(index, 8) / 8] & (1UL << (index % 8)))
void
utest_log_lv_set
(
rt_uint8_t
lv
)
{
if
(
lv
==
UTEST_LOG_ALL
||
lv
==
UTEST_LOG_ASSERT
)
...
...
@@ -78,6 +83,11 @@ int utest_init(void)
tc_num
=
(
utest_tc_export_t
)
&
__rt_utest_tc_tab_end
-
tc_table
;
#endif
tc_fail_list
=
rt_malloc
(
TC_FAIL_LIST_SIZE
);
if
(
!
tc_fail_list
)
{
LOG_E
(
"no memory, tc_fail_list init failed!"
);
}
LOG_I
(
"utest is initialize success."
);
LOG_I
(
"total utest testcase num: (%d)"
,
tc_num
);
return
tc_num
;
...
...
@@ -147,6 +157,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 +166,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 +212,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 +234,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 +246,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
);
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录