Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
py_free-物联智能
rt-thread
提交
0962469c
R
rt-thread
项目概览
py_free-物联智能
/
rt-thread
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
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,发现更多精彩内容 >>
未验证
提交
0962469c
编写于
1月 23, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
1月 23, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2251 from zhaojuntao/fix-utest-0122
[components][utest] 修复日志打印问题并增加内存比较接口
上级
ec7ee29c
f9e5d87c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
6 deletion
+44
-6
components/utilities/utest/utest.c
components/utilities/utest/utest.c
+35
-4
components/utilities/utest/utest.h
components/utilities/utest/utest.h
+3
-2
components/utilities/utest/utest_assert.h
components/utilities/utest/utest_assert.h
+6
-0
未找到文件。
components/utilities/utest/utest.c
浏览文件 @
0962469c
...
...
@@ -112,7 +112,7 @@ static void utest_run(const char *utest_name)
{
if
(
tc_table
[
i
].
init
()
!=
RT_EOK
)
{
LOG_
I
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
LOG_
E
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
goto
__tc_continue
;
}
}
...
...
@@ -126,19 +126,19 @@ static void utest_run(const char *utest_name)
}
else
{
LOG_
I
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
LOG_
E
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
}
}
else
{
LOG_
I
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
LOG_
E
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
}
if
(
tc_table
[
i
].
cleanup
!=
RT_NULL
)
{
if
(
tc_table
[
i
].
cleanup
()
!=
RT_EOK
)
{
LOG_
I
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
LOG_
E
(
"[ FAILED ] [ result ] testcase (%s)"
,
tc_table
[
i
].
name
);
goto
__tc_continue
;
}
}
...
...
@@ -236,3 +236,34 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
}
}
}
void
utest_assert_buf
(
const
char
*
a
,
const
char
*
b
,
rt_size_t
sz
,
rt_bool_t
equal
,
const
char
*
file
,
int
line
,
const
char
*
func
,
const
char
*
msg
)
{
if
(
a
==
RT_NULL
||
b
==
RT_NULL
)
{
utest_assert
(
0
,
file
,
line
,
func
,
msg
);
}
if
(
equal
)
{
if
(
rt_memcmp
(
a
,
b
,
sz
)
==
0
)
{
utest_assert
(
1
,
file
,
line
,
func
,
msg
);
}
else
{
utest_assert
(
0
,
file
,
line
,
func
,
msg
);
}
}
else
{
if
(
rt_memcmp
(
a
,
b
,
sz
)
==
0
)
{
utest_assert
(
0
,
file
,
line
,
func
,
msg
);
}
else
{
utest_assert
(
1
,
file
,
line
,
func
,
msg
);
}
}
}
components/utilities/utest/utest.h
浏览文件 @
0962469c
...
...
@@ -13,6 +13,7 @@
#include <rtthread.h>
#include "utest_log.h"
#include "utest_assert.h"
/**
* utest_error
...
...
@@ -57,7 +58,7 @@ typedef struct utest *utest_t;
* Will export the data to `UtestTcTab` section in flash.
*
* @member name Testcase name.
* @member run_timeout Testcase maximum test time.
* @member run_timeout Testcase maximum test time
(Time unit: seconds)
.
* @member init Necessary initialization before executing the test case function.
* @member tc Total number of tests failed.
* @member cleanup Total number of tests failed.
...
...
@@ -125,7 +126,7 @@ utest_t utest_handle_get(void);
* @param name The testcase name.
* @param init The initialization function of the test case.
* @param cleanup The cleanup function of the test case.
* @param timeout Testcase maximum test time.
* @param timeout Testcase maximum test time
(Time unit: seconds)
.
*
* @return None
*
...
...
components/utilities/utest/utest_assert.h
浏览文件 @
0962469c
...
...
@@ -19,6 +19,7 @@ void utest_assert(int value, const char *file, int line, const char *func, const
/* No need for the user to use this function directly */
void
utest_assert_string
(
const
char
*
a
,
const
char
*
b
,
rt_bool_t
equal
,
const
char
*
file
,
int
line
,
const
char
*
func
,
const
char
*
msg
);
void
utest_assert_buf
(
const
char
*
a
,
const
char
*
b
,
rt_size_t
sz
,
rt_bool_t
equal
,
const
char
*
file
,
int
line
,
const
char
*
func
,
const
char
*
msg
);
/* No need for the user to use this macro directly */
#define __utest_assert(value, msg) utest_assert(value, __FILE__, __LINE__, __func__, msg)
...
...
@@ -37,6 +38,8 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
* @macro uassert_int_not_equal if @a not equal to @b, not assert, means passing. Integer type test.
* @macro uassert_str_equal if @a equal to @b, not assert, means passing. String type test.
* @macro uassert_str_not_equal if @a not equal to @b, not assert, means passing. String type test.
* @macro uassert_buf_equal if @a equal to @b, not assert, means passing. buf type test.
* @macro uassert_buf_not_equal if @a not equal to @b, not assert, means passing. buf type test.
* @macro uassert_in_range if @value is in range of min and max, not assert, means passing.
* @macro uassert_not_in_range if @value is not in range of min and max, not assert, means passing.
*
...
...
@@ -52,6 +55,9 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch
#define uassert_str_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_TRUE, __FILE__, __LINE__, __func__, "string not equal")
#define uassert_str_not_equal(a, b) utest_assert_string((const char*)(a), (const char*)(b), RT_FALSE, __FILE__, __LINE__, __func__, "string equal")
#define uassert_buf_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_TRUE, __FILE__, __LINE__, __func__, "buf not equal")
#define uassert_buf_not_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_FALSE, __FILE__, __LINE__, __func__, "buf equal")
#define uassert_in_range(value, min, max) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")")
#define uassert_not_in_range(value, min, max) __utest_assert(!((value >= min) && (value <= max)), "(" #value ") in range("#min","#max")")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录