Update the qemu-iotests tarball, also fix a bug that happens if no tests failed during test execution.
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/tests/qemu_iotests/control | 8 +++- client/tests/qemu_iotests/qemu_iotests.py | 70 +++++++++++++++------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/client/tests/qemu_iotests/control b/client/tests/qemu_iotests/control index e24e280..789296a 100644 --- a/client/tests/qemu_iotests/control +++ b/client/tests/qemu_iotests/control @@ -26,5 +26,9 @@ Please send improvements to the upstream test suite, general feedback or just reports of failing tests cases to [email protected]. """ -#job.run_test('qemu_iotests', qemu_path='', options='-qcow2', tag="qcow2") -job.run_test('qemu_iotests', qemu_path='', options='-raw', tag="raw") +image_types = ['raw', 'cow', 'qcow', 'qcow2', 'vpc', 'vmdk'] + +for image_type in image_types: + option_flag = '-' + image_type + job.run_test('qemu_iotests', qemu_path='', options=option_flag, + tag=image_type) diff --git a/client/tests/qemu_iotests/qemu_iotests.py b/client/tests/qemu_iotests/qemu_iotests.py index d484323..33b24c3 100644 --- a/client/tests/qemu_iotests/qemu_iotests.py +++ b/client/tests/qemu_iotests/qemu_iotests.py @@ -1,5 +1,5 @@ import os, re, logging -from autotest_lib.client.bin import test, utils +from autotest_lib.client.bin import test, utils, os_dep from autotest_lib.client.common_lib import error @@ -11,8 +11,21 @@ class qemu_iotests(test.test): @author: Yolkfull Chow ([email protected]) @see: http://www.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git """ - version = 1 - def setup(self, tarball = 'qemu_iotests.tar.bz2'): + 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. @@ -24,7 +37,7 @@ class qemu_iotests(test.test): utils.system("make clean") - def run_once(self, qemu_path='', options='', testlist=''): + def run_once(self, options='', testlist=''): """ Passes the appropriate parameters to the testsuite. @@ -54,11 +67,6 @@ class qemu_iotests(test.test): @param testlist: List of tests that will be executed (by default, all testcases will be executed). """ - 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'] - os.chdir(self.srcdir) test_dir = os.path.join(self.srcdir, "scratch") if not os.path.exists(test_dir): @@ -68,28 +76,24 @@ class qemu_iotests(test.test): cmd += " " + options if testlist: cmd += " " + testlist - result = utils.run(cmd, ignore_status=True) - - msg = re.findall("Failures: .*", result.stdout)[0] - if msg: - self.failed_cases = re.findall("(\d+)", msg) - raise error.TestFail("Failed cases: %s" % self.failed_cases) - - - def postprocess_iteration(self): - """ - Copies the log files to the results dir. - """ - src = os.path.join(self.srcdir, "check.log") - dest = os.path.join(self.resultsdir, "qemu_iotests.log") - logging.critical('First copy') - utils.get_file(src, dest) - # copy the failed cases' log file to self.resultsdir - if self.failed_cases: - for num in self.failed_cases: - failed_name = num + ".out.bad" - src = os.path.join(self.srcdir, failed_name) - dest = os.path.join(self.resultsdir, failed_name) - logging.critical('Second copy') - utils.get_file(src, dest) + 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) -- 1.7.0.1 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
