Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
01f2f6c6
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看板
提交
01f2f6c6
编写于
4月 23, 2015
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE
To remove a bunch of TestGetDebug()/TestGetVerbose() checks
上级
1268820a
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
188 addition
and
288 deletion
+188
-288
tests/cputest.c
tests/cputest.c
+14
-20
tests/jsontest.c
tests/jsontest.c
+18
-30
tests/nodeinfotest.c
tests/nodeinfotest.c
+1
-1
tests/qemuargv2xmltest.c
tests/qemuargv2xmltest.c
+5
-10
tests/qemuhelptest.c
tests/qemuhelptest.c
+2
-4
tests/qemuhotplugtest.c
tests/qemuhotplugtest.c
+8
-11
tests/qemumonitortest.c
tests/qemumonitortest.c
+10
-14
tests/qemuxml2argvtest.c
tests/qemuxml2argvtest.c
+6
-8
tests/qemuxmlnstest.c
tests/qemuxmlnstest.c
+3
-3
tests/securityselinuxlabeltest.c
tests/securityselinuxlabeltest.c
+3
-3
tests/statstest.c
tests/statstest.c
+1
-2
tests/testutils.c
tests/testutils.c
+1
-1
tests/testutils.h
tests/testutils.h
+12
-0
tests/testutilslxc.c
tests/testutilslxc.c
+1
-1
tests/testutilsqemu.c
tests/testutilsqemu.c
+1
-1
tests/utiltest.c
tests/utiltest.c
+11
-19
tests/virbuftest.c
tests/virbuftest.c
+27
-33
tests/virhashtest.c
tests/virhashtest.c
+50
-102
tests/virpcitest.c
tests/virpcitest.c
+2
-2
tests/virportallocatortest.c
tests/virportallocatortest.c
+12
-23
未找到文件。
tests/cputest.c
浏览文件 @
01f2f6c6
...
...
@@ -235,13 +235,11 @@ cpuTestCompare(const void *arg)
virResetLastError
();
if
(
data
->
result
!=
result
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
Expected result %s, got %s
\n
"
,
VIR_TEST_VERBOSE
(
"
\n
Expected result %s, got %s
\n
"
,
cpuTestCompResStr
(
data
->
result
),
cpuTestCompResStr
(
result
));
/* Pad to line up with test name ... in virTestRun */
fprintf
(
stderr
,
"%74s"
,
"... "
);
}
/* Pad to line up with test name ... in virTestRun */
VIR_TEST_VERBOSE
(
"%74s"
,
"... "
);
goto
cleanup
;
}
...
...
@@ -337,8 +335,8 @@ cpuTestBaseline(const void *arg)
virResetLastError
();
if
(
!
baseline
)
{
ret
=
0
;
}
else
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
%-70s... "
,
}
else
{
VIR_TEST_VERBOSE
(
"
\n
%-70s... "
,
"cpuBaseline was expected to fail but it succeeded"
);
}
goto
cleanup
;
...
...
@@ -364,11 +362,9 @@ cpuTestBaseline(const void *arg)
cmp
=
cpuCompare
(
cpus
[
i
],
baseline
,
false
);
if
(
cmp
!=
VIR_CPU_COMPARE_SUPERSET
&&
cmp
!=
VIR_CPU_COMPARE_IDENTICAL
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
baseline CPU is incompatible with CPU %zu
\n
"
,
i
);
fprintf
(
stderr
,
"%74s"
,
"... "
);
}
VIR_TEST_VERBOSE
(
"
\n
baseline CPU is incompatible with CPU %zu
\n
"
,
i
);
VIR_TEST_VERBOSE
(
"%74s"
,
"... "
);
ret
=
-
1
;
goto
cleanup
;
}
...
...
@@ -438,13 +434,11 @@ cpuTestHasFeature(const void *arg)
virResetLastError
();
if
(
data
->
result
!=
result
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
Expected result %s, got %s
\n
"
,
cpuTestBoolWithErrorStr
(
data
->
result
),
cpuTestBoolWithErrorStr
(
result
));
/* Pad to line up with test name ... in virTestRun */
fprintf
(
stderr
,
"%74s"
,
"... "
);
}
VIR_TEST_VERBOSE
(
"
\n
Expected result %s, got %s
\n
"
,
cpuTestBoolWithErrorStr
(
data
->
result
),
cpuTestBoolWithErrorStr
(
result
));
/* Pad to line up with test name ... in virTestRun */
VIR_TEST_VERBOSE
(
"%74s"
,
"... "
);
goto
cleanup
;
}
...
...
@@ -483,7 +477,7 @@ cpuTestRun(const char *name, const struct data *data)
char
*
log
;
if
((
log
=
virtTestLogContentAndReset
())
&&
strlen
(
log
)
>
0
)
fprintf
(
stderr
,
"
\n
%s
\n
"
,
log
);
VIR_TEST_DEBUG
(
"
\n
%s
\n
"
,
log
);
VIR_FREE
(
log
);
}
...
...
tests/jsontest.c
浏览文件 @
01f2f6c6
...
...
@@ -27,23 +27,19 @@ testJSONFromString(const void *data)
if
(
info
->
pass
)
{
if
(
!
json
)
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"Fail to parse %s
\n
"
,
info
->
doc
);
VIR_TEST_VERBOSE
(
"Fail to parse %s
\n
"
,
info
->
doc
);
ret
=
-
1
;
goto
cleanup
;
}
else
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Parsed %s
\n
"
,
info
->
doc
);
VIR_TEST_DEBUG
(
"Parsed %s
\n
"
,
info
->
doc
);
}
}
else
{
if
(
json
)
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"Should not have parsed %s
\n
"
,
info
->
doc
);
VIR_TEST_VERBOSE
(
"Should not have parsed %s
\n
"
,
info
->
doc
);
ret
=
-
1
;
goto
cleanup
;
}
else
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Fail to parse %s
\n
"
,
info
->
doc
);
VIR_TEST_DEBUG
(
"Fail to parse %s
\n
"
,
info
->
doc
);
}
}
...
...
@@ -66,8 +62,7 @@ testJSONAddRemove(const void *data)
json
=
virJSONValueFromString
(
info
->
doc
);
if
(
!
json
)
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"Fail to parse %s
\n
"
,
info
->
doc
);
VIR_TEST_VERBOSE
(
"Fail to parse %s
\n
"
,
info
->
doc
);
ret
=
-
1
;
goto
cleanup
;
}
...
...
@@ -75,49 +70,42 @@ testJSONAddRemove(const void *data)
switch
(
virJSONValueObjectRemoveKey
(
json
,
"name"
,
&
name
))
{
case
1
:
if
(
!
info
->
pass
)
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"should not remove from non-object %s
\n
"
,
info
->
doc
);
VIR_TEST_VERBOSE
(
"should not remove from non-object %s
\n
"
,
info
->
doc
);
goto
cleanup
;
}
break
;
case
-
1
:
if
(
!
info
->
pass
)
ret
=
0
;
else
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"Fail to recognize non-object %s
\n
"
,
info
->
doc
);
else
VIR_TEST_VERBOSE
(
"Fail to recognize non-object %s
\n
"
,
info
->
doc
);
goto
cleanup
;
default:
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"unexpected result when removing from %s
\n
"
,
info
->
doc
);
VIR_TEST_VERBOSE
(
"unexpected result when removing from %s
\n
"
,
info
->
doc
);
goto
cleanup
;
}
if
(
STRNEQ_NULLABLE
(
virJSONValueGetString
(
name
),
"sample"
))
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"unexpected value after removing name: %s
\n
"
,
NULLSTR
(
virJSONValueGetString
(
name
)));
VIR_TEST_VERBOSE
(
"unexpected value after removing name: %s
\n
"
,
NULLSTR
(
virJSONValueGetString
(
name
)));
goto
cleanup
;
}
if
(
virJSONValueObjectRemoveKey
(
json
,
"name"
,
NULL
))
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"%s"
,
"unexpected success when removing missing key
\n
"
);
VIR_TEST_VERBOSE
(
"%s"
,
"unexpected success when removing missing key
\n
"
);
goto
cleanup
;
}
if
(
virJSONValueObjectAppendString
(
json
,
"newname"
,
"foo"
)
<
0
)
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"%s"
,
"unexpected failure adding new key
\n
"
);
VIR_TEST_VERBOSE
(
"%s"
,
"unexpected failure adding new key
\n
"
);
goto
cleanup
;
}
if
(
!
(
result
=
virJSONValueToString
(
json
,
false
)))
{
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"%s"
,
"failed to stringize result
\n
"
);
VIR_TEST_VERBOSE
(
"%s"
,
"failed to stringize result
\n
"
);
goto
cleanup
;
}
if
(
STRNEQ
(
info
->
expect
,
result
))
{
if
(
virTestGetVerbose
())
virtTestDifference
(
stderr
,
info
->
expect
,
result
);
virtTestDifference
(
stderr
,
info
->
expect
,
result
);
goto
cleanup
;
}
ret
=
0
;
...
...
tests/nodeinfotest.c
浏览文件 @
01f2f6c6
...
...
@@ -50,7 +50,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
if
(
virTestGetDebug
())
{
virErrorPtr
error
=
virSaveLastError
();
if
(
error
&&
error
->
code
!=
VIR_ERR_OK
)
fprintf
(
stderr
,
"
\n
%s
\n
"
,
error
->
message
);
VIR_TEST_DEBUG
(
"
\n
%s
\n
"
,
error
->
message
);
virFreeError
(
error
);
}
VIR_FORCE_FCLOSE
(
cpuinfo
);
...
...
tests/qemuargv2xmltest.c
浏览文件 @
01f2f6c6
...
...
@@ -64,22 +64,17 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto
fail
;
if
(
flags
&
FLAG_EXPECT_WARNING
)
{
if
(
*
log
)
{
if
(
virTestGetDebug
()
>
1
)
fprintf
(
stderr
,
"Got expected warning from "
VIR_TEST_DEBUG
(
"Got expected warning from "
"qemuParseCommandLineString:
\n
%s"
,
log
);
}
else
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"qemuParseCommandLineString "
"should have logged a warning
\n
"
);
VIR_TEST_DEBUG
(
"qemuParseCommandLineString "
"should have logged a warning
\n
"
);
goto
fail
;
}
}
else
{
/* didn't expect a warning */
if
(
*
log
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Got unexpected warning from "
VIR_TEST_DEBUG
(
"Got unexpected warning from "
"qemuParseCommandLineString:
\n
%s"
,
log
);
goto
fail
;
...
...
@@ -88,7 +83,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
if
(
!
virDomainDefCheckABIStability
(
vmdef
,
vmdef
))
{
fprintf
(
stderr
,
"ABI stability check failed on %s"
,
xml
);
VIR_TEST_DEBUG
(
"ABI stability check failed on %s"
,
xml
);
goto
fail
;
}
...
...
tests/qemuhelptest.c
浏览文件 @
01f2f6c6
...
...
@@ -90,10 +90,8 @@ static int testHelpStrParsing(const void *data)
goto
cleanup
;
if
(
STRNEQ
(
got
,
expected
))
{
if
(
virTestGetVerbose
()
||
virTestGetDebug
())
fprintf
(
stderr
,
"%s: computed flags do not match: got %s, expected %s
\n
"
,
info
->
name
,
got
,
expected
);
VIR_TEST_DEBUG
(
"%s: computed flags do not match: got %s, expected %s
\n
"
,
info
->
name
,
got
,
expected
);
if
(
virTestGetDebug
())
printMismatchedFlags
(
flags
,
info
->
flags
);
...
...
tests/qemuhotplugtest.c
浏览文件 @
01f2f6c6
...
...
@@ -115,9 +115,8 @@ testQemuHotplugAttach(virDomainObjPtr vm,
ret
=
qemuDomainAttachChrDevice
(
&
driver
,
vm
,
dev
->
data
.
chr
);
break
;
default:
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"device type '%s' cannot be attached
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
VIR_TEST_VERBOSE
(
"device type '%s' cannot be attached
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
break
;
}
...
...
@@ -138,9 +137,8 @@ testQemuHotplugDetach(virDomainObjPtr vm,
ret
=
qemuDomainDetachChrDevice
(
&
driver
,
vm
,
dev
->
data
.
chr
);
break
;
default:
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"device type '%s' cannot be detached
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
VIR_TEST_VERBOSE
(
"device type '%s' cannot be detached
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
break
;
}
...
...
@@ -163,9 +161,8 @@ testQemuHotplugUpdate(virDomainObjPtr vm,
ret
=
qemuDomainChangeGraphics
(
&
driver
,
vm
,
dev
->
data
.
graphics
);
break
;
default:
if
(
virTestGetVerbose
())
fprintf
(
stderr
,
"device type '%s' cannot be updated
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
VIR_TEST_VERBOSE
(
"device type '%s' cannot be updated
\n
"
,
virDomainDeviceTypeToString
(
dev
->
type
));
break
;
}
...
...
@@ -187,8 +184,8 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
vm
->
def
->
id
=
QEMU_HOTPLUG_TEST_DOMAIN_ID
;
if
(
STREQ
(
expected
,
actual
))
{
if
(
fail
&&
virTestGetVerbose
()
)
fprintf
(
stderr
,
"domain XML should not match the expected result
\n
"
);
if
(
fail
)
VIR_TEST_VERBOSE
(
"domain XML should not match the expected result
\n
"
);
ret
=
0
;
}
else
{
if
(
!
fail
)
...
...
tests/qemumonitortest.c
浏览文件 @
01f2f6c6
...
...
@@ -43,13 +43,11 @@ static int testEscapeArg(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
escapeStrings
);
++
i
)
{
escaped
=
qemuMonitorEscapeArg
(
escapeStrings
[
i
].
unescaped
);
if
(
!
escaped
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Unescaped string [%s]
\n
"
,
escapeStrings
[
i
].
unescaped
);
fprintf
(
stderr
,
"Expect result [%s]
\n
"
,
escapeStrings
[
i
].
escaped
);
fprintf
(
stderr
,
"Actual result [(null)]
\n
"
);
}
VIR_TEST_DEBUG
(
"
\n
Unescaped string [%s]
\n
"
,
escapeStrings
[
i
].
unescaped
);
VIR_TEST_DEBUG
(
"Expect result [%s]
\n
"
,
escapeStrings
[
i
].
escaped
);
VIR_TEST_DEBUG
(
"Actual result [(null)]
\n
"
);
return
-
1
;
}
if
(
STRNEQ
(
escapeStrings
[
i
].
escaped
,
escaped
))
{
...
...
@@ -70,13 +68,11 @@ static int testUnescapeArg(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
escapeStrings
);
++
i
)
{
unescaped
=
qemuMonitorUnescapeArg
(
escapeStrings
[
i
].
escaped
);
if
(
!
unescaped
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Escaped string [%s]
\n
"
,
escapeStrings
[
i
].
escaped
);
fprintf
(
stderr
,
"Expect result [%s]
\n
"
,
escapeStrings
[
i
].
unescaped
);
fprintf
(
stderr
,
"Actual result [(null)]
\n
"
);
}
VIR_TEST_DEBUG
(
"
\n
Escaped string [%s]
\n
"
,
escapeStrings
[
i
].
escaped
);
VIR_TEST_DEBUG
(
"Expect result [%s]
\n
"
,
escapeStrings
[
i
].
unescaped
);
VIR_TEST_DEBUG
(
"Actual result [(null)]
\n
"
);
return
-
1
;
}
if
(
STRNEQ
(
escapeStrings
[
i
].
unescaped
,
unescaped
))
{
...
...
tests/qemuxml2argvtest.c
浏览文件 @
01f2f6c6
...
...
@@ -282,7 +282,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
if
(
!
virDomainDefCheckABIStability
(
vmdef
,
vmdef
))
{
fprintf
(
stderr
,
"ABI stability check failed on %s"
,
xml
);
VIR_TEST_DEBUG
(
"ABI stability check failed on %s"
,
xml
);
goto
out
;
}
...
...
@@ -353,22 +353,20 @@ static int testCompareXMLToArgvFiles(const char *xml,
if
(
!
virtTestOOMActive
()
&&
(
flags
&
FLAG_EXPECT_FAILURE
))
{
ret
=
0
;
if
(
virTestGetDebug
()
>
1
)
fprintf
(
stderr
,
"Got expected error: %s
\n
"
,
virGetLastErrorMessage
());
VIR_TEST_DEBUG
(
"Got expected error: %s
\n
"
,
virGetLastErrorMessage
());
virResetLastError
();
}
goto
out
;
}
else
if
(
flags
&
FLAG_EXPECT_FAILURE
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"qemuBuildCommandLine should have failed
\n
"
);
VIR_TEST_DEBUG
(
"qemuBuildCommandLine should have failed
\n
"
);
goto
out
;
}
if
(
!
virtTestOOMActive
()
&&
(
!!
virGetLastError
()
!=
!!
(
flags
&
FLAG_EXPECT_ERROR
)))
{
if
(
virTestGetDebug
()
&&
(
log
=
virtTestLogContentAndReset
()))
fprintf
(
stderr
,
"
\n
%s"
,
log
);
if
((
log
=
virtTestLogContentAndReset
()))
VIR_TEST_DEBUG
(
"
\n
%s"
,
log
);
goto
out
;
}
...
...
tests/qemuxmlnstest.c
浏览文件 @
01f2f6c6
...
...
@@ -59,7 +59,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto
fail
;
if
(
!
virDomainDefCheckABIStability
(
vmdef
,
vmdef
))
{
fprintf
(
stderr
,
"ABI stability check failed on %s"
,
xml
);
VIR_TEST_DEBUG
(
"ABI stability check failed on %s"
,
xml
);
goto
fail
;
}
...
...
@@ -121,8 +121,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
if
(
!
virtTestOOMActive
())
{
if
(
!!
virGetLastError
()
!=
expectError
)
{
if
(
virTestGetDebug
()
&&
(
log
=
virtTestLogContentAndReset
()))
fprintf
(
stderr
,
"
\n
%s"
,
log
);
if
((
log
=
virtTestLogContentAndReset
()))
VIR_TEST_DEBUG
(
"
\n
%s"
,
log
);
goto
fail
;
}
...
...
tests/securityselinuxlabeltest.c
浏览文件 @
01f2f6c6
...
...
@@ -336,9 +336,9 @@ testSELinuxLabeling(const void *opaque)
VIR_FREE
(
files
[
i
].
context
);
}
VIR_FREE
(
files
);
if
(
ret
<
0
&&
virTestGetVerbose
()
)
{
if
(
ret
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"%s
\n
"
,
err
?
err
->
message
:
"<unknown>"
);
VIR_TEST_VERBOSE
(
"%s
\n
"
,
err
?
err
->
message
:
"<unknown>"
);
}
return
ret
;
}
...
...
@@ -358,7 +358,7 @@ mymain(void)
if
(
!
(
mgr
=
virSecurityManagerNew
(
"selinux"
,
"QEMU"
,
false
,
true
,
false
)))
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Unable to initialize security driver: %s
\n
"
,
VIR_TEST_VERBOSE
(
"Unable to initialize security driver: %s
\n
"
,
err
->
message
);
return
EXIT_FAILURE
;
}
...
...
tests/statstest.c
浏览文件 @
01f2f6c6
...
...
@@ -18,8 +18,7 @@ static int testDevice(const char *path, int expect)
if
(
actual
==
expect
)
{
return
0
;
}
else
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expect %-6d Actual %-6d
\n
"
,
expect
,
actual
);
VIR_TEST_DEBUG
(
"Expect %-6d Actual %-6d
\n
"
,
expect
,
actual
);
return
-
1
;
}
}
...
...
tests/testutils.c
浏览文件 @
01f2f6c6
...
...
@@ -960,7 +960,7 @@ virCapsPtr virTestGenericCapsInit(void)
if
(
!
caps_str
)
goto
error
;
fprintf
(
stderr
,
"Generic driver capabilities:
\n
%s"
,
caps_str
);
VIR_TEST_DEBUG
(
"Generic driver capabilities:
\n
%s"
,
caps_str
);
VIR_FREE
(
caps_str
);
}
...
...
tests/testutils.h
浏览文件 @
01f2f6c6
...
...
@@ -78,6 +78,18 @@ unsigned int virTestGetDebug(void);
unsigned
int
virTestGetVerbose
(
void
);
unsigned
int
virTestGetExpensive
(
void
);
# define VIR_TEST_DEBUG(...) \
do { \
if (virTestGetDebug()) \
fprintf(stderr, __VA_ARGS__); \
} while (0)
# define VIR_TEST_VERBOSE(...) \
do { \
if (virTestGetVerbose()) \
fprintf(stderr, __VA_ARGS__); \
} while (0)
char
*
virtTestLogContentAndReset
(
void
);
void
virtTestQuiesceLibvirtErrors
(
bool
always
);
...
...
tests/testutilslxc.c
浏览文件 @
01f2f6c6
...
...
@@ -44,7 +44,7 @@ virCapsPtr testLXCCapsInit(void)
if
(
!
caps_str
)
goto
error
;
fprintf
(
stderr
,
"LXC driver capabilities:
\n
%s"
,
caps_str
);
VIR_TEST_DEBUG
(
"LXC driver capabilities:
\n
%s"
,
caps_str
);
VIR_FREE
(
caps_str
);
}
...
...
tests/testutilsqemu.c
浏览文件 @
01f2f6c6
...
...
@@ -427,7 +427,7 @@ virCapsPtr testQemuCapsInit(void)
if
(
!
caps_str
)
goto
cleanup
;
fprintf
(
stderr
,
"QEMU driver capabilities:
\n
%s"
,
caps_str
);
VIR_TEST_DEBUG
(
"QEMU driver capabilities:
\n
%s"
,
caps_str
);
VIR_FREE
(
caps_str
);
}
...
...
tests/utiltest.c
浏览文件 @
01f2f6c6
...
...
@@ -63,10 +63,8 @@ testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
idx
=
virDiskNameToIndex
(
diskName
);
if
(
idx
<
0
||
idx
!=
i
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Expect [%zu]
\n
"
,
i
);
fprintf
(
stderr
,
"Actual [%d]
\n
"
,
idx
);
}
VIR_TEST_DEBUG
(
"
\n
Expect [%zu]
\n
"
,
i
);
VIR_TEST_DEBUG
(
"Actual [%d]
\n
"
,
idx
);
VIR_FREE
(
diskName
);
...
...
@@ -115,11 +113,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
versions
[
i
].
allowMissing
);
if
(
result
!=
versions
[
i
].
result
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Version string [%s]
\n
"
,
versions
[
i
].
string
);
fprintf
(
stderr
,
"Expect result [%d]
\n
"
,
versions
[
i
].
result
);
fprintf
(
stderr
,
"Actual result [%d]
\n
"
,
result
);
}
VIR_TEST_DEBUG
(
"
\n
Version string [%s]
\n
"
,
versions
[
i
].
string
);
VIR_TEST_DEBUG
(
"Expect result [%d]
\n
"
,
versions
[
i
].
result
);
VIR_TEST_DEBUG
(
"Actual result [%d]
\n
"
,
result
);
return
-
1
;
}
...
...
@@ -128,11 +124,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
continue
;
if
(
version
!=
versions
[
i
].
version
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Version string [%s]
\n
"
,
versions
[
i
].
string
);
fprintf
(
stderr
,
"Expect version [%lu]
\n
"
,
versions
[
i
].
version
);
fprintf
(
stderr
,
"Actual version [%lu]
\n
"
,
version
);
}
VIR_TEST_DEBUG
(
"
\n
Version string [%s]
\n
"
,
versions
[
i
].
string
);
VIR_TEST_DEBUG
(
"Expect version [%lu]
\n
"
,
versions
[
i
].
version
);
VIR_TEST_DEBUG
(
"Actual version [%lu]
\n
"
,
version
);
return
-
1
;
}
...
...
@@ -166,11 +160,9 @@ testRoundValueToPowerOfTwo(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
roundData
);
i
++
)
{
result
=
VIR_ROUND_UP_POWER_OF_TWO
(
roundData
[
i
].
input
);
if
(
roundData
[
i
].
output
!=
result
)
{
if
(
virTestGetDebug
()
>
0
)
{
fprintf
(
stderr
,
"
\n
Input number [%u]
\n
"
,
roundData
[
i
].
input
);
fprintf
(
stderr
,
"Expected number [%u]
\n
"
,
roundData
[
i
].
output
);
fprintf
(
stderr
,
"Actual number [%u]
\n
"
,
result
);
}
VIR_TEST_DEBUG
(
"
\n
Input number [%u]
\n
"
,
roundData
[
i
].
input
);
VIR_TEST_DEBUG
(
"Expected number [%u]
\n
"
,
roundData
[
i
].
output
);
VIR_TEST_DEBUG
(
"Actual number [%u]
\n
"
,
result
);
return
-
1
;
}
...
...
tests/virbuftest.c
浏览文件 @
01f2f6c6
...
...
@@ -12,12 +12,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define TEST_ERROR(...) \
do { \
if (virTestGetDebug()) \
fprintf(stderr, __VA_ARGS__); \
} while (0)
struct
testInfo
{
int
doEscape
;
};
...
...
@@ -50,7 +44,7 @@ static int testBufInfiniteLoop(const void *data)
out:
bufret
=
virBufferContentAndReset
(
buf
);
if
(
!
bufret
)
{
TEST_ERROR
(
"Buffer had error set"
);
VIR_TEST_DEBUG
(
"Buffer had error set"
);
ret
=
-
1
;
}
...
...
@@ -70,54 +64,54 @@ static int testBufAutoIndent(const void *data ATTRIBUTE_UNUSED)
if
(
virBufferGetIndent
(
buf
,
false
)
!=
0
||
virBufferGetIndent
(
buf
,
true
)
!=
0
)
{
TEST_ERROR
(
"Wrong indentation"
);
VIR_TEST_DEBUG
(
"Wrong indentation"
);
ret
=
-
1
;
}
virBufferAdjustIndent
(
buf
,
3
);
if
(
STRNEQ
(
virBufferCurrentContent
(
buf
),
""
))
{
TEST_ERROR
(
"Wrong content"
);
VIR_TEST_DEBUG
(
"Wrong content"
);
ret
=
-
1
;
}
if
(
virBufferGetIndent
(
buf
,
false
)
!=
3
||
virBufferGetIndent
(
buf
,
true
)
!=
3
||
virBufferError
(
buf
))
{
TEST_ERROR
(
"Wrong indentation"
);
VIR_TEST_DEBUG
(
"Wrong indentation"
);
ret
=
-
1
;
}
virBufferAdjustIndent
(
buf
,
-
2
);
if
(
virBufferGetIndent
(
buf
,
false
)
!=
1
||
virBufferGetIndent
(
buf
,
true
)
!=
1
||
virBufferError
(
buf
))
{
TEST_ERROR
(
"Wrong indentation"
);
VIR_TEST_DEBUG
(
"Wrong indentation"
);
ret
=
-
1
;
}
virBufferAdjustIndent
(
buf
,
-
3
);
if
(
virBufferGetIndent
(
buf
,
false
)
!=
-
1
||
virBufferGetIndent
(
buf
,
true
)
!=
-
1
||
virBufferError
(
buf
)
!=
-
1
)
{
TEST_ERROR
(
"Usage error not flagged"
);
VIR_TEST_DEBUG
(
"Usage error not flagged"
);
ret
=
-
1
;
}
virBufferFreeAndReset
(
buf
);
if
(
virBufferGetIndent
(
buf
,
false
)
!=
0
||
virBufferGetIndent
(
buf
,
true
)
!=
0
||
virBufferError
(
buf
))
{
TEST_ERROR
(
"Reset didn't clear indentation"
);
VIR_TEST_DEBUG
(
"Reset didn't clear indentation"
);
ret
=
-
1
;
}
virBufferAdjustIndent
(
buf
,
2
);
virBufferAddLit
(
buf
,
"1"
);
if
(
virBufferError
(
buf
))
{
TEST_ERROR
(
"Buffer had error"
);
VIR_TEST_DEBUG
(
"Buffer had error"
);
return
-
1
;
}
if
(
STRNEQ
(
virBufferCurrentContent
(
buf
),
" 1"
))
{
TEST_ERROR
(
"Wrong content"
);
VIR_TEST_DEBUG
(
"Wrong content"
);
ret
=
-
1
;
}
if
(
virBufferGetIndent
(
buf
,
false
)
!=
2
||
virBufferGetIndent
(
buf
,
true
)
!=
0
)
{
TEST_ERROR
(
"Wrong indentation"
);
VIR_TEST_DEBUG
(
"Wrong indentation"
);
ret
=
-
1
;
}
virBufferAddLit
(
buf
,
"
\n
"
);
...
...
@@ -138,7 +132,7 @@ static int testBufAutoIndent(const void *data ATTRIBUTE_UNUSED)
virBufferAddChar
(
buf
,
'\n'
);
if
(
virBufferError
(
buf
))
{
TEST_ERROR
(
"Buffer had error"
);
VIR_TEST_DEBUG
(
"Buffer had error"
);
return
-
1
;
}
...
...
@@ -175,7 +169,7 @@ static int testBufTrim(const void *data ATTRIBUTE_UNUSED)
virBufferTrim
(
buf
,
","
,
-
1
);
if
(
virBufferError
(
buf
))
{
TEST_ERROR
(
"Buffer had error"
);
VIR_TEST_DEBUG
(
"Buffer had error"
);
return
-
1
;
}
...
...
@@ -187,7 +181,7 @@ static int testBufTrim(const void *data ATTRIBUTE_UNUSED)
virBufferTrim
(
buf
,
NULL
,
-
1
);
if
(
virBufferError
(
buf
)
!=
-
1
)
{
TEST_ERROR
(
"Usage error not flagged"
);
VIR_TEST_DEBUG
(
"Usage error not flagged"
);
goto
cleanup
;
}
...
...
@@ -223,17 +217,17 @@ static int testBufAddBuffer(const void *data ATTRIBUTE_UNUSED)
" destroy an entire planet.
\n
"
;
if
(
virBufferUse
(
&
buf1
))
{
TEST_ERROR
(
"buf1 already in use"
);
VIR_TEST_DEBUG
(
"buf1 already in use"
);
goto
cleanup
;
}
if
(
virBufferUse
(
&
buf2
))
{
TEST_ERROR
(
"buf2 already in use"
);
VIR_TEST_DEBUG
(
"buf2 already in use"
);
goto
cleanup
;
}
if
(
virBufferUse
(
&
buf3
))
{
TEST_ERROR
(
"buf3 already in use"
);
VIR_TEST_DEBUG
(
"buf3 already in use"
);
goto
cleanup
;
}
...
...
@@ -258,41 +252,41 @@ static int testBufAddBuffer(const void *data ATTRIBUTE_UNUSED)
virBufferAddLit
(
&
buf3
,
"destroy an entire planet.
\n
"
);
if
(
!
virBufferUse
(
&
buf1
))
{
TEST_ERROR
(
"Error adding to buf1"
);
VIR_TEST_DEBUG
(
"Error adding to buf1"
);
goto
cleanup
;
}
if
(
!
virBufferUse
(
&
buf2
))
{
TEST_ERROR
(
"Error adding to buf2"
);
VIR_TEST_DEBUG
(
"Error adding to buf2"
);
goto
cleanup
;
}
if
(
!
virBufferUse
(
&
buf3
))
{
TEST_ERROR
(
"Error adding to buf3"
);
VIR_TEST_DEBUG
(
"Error adding to buf3"
);
goto
cleanup
;
}
virBufferAddBuffer
(
&
buf2
,
&
buf3
);
if
(
!
virBufferUse
(
&
buf2
))
{
TEST_ERROR
(
"buf2 cleared mistakenly"
);
VIR_TEST_DEBUG
(
"buf2 cleared mistakenly"
);
goto
cleanup
;
}
if
(
virBufferUse
(
&
buf3
))
{
TEST_ERROR
(
"buf3 is not clear even though it should be"
);
VIR_TEST_DEBUG
(
"buf3 is not clear even though it should be"
);
goto
cleanup
;
}
virBufferAddBuffer
(
&
buf1
,
&
buf2
);
if
(
!
virBufferUse
(
&
buf1
))
{
TEST_ERROR
(
"buf1 cleared mistakenly"
);
VIR_TEST_DEBUG
(
"buf1 cleared mistakenly"
);
goto
cleanup
;
}
if
(
virBufferUse
(
&
buf2
))
{
TEST_ERROR
(
"buf2 is not clear even though it should be"
);
VIR_TEST_DEBUG
(
"buf2 is not clear even though it should be"
);
goto
cleanup
;
}
...
...
@@ -330,12 +324,12 @@ testBufAddStr(const void *opaque ATTRIBUTE_UNUSED)
virBufferAddLit
(
&
buf
,
"</c>"
);
if
(
!
(
actual
=
virBufferContentAndReset
(
&
buf
)))
{
TEST_ERROR
(
"buf is empty"
);
VIR_TEST_DEBUG
(
"buf is empty"
);
goto
cleanup
;
}
if
(
STRNEQ_NULLABLE
(
actual
,
data
->
expect
))
{
TEST_ERROR
(
"testBufAddStr(): Strings don't match:
\n
"
);
VIR_TEST_DEBUG
(
"testBufAddStr(): Strings don't match:
\n
"
);
virtTestDifference
(
stderr
,
data
->
expect
,
actual
);
goto
cleanup
;
}
...
...
@@ -363,12 +357,12 @@ testBufEscapeStr(const void *opaque ATTRIBUTE_UNUSED)
virBufferAddLit
(
&
buf
,
"</c>"
);
if
(
!
(
actual
=
virBufferContentAndReset
(
&
buf
)))
{
TEST_ERROR
(
"buf is empty"
);
VIR_TEST_DEBUG
(
"buf is empty"
);
goto
cleanup
;
}
if
(
STRNEQ_NULLABLE
(
actual
,
data
->
expect
))
{
TEST_ERROR
(
"testBufEscapeStr(): Strings don't match:
\n
"
);
VIR_TEST_DEBUG
(
"testBufEscapeStr(): Strings don't match:
\n
"
);
virtTestDifference
(
stderr
,
data
->
expect
,
actual
);
goto
cleanup
;
}
...
...
tests/virhashtest.c
浏览文件 @
01f2f6c6
...
...
@@ -17,18 +17,6 @@
VIR_LOG_INIT
(
"tests.hashtest"
);
#define testError(...) \
do { \
char *str; \
if (virAsprintfQuiet(&str, __VA_ARGS__) >= 0) { \
fprintf(stderr, "%s", str); \
VIR_FREE(str); \
} \
/* Pad to line up with test name ... in virTestRun */
\
fprintf(stderr, "%74s", "... "); \
} while (0)
static
virHashTablePtr
testHashInit
(
int
size
)
{
...
...
@@ -48,25 +36,22 @@ testHashInit(int size)
return
NULL
;
}
if
(
virHashTableSize
(
hash
)
!=
oldsize
&&
virTestGetDebug
()
)
{
VIR_
WARN
(
"hash grown from %zd to %zd"
,
if
(
virHashTableSize
(
hash
)
!=
oldsize
)
{
VIR_
TEST_DEBUG
(
"hash grown from %zd to %zd"
,
(
size_t
)
oldsize
,
(
size_t
)
virHashTableSize
(
hash
));
}
}
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids
);
i
++
)
{
if
(
!
virHashLookup
(
hash
,
uuids
[
i
]))
{
if
(
virTestGetVerbose
())
{
VIR_WARN
(
"
\n
entry
\"
%s
\"
could not be found
\n
"
,
uuids
[
i
]);
}
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
could not be found
\n
"
,
uuids
[
i
]);
virHashFree
(
hash
);
return
NULL
;
}
}
if
(
size
&&
size
!=
virHashTableSize
(
hash
)
&&
virTestGetDebug
()
)
fprintf
(
stderr
,
"
\n
"
);
if
(
size
&&
size
!=
virHashTableSize
(
hash
))
VIR_TEST_DEBUG
(
"
\n
"
);
return
hash
;
}
...
...
@@ -84,14 +69,14 @@ testHashCheckCount(virHashTablePtr hash, size_t count)
ssize_t
iter_count
=
0
;
if
(
virHashSize
(
hash
)
!=
count
)
{
testError
(
"
\n
hash contains %zu instead of %zu elements
\n
"
,
VIR_TEST_VERBOSE
(
"
\n
hash contains %zu instead of %zu elements
\n
"
,
(
size_t
)
virHashSize
(
hash
),
count
);
return
-
1
;
}
iter_count
=
virHashForEach
(
hash
,
testHashCheckForEachCount
,
NULL
);
if
(
count
!=
iter_count
)
{
testError
(
"
\n
hash claims to have %zu elements but iteration finds %zu
\n
"
,
VIR_TEST_VERBOSE
(
"
\n
hash claims to have %zu elements but iteration finds %zu
\n
"
,
count
,
(
size_t
)
iter_count
);
return
-
1
;
}
...
...
@@ -140,20 +125,16 @@ testHashUpdate(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids_subset
);
i
++
)
{
if
(
virHashUpdateEntry
(
hash
,
uuids_subset
[
i
],
(
void
*
)
1
)
<
0
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
entry
\"
%s
\"
could not be updated
\n
"
,
uuids_subset
[
i
]);
}
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
could not be updated
\n
"
,
uuids_subset
[
i
]);
goto
cleanup
;
}
}
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids_new
);
i
++
)
{
if
(
virHashUpdateEntry
(
hash
,
uuids_new
[
i
],
(
void
*
)
1
)
<
0
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
new entry
\"
%s
\"
could not be updated
\n
"
,
uuids_new
[
i
]);
}
VIR_TEST_VERBOSE
(
"
\n
new entry
\"
%s
\"
could not be updated
\n
"
,
uuids_new
[
i
]);
goto
cleanup
;
}
}
...
...
@@ -182,10 +163,8 @@ testHashRemove(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids_subset
);
i
++
)
{
if
(
virHashRemoveEntry
(
hash
,
uuids_subset
[
i
])
<
0
)
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
entry
\"
%s
\"
could not be removed
\n
"
,
uuids_subset
[
i
]);
}
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
could not be removed
\n
"
,
uuids_subset
[
i
]);
goto
cleanup
;
}
}
...
...
@@ -214,8 +193,8 @@ testHashRemoveForEachSome(void *payload ATTRIBUTE_UNUSED,
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids_subset
);
i
++
)
{
if
(
STREQ
(
uuids_subset
[
i
],
name
))
{
if
(
virHashRemoveEntry
(
hash
,
name
)
<
0
&&
virTestGetVerbose
()
)
{
fprintf
(
stderr
,
"
\n
entry
\"
%s
\"
could not be removed"
,
if
(
virHashRemoveEntry
(
hash
,
name
)
<
0
)
{
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
could not be removed"
,
uuids_subset
[
i
]);
}
break
;
...
...
@@ -251,9 +230,8 @@ testHashRemoveForEachForbidden(void *payload ATTRIBUTE_UNUSED,
if
(
STREQ
(
uuids_subset
[
i
],
name
))
{
int
next
=
(
i
+
1
)
%
ARRAY_CARDINALITY
(
uuids_subset
);
if
(
virHashRemoveEntry
(
hash
,
uuids_subset
[
next
])
==
0
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
if
(
virHashRemoveEntry
(
hash
,
uuids_subset
[
next
])
==
0
)
{
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
should not be allowed to be removed"
,
uuids_subset
[
next
]);
}
...
...
@@ -277,11 +255,9 @@ testHashRemoveForEach(const void *data)
count
=
virHashForEach
(
hash
,
(
virHashIterator
)
info
->
data
,
hash
);
if
(
count
!=
ARRAY_CARDINALITY
(
uuids
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
virHashForEach didn't go through all entries,"
" %d != %zu
\n
"
,
count
,
ARRAY_CARDINALITY
(
uuids
));
}
VIR_TEST_VERBOSE
(
"
\n
virHashForEach didn't go through all entries,"
" %d != %zu
\n
"
,
count
,
ARRAY_CARDINALITY
(
uuids
));
goto
cleanup
;
}
...
...
@@ -309,10 +285,8 @@ testHashSteal(const void *data ATTRIBUTE_UNUSED)
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
uuids_subset
);
i
++
)
{
if
(
!
virHashSteal
(
hash
,
uuids_subset
[
i
]))
{
if
(
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
entry
\"
%s
\"
could not be stolen
\n
"
,
uuids_subset
[
i
]);
}
VIR_TEST_VERBOSE
(
"
\n
entry
\"
%s
\"
could not be stolen
\n
"
,
uuids_subset
[
i
]);
goto
cleanup
;
}
}
...
...
@@ -343,31 +317,21 @@ testHashForEachIter(void *payload ATTRIBUTE_UNUSED,
{
virHashTablePtr
hash
=
data
;
if
(
virHashAddEntry
(
hash
,
uuids_new
[
0
],
NULL
)
==
0
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
adding entries in ForEach should be forbidden"
);
}
if
(
virHashAddEntry
(
hash
,
uuids_new
[
0
],
NULL
)
==
0
)
VIR_TEST_VERBOSE
(
"
\n
adding entries in ForEach should be forbidden"
);
if
(
virHashUpdateEntry
(
hash
,
uuids_new
[
0
],
NULL
)
==
0
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
updating entries in ForEach should be forbidden"
);
}
if
(
virHashUpdateEntry
(
hash
,
uuids_new
[
0
],
NULL
)
==
0
)
VIR_TEST_VERBOSE
(
"
\n
updating entries in ForEach should be forbidden"
);
if
(
virHashSteal
(
hash
,
uuids_new
[
0
])
!=
NULL
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
stealing entries in ForEach should be forbidden"
);
}
if
(
virHashSteal
(
hash
,
uuids_new
[
0
])
!=
NULL
)
VIR_TEST_VERBOSE
(
"
\n
stealing entries in ForEach should be forbidden"
);
if
(
virHashSteal
(
hash
,
uuids_new
[
0
])
!=
NULL
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
stealing entries in ForEach should be forbidden"
);
}
if
(
virHashSteal
(
hash
,
uuids_new
[
0
])
!=
NULL
)
VIR_TEST_VERBOSE
(
"
\n
stealing entries in ForEach should be forbidden"
);
if
(
virHashForEach
(
hash
,
testHashIter
,
NULL
)
>=
0
&&
virTestGetVerbose
())
{
fprintf
(
stderr
,
"
\n
iterating through hash in ForEach"
if
(
virHashForEach
(
hash
,
testHashIter
,
NULL
)
>=
0
)
VIR_TEST_VERBOSE
(
"
\n
iterating through hash in ForEach"
" should be forbidden"
);
}
}
static
int
...
...
@@ -383,11 +347,9 @@ testHashForEach(const void *data ATTRIBUTE_UNUSED)
count
=
virHashForEach
(
hash
,
testHashForEachIter
,
hash
);
if
(
count
!=
ARRAY_CARDINALITY
(
uuids
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
virHashForEach didn't go through all entries,"
" %d != %zu
\n
"
,
count
,
ARRAY_CARDINALITY
(
uuids
));
}
VIR_TEST_VERBOSE
(
"
\n
virHashForEach didn't go through all entries,"
" %d != %zu
\n
"
,
count
,
ARRAY_CARDINALITY
(
uuids
));
goto
cleanup
;
}
...
...
@@ -440,11 +402,9 @@ testHashRemoveSet(const void *data ATTRIBUTE_UNUSED)
rcount
=
virHashRemoveSet
(
hash
,
testHashRemoveSetIter
,
&
count
);
if
(
count
!=
rcount
)
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
virHashRemoveSet didn't remove expected number of"
" entries, %d != %u
\n
"
,
rcount
,
count
);
}
VIR_TEST_VERBOSE
(
"
\n
virHashRemoveSet didn't remove expected number of"
" entries, %d != %u
\n
"
,
rcount
,
count
);
goto
cleanup
;
}
...
...
@@ -482,10 +442,8 @@ testHashSearch(const void *data ATTRIBUTE_UNUSED)
entry
=
virHashSearch
(
hash
,
testHashSearchIter
,
NULL
);
if
(
!
entry
||
STRNEQ
(
uuids_subset
[
testSearchIndex
],
entry
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
virHashSearch didn't find entry '%s'
\n
"
,
uuids_subset
[
testSearchIndex
]);
}
VIR_TEST_VERBOSE
(
"
\n
virHashSearch didn't find entry '%s'
\n
"
,
uuids_subset
[
testSearchIndex
]);
goto
cleanup
;
}
...
...
@@ -531,15 +489,13 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
virHashAddEntry
(
hash
,
keya
,
value3
)
<
0
||
virHashAddEntry
(
hash
,
keyc
,
value1
)
<
0
||
virHashAddEntry
(
hash
,
keyb
,
value2
)
<
0
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to create hash"
);
VIR_TEST_VERBOSE
(
"
\n
failed to create hash"
);
goto
cleanup
;
}
if
(
!
(
array
=
virHashGetItems
(
hash
,
NULL
))
||
array
[
3
].
key
||
array
[
3
].
value
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to get items with NULL sort"
);
VIR_TEST_VERBOSE
(
"
\n
failed to get items with NULL sort"
);
goto
cleanup
;
}
VIR_FREE
(
array
);
...
...
@@ -552,8 +508,7 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
STRNEQ
(
array
[
2
].
key
,
"c"
)
||
STRNEQ
(
array
[
2
].
value
,
"1"
)
||
array
[
3
].
key
||
array
[
3
].
value
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to get items with key sort"
);
VIR_TEST_VERBOSE
(
"
\n
failed to get items with key sort"
);
goto
cleanup
;
}
VIR_FREE
(
array
);
...
...
@@ -566,8 +521,7 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED)
STRNEQ
(
array
[
2
].
key
,
"a"
)
||
STRNEQ
(
array
[
2
].
value
,
"3"
)
||
array
[
3
].
key
||
array
[
3
].
value
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to get items with value sort"
);
VIR_TEST_VERBOSE
(
"
\n
failed to get items with value sort"
);
goto
cleanup
;
}
...
...
@@ -608,38 +562,32 @@ testHashEqual(const void *data ATTRIBUTE_UNUSED)
virHashAddEntry
(
hash1
,
keyc
,
value3_l
)
<
0
||
virHashAddEntry
(
hash2
,
keya
,
value1_u
)
<
0
||
virHashAddEntry
(
hash2
,
keyb
,
value2_u
)
<
0
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to create hashes"
);
VIR_TEST_VERBOSE
(
"
\n
failed to create hashes"
);
goto
cleanup
;
}
if
(
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed equal test for different number of elements"
);
VIR_TEST_VERBOSE
(
"
\n
failed equal test for different number of elements"
);
goto
cleanup
;
}
if
(
virHashAddEntry
(
hash2
,
keyc
,
value4_u
)
<
0
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to add element to hash2"
);
VIR_TEST_VERBOSE
(
"
\n
failed to add element to hash2"
);
goto
cleanup
;
}
if
(
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed equal test for same number of elements"
);
VIR_TEST_VERBOSE
(
"
\n
failed equal test for same number of elements"
);
goto
cleanup
;
}
if
(
virHashUpdateEntry
(
hash2
,
keyc
,
value3_u
)
<
0
)
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed to update element in hash2"
);
VIR_TEST_VERBOSE
(
"
\n
failed to update element in hash2"
);
goto
cleanup
;
}
if
(
!
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
testError
(
"
\n
failed equal test for equal hash tables"
);
VIR_TEST_VERBOSE
(
"
\n
failed equal test for equal hash tables"
);
goto
cleanup
;
}
...
...
tests/virpcitest.c
浏览文件 @
01f2f6c6
...
...
@@ -359,12 +359,12 @@ mymain(void)
char
*
fakesysfsdir
;
if
(
VIR_STRDUP_QUIET
(
fakesysfsdir
,
FAKESYSFSDIRTEMPLATE
)
<
0
)
{
fprintf
(
stderr
,
"Out of memory
\n
"
);
VIR_TEST_DEBUG
(
"Out of memory
\n
"
);
abort
();
}
if
(
!
mkdtemp
(
fakesysfsdir
))
{
fprintf
(
stderr
,
"Cannot create fakesysfsdir"
);
VIR_TEST_DEBUG
(
"Cannot create fakesysfsdir"
);
abort
();
}
...
...
tests/virportallocatortest.c
浏览文件 @
01f2f6c6
...
...
@@ -49,7 +49,7 @@ static void init_syms(void)
realsocket
=
dlsym
(
RTLD_NEXT
,
"socket"
);
if
(
!
realsocket
)
{
fprintf
(
stderr
,
"Unable to find 'socket' symbol
\n
"
);
VIR_TEST_DEBUG
(
"Unable to find 'socket' symbol
\n
"
);
abort
();
}
...
...
@@ -132,54 +132,47 @@ static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
if
(
virPortAllocatorAcquire
(
alloc
,
&
p1
)
<
0
)
goto
cleanup
;
if
(
p1
!=
5901
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5901, got %d"
,
p1
);
VIR_TEST_DEBUG
(
"Expected 5901, got %d"
,
p1
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p2
)
<
0
)
goto
cleanup
;
if
(
p2
!=
5902
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5902, got %d"
,
p2
);
VIR_TEST_DEBUG
(
"Expected 5902, got %d"
,
p2
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p3
)
<
0
)
goto
cleanup
;
if
(
p3
!=
5903
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5903, got %d"
,
p3
);
VIR_TEST_DEBUG
(
"Expected 5903, got %d"
,
p3
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p4
)
<
0
)
goto
cleanup
;
if
(
p4
!=
5907
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5907, got %d"
,
p4
);
VIR_TEST_DEBUG
(
"Expected 5907, got %d"
,
p4
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p5
)
<
0
)
goto
cleanup
;
if
(
p5
!=
5908
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5908, got %d"
,
p5
);
VIR_TEST_DEBUG
(
"Expected 5908, got %d"
,
p5
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p6
)
<
0
)
goto
cleanup
;
if
(
p6
!=
5909
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5909, got %d"
,
p6
);
VIR_TEST_DEBUG
(
"Expected 5909, got %d"
,
p6
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p7
)
==
0
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected error, got %d"
,
p7
);
VIR_TEST_DEBUG
(
"Expected error, got %d"
,
p7
);
goto
cleanup
;
}
...
...
@@ -203,24 +196,21 @@ static int testAllocReuse(const void *args ATTRIBUTE_UNUSED)
if
(
virPortAllocatorAcquire
(
alloc
,
&
p1
)
<
0
)
goto
cleanup
;
if
(
p1
!=
5901
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5901, got %d"
,
p1
);
VIR_TEST_DEBUG
(
"Expected 5901, got %d"
,
p1
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p2
)
<
0
)
goto
cleanup
;
if
(
p2
!=
5902
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5902, got %d"
,
p2
);
VIR_TEST_DEBUG
(
"Expected 5902, got %d"
,
p2
);
goto
cleanup
;
}
if
(
virPortAllocatorAcquire
(
alloc
,
&
p3
)
<
0
)
goto
cleanup
;
if
(
p3
!=
5903
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5903, got %d"
,
p3
);
VIR_TEST_DEBUG
(
"Expected 5903, got %d"
,
p3
);
goto
cleanup
;
}
...
...
@@ -231,8 +221,7 @@ static int testAllocReuse(const void *args ATTRIBUTE_UNUSED)
if
(
virPortAllocatorAcquire
(
alloc
,
&
p4
)
<
0
)
goto
cleanup
;
if
(
p4
!=
5902
)
{
if
(
virTestGetDebug
())
fprintf
(
stderr
,
"Expected 5902, got %d"
,
p4
);
VIR_TEST_DEBUG
(
"Expected 5902, got %d"
,
p4
);
goto
cleanup
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录