Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
56e1b4c3
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看板
提交
56e1b4c3
编写于
2月 18, 2013
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage: add test for qemu-img command line generation
上级
c6e87d1a
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
297 addition
and
0 deletion
+297
-0
tests/Makefile.am
tests/Makefile.am
+9
-0
tests/storagevolxml2argvdata/pool-dir.xml
tests/storagevolxml2argvdata/pool-dir.xml
+18
-0
tests/storagevolxml2argvdata/qcow2-flag.argv
tests/storagevolxml2argvdata/qcow2-flag.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-convert-flag.argv
.../storagevolxml2argvdata/qcow2-nobacking-convert-flag.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-convert-none.argv
.../storagevolxml2argvdata/qcow2-nobacking-convert-none.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-convert-prealloc.argv
...ragevolxml2argvdata/qcow2-nobacking-convert-prealloc.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-flag.argv
tests/storagevolxml2argvdata/qcow2-nobacking-flag.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-none.argv
tests/storagevolxml2argvdata/qcow2-nobacking-none.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-nobacking-prealloc.argv
tests/storagevolxml2argvdata/qcow2-nobacking-prealloc.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-none.argv
tests/storagevolxml2argvdata/qcow2-none.argv
+1
-0
tests/storagevolxml2argvdata/qcow2.argv
tests/storagevolxml2argvdata/qcow2.argv
+1
-0
tests/storagevolxml2argvdata/vol-file.xml
tests/storagevolxml2argvdata/vol-file.xml
+20
-0
tests/storagevolxml2argvdata/vol-qcow2-nobacking.xml
tests/storagevolxml2argvdata/vol-qcow2-nobacking.xml
+21
-0
tests/storagevolxml2argvdata/vol-qcow2.xml
tests/storagevolxml2argvdata/vol-qcow2.xml
+31
-0
tests/storagevolxml2argvtest.c
tests/storagevolxml2argvtest.c
+189
-0
未找到文件。
tests/Makefile.am
浏览文件 @
56e1b4c3
...
...
@@ -74,6 +74,7 @@ EXTRA_DIST = \
storagepoolschematest
\
storagepoolxml2xmlin
\
storagepoolxml2xmlout
\
storagevolxml2argvdata
\
storagevolschematest
\
storagevolxml2xmlin
\
storagevolxml2xmlout
\
...
...
@@ -170,6 +171,8 @@ endif
test_programs
+=
nwfilterxml2xmltest
test_programs
+=
storagevolxml2argvtest
test_programs
+=
storagevolxml2xmltest storagepoolxml2xmltest
test_programs
+=
nodedevxml2xmltest
...
...
@@ -470,6 +473,12 @@ nwfilterxml2xmltest_SOURCES = \
testutils.c testutils.h
nwfilterxml2xmltest_LDADD
=
$(LDADDS)
storagevolxml2argvtest_SOURCES
=
\
storagevolxml2argvtest.c
\
testutils.c testutils.h
storagevolxml2argvtest_LDADD
=
\
../src/libvirt_driver_storage_impl.la
$(LDADDS)
storagevolxml2xmltest_SOURCES
=
\
storagevolxml2xmltest.c
\
testutils.c testutils.h
...
...
tests/storagevolxml2argvdata/pool-dir.xml
0 → 100644
浏览文件 @
56e1b4c3
<pool
type=
'dir'
>
<name>
virtimages
</name>
<uuid>
70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2
</uuid>
<capacity>
0
</capacity>
<allocation>
0
</allocation>
<available>
0
</available>
<source>
</source>
<target>
<path>
///var/////lib/libvirt/images//
</path>
<permissions>
<mode>
0700
</mode>
<owner>
-1
</owner>
<group>
-1
</group>
<label>
some_label_t
</label>
</permissions>
</target>
</pool>
tests/storagevolxml2argvdata/qcow2-flag.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 -b /dev/null -F raw /var/lib/libvirt/images/OtherDemo.img 5242880K -e
tests/storagevolxml2argvdata/qcow2-nobacking-convert-flag.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img convert -f raw -O qcow2 /var/lib/libvirt/images/sparse.img /var/lib/libvirt/images/OtherDemo.img -e
tests/storagevolxml2argvdata/qcow2-nobacking-convert-none.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img convert -f raw -O qcow2 /var/lib/libvirt/images/sparse.img /var/lib/libvirt/images/OtherDemo.img -e
tests/storagevolxml2argvdata/qcow2-nobacking-convert-prealloc.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img convert -f raw -O qcow2 /var/lib/libvirt/images/sparse.img /var/lib/libvirt/images/OtherDemo.img -o encryption=on,preallocation=metadata
tests/storagevolxml2argvdata/qcow2-nobacking-flag.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 /var/lib/libvirt/images/OtherDemo.img 5242880K -e
tests/storagevolxml2argvdata/qcow2-nobacking-none.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 /var/lib/libvirt/images/OtherDemo.img 5242880K -e
tests/storagevolxml2argvdata/qcow2-nobacking-prealloc.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 /var/lib/libvirt/images/OtherDemo.img 5242880K -o encryption=on,preallocation=metadata
tests/storagevolxml2argvdata/qcow2-none.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 -b /dev/null /var/lib/libvirt/images/OtherDemo.img 5242880K -e
tests/storagevolxml2argvdata/qcow2.argv
0 → 100644
浏览文件 @
56e1b4c3
qemu-img create -f qcow2 -b /dev/null -o backing_fmt=raw,encryption=on /var/lib/libvirt/images/OtherDemo.img 5242880K
tests/storagevolxml2argvdata/vol-file.xml
0 → 100644
浏览文件 @
56e1b4c3
<volume>
<name>
sparse.img
</name>
<source/>
<capacity
unit=
"TiB"
>
1
</capacity>
<allocation
unit=
"bytes"
>
0
</allocation>
<target>
<path>
/var/lib/libvirt/images/sparse.img
</path>
<permissions>
<mode>
0
</mode>
<owner>
0744
</owner>
<group>
0
</group>
<label>
virt_image_t
</label>
</permissions>
<timestamps>
<atime>
1341933637.273190990
</atime>
<mtime>
1341930622.047245868
</mtime>
<ctime>
1341930622.047245868
</ctime>
</timestamps>
</target>
</volume>
tests/storagevolxml2argvdata/vol-qcow2-nobacking.xml
0 → 100644
浏览文件 @
56e1b4c3
<volume>
<name>
OtherDemo.img
</name>
<key>
/var/lib/libvirt/images/OtherDemo.img
</key>
<source>
</source>
<capacity
unit=
"G"
>
5
</capacity>
<allocation>
294912
</allocation>
<target>
<path>
/var/lib/libvirt/images/OtherDemo.img
</path>
<format
type=
'qcow2'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
<encryption
format=
'qcow'
>
<secret
type=
'passphrase'
uuid=
'e78d4b51-a2af-485f-b0f5-afca709a80f4'
/>
</encryption>
</target>
</volume>
tests/storagevolxml2argvdata/vol-qcow2.xml
0 → 100644
浏览文件 @
56e1b4c3
<volume>
<name>
OtherDemo.img
</name>
<key>
/var/lib/libvirt/images/OtherDemo.img
</key>
<source>
</source>
<capacity
unit=
"G"
>
5
</capacity>
<allocation>
294912
</allocation>
<target>
<path>
/var/lib/libvirt/images/OtherDemo.img
</path>
<format
type=
'qcow2'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
<encryption
format=
'qcow'
>
<secret
type=
'passphrase'
uuid=
'e78d4b51-a2af-485f-b0f5-afca709a80f4'
/>
</encryption>
</target>
<backingStore>
<path>
/dev/null
</path>
<format
type=
'raw'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
</backingStore>
</volume>
tests/storagevolxml2argvtest.c
0 → 100644
浏览文件 @
56e1b4c3
#include <config.h>
#include "internal.h"
#include "testutils.h"
#include "datatypes.h"
#include "storage/storage_backend.h"
#include "testutilsqemu.h"
const
char
create_tool
[]
=
"qemu-img"
;
static
int
testCompareXMLToArgvFiles
(
bool
shouldFail
,
const
char
*
poolxml
,
const
char
*
volxml
,
const
char
*
inputvolxml
,
const
char
*
cmdline
,
unsigned
int
flags
,
int
imgformat
)
{
char
*
volXmlData
=
NULL
;
char
*
poolXmlData
=
NULL
;
char
*
inputvolXmlData
=
NULL
;
char
*
expectedCmdline
=
NULL
;
char
*
actualCmdline
=
NULL
;
int
ret
=
-
1
;
int
len
;
virCommandPtr
cmd
=
NULL
;
virConnectPtr
conn
;
virStorageVolDefPtr
vol
=
NULL
,
inputvol
=
NULL
;
virStoragePoolDefPtr
pool
=
NULL
;
virStoragePoolObj
poolobj
=
{.
def
=
NULL
};
if
(
!
(
conn
=
virGetConnect
()))
goto
cleanup
;
if
(
virtTestLoadFile
(
poolxml
,
&
poolXmlData
)
<
0
)
goto
cleanup
;
if
(
virtTestLoadFile
(
volxml
,
&
volXmlData
)
<
0
)
goto
cleanup
;
if
(
inputvolxml
&&
virtTestLoadFile
(
inputvolxml
,
&
inputvolXmlData
)
<
0
)
goto
cleanup
;
if
(
!
(
pool
=
virStoragePoolDefParseString
(
poolXmlData
)))
goto
cleanup
;
poolobj
.
def
=
pool
;
if
(
!
(
vol
=
virStorageVolDefParseString
(
pool
,
volXmlData
)))
goto
cleanup
;
if
(
inputvolxml
&&
!
(
inputvol
=
virStorageVolDefParseString
(
pool
,
inputvolXmlData
)))
goto
cleanup
;
cmd
=
virStorageBackendCreateQemuImgCmd
(
conn
,
&
poolobj
,
vol
,
inputvol
,
flags
,
create_tool
,
imgformat
);
actualCmdline
=
virCommandToString
(
cmd
);
if
(
!
actualCmdline
)
{
if
(
shouldFail
)
{
virResetLastError
();
ret
=
0
;
}
goto
cleanup
;
}
len
=
virtTestLoadFile
(
cmdline
,
&
expectedCmdline
);
if
(
len
<
0
)
goto
cleanup
;
if
(
len
&&
expectedCmdline
[
len
-
1
]
==
'\n'
)
expectedCmdline
[
len
-
1
]
=
'\0'
;
if
(
STRNEQ_NULLABLE
(
expectedCmdline
,
actualCmdline
))
{
virtTestDifference
(
stderr
,
expectedCmdline
,
actualCmdline
);
goto
cleanup
;
}
ret
=
0
;
cleanup:
virStoragePoolDefFree
(
pool
);
virStorageVolDefFree
(
vol
);
virStorageVolDefFree
(
inputvol
);
virCommandFree
(
cmd
);
VIR_FREE
(
actualCmdline
);
VIR_FREE
(
expectedCmdline
);
return
ret
;
}
struct
testInfo
{
bool
shouldFail
;
const
char
*
pool
;
const
char
*
vol
;
const
char
*
inputvol
;
const
char
*
cmdline
;
unsigned
int
flags
;
int
imgformat
;
};
static
int
testCompareXMLToArgvHelper
(
const
void
*
data
)
{
int
result
=
-
1
;
const
struct
testInfo
*
info
=
data
;
char
*
poolxml
=
NULL
;
char
*
volxml
=
NULL
;
char
*
inputvolxml
=
NULL
;
char
*
cmdline
=
NULL
;
if
(
info
->
inputvol
&&
virAsprintf
(
&
inputvolxml
,
"%s/storagevolxml2argvdata/%s.xml"
,
abs_srcdir
,
info
->
inputvol
)
<
0
)
goto
cleanup
;
if
(
virAsprintf
(
&
poolxml
,
"%s/storagevolxml2argvdata/%s.xml"
,
abs_srcdir
,
info
->
pool
)
<
0
||
virAsprintf
(
&
volxml
,
"%s/storagevolxml2argvdata/%s.xml"
,
abs_srcdir
,
info
->
vol
)
<
0
)
{
goto
cleanup
;
}
if
(
virAsprintf
(
&
cmdline
,
"%s/storagevolxml2argvdata/%s.argv"
,
abs_srcdir
,
info
->
cmdline
)
<
0
&&
!
info
->
shouldFail
)
goto
cleanup
;
result
=
testCompareXMLToArgvFiles
(
info
->
shouldFail
,
poolxml
,
volxml
,
inputvolxml
,
cmdline
,
info
->
flags
,
info
->
imgformat
);
cleanup:
VIR_FREE
(
poolxml
);
VIR_FREE
(
volxml
);
VIR_FREE
(
inputvolxml
);
VIR_FREE
(
cmdline
);
return
result
;
}
enum
{
FMT_NONE
=
0
,
FMT_FLAG
,
FMT_OPTIONS
,
};
static
int
mymain
(
void
)
{
int
ret
=
0
;
unsigned
int
flags
=
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
;
#define DO_TEST(shouldFail, pool, vol, inputvol, cmdline, flags, imgformat) \
do { \
struct testInfo info = { shouldFail, pool, vol, inputvol, cmdline, \
flags, imgformat }; \
if (virtTestRun("Storage Vol XML-2-argv " cmdline, \
1, testCompareXMLToArgvHelper, &info) < 0) \
ret = -1; \
} \
while (0);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2"
,
NULL
,
"qcow2"
,
0
,
FMT_OPTIONS
);
DO_TEST
(
true
,
"pool-dir"
,
"vol-qcow2"
,
NULL
,
"qcow2-prealloc"
,
flags
,
FMT_OPTIONS
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
NULL
,
"qcow2-nobacking-prealloc"
,
flags
,
FMT_OPTIONS
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
"vol-file"
,
"qcow2-nobacking-convert-prealloc"
,
flags
,
FMT_OPTIONS
);
DO_TEST
(
true
,
"pool-dir"
,
"vol-qcow2"
,
"vol-file"
,
"qcow2-convert-prealloc"
,
flags
,
FMT_OPTIONS
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2"
,
NULL
,
"qcow2-flag"
,
0
,
FMT_FLAG
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
NULL
,
"qcow2-nobacking-flag"
,
0
,
FMT_FLAG
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
"vol-file"
,
"qcow2-nobacking-convert-flag"
,
0
,
FMT_FLAG
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2"
,
NULL
,
"qcow2-none"
,
0
,
FMT_NONE
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
NULL
,
"qcow2-nobacking-none"
,
0
,
FMT_NONE
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
"vol-file"
,
"qcow2-nobacking-convert-none"
,
0
,
FMT_NONE
);
return
ret
==
0
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
VIRT_TEST_MAIN
(
mymain
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录