Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
3c63a15b
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看板
提交
3c63a15b
编写于
12月 06, 2010
作者:
E
Eric Blake
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: fix leaks in commandtest
Most leaks could only occur on error cleanup paths.
上级
c426d13b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
27 deletion
+45
-27
tests/commandtest.c
tests/commandtest.c
+45
-27
未找到文件。
tests/commandtest.c
浏览文件 @
3c63a15b
...
...
@@ -154,6 +154,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
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -165,6 +166,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
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -183,6 +185,7 @@ static int test3(const void *unused ATTRIBUTE_UNUSED)
int
newfd1
=
dup
(
STDERR_FILENO
);
int
newfd2
=
dup
(
STDERR_FILENO
);
int
newfd3
=
dup
(
STDERR_FILENO
);
int
ret
=
-
1
;
virCommandPreserveFD
(
cmd
,
newfd1
);
virCommandTransferFD
(
cmd
,
newfd3
);
...
...
@@ -190,21 +193,23 @@ static int test3(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
return
-
1
;
goto
cleanup
;
}
if
(
fcntl
(
newfd1
,
F_GETFL
)
<
0
||
fcntl
(
newfd2
,
F_GETFL
)
<
0
||
fcntl
(
newfd3
,
F_GETFL
)
>=
0
)
{
puts
(
"fds in wrong state"
);
return
-
1
;
goto
cleanup
;
}
ret
=
checkoutput
(
"test3"
);
cleanup:
virCommandFree
(
cmd
);
VIR_FORCE_CLOSE
(
newfd1
);
VIR_FORCE_CLOSE
(
newfd2
);
return
checkoutput
(
"test3"
);
return
ret
;
}
...
...
@@ -216,8 +221,12 @@ static int test3(const void *unused ATTRIBUTE_UNUSED)
static
int
test4
(
const
void
*
unused
ATTRIBUTE_UNUSED
)
{
virCommandPtr
cmd
=
virCommandNew
(
abs_builddir
"/commandhelper"
);
pid_t
pid
;
char
*
pidfile
=
virFilePid
(
abs_builddir
,
"commandhelper"
);
pid_t
pid
;
int
ret
=
-
1
;
if
(
!
pidfile
)
goto
cleanup
;
virCommandSetPidFile
(
cmd
,
pidfile
);
virCommandDaemonize
(
cmd
);
...
...
@@ -225,21 +234,22 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
return
-
1
;
goto
cleanup
;
}
if
(
virFileReadPid
(
abs_builddir
,
"commandhelper"
,
&
pid
)
!=
0
)
{
printf
(
"cannot read pidfile
\n
"
);
return
-
1
;
goto
cleanup
;
}
while
(
kill
(
pid
,
0
)
!=
-
1
)
usleep
(
100
*
1000
);
virCommandFree
(
cmd
);
ret
=
checkoutput
(
"test4"
);
cleanup:
virCommandFree
(
cmd
);
VIR_FREE
(
pidfile
);
return
checkoutput
(
"test4"
);
return
ret
;
}
...
...
@@ -256,6 +266,7 @@ static int test5(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -279,6 +290,7 @@ static int test6(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -303,6 +315,7 @@ static int test7(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -325,6 +338,7 @@ static int test8(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -351,6 +365,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
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -376,6 +391,7 @@ static int test10(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -399,6 +415,7 @@ static int test11(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -420,6 +437,7 @@ static int test12(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -447,22 +465,23 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
return
-
1
;
goto
cleanup
;
}
if
(
!
outactual
)
goto
cleanup
;
virCommandFree
(
cmd
);
cmd
=
NULL
;
if
(
!
STREQ
(
outactual
,
outexpect
))
{
virtTestDifference
(
stderr
,
outactual
,
outexpect
);
goto
cleanup
;
}
if
(
checkoutput
(
"test13"
)
<
0
)
goto
cleanup
;
ret
=
0
;
ret
=
checkoutput
(
"test13"
);
cleanup:
virCommandFree
(
cmd
);
VIR_FREE
(
outactual
);
return
ret
;
}
...
...
@@ -491,10 +510,13 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
return
-
1
;
goto
cleanup
;
}
if
(
!
outactual
||
!
erractual
)
goto
cleanup
;
virCommandFree
(
cmd
);
cmd
=
NULL
;
if
(
!
STREQ
(
outactual
,
outexpect
))
{
virtTestDifference
(
stderr
,
outactual
,
outexpect
);
...
...
@@ -505,12 +527,10 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
goto
cleanup
;
}
if
(
checkoutput
(
"test14"
)
<
0
)
goto
cleanup
;
ret
=
0
;
ret
=
checkoutput
(
"test14"
);
cleanup:
virCommandFree
(
cmd
);
VIR_FREE
(
outactual
);
VIR_FREE
(
erractual
);
return
ret
;
...
...
@@ -530,6 +550,7 @@ static int test15(const void *unused ATTRIBUTE_UNUSED)
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot run child %s
\n
"
,
err
->
message
);
virCommandFree
(
cmd
);
return
-
1
;
}
...
...
@@ -555,7 +576,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
if
((
outactual
=
virCommandToString
(
cmd
))
==
NULL
)
{
virErrorPtr
err
=
virGetLastError
();
printf
(
"Cannot convert to string: %s
\n
"
,
err
->
message
);
return
-
1
;
goto
cleanup
;
}
if
((
fd
=
open
(
abs_builddir
"/commandhelper.log"
,
O_CREAT
|
O_TRUNC
|
O_WRONLY
,
0600
))
<
0
)
{
...
...
@@ -568,18 +589,15 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
goto
cleanup
;
}
virCommandFree
(
cmd
);
if
(
checkoutput
(
"test16"
)
<
0
)
goto
cleanup
;
if
(
!
STREQ
(
outactual
,
outexpect
))
{
virtTestDifference
(
stderr
,
outactual
,
outexpect
);
goto
cleanup
;
}
ret
=
0
;
ret
=
checkoutput
(
"test16"
);
cleanup:
virCommandFree
(
cmd
);
VIR_FORCE_CLOSE
(
fd
);
VIR_FREE
(
outactual
);
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录