Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
c66150ec
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看板
提交
c66150ec
编写于
5月 19, 2016
作者:
J
Jovanka Gulicoska
提交者:
Cole Robinson
5月 19, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: More usage of virGetLastErrorMessage()
Use virGetLastErrorMessage() instead of virGetLastError() in tests
上级
ee7e99fe
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
80 deletion
+46
-80
tests/commandtest.c
tests/commandtest.c
+27
-54
tests/libvirtdconftest.c
tests/libvirtdconftest.c
+13
-13
tests/openvzutilstest.c
tests/openvzutilstest.c
+2
-5
tests/qemucapsprobe.c
tests/qemucapsprobe.c
+2
-4
tests/securityselinuxtest.c
tests/securityselinuxtest.c
+2
-4
未找到文件。
tests/commandtest.c
浏览文件 @
c66150ec
...
...
@@ -178,8 +178,7 @@ static int test2(const void *unused ATTRIBUTE_UNUSED)
int
ret
;
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -190,8 +189,7 @@ static int test2(const void *unused ATTRIBUTE_UNUSED)
}
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -218,8 +216,7 @@ static int test3(const void *unused ATTRIBUTE_UNUSED)
VIR_COMMAND_PASS_FD_CLOSE_PARENT
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -260,8 +257,7 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
virCommandDaemonize
(
cmd
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -294,8 +290,7 @@ static int test5(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassCommon
(
cmd
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -318,8 +313,7 @@ static int test6(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassBlockSUID
(
cmd
,
"DOESNOTEXIST"
,
NULL
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -343,8 +337,7 @@ static int test7(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassBlockSUID
(
cmd
,
"DOESNOTEXIST"
,
NULL
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -368,8 +361,7 @@ static int test8(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPair
(
cmd
,
"USER"
,
"test"
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -406,8 +398,7 @@ static int test9(const void *unused ATTRIBUTE_UNUSED)
}
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -432,8 +423,7 @@ static int test10(const void *unused ATTRIBUTE_UNUSED)
virCommandAddArgSet
(
cmd
,
args
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -456,8 +446,7 @@ static int test11(const void *unused ATTRIBUTE_UNUSED)
virCommandPtr
cmd
=
virCommandNewArgs
(
args
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -478,8 +467,7 @@ static int test12(const void *unused ATTRIBUTE_UNUSED)
virCommandSetInputBuffer
(
cmd
,
"Hello World
\n
"
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -506,8 +494,7 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
virCommandSetOutputBuffer
(
cmd
,
&
outactual
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
!
outactual
)
...
...
@@ -559,8 +546,7 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
virCommandSetErrorBuffer
(
cmd
,
&
erractual
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
!
outactual
||
!
erractual
)
...
...
@@ -573,8 +559,7 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
virCommandSetOutputBuffer
(
cmd
,
&
jointactual
);
virCommandSetErrorBuffer
(
cmd
,
&
jointactual
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
!
jointactual
)
...
...
@@ -620,8 +605,7 @@ static int test15(const void *unused ATTRIBUTE_UNUSED)
virCommandSetUmask
(
cmd
,
002
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -651,8 +635,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
virCommandAddArg
(
cmd
,
"G H"
);
if
((
outactual
=
virCommandToString
(
cmd
))
==
NULL
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot convert to string: %s
\n
"
,
err
->
message
);
printf
(
"Cannot convert to string: %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
((
fd
=
open
(
abs_builddir
"/commandhelper.log"
,
...
...
@@ -697,8 +680,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED)
}
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -720,8 +702,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED)
}
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -756,8 +737,7 @@ static int test18(const void *unused ATTRIBUTE_UNUSED)
alarm
(
5
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
alarm
(
0
);
...
...
@@ -798,8 +778,7 @@ static int test19(const void *unused ATTRIBUTE_UNUSED)
alarm
(
5
);
if
(
virCommandRunAsync
(
cmd
,
&
pid
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -848,8 +827,7 @@ static int test20(const void *unused ATTRIBUTE_UNUSED)
virCommandSetInputBuffer
(
cmd
,
buf
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -891,8 +869,7 @@ static int test21(const void *unused ATTRIBUTE_UNUSED)
virCommandDoAsyncIO
(
cmd
);
if
(
virCommandRunAsync
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -930,8 +907,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
cmd
=
virCommandNewArgList
(
"/bin/sh"
,
"-c"
,
"exit 3"
,
NULL
);
if
(
virCommandRun
(
cmd
,
&
status
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
status
!=
3
)
{
...
...
@@ -941,8 +917,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
virCommandRawStatus
(
cmd
);
if
(
virCommandRun
(
cmd
,
&
status
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)
!=
3
)
{
...
...
@@ -960,8 +935,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
virCommandRawStatus
(
cmd
);
if
(
virCommandRun
(
cmd
,
&
status
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
if
(
!
WIFSIGNALED
(
status
)
||
WTERMSIG
(
status
)
!=
SIGKILL
)
{
...
...
@@ -1057,8 +1031,7 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
virCommandPassListenFDs
(
cmd
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
printf
(
"Cannot run child %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
tests/libvirtdconftest.c
浏览文件 @
c66150ec
...
...
@@ -102,7 +102,7 @@ testCorrupt(const void *opaque)
data
->
params
,
data
->
paramnum
,
&
type
);
virErrorPtr
err
=
NULL
;
const
char
*
err
=
NULL
;
if
(
!
newdata
)
return
-
1
;
...
...
@@ -115,15 +115,15 @@ testCorrupt(const void *opaque)
goto
cleanup
;
}
err
=
virGetLastError
();
if
(
!
err
||
!
err
->
message
)
{
err
=
virGetLastError
Message
();
if
(
!
err
)
{
VIR_DEBUG
(
"No error or message %p"
,
err
);
ret
=
-
1
;
goto
cleanup
;
}
#if !WITH_SASL
if
(
strstr
(
err
->
message
,
"unsupported auth sasl"
))
{
if
(
strstr
(
err
,
"unsupported auth sasl"
))
{
VIR_DEBUG
(
"sasl unsupported, skipping this config"
);
goto
cleanup
;
}
...
...
@@ -131,24 +131,24 @@ testCorrupt(const void *opaque)
switch
(
type
)
{
case
VIR_CONF_ULONG
:
if
(
!
strstr
(
err
->
message
,
"invalid type: got string; expected unsigned long"
)
&&
!
strstr
(
err
->
message
,
"invalid type: got string; expected long"
))
{
if
(
!
strstr
(
err
,
"invalid type: got string; expected unsigned long"
)
&&
!
strstr
(
err
,
"invalid type: got string; expected long"
))
{
VIR_DEBUG
(
"Wrong error for long: '%s'"
,
err
->
message
);
err
);
ret
=
-
1
;
}
break
;
case
VIR_CONF_STRING
:
if
(
!
strstr
(
err
->
message
,
"invalid type: got unsigned long; expected string"
))
{
if
(
!
strstr
(
err
,
"invalid type: got unsigned long; expected string"
))
{
VIR_DEBUG
(
"Wrong error for string: '%s'"
,
err
->
message
);
err
);
ret
=
-
1
;
}
break
;
case
VIR_CONF_LIST
:
if
(
!
strstr
(
err
->
message
,
"must be a string or list of strings"
))
{
if
(
!
strstr
(
err
,
"must be a string or list of strings"
))
{
VIR_DEBUG
(
"Wrong error for list: '%s'"
,
err
->
message
);
err
);
ret
=
-
1
;
}
break
;
...
...
@@ -212,8 +212,8 @@ mymain(void)
}
if
(
virFileReadAll
(
filename
,
1024
*
1024
,
&
filedata
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Cannot load %s for testing: %s"
,
filename
,
err
->
message
);
const
char
*
err
=
virGetLastErrorMessage
();
fprintf
(
stderr
,
"Cannot load %s for testing: %s"
,
filename
,
err
);
ret
=
-
1
;
goto
cleanup
;
}
...
...
tests/openvzutilstest.c
浏览文件 @
c66150ec
...
...
@@ -75,7 +75,6 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
int
result
=
-
1
;
virDomainDefPtr
def
=
NULL
;
char
*
actual
=
NULL
;
virErrorPtr
err
=
NULL
;
const
char
*
expected
=
"<domain type='openvz'>
\n
"
" <uuid>00000000-0000-0000-0000-000000000000</uuid>
\n
"
...
...
@@ -110,16 +109,14 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
def
->
os
.
type
=
VIR_DOMAIN_OSTYPE_EXE
;
if
(
openvzReadNetworkConf
(
def
,
1
)
<
0
)
{
err
=
virGetLastError
();
fprintf
(
stderr
,
"ERROR: %s
\n
"
,
err
!=
NULL
?
err
->
message
:
"<unknown>"
);
fprintf
(
stderr
,
"ERROR: %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
actual
=
virDomainDefFormat
(
def
,
NULL
,
VIR_DOMAIN_DEF_FORMAT_INACTIVE
);
if
(
actual
==
NULL
)
{
err
=
virGetLastError
();
fprintf
(
stderr
,
"ERROR: %s
\n
"
,
err
!=
NULL
?
err
->
message
:
"<unknown>"
);
fprintf
(
stderr
,
"ERROR: %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
tests/qemucapsprobe.c
浏览文件 @
c66150ec
...
...
@@ -35,9 +35,8 @@ eventLoop(void *opaque ATTRIBUTE_UNUSED)
{
while
(
1
)
{
if
(
virEventRunDefaultImpl
()
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Failed to run event loop: %s
\n
"
,
err
&&
err
->
message
?
err
->
message
:
"Unknown error"
);
virGetLastErrorMessage
()
);
}
}
}
...
...
@@ -63,9 +62,8 @@ main(int argc, char **argv)
}
if
(
virEventRegisterDefaultImpl
()
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Failed to register event implementation: %s
\n
"
,
err
&&
err
->
message
?
err
->
message
:
"Unknown error"
);
virGetLastErrorMessage
()
);
return
EXIT_FAILURE
;
}
...
...
tests/securityselinuxtest.c
浏览文件 @
c66150ec
...
...
@@ -230,8 +230,7 @@ testSELinuxGenLabel(const void *opaque)
goto
cleanup
;
if
(
virSecurityManagerGenLabel
(
data
->
mgr
,
def
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Cannot generate label: %s
\n
"
,
err
->
message
);
fprintf
(
stderr
,
"Cannot generate label: %s
\n
"
,
virGetLastErrorMessage
());
goto
cleanup
;
}
...
...
@@ -275,9 +274,8 @@ mymain(void)
if
(
!
(
mgr
=
virSecurityManagerNew
(
"selinux"
,
"QEMU"
,
VIR_SECURITY_MANAGER_DEFAULT_CONFINED
|
VIR_SECURITY_MANAGER_PRIVILEGED
)))
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Unable to initialize security driver: %s
\n
"
,
err
->
message
);
virGetLastErrorMessage
()
);
return
EXIT_FAILURE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录