From: Lucas Meneghel Rodrigues Subject: Re: [PATCH 1/2] KVM test: Refactoring the 'autotest' subtest Date: Wed, 17 Mar 2010 10:01:55 -0300 Message-ID: <6ac58f4f1003170601o123ab511ube84388ea6614cb@mail.gmail.com> References: <1267127003-14290-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: sudhir kumar Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org On Fri, Feb 26, 2010 at 1:13 AM, sudhir kumar wrote: > Looks good to me. It will definitely boost test speed for certain > tests and give flexibility to use existing autotest strength in more > granular way. Thank you! FYI, this patch was applied, mainly because it's not dependent on cpu_set test itself: http://autotest.kernel.org/changeset/4308 > On Fri, Feb 26, 2010 at 1:13 AM, Lucas Meneghel Rodrigues > wrote: >> Refactor autotest subtest into a utility function, so other >> KVM subtests can run autotest control files in hosts as part >> of their routine. >> >> This arrangement was made to accomodate the upcoming 'cpu_set' >> test. >> >> Signed-off-by: Lucas Meneghel Rodrigues >> --- >> =A0client/tests/kvm/kvm_test_utils.py | =A0165 +++++++++++++++++++++++++= ++++++++++- >> =A0client/tests/kvm/tests/autotest.py | =A0153 ++-----------------------= -------- >> =A02 files changed, 171 insertions(+), 147 deletions(-) >> >> diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_t= est_utils.py >> index 7d96d6e..71d6303 100644 >> --- a/client/tests/kvm/kvm_test_utils.py >> +++ b/client/tests/kvm/kvm_test_utils.py >> @@ -24,7 +24,7 @@ More specifically: >> =A0import time, os, logging, re, commands >> =A0from autotest_lib.client.common_lib import error >> =A0from autotest_lib.client.bin import utils >> -import kvm_utils, kvm_vm, kvm_subprocess >> +import kvm_utils, kvm_vm, kvm_subprocess, scan_results >> >> >> =A0def get_living_vm(env, vm_name): >> @@ -237,3 +237,166 @@ def get_memory_info(lvms): >> =A0 =A0 meminfo =3D meminfo[0:-2] + "}" >> >> =A0 =A0 return meminfo >> + >> + >> +def run_autotest(vm, session, control_path, timeout, test_name, outputd= ir): >> + =A0 =A0""" >> + =A0 =A0Run an autotest control file inside a guest (linux only utility= ). >> + >> + =A0 =A0@param vm: VM object. >> + =A0 =A0@param session: A shell session on the VM provided. >> + =A0 =A0@param control: An autotest control file. >> + =A0 =A0@param timeout: Timeout under which the autotest test must comp= lete. >> + =A0 =A0@param test_name: Autotest client test name. >> + =A0 =A0@param outputdir: Path on host where we should copy the guest a= utotest >> + =A0 =A0 =A0 =A0 =A0 =A0results to. >> + =A0 =A0""" >> + =A0 =A0def copy_if_size_differs(vm, local_path, remote_path): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Copy a file to a guest if it doesn't exist or if its si= ze differs. >> + >> + =A0 =A0 =A0 =A0@param vm: VM object. >> + =A0 =A0 =A0 =A0@param local_path: Local path. >> + =A0 =A0 =A0 =A0@param remote_path: Remote path. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0copy =3D False >> + =A0 =A0 =A0 =A0basename =3D os.path.basename(local_path) >> + =A0 =A0 =A0 =A0local_size =3D os.path.getsize(local_path) >> + =A0 =A0 =A0 =A0output =3D session.get_command_output("ls -l %s" % remo= te_path) >> + =A0 =A0 =A0 =A0if "such file" in output: >> + =A0 =A0 =A0 =A0 =A0 =A0logging.info("Copying %s to guest (remote file = is missing)" % >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 basename) >> + =A0 =A0 =A0 =A0 =A0 =A0copy =3D True >> + =A0 =A0 =A0 =A0else: >> + =A0 =A0 =A0 =A0 =A0 =A0try: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0remote_size =3D output.split()[4] >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0remote_size =3D int(remote_size) >> + =A0 =A0 =A0 =A0 =A0 =A0except IndexError, ValueError: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logging.error("Check for remote path si= ze %s returned %s. " >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Cannot pro= cess.", remote_path, output) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Failed to check f= or %s (Guest died?)" % >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 remote_path) >> + =A0 =A0 =A0 =A0 =A0 =A0if remote_size !=3D local_size: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logging.debug("Copying %s to guest due = to size mismatch" >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"(remote si= ze %s, local size %s)" % >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(basename, = remote_size, local_size)) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0copy =3D True >> + >> + =A0 =A0 =A0 =A0if copy: >> + =A0 =A0 =A0 =A0 =A0 =A0if not vm.copy_files_to(local_path, remote_path= ): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Could not copy %s= to guest" % local_path) >> + >> + >> + =A0 =A0def extract(vm, remote_path, dest_dir=3D"."): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Extract a .tar.bz2 file on the guest. >> + >> + =A0 =A0 =A0 =A0@param vm: VM object >> + =A0 =A0 =A0 =A0@param remote_path: Remote file path >> + =A0 =A0 =A0 =A0@param dest_dir: Destination dir for the contents >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0basename =3D os.path.basename(remote_path) >> + =A0 =A0 =A0 =A0logging.info("Extracting %s..." % basename) >> + =A0 =A0 =A0 =A0(status, output) =3D session.get_command_status_output( >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"ta= r xjvf %s -C %s" % (remote_path, dest_dir)) >> + =A0 =A0 =A0 =A0if status !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0logging.error("Uncompress output:\n%s" % output) >> + =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Could not extract % on gu= est") >> + >> + =A0 =A0if not os.path.isfile(control_path): >> + =A0 =A0 =A0 =A0raise error.TestError("Invalid path to autotest control= file: %s" % >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0control_pat= h) >> + >> + =A0 =A0tarred_autotest_path =3D "/tmp/autotest.tar.bz2" >> + =A0 =A0tarred_test_path =3D "/tmp/%s.tar.bz2" % test_name >> + >> + =A0 =A0# To avoid problems, let's make the test use the current AUTODIR >> + =A0 =A0# (autotest client path) location >> + =A0 =A0autotest_path =3D os.environ['AUTODIR'] >> + =A0 =A0tests_path =3D os.path.join(autotest_path, 'tests') >> + =A0 =A0test_path =3D os.path.join(tests_path, test_name) >> + >> + =A0 =A0# tar the contents of bindir/autotest >> + =A0 =A0cmd =3D "tar cvjf %s %s/*" % (tarred_autotest_path, autotest_pa= th) >> + =A0 =A0cmd +=3D " --exclude=3D%s/tests" % autotest_path >> + =A0 =A0cmd +=3D " --exclude=3D%s/results" % autotest_path >> + =A0 =A0cmd +=3D " --exclude=3D%s/tmp" % autotest_path >> + =A0 =A0cmd +=3D " --exclude=3D%s/control" % autotest_path >> + =A0 =A0cmd +=3D " --exclude=3D*.pyc" >> + =A0 =A0cmd +=3D " --exclude=3D*.svn" >> + =A0 =A0cmd +=3D " --exclude=3D*.git" >> + =A0 =A0utils.run(cmd) >> + >> + =A0 =A0# tar the contents of bindir/autotest/tests/ >> + =A0 =A0cmd =3D "tar cvjf %s %s/*" % (tarred_test_path, test_path) >> + =A0 =A0cmd +=3D " --exclude=3D*.pyc" >> + =A0 =A0cmd +=3D " --exclude=3D*.svn" >> + =A0 =A0cmd +=3D " --exclude=3D*.git" >> + =A0 =A0utils.run(cmd) >> + >> + =A0 =A0# Copy autotest.tar.bz2 >> + =A0 =A0copy_if_size_differs(vm, tarred_autotest_path, tarred_autotest_= path) >> + >> + =A0 =A0# Copy .tar.bz2 >> + =A0 =A0copy_if_size_differs(vm, tarred_test_path, tarred_test_path) >> + >> + =A0 =A0# Extract autotest.tar.bz2 >> + =A0 =A0extract(vm, tarred_autotest_path, "/") >> + >> + =A0 =A0# mkdir autotest/tests >> + =A0 =A0session.get_command_output("mkdir -p %s" % tests_path) >> + >> + =A0 =A0# Extract .tar.bz2 into autotest/tests >> + =A0 =A0extract(vm, tarred_test_path, "/") >> + >> + =A0 =A0if not vm.copy_files_to(control_path, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0os.path.join(au= totest_path, 'control')): >> + =A0 =A0 =A0 =A0raise error.TestFail("Could not copy the test control f= ile to guest") >> + >> + =A0 =A0# Run the test >> + =A0 =A0logging.info("Running test '%s'..." % test_name) >> + =A0 =A0session.get_command_output("cd %s" % autotest_path) >> + =A0 =A0session.get_command_output("rm -f control.state") >> + =A0 =A0session.get_command_output("rm -rf results/*") >> + =A0 =A0logging.info("---------------- Test output ----------------") >> + =A0 =A0status =3D session.get_command_status("bin/autotest control", >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0timeout=3Dtimeout, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0print_func=3Dlogging.info) >> + =A0 =A0logging.info("--------------End of test output ------------") >> + =A0 =A0if status is None: >> + =A0 =A0 =A0 =A0raise error.TestFail("Timeout elapsed while waiting for= autotest to " >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "complete") >> + >> + =A0 =A0# Get the results generated by autotest >> + =A0 =A0output =3D session.get_command_output("cat results/*/status") >> + =A0 =A0results =3D scan_results.parse_results(output) >> + =A0 =A0session.close >> + >> + =A0 =A0# Copy test results to the local bindir/guest_results >> + =A0 =A0logging.info("Copying results back from guest...") >> + =A0 =A0guest_results_dir =3D os.path.join(outputdir, "guest_autotest_r= esults") >> + =A0 =A0if not os.path.exists(guest_results_dir): >> + =A0 =A0 =A0 =A0os.mkdir(guest_results_dir) >> + =A0 =A0if not vm.copy_files_from("%s/results/default/*" % autotest_pat= h, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0guest_resul= ts_dir): >> + =A0 =A0 =A0 =A0logging.error("Could not copy results back from guest") >> + >> + =A0 =A0# Report test results >> + =A0 =A0logging.info("Results (test, status, duration, info):") >> + =A0 =A0for result in results: >> + =A0 =A0 =A0 =A0logging.info(str(result)) >> + >> + =A0 =A0# Make a list of FAIL/ERROR/ABORT results (make sure FAIL resul= ts appear >> + =A0 =A0# before ERROR results, and ERROR results appear before ABORT r= esults) >> + =A0 =A0bad_results =3D [r for r in results if r[1] =3D=3D "FAIL"] >> + =A0 =A0bad_results +=3D [r for r in results if r[1] =3D=3D "ERROR"] >> + =A0 =A0bad_results +=3D [r for r in results if r[1] =3D=3D "ABORT"] >> + >> + =A0 =A0# Fail the test if necessary >> + =A0 =A0if not results: >> + =A0 =A0 =A0 =A0raise error.TestFail("Test '%s' did not produce any rec= ognizable " >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "results" % te= st_name) >> + =A0 =A0if bad_results: >> + =A0 =A0 =A0 =A0result =3D bad_results[0] >> + =A0 =A0 =A0 =A0raise error.TestFail("Test '%s' ended with %s (reason: = '%s')" >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 % (result[0], = result[1], result[3])) >> diff --git a/client/tests/kvm/tests/autotest.py b/client/tests/kvm/tests= /autotest.py >> index f19a2ec..07dd0a9 100644 >> --- a/client/tests/kvm/tests/autotest.py >> +++ b/client/tests/kvm/tests/autotest.py >> @@ -1,7 +1,7 @@ >> =A0import os, logging >> =A0from autotest_lib.client.common_lib import error >> =A0from autotest_lib.client.bin import utils >> -import kvm_subprocess, kvm_utils, kvm_test_utils, scan_results >> +import kvm_subprocess, kvm_utils, kvm_test_utils >> >> >> =A0def run_autotest(test, params, env): >> @@ -12,155 +12,16 @@ def run_autotest(test, params, env): >> =A0 =A0 @param params: Dictionary with test parameters. >> =A0 =A0 @param env: Dictionary with the test environment. >> =A0 =A0 """ >> - =A0 =A0# Helper functions >> - =A0 =A0def copy_if_size_differs(vm, local_path, remote_path): >> - =A0 =A0 =A0 =A0""" >> - =A0 =A0 =A0 =A0Copy a file to a guest if it doesn't exist or if its si= ze differs. >> - >> - =A0 =A0 =A0 =A0@param vm: VM object >> - =A0 =A0 =A0 =A0@param local_path: Local path >> - =A0 =A0 =A0 =A0@param remote_path: Remote path >> - =A0 =A0 =A0 =A0""" >> - =A0 =A0 =A0 =A0copy =3D False >> - =A0 =A0 =A0 =A0basename =3D os.path.basename(local_path) >> - =A0 =A0 =A0 =A0output =3D session.get_command_output("ls -l %s" % remo= te_path) >> - =A0 =A0 =A0 =A0local_size =3D os.path.getsize(local_path) >> - =A0 =A0 =A0 =A0if "such file" in output: >> - =A0 =A0 =A0 =A0 =A0 =A0logging.info("Copying %s to guest (remote file = is missing)" % >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 basename) >> - =A0 =A0 =A0 =A0 =A0 =A0copy =3D True >> - =A0 =A0 =A0 =A0else: >> - =A0 =A0 =A0 =A0 =A0 =A0remote_size =3D int(output.split()[4]) >> - =A0 =A0 =A0 =A0 =A0 =A0if remote_size !=3D local_size: >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logging.info("Copying %s to guest due t= o size mismatch" >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "(remote size = %s, local size %s)" % (basename, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0remote_size, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0local_size)) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0copy =3D True >> - >> - =A0 =A0 =A0 =A0if copy: >> - =A0 =A0 =A0 =A0 =A0 =A0if not vm.copy_files_to(local_path, remote_path= ): >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Could not copy %s= to guest" % local_path) >> - >> - >> - =A0 =A0def extract(vm, remote_path, dest_dir=3D"."): >> - =A0 =A0 =A0 =A0""" >> - =A0 =A0 =A0 =A0Extract a .tar.bz2 file on the guest. >> - >> - =A0 =A0 =A0 =A0@param vm: VM object >> - =A0 =A0 =A0 =A0@param remote_path: Remote file path >> - =A0 =A0 =A0 =A0@param dest_dir: Destination dir for the contents >> - =A0 =A0 =A0 =A0""" >> - =A0 =A0 =A0 =A0basename =3D os.path.basename(remote_path) >> - =A0 =A0 =A0 =A0logging.info("Extracting %s..." % basename) >> - =A0 =A0 =A0 =A0(status, output) =3D session.get_command_status_output( >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"ta= r xjvf %s -C %s" % (remote_path, dest_dir)) >> - =A0 =A0 =A0 =A0if status !=3D 0: >> - =A0 =A0 =A0 =A0 =A0 =A0raise error.TestFail("Could not extract %s, com= mand output: %s" % >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (basen= ame, output)) >> - >> =A0 =A0 vm =3D kvm_test_utils.get_living_vm(env, params.get("main_vm")) >> =A0 =A0 session =3D kvm_test_utils.wait_for_login(vm) >> >> =A0 =A0 # Collect test parameters >> + =A0 =A0timeout =3D int(params.get("test_timeout", 300)) >> =A0 =A0 test_name =3D params.get("test_name") >> - =A0 =A0test_timeout =3D int(params.get("test_timeout", 300)) >> - =A0 =A0test_control_file =3D params.get("test_control_file", "control") >> - >> - =A0 =A0tarred_autotest_path =3D "/tmp/autotest.tar.bz2" >> - =A0 =A0tarred_test_path =3D "/tmp/%s.tar.bz2" % test_name >> - >> - =A0 =A0# To avoid problems, let's make the test use the current AUTODIR >> - =A0 =A0# (autotest client path) location >> - =A0 =A0autotest_path =3D os.environ['AUTODIR'] >> - =A0 =A0tests_path =3D os.path.join(autotest_path, 'tests') >> - =A0 =A0test_path =3D os.path.join(tests_path, test_name) >> - >> - =A0 =A0# tar the contents of bindir/autotest >> - =A0 =A0cmd =3D "tar cvjf %s %s/*" % (tarred_autotest_path, autotest_pa= th) >> - =A0 =A0cmd +=3D " --exclude=3D%s/tests" % autotest_path >> - =A0 =A0cmd +=3D " --exclude=3D%s/results" % autotest_path >> - =A0 =A0cmd +=3D " --exclude=3D%s/tmp" % autotest_path >> - =A0 =A0cmd +=3D " --exclude=3D%s/control" % autotest_path >> - =A0 =A0cmd +=3D " --exclude=3D*.pyc" >> - =A0 =A0cmd +=3D " --exclude=3D*.svn" >> - =A0 =A0cmd +=3D " --exclude=3D*.git" >> - =A0 =A0utils.run(cmd) >> - >> - =A0 =A0# tar the contents of bindir/autotest/tests/ >> - =A0 =A0cmd =3D "tar cvjf %s %s/*" % (tarred_test_path, test_path) >> - =A0 =A0cmd +=3D " --exclude=3D*.pyc" >> - =A0 =A0cmd +=3D " --exclude=3D*.svn" >> - =A0 =A0cmd +=3D " --exclude=3D*.git" >> - =A0 =A0utils.run(cmd) >> - >> - =A0 =A0# Copy autotest.tar.bz2 >> - =A0 =A0copy_if_size_differs(vm, tarred_autotest_path, tarred_autotest_= path) >> - >> - =A0 =A0# Copy .tar.bz2 >> - =A0 =A0copy_if_size_differs(vm, tarred_test_path, tarred_test_path) >> - >> - =A0 =A0# Extract autotest.tar.bz2 >> - =A0 =A0extract(vm, tarred_autotest_path, "/") >> - >> - =A0 =A0# mkdir autotest/tests >> - =A0 =A0session.get_command_output("mkdir -p %s" % tests_path) >> - >> - =A0 =A0# Extract .tar.bz2 into autotest/tests >> - =A0 =A0extract(vm, tarred_test_path, "/") >> - >> - =A0 =A0# Copy the selected control file (located inside >> - =A0 =A0# test.bindir/autotest_control) to the autotest dir >> - =A0 =A0control_file_path =3D os.path.join(test.bindir, "autotest_contr= ol", >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 test_control_file) >> - =A0 =A0if not vm.copy_files_to(control_file_path, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0os.path.join(au= totest_path, 'control')): >> - =A0 =A0 =A0 =A0raise error.TestFail("Could not copy the test control f= ile to guest") >> - >> - =A0 =A0# Run the test >> - =A0 =A0logging.info("Running test '%s'..." % test_name) >> - =A0 =A0session.get_command_output("cd %s" % autotest_path) >> - =A0 =A0session.get_command_output("rm -f control.state") >> - =A0 =A0session.get_command_output("rm -rf results/*") >> - =A0 =A0logging.info("---------------- Test output ----------------") >> - =A0 =A0status =3D session.get_command_status("bin/autotest control", >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0timeout=3Dtest_timeout, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0print_func=3Dlogging.info) >> - =A0 =A0logging.info("---------------- End of test output -------------= ---") >> - =A0 =A0if status is None: >> - =A0 =A0 =A0 =A0raise error.TestFail("Timeout elapsed while waiting for= test to " >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "complete") >> - >> - =A0 =A0# Get the results generated by autotest >> - =A0 =A0output =3D session.get_command_output("cat results/*/status") >> - =A0 =A0results =3D scan_results.parse_results(output) >> - =A0 =A0session.close >> - >> - =A0 =A0# Copy test results to the local bindir/guest_results >> - =A0 =A0logging.info("Copying results back from guest...") >> - =A0 =A0guest_results_dir =3D os.path.join(test.outputdir, "guest_resul= ts") >> - =A0 =A0if not os.path.exists(guest_results_dir): >> - =A0 =A0 =A0 =A0os.mkdir(guest_results_dir) >> - =A0 =A0if not vm.copy_files_from("%s/results/default/*" % autotest_pat= h, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0guest_resul= ts_dir): >> - =A0 =A0 =A0 =A0logging.error("Could not copy results back from guest") >> - >> - =A0 =A0# Report test results >> - =A0 =A0logging.info("Results (test, status, duration, info):") >> - =A0 =A0for result in results: >> - =A0 =A0 =A0 =A0logging.info(str(result)) >> + =A0 =A0control_path =3D os.path.join(test.bindir, "autotest_control", >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0params.= get("test_control_file")) >> + =A0 =A0outputdir =3D test.outputdir >> >> - =A0 =A0# Make a list of FAIL/ERROR/ABORT results (make sure FAIL resul= ts appear >> - =A0 =A0# before ERROR results, and ERROR results appear before ABORT r= esults) >> - =A0 =A0bad_results =3D [r for r in results if r[1] =3D=3D "FAIL"] >> - =A0 =A0bad_results +=3D [r for r in results if r[1] =3D=3D "ERROR"] >> - =A0 =A0bad_results +=3D [r for r in results if r[1] =3D=3D "ABORT"] >> + =A0 =A0kvm_test_utils.run_autotest(vm, session, control_path, timeout,= test_name, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0outputd= ir) >> >> - =A0 =A0# Fail the test if necessary >> - =A0 =A0if not results: >> - =A0 =A0 =A0 =A0raise error.TestFail("Test '%s' did not produce any rec= ognizable " >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "results" % te= st_name) >> - =A0 =A0if bad_results: >> - =A0 =A0 =A0 =A0result =3D bad_results[0] >> - =A0 =A0 =A0 =A0raise error.TestFail("Test '%s' ended with %s (reason: = '%s')" >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 % (result[0], = result[1], result[3])) >> -- >> 1.6.6.1 >> >> _______________________________________________ >> Autotest mailing list >> Autotest@test.kernel.org >> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >> > > > > -- > Sudhir Kumar > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > -- = Lucas