From: Michael Goldish Subject: Re: [Autotest] [PATCH] KVM test: Change the way subtests are loaded Date: Wed, 25 Nov 2009 06:09:02 -0500 (EST) Message-ID: <1788706000.650411259147342437.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> References: <928762109.650331259147186736.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org, Lucas Meneghel Rodrigues To: sudhir kumar Return-path: Received: from mx1.redhat.com ([209.132.183.28]:16874 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbZKYLI5 convert rfc822-to-8bit (ORCPT ); Wed, 25 Nov 2009 06:08:57 -0500 In-Reply-To: <928762109.650331259147186736.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: ----- "sudhir kumar" wrote: > On Sat, Oct 31, 2009 at 3:37 AM, Lucas Meneghel Rodrigues > wrote: > > Recently autoserv changed its default behavior of rsyncing > > the whole client directory to the test machine, now it > > will copy only the needed tests to the client machine. > > > > Also, the way the tests are loaded when running from the > > server has changed, breaking the KVM test when ran from > > autoserv. > > > > So change the mechanism to load KVM subtests, in order to > > cope with the recent autoserv changes. > > > > Thanks to Ryan Harper for having noticed this issue. > > > > Signed-off-by: Lucas Meneghel Rodrigues > > --- > > =C2=A0client/tests/kvm/kvm.py | =C2=A0 =C2=A09 +++++---- > > =C2=A01 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py > > index 204164d..06ef9f5 100644 > > --- a/client/tests/kvm/kvm.py > > +++ b/client/tests/kvm/kvm.py > > @@ -22,9 +22,9 @@ class kvm(test.test): > > =C2=A0 =C2=A0 """ > > =C2=A0 =C2=A0 version =3D 1 > > =C2=A0 =C2=A0 def initialize(self): > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0# Make it possible to import modules f= rom the test's > bindir > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0sys.path.append(self.bindir) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Make it possible to import modules f= rom the subtest dir > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.subtest_dir =3D os.path.join(self.= bindir, 'tests') > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0sys.path.append(self.subtest_dir) > > > > > > =C2=A0 =C2=A0 def run_once(self, params): > > @@ -51,7 +51,7 @@ class kvm(test.test): > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= raise error.TestError("No %s.py test file found" > % type) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Load the = tests directory (which was turned into a > py module) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try: > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0test_module =3D __import__("tests.%s" % type) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0test_module =3D __import__(type) >=20 > This seems to have broken the execution of autotest under kvm guests. > I see the following error > 'module' object has no attribute 'run_autotest' > Traceback (most recent call last): > File > "/scratch/images/sudhir/devel/autotest/client/common_lib/test.py", > line 570, in _call_test_function > return func(*args, **dargs) > File > "/scratch/images/sudhir/devel/autotest/client/common_lib/test.py", > line 279, in execute > postprocess_profiled_run, args, dargs) > File > "/scratch/images/sudhir/devel/autotest/client/common_lib/test.py", > line 201, in _call_run_once > self.run_once(*args, **dargs) > File > "/scratch/images/sudhir/devel/autotest/client/tests/kvm/kvm.py", line > 63, in run_once > run_func =3D getattr(test_module, "run_%s" % > type) > AttributeError: 'module' object has no attribute > 'run_autotest' >=20 > A little more debugging prints out that the module 'autotest' has > been > imported from a wrong place. > '/scratch/images/sudhir/devel/autotest/client/tests/kvm/autotest/__in= it__.pyc'> > So may be either we need to force to import from specific path or > change the name autotest. >=20 > I had the test variant as below > only autotest.hackbench > I am unable to run any of the tests under autotest. I've encountered the same problem. I suggest we use the builtin imp module and import by filename. I'll try it and post a patch if it works. > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 except Impo= rtError, e: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= raise error.TestError("Failed to import test %s: > %s" % > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (type, e)) > > @@ -60,7 +60,8 @@ class kvm(test.test): > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kvm_preproc= essing.preprocess(self, params, env) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kvm_utils.d= ump_env(env, env_filename) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Run the t= est function > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0eval("test= _module.%s.run_%s(self, params, env)" % > (type, type)) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0run_func =3D= getattr(test_module, "run_%s" % type) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0run_func(s= elf, params, env) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kvm_utils.d= ump_env(env, env_filename) > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 except Exception, e: > > -- > > 1.6.2.5 > > > > _______________________________________________ > > Autotest mailing list > > Autotest@test.kernel.org > > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > > >=20 >=20 >=20 > --=20 > Sudhir Kumar > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest