Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
码匠许师傅
rt-thread
提交
2c119a5c
R
rt-thread
项目概览
码匠许师傅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
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,发现更多精彩内容 >>
提交
2c119a5c
编写于
6月 03, 2021
作者:
G
guozhanxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add memheap testcase for ac6 Oz optimization.
上级
aa13a78b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
1 deletion
+125
-1
examples/utest/testcases/Kconfig
examples/utest/testcases/Kconfig
+1
-0
examples/utest/testcases/kernel/Kconfig
examples/utest/testcases/kernel/Kconfig
+8
-0
examples/utest/testcases/kernel/SConscript
examples/utest/testcases/kernel/SConscript
+15
-0
examples/utest/testcases/kernel/memheap_tc.c
examples/utest/testcases/kernel/memheap_tc.c
+100
-0
examples/utest/testcases/utest/pass_tc.c
examples/utest/testcases/utest/pass_tc.c
+1
-1
未找到文件。
examples/utest/testcases/Kconfig
浏览文件 @
2c119a5c
...
...
@@ -8,6 +8,7 @@ config RT_USING_UTESTCASES
if RT_USING_UTESTCASES
source "$RTT_DIR/examples/utest/testcases/utest/Kconfig"
source "$RTT_DIR/examples/utest/testcases/kernel/Kconfig"
endif
...
...
examples/utest/testcases/kernel/Kconfig
0 → 100644
浏览文件 @
2c119a5c
menu "Kernel Testcase"
config UTEST_MEMHEAP_TC
bool "memheap stability test"
default y
depends on RT_USING_MEMHEAP
endmenu
examples/utest/testcases/kernel/SConscript
0 → 100644
浏览文件 @
2c119a5c
Import
(
'rtconfig'
)
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Split
(
'''
'''
)
if
GetDepend
([
'UTEST_MEMHEAP_TC'
]):
src
+=
[
'memheap_tc.c'
]
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'utestcases'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
examples/utest/testcases/kernel/memheap_tc.c
0 → 100644
浏览文件 @
2c119a5c
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-01-16 flybreak the first version
*/
#include <rtthread.h>
#include <stdlib.h>
#include "utest.h"
#define HEAP_SIZE (64 * 1024)
#define HEAP_ALIGN (4)
#define SLICE_NUM (40)
#define TEST_TIMES (100000)
#define HEAP_NAME "heap1"
#define SLICE_SIZE_MAX (HEAP_SIZE/SLICE_NUM)
static
void
memheap_test
(
void
)
{
struct
rt_memheap
heap1
;
rt_uint32_t
ptr_start
;
void
*
ptr
[
SLICE_NUM
];
int
i
,
cnt
=
0
;
/* init heap */
ptr_start
=
(
rt_uint32_t
)
rt_malloc_align
(
HEAP_SIZE
,
HEAP_ALIGN
);
if
(
ptr_start
==
RT_NULL
)
{
rt_kprintf
(
"totle size too big,can not malloc memory!"
);
return
;
}
rt_memheap_init
(
&
heap1
,
HEAP_NAME
,
(
void
*
)
ptr_start
,
HEAP_SIZE
);
/* test start */
for
(
i
=
0
;
i
<
SLICE_NUM
;
i
++
)
{
ptr
[
i
]
=
0
;
}
/* test alloc */
for
(
i
=
0
;
i
<
SLICE_NUM
;
i
++
)
{
rt_uint32_t
slice_size
=
rand
()
%
SLICE_SIZE_MAX
;
ptr
[
i
]
=
rt_memheap_alloc
(
&
heap1
,
slice_size
);
}
/* test realloc */
while
(
cnt
<
TEST_TIMES
)
{
rt_uint32_t
slice_size
=
rand
()
%
SLICE_SIZE_MAX
;
rt_uint32_t
ptr_index
=
rand
()
%
SLICE_NUM
;
rt_uint32_t
operation
=
rand
()
%
2
;
if
(
ptr
[
ptr_index
])
{
if
(
operation
==
0
)
/* free and malloc */
{
if
(
ptr
[
ptr_index
])
{
rt_memheap_free
(
ptr
[
ptr_index
]);
}
ptr
[
ptr_index
]
=
rt_memheap_alloc
(
&
heap1
,
slice_size
);
}
else
/* realloc */
{
ptr
[
ptr_index
]
=
rt_memheap_realloc
(
&
heap1
,
ptr
[
ptr_index
],
slice_size
);
}
}
cnt
++
;
if
(
cnt
%
(
TEST_TIMES
/
10
)
==
0
)
{
rt_kprintf
(
">"
);
}
}
rt_kprintf
(
"test OK!
\n
"
);
/* test end */
rt_memheap_detach
(
&
heap1
);
rt_free_align
((
void
*
)
ptr_start
);
}
static
rt_err_t
utest_tc_init
(
void
)
{
return
RT_EOK
;
}
static
rt_err_t
utest_tc_cleanup
(
void
)
{
return
RT_EOK
;
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
memheap_test
);
}
UTEST_TC_EXPORT
(
testcase
,
"testcases.kernel.memheap_tc"
,
utest_tc_init
,
utest_tc_cleanup
,
10
);
examples/utest/testcases/utest/pass_tc.c
浏览文件 @
2c119a5c
...
...
@@ -43,4 +43,4 @@ static void testcase(void)
{
UTEST_UNIT_RUN
(
test_assert_pass
);
}
UTEST_TC_EXPORT
(
testcase
,
"testcases.utest.pass_tc"
,
utest_tc_init
,
utest_tc_cleanup
,
10
);
\ No newline at end of file
UTEST_TC_EXPORT
(
testcase
,
"testcases.utest.pass_tc"
,
utest_tc_init
,
utest_tc_cleanup
,
10
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录