Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libwd
提交
5fcd5067
L
libwd
项目概览
openeuler
/
libwd
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libwd
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5fcd5067
编写于
6月 29, 2020
作者:
W
wunianqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove the unnecessary ut file
上级
e3a3eea1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
298 deletion
+0
-298
ut/ut.c
ut/ut.c
+0
-105
ut/ut.rst
ut/ut.rst
+0
-4
ut/wd_sched.ut.c
ut/wd_sched.ut.c
+0
-189
未找到文件。
ut/ut.c
已删除
100644 → 0
浏览文件 @
e3a3eea1
/*
* Copyright (C) 2019. Huawei Technologies Co.,Ltd.All rights reserved.
*
* Description: unit testing helper file, use only under linux with glibc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <execinfo.h>
#include <stdarg.h>
#include <setjmp.h>
/**** ut_assert ****/
#define ut_assert(cond) ut_assert_func(__FILE__, __LINE__, !!(cond), "")
#define ut_assert_str(cond, fmt, ...) ut_assert_func(__FILE__, __LINE__, !!(cond), fmt, ##__VA_ARGS__)
#ifdef UT_DUMPSTACK
#define ut_dumpstack() dumpstack()
#ifndef DUMP_DEEP
#define DUMP_DEEP 10
#endif
void
dumpstack
(
void
)
{
void
*
arr
[
DUMP_DEEP
];
int
l
,
i
;
l
=
backtrace
(
arr
,
DUMP_DEEP
);
fprintf
(
stderr
,
"dump stack:
\n
"
);
for
(
i
=
0
;
i
<
l
;
i
++
)
{
fprintf
(
stderr
,
"0x%lx
\n
"
,
(
unsigned
long
)
arr
[
i
]);
}
}
#else
#define ut_dumpstack()
#endif
void
ut_assert_func
(
char
*
f
,
int
line
,
int
cond
,
const
char
*
fmt
,
...)
{
va_list
args
;
va_start
(
args
,
fmt
);
if
(
!
cond
)
{
printf
(
"testfail at %s:%i: "
,
f
,
line
);
vprintf
(
fmt
,
args
);
printf
(
"
\n
"
);
ut_dumpstack
();
abort
();
}
va_end
(
args
);
}
/**** testcase and broken jump ****/
void
default_broken
(
int
val
)
{
printf
(
"broken from test (val=%d)
\n
"
,
val
);
}
int
testcase
=
0
;
jmp_buf
jmpenv
;
void
(
*
broken
)(
int
val
)
=
default_broken
;
static
inline
void
testj
(
void
(
*
test_func
)(
void
))
{
if
(
setjmp
(
jmpenv
))
{
broken
(
-
1
);
}
else
{
test_func
();
}
}
#define ut_break(val) longjmp(jmpenv, val)
#define test(tc, test_func) \
testcase = tc; \
printf("test %s(%d)...", #test_func, tc); \
testj(test_func); \
printf("done\n");
#define in_test(from, to) (testcase >= (from) && testcase < (to))
#define ret_in_test(from, to) if(in_test(from, to)) return
/**** pair counter ****/
#define ut_cnt_val_range(tcid1, tcid2, cls) utcnt_##tcid1##_##tcid2##cls
#define ut_cnt_def_range(tcid1, tcid2, cls) int ut_cnt_val_range(tcid1, tcid2, cls) = 0
#define ut_cnt_add_range(tcid1, tcid2, cls) if(testcase>=tcid1&&testcase<=tcid2) ut_cnt_val_range(tcid1, tcid2, cls)++
#define ut_cnt_sub_range(tcid1, tcid2, cls) if(testcase>=tcid1&&testcase<=tcid2) ut_cnt_val_range(tcid1, tcid2, cls)--
#define ut_check_cnt_var_range(tcid1, tcid2, cls, var) \
ut_assert_str(ut_cnt_val_range(tcid1, tcid2, cls)==var, \
"testcase %d-%d fail on pair check for %s: %d\n", \
tcid1, tcid2, #cls, ut_cnt_val_range(tcid1, tcid2, cls))
#define ut_check_cnt_range(tcid1, tcid2, cls) ut_check_cnt_var_range(tcid1, tcid2, cls, 0)
#define ut_cnt_def(tcid, cls) ut_cnt_def_range(tcid, tcid, cls)
#define ut_cnt_add(tcid, cls) ut_cnt_add_range(tcid, tcid, cls)
#define ut_cnt_sub(tcid, cls) ut_cnt_sub_range(tcid, tcid, cls)
#define ut_check_cnt_var(tcid, cls, var) ut_check_cnt_var_range(tcid, tcid, cls, var)
#define ut_check_cnt(tcid, cls) ut_check_cnt_range(tcid, tcid, cls)
ut/ut.rst
已删除
100644 → 0
浏览文件 @
e3a3eea1
WarpDrive UT
============
This directory contains UT code for any WarpDrive user modules.
ut/wd_sched.ut.c
已删除
100644 → 0
浏览文件 @
e3a3eea1
/*
* Copyright (C) 2019. Huawei Technologies Co.,Ltd.All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ut.c"
#include "../wd_sched.c"
static
ut_cnt_def_range
(
100
,
110
,
get_q
);
int
wd_request_queue
(
struct
wd_queue
*
q
)
{
static
int
tc_101_cnt
=
0
;
if
(
testcase
==
101
&&
tc_101_cnt
++==
2
)
{
return
-
1
;
}
ut_cnt_add_range
(
100
,
110
,
get_q
);
return
0
;
}
void
wd_release_queue
(
struct
wd_queue
*
q
)
{
ut_cnt_sub_range
(
100
,
110
,
get_q
);
}
void
*
wd_reserve_memory
(
struct
wd_queue
*
q
,
size_t
size
)
{
return
NULL
;
}
int
wd_share_reserved_memory
(
struct
wd_queue
*
q
,
struct
wd_queue
*
target_q
)
{
return
0
;
}
struct
wd_queue
*
last_used_sq
,
*
last_used_rq
;
int
wd_send
(
struct
wd_queue
*
q
,
void
*
req
)
{
last_used_sq
=
q
;
return
0
;
}
int
wd_recv_sync
(
struct
wd_queue
*
q
,
void
**
resp
,
__u16
ms
)
{
last_used_rq
=
q
;
return
0
;
}
int
smm_init
(
void
*
pt_addr
,
size_t
size
,
int
align_mask
)
{
return
0
;
}
void
*
smm_alloc
(
void
*
pt_addr
,
size_t
size
)
{
return
malloc
(
size
);
}
static
void
_sched_init_cache
(
struct
wd_scheduler
*
sched
,
int
i
)
{
}
static
int
_sched_input
(
struct
wd_msg
*
msg
,
void
*
priv
)
{
return
0
;
}
static
int
_sched_output
(
struct
wd_msg
*
msg
,
void
*
priv
)
{
return
0
;
}
#define Q_NUM 3
#define MSG_CACHE_NUM 4
#define MSG_DATA_SIZE 32
struct
wd_queue
qs
[
Q_NUM
];
struct
wd_scheduler
sched
=
{
.
q_num
=
Q_NUM
,
.
ss_region_size
=
0
,
.
msg_cache_num
=
MSG_CACHE_NUM
,
.
msg_data_size
=
MSG_DATA_SIZE
,
.
init_cache
=
_sched_init_cache
,
.
input
=
_sched_input
,
.
output
=
_sched_output
,
.
qs
=
qs
,
};
void
common_init
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
Q_NUM
;
i
++
)
{
qs
[
i
].
dev_flags
=
UACCE_DEV_PASID
;
}
}
void
case_init
(
void
)
{
int
ret
;
common_init
();
//test to pass
ret
=
wd_sched_init
(
&
sched
);
ut_assert
(
!
ret
);
wd_sched_fini
(
&
sched
);
ut_check_cnt_range
(
100
,
110
,
get_q
);
//fail in the middle of get queue
testcase
=
101
;
ret
=
wd_sched_init
(
&
sched
);
ut_assert
(
ret
);
ut_check_cnt_range
(
100
,
110
,
get_q
);
}
int
get_qi
(
struct
wd_queue
*
q
)
{
int
i
;
for
(
i
=
0
;
i
<
Q_NUM
;
i
++
)
{
if
(
&
qs
[
i
]
==
q
)
return
i
;
}
return
-
1
;
}
void
ut_check_and_reset_last_queue
(
int
sqi
,
int
rqi
)
{
if
(
sqi
>=
0
)
ut_assert_str
(
&
qs
[
sqi
]
==
last_used_sq
,
"sqi=%d expect %d
\n
"
,
get_qi
(
last_used_sq
),
sqi
);
else
ut_assert
(
last_used_sq
==
NULL
);
if
(
rqi
>=
0
)
ut_assert_str
(
&
qs
[
rqi
]
==
last_used_rq
,
"rqi=%d, expect %d
\n
"
,
get_qi
(
last_used_rq
),
rqi
);
else
ut_assert
(
last_used_rq
==
NULL
);
last_used_rq
=
last_used_sq
=
NULL
;
}
void
case_sched
(
void
)
{
int
ret
;
common_init
();
ret
=
wd_sched_init
(
&
sched
);
ut_assert
(
!
ret
);
ut_check_and_reset_last_queue
(
-
1
,
-
1
);
ret
=
wd_sched_work
(
&
sched
,
1
);
//c0, q0
ut_assert
(
ret
==
3
);
ut_check_and_reset_last_queue
(
0
,
-
1
);
ret
=
wd_sched_work
(
&
sched
,
1
);
//c1, q1
ut_assert
(
ret
==
2
);
ut_check_and_reset_last_queue
(
1
,
-
1
);
ret
=
wd_sched_work
(
&
sched
,
1
);
//c2, q2
ut_assert
(
ret
==
1
);
ut_check_and_reset_last_queue
(
2
,
-
1
);
ret
=
wd_sched_work
(
&
sched
,
1
);
//c3, q0
ut_assert
(
ret
==
0
);
ut_check_and_reset_last_queue
(
0
,
-
1
);
//cache is out now
ret
=
wd_sched_work
(
&
sched
,
1
);
//should recv
ut_assert
(
ret
==
1
);
ut_check_and_reset_last_queue
(
-
1
,
0
);
ret
=
wd_sched_work
(
&
sched
,
0
);
//recv one more
ut_assert
(
ret
==
2
);
ut_check_and_reset_last_queue
(
-
1
,
1
);
//send 2 more and recv 1
ret
=
wd_sched_work
(
&
sched
,
1
);
//send
ret
=
wd_sched_work
(
&
sched
,
1
);
//send
ret
=
wd_sched_work
(
&
sched
,
1
);
//recv
ut_assert
(
ret
==
1
);
}
int
main
(
void
)
{
test
(
100
,
case_init
);
test
(
120
,
case_sched
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录