Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
宁楠萍
rt-thread
提交
0e8b23ff
R
rt-thread
项目概览
宁楠萍
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e8b23ff
编写于
12月 18, 2013
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #212 from grissiom/fix-tc
Fix tc
上级
cb347f5a
a51b5799
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
85 addition
and
60 deletion
+85
-60
examples/kernel/heap_malloc.c
examples/kernel/heap_malloc.c
+13
-11
examples/kernel/heap_realloc.c
examples/kernel/heap_realloc.c
+37
-18
examples/kernel/semaphore_dynamic.c
examples/kernel/semaphore_dynamic.c
+6
-3
examples/kernel/semaphore_priority.c
examples/kernel/semaphore_priority.c
+6
-0
examples/kernel/semaphore_producer_consumer.c
examples/kernel/semaphore_producer_consumer.c
+4
-0
examples/kernel/tc_comm.c
examples/kernel/tc_comm.c
+19
-28
未找到文件。
examples/kernel/heap_malloc.c
浏览文件 @
0e8b23ff
...
...
@@ -9,8 +9,8 @@ static rt_bool_t mem_check(rt_uint8_t *ptr, rt_uint8_t value, rt_uint32_t len)
{
while
(
len
)
{
if
(
*
ptr
!=
value
)
return
RT_FALSE
;
if
(
*
ptr
!=
value
)
return
RT_FALSE
;
ptr
++
;
len
--
;
}
...
...
@@ -20,6 +20,7 @@ static rt_bool_t mem_check(rt_uint8_t *ptr, rt_uint8_t value, rt_uint32_t len)
static
void
heap_malloc_init
()
{
rt_uint8_t
res
=
TC_STAT_PASSED
;
rt_uint8_t
*
ptr1
,
*
ptr2
,
*
ptr3
,
*
ptr4
,
*
ptr5
;
ptr1
=
rt_malloc
(
1
);
...
...
@@ -33,14 +34,18 @@ static void heap_malloc_init()
memset
(
ptr3
,
3
,
31
);
memset
(
ptr4
,
4
,
127
);
if
(
mem_check
(
ptr1
,
1
,
1
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr2
,
2
,
13
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr3
,
3
,
31
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr4
,
4
,
127
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr1
,
1
,
1
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr2
,
2
,
13
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr3
,
3
,
31
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr4
,
4
,
127
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
rt_free
(
ptr4
);
rt_free
(
ptr3
);
rt_free
(
ptr
3
);
rt_free
(
ptr
2
);
rt_free
(
ptr1
);
if
(
ptr5
!=
RT_NULL
)
...
...
@@ -48,10 +53,7 @@ static void heap_malloc_init()
rt_free
(
ptr5
);
}
tc_done
(
TC_STAT_PASSED
);
_failed:
tc_done
(
TC_STAT_FAILED
);
tc_done
(
res
);
}
#ifdef RT_USING_TC
...
...
examples/kernel/heap_realloc.c
浏览文件 @
0e8b23ff
...
...
@@ -20,6 +20,7 @@ static rt_bool_t mem_check(rt_uint8_t *ptr, rt_uint8_t value, rt_uint32_t len)
static
void
heap_realloc_init
()
{
rt_uint8_t
res
=
TC_STAT_PASSED
;
rt_uint8_t
*
ptr1
,
*
ptr2
,
*
ptr3
,
*
ptr4
,
*
ptr5
;
ptr1
=
rt_malloc
(
1
);
...
...
@@ -33,36 +34,54 @@ static void heap_realloc_init()
memset
(
ptr3
,
3
,
31
);
memset
(
ptr4
,
4
,
127
);
if
(
mem_check
(
ptr1
,
1
,
1
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr2
,
2
,
13
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr3
,
3
,
31
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr4
,
4
,
127
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr1
,
1
,
1
)
==
RT_FALSE
)
{
res
=
TC_STAT_FAILED
;
goto
_free
;
}
if
(
mem_check
(
ptr2
,
2
,
13
)
==
RT_FALSE
)
{
res
=
TC_STAT_FAILED
;
goto
_free
;
}
if
(
mem_check
(
ptr3
,
3
,
31
)
==
RT_FALSE
)
{
res
=
TC_STAT_FAILED
;
goto
_free
;
}
if
(
mem_check
(
ptr4
,
4
,
127
)
==
RT_FALSE
)
{
res
=
TC_STAT_FAILED
;
goto
_free
;
}
ptr1
=
rt_realloc
(
ptr1
,
13
);
ptr2
=
rt_realloc
(
ptr2
,
31
);
ptr3
=
rt_realloc
(
ptr3
,
127
);
ptr4
=
rt_realloc
(
ptr4
,
1
);
ptr5
=
rt_realloc
(
ptr5
,
0
);
if
(
ptr5
)
{
rt_kprintf
(
"realloc(ptr, 0) should return NULL
\n
"
);
res
=
TC_STAT_FAILED
;
}
if
(
mem_check
(
ptr1
,
1
,
1
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr2
,
2
,
13
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr3
,
3
,
31
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr4
,
4
,
1
)
!=
RT_FALSE
)
goto
_failed
;
if
(
mem_check
(
ptr1
,
1
,
1
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr2
,
2
,
13
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr3
,
3
,
31
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
if
(
mem_check
(
ptr4
,
4
,
1
)
==
RT_FALSE
)
res
=
TC_STAT_FAILED
;
_free:
rt_free
(
ptr4
);
rt_free
(
ptr3
);
rt_free
(
ptr
3
);
rt_free
(
ptr
2
);
rt_free
(
ptr1
);
if
(
ptr5
!=
RT_NULL
)
{
rt_free
(
ptr5
);
}
tc_done
(
TC_STAT_PASSED
);
_failed:
tc_done
(
TC_STAT_FAILED
);
tc_done
(
res
);
}
#ifdef RT_USING_TC
...
...
examples/kernel/semaphore_dynamic.c
浏览文件 @
0e8b23ff
...
...
@@ -90,13 +90,16 @@ static void _tc_cleanup()
/* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */
rt_enter_critical
();
if
(
sem
)
{
rt_sem_delete
(
sem
);
sem
=
RT_NULL
;
}
/* 删除线程 */
if
(
tid
!=
RT_NULL
&&
tid
->
stat
!=
RT_THREAD_CLOSE
)
{
rt_thread_delete
(
tid
);
/* 删除信号量 */
rt_sem_delete
(
sem
);
}
/* 调度器解锁 */
...
...
examples/kernel/semaphore_priority.c
浏览文件 @
0e8b23ff
...
...
@@ -100,6 +100,12 @@ static void _tc_cleanup()
rt_thread_delete
(
t2
);
rt_thread_delete
(
worker
);
if
(
sem
)
{
rt_sem_delete
(
sem
);
sem
=
RT_NULL
;
}
if
(
t1_count
>
t2_count
)
tc_done
(
TC_STAT_FAILED
);
else
...
...
examples/kernel/semaphore_producer_consumer.c
浏览文件 @
0e8b23ff
...
...
@@ -119,6 +119,10 @@ static void _tc_cleanup()
/* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */
rt_enter_critical
();
rt_sem_detach
(
&
sem_lock
);
rt_sem_detach
(
&
sem_empty
);
rt_sem_detach
(
&
sem_full
);
/* 删除线程 */
if
(
producer_tid
!=
RT_NULL
&&
producer_tid
->
stat
!=
RT_THREAD_CLOSE
)
rt_thread_delete
(
producer_tid
);
...
...
examples/kernel/tc_comm.c
浏览文件 @
0e8b23ff
...
...
@@ -37,34 +37,25 @@ void tc_thread_entry(void* parameter)
_tc_current
=
index
->
name
+
4
;
rt_kprintf
(
"Run TestCase: %s
\n
"
,
_tc_current
);
_tc_stat
=
TC_STAT_PASSED
|
TC_STAT_RUNNING
;
tick
=
index
->
func
();
if
(
tick
>
0
)
{
rt_sem_take
(
&
_tc_sem
,
tick
*
_tc_scale
);
if
(
_tc_cleanup
!=
RT_NULL
)
{
/* perform testcase cleanup */
_tc_cleanup
();
_tc_cleanup
=
RT_NULL
;
}
rt_sem_trytake
(
&
_tc_sem
);
/* by nl1031 */
if
(
_tc_stat
&
TC_STAT_FAILED
)
rt_kprintf
(
"TestCase[%s] failed
\n
"
,
_tc_current
);
else
rt_kprintf
(
"TestCase[%s] passed
\n
"
,
_tc_current
);
}
else
{
if
(
_tc_cleanup
!=
RT_NULL
)
{
/* perform testcase cleanup */
_tc_cleanup
();
_tc_cleanup
=
RT_NULL
;
}
}
tick
=
index
->
func
();
if
(
tick
>
0
)
{
/* Make sure we are going to be blocked. */
rt_sem_control
(
&
_tc_sem
,
RT_IPC_CMD_RESET
,
0
);
rt_sem_take
(
&
_tc_sem
,
tick
*
_tc_scale
);
}
if
(
_tc_cleanup
!=
RT_NULL
)
{
/* perform testcase cleanup */
_tc_cleanup
();
_tc_cleanup
=
RT_NULL
;
}
if
(
_tc_stat
&
TC_STAT_FAILED
)
rt_kprintf
(
"TestCase[%s] failed
\n
"
,
_tc_current
);
else
rt_kprintf
(
"TestCase[%s] passed
\n
"
,
_tc_current
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录