Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4ece51ae
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ece51ae
编写于
6月 08, 2016
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cputest: Get rid of the array of test functions
Signed-off-by:
N
Jiri Denemark
<
jdenemar@redhat.com
>
上级
6445ad48
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
83 deletion
+51
-83
tests/cputest.c
tests/cputest.c
+51
-83
未找到文件。
tests/cputest.c
浏览文件 @
4ece51ae
...
...
@@ -54,31 +54,9 @@ enum cpuTestBoolWithError {
YES
=
1
};
enum
api
{
API_COMPARE
,
API_GUEST_DATA
,
API_BASELINE
,
API_UPDATE
,
API_HAS_FEATURE
,
API_HOST_CPUID
,
API_GUEST_CPUID
,
API_JSON_CPUID
,
};
static
const
char
*
apis
[]
=
{
"compare"
,
"guest data"
,
"baseline"
,
"update"
,
"has feature"
,
"host CPUID"
,
"guest CPUID"
,
"json CPUID"
,
};
struct
data
{
const
char
*
arch
;
enum
api
api
;
const
char
*
host
;
const
char
*
name
;
const
char
**
models
;
...
...
@@ -475,7 +453,7 @@ cpuTestHasFeature(const void *arg)
static
int
cpuTestCPUID
(
const
void
*
arg
)
cpuTestCPUID
(
bool
guest
,
const
void
*
arg
)
{
const
struct
data
*
data
=
arg
;
int
ret
=
-
1
;
...
...
@@ -497,7 +475,7 @@ cpuTestCPUID(const void *arg)
goto
cleanup
;
cpu
->
arch
=
hostData
->
arch
;
if
(
data
->
api
==
API_GUEST_CPUID
)
{
if
(
guest
)
{
cpu
->
type
=
VIR_CPU_TYPE_GUEST
;
cpu
->
match
=
VIR_CPU_MATCH_EXACT
;
cpu
->
fallback
=
VIR_CPU_FALLBACK_FORBID
;
...
...
@@ -510,7 +488,7 @@ cpuTestCPUID(const void *arg)
if
(
virAsprintf
(
&
result
,
"cpuid-%s-%s"
,
data
->
host
,
data
->
api
==
API_HOST_CPUID
?
"host"
:
"gue
st"
)
<
0
)
guest
?
"guest"
:
"ho
st"
)
<
0
)
goto
cleanup
;
ret
=
cpuTestCompareXML
(
data
->
arch
,
cpu
,
result
,
false
);
...
...
@@ -525,6 +503,20 @@ cpuTestCPUID(const void *arg)
}
static
int
cpuTestHostCPUID
(
const
void
*
arg
)
{
return
cpuTestCPUID
(
false
,
arg
);
}
static
int
cpuTestGuestCPUID
(
const
void
*
arg
)
{
return
cpuTestCPUID
(
true
,
arg
);
}
#if WITH_QEMU && WITH_YAJL
static
int
cpuTestJSONCPUID
(
const
void
*
arg
)
...
...
@@ -573,52 +565,6 @@ cpuTestJSONCPUID(const void *arg)
#endif
static
int
(
*
cpuTest
[])(
const
void
*
)
=
{
cpuTestCompare
,
cpuTestGuestData
,
cpuTestBaseline
,
cpuTestUpdate
,
cpuTestHasFeature
,
cpuTestCPUID
,
cpuTestCPUID
,
#if WITH_QEMU && WITH_YAJL
cpuTestJSONCPUID
,
#else
NULL
,
#endif
};
static
int
cpuTestRun
(
const
char
*
name
,
const
struct
data
*
data
)
{
char
*
label
=
NULL
;
char
*
tmp
;
if
(
virAsprintf
(
&
label
,
"CPU %s(%s): %s"
,
apis
[
data
->
api
],
data
->
arch
,
name
)
<
0
)
return
-
1
;
tmp
=
virTestLogContentAndReset
();
VIR_FREE
(
tmp
);
if
(
virTestRun
(
label
,
cpuTest
[
data
->
api
],
data
)
<
0
)
{
if
(
virTestGetDebug
())
{
char
*
log
;
if
((
log
=
virTestLogContentAndReset
())
&&
strlen
(
log
)
>
0
)
VIR_TEST_DEBUG
(
"
\n
%s
\n
"
,
log
);
VIR_FREE
(
log
);
}
VIR_FREE
(
label
);
return
-
1
;
}
VIR_FREE
(
label
);
return
0
;
}
static
const
char
*
model486
[]
=
{
"486"
};
static
const
char
*
nomodel
[]
=
{
"nomodel"
};
static
const
char
*
models
[]
=
{
"qemu64"
,
"core2duo"
,
"Nehalem"
};
...
...
@@ -640,23 +586,45 @@ mymain(void)
#define DO_TEST(arch, api, name, host, cpu, \
models, nmodels, preferred, flags, result) \
do { \
st
atic struct data data = {
\
arch,
api, host, cpu, models,
\
st
ruct data data = {
\
arch,
host, cpu, models,
\
models == NULL ? NULL : #models, \
nmodels, preferred, flags, result \
}; \
if (cpuTestRun(name, &data) < 0) \
char *testLabel; \
char *tmp; \
\
tmp = virTestLogContentAndReset(); \
VIR_FREE(tmp); \
\
if (virAsprintf(&testLabel, "%s(%s): %s", \
#api, arch, name) < 0) { \
ret = -1; \
break; \
} \
\
if (virTestRun(testLabel, api, &data) < 0) { \
if (virTestGetDebug()) { \
char *log; \
if ((log = virTestLogContentAndReset()) && \
strlen(log) > 0) \
VIR_TEST_DEBUG("\n%s\n", log); \
VIR_FREE(log); \
} \
ret = -1; \
} \
\
VIR_FREE(testLabel); \
} while (0)
#define DO_TEST_COMPARE(arch, host, cpu, result) \
DO_TEST(arch,
API_COMPARE,
\
DO_TEST(arch,
cpuTestCompare,
\
host "/" cpu " (" #result ")", \
host, cpu, NULL, 0, NULL, 0, result)
#define DO_TEST_UPDATE(arch, host, cpu, result) \
do { \
DO_TEST(arch,
API_UPDATE,
\
DO_TEST(arch,
cpuTestUpdate,
\
cpu " on " host, \
host, cpu, NULL, 0, NULL, 0, 0); \
DO_TEST_COMPARE(arch, host, host "+" cpu, result); \
...
...
@@ -673,19 +641,19 @@ mymain(void)
if (virAsprintf(&label, "%s%s", name, suffix) < 0) { \
ret = -1; \
} else { \
DO_TEST(arch,
API_BASELINE, label, NULL, "baseline-" name,
\
NULL, 0, NULL, flags, result);
\
DO_TEST(arch,
cpuTestBaseline, label, NULL,
\
"baseline-" name, NULL, 0, NULL, flags, result);
\
} \
VIR_FREE(label); \
} while (0)
#define DO_TEST_HASFEATURE(arch, host, feature, result) \
DO_TEST(arch,
API_HAS_FEATURE,
\
DO_TEST(arch,
cpuTestHasFeature,
\
host "/" feature " (" #result ")", \
host, feature, NULL, 0, NULL, 0, result)
#define DO_TEST_GUESTDATA(arch, host, cpu, models, preferred, result) \
DO_TEST(arch,
API_GUEST_DATA,
\
DO_TEST(arch,
cpuTestGuestData,
\
host "/" cpu " (" #models ", pref=" #preferred ")", \
host, cpu, models, \
models == NULL ? 0 : sizeof(models) / sizeof(char *), \
...
...
@@ -695,7 +663,7 @@ mymain(void)
# define DO_TEST_CPUID_JSON(arch, host, json) \
do { \
if (json) { \
DO_TEST(arch,
API_JSON_CPUID, host, host,
\
DO_TEST(arch,
cpuTestJSONCPUID, host, host,
\
NULL, NULL, 0, NULL, 0, 0); \
} \
} while (0)
...
...
@@ -705,9 +673,9 @@ mymain(void)
#define DO_TEST_CPUID(arch, host, json) \
do { \
DO_TEST(arch,
API_HOST_CPUID, host, host,
\
DO_TEST(arch,
cpuTestHostCPUID, host, host,
\
NULL, NULL, 0, NULL, 0, 0); \
DO_TEST(arch,
API_GUEST_CPUID, host, host,
\
DO_TEST(arch,
cpuTestGuestCPUID, host, host,
\
NULL, NULL, 0, NULL, 0, 0); \
DO_TEST_CPUID_JSON(arch, host, json); \
} while (0)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录