-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathqemu_iotests.py
102 lines (90 loc) · 3.81 KB
/
qemu_iotests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import re
from autotest.client import test, utils, os_dep
from autotest.client.shared import error
class qemu_iotests(test.test):
"""
This autotest module runs the qemu_iotests testsuite.
@copyright: Red Hat 2009
@author: Yolkfull Chow ([email protected])
@see: http://www.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git
"""
version = 2
def initialize(self, qemu_path=''):
if qemu_path:
# Prepending the path at the beginning of $PATH will make the
# version found on qemu_path be preferred over other ones.
os.environ['PATH'] = qemu_path + ":" + os.environ['PATH']
try:
self.qemu_img_path = os_dep.command('qemu-img')
self.qemu_io_path = os_dep.command('qemu-io')
except ValueError, e:
raise error.TestNAError('Commands qemu-img or qemu-io missing')
self.job.require_gcc()
def setup(self, tarball='qemu-iotests.tar.bz2'):
"""
Uncompresses the tarball and cleans any leftover output files.
:param tarball: Relative path to the testsuite tarball.
"""
tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
utils.extract_tarball_to_dir(tarball, self.srcdir)
os.chdir(self.srcdir)
utils.make('clean')
def run_once(self, options='', testlist=''):
"""
Passes the appropriate parameters to the testsuite.
# Usage: $0 [options] [testlist]
# check options
# -raw test raw (default)
# -cow test cow
# -qcow test qcow
# -qcow2 test qcow2
# -vpc test vpc
# -vmdk test vmdk
# -qed test qed
# -xdiff graphical mode diff
# -nocache use O_DIRECT on backing file
# -misalign misalign memory allocations
# -n show me, do not run tests
# -T output timestamps
# -r randomize test order
#
# testlist options
# -g group[,group...] include tests from these groups
# -x group[,group...] exclude tests from these groups
# NNN include test NNN
# NNN-NNN include test range (eg. 012-021)
:param qemu_path: Optional qemu install path.
:param options: Options accepted by the testsuite.
:param testlist: List of tests that will be executed (by default, all
testcases will be executed).
"""
os.chdir(self.srcdir)
test_dir = os.path.join(self.srcdir, "scratch")
if not os.path.exists(test_dir):
os.mkdir(test_dir)
cmd = "./check"
if options:
cmd += " " + options
if testlist:
cmd += " " + testlist
try:
try:
result = utils.system(cmd)
except error.CmdError, e:
failed_cases = re.findall("Failures: (\d+)", str(e))
for num in failed_cases:
failed_name = num + ".out.bad"
src = os.path.join(self.srcdir, failed_name)
dest = os.path.join(self.resultsdir, failed_name)
utils.get_file(src, dest)
if failed_cases:
e_msg = ("Qemu-iotests failed. Failed cases: %s" %
failed_cases)
else:
e_msg = "Qemu-iotests failed"
raise error.TestFail(e_msg)
finally:
src = os.path.join(self.srcdir, "check.log")
dest = os.path.join(self.resultsdir, "check.log")
utils.get_file(src, dest)