Makes some changes to the partitioning code and the autotest.py code to make it a little easier to override more reliably. Specifically: - Switch the partition imports from execfile back to an import * style of loading, ultimately import seems to be the most reliable and portable - Clean up the base+site definitions in autotest.py to make Site overrides more consistent - Drop the explicit failure if the Autotest.source_material is a file and not a directory, there's no reason to outright fail and it just introduces some unnecessary fragility
Signed-off-by: John Admanski <[email protected]> --- autotest/client/bin/partition.py 2010-07-27 15:43:08.000000000 -0700 +++ autotest/client/bin/partition.py 2010-07-27 15:43:08.000000000 -0700 @@ -2,10 +2,9 @@ This is a high level partition module that executes the contents of base_partition.py and if it exists the contents of site_partition.py. """ -import os -execfile(os.path.join(os.path.dirname(__file__), 'base_partition.py')) - -__site_path = os.path.join(os.path.dirname(__file__), 'site_partition.py') -if os.path.exists(__site_path): - execfile(__site_path) +from autotest_lib.client.bin.base_partition import * +try: + from autotest_lib.client.bin.site_partition import * +except ImportError: + pass --- autotest/server/autotest.py 2010-07-27 15:43:08.000000000 -0700 +++ autotest/server/autotest.py 2010-07-27 15:43:08.000000000 -0700 @@ -221,20 +221,14 @@ # try to install from file or directory if self.source_material: - if os.path.isdir(self.source_material): - c = global_config.global_config - supports_autoserv_packaging = c.get_config_value( - "PACKAGES", "serve_packages_from_autoserv", type=bool) - # Copy autotest recursively - if supports_autoserv_packaging and use_autoserv: - self._install_using_send_file(host, autodir) - else: - host.send_file(self.source_material, autodir, - delete_dest=True) + c = global_config.global_config + supports_autoserv_packaging = c.get_config_value( + "PACKAGES", "serve_packages_from_autoserv", type=bool) + # Copy autotest recursively + if supports_autoserv_packaging and use_autoserv: + self._install_using_send_file(host, autodir) else: - # Copy autotest via tarball - e_msg = 'Installation method not yet implemented!' - raise NotImplementedError(e_msg) + host.send_file(self.source_material, autodir, delete_dest=True) logging.info("Installation of autotest completed") self.installed = True return @@ -427,7 +421,7 @@ *args, **dargs) -class _Run(object): +class _BaseRun(object): """ Represents a run of autotest control file. This class maintains all the state necessary as an autotest control file is executed. @@ -485,7 +479,7 @@ def get_background_cmd(self, section): cmd = ['nohup', os.path.join(self.autodir, 'bin/autotest_client')] cmd += self.get_base_cmd_args(section) - cmd.append('>/dev/null 2>/dev/null &') + cmd += ['>/dev/null', '2>/dev/null', '&'] return ' '.join(cmd) @@ -493,7 +487,7 @@ cmd = ['nohup', os.path.join(self.autodir, 'bin/autotestd'), monitor_dir, '-H autoserv'] cmd += self.get_base_cmd_args(section) - cmd.append('>/dev/null 2>/dev/null </dev/null &') + cmd += ['>/dev/null', '2>/dev/null', '&'] return ' '.join(cmd) @@ -1046,10 +1040,18 @@ BaseAutotest) +_SiteRun = client_utils.import_site_class( + __file__, "autotest_lib.server.site_autotest", "_SiteRun", _BaseRun) + + class Autotest(SiteAutotest): pass +class _Run(_SiteRun): + pass + + class AutotestHostMixin(object): """A generic mixin to add a run_test method to classes, which will allow you to run an autotest client test on a machine directly.""" --- autotest/server/autotest_unittest.py 2010-07-27 15:43:08.000000000 -0700 +++ autotest/server/autotest_unittest.py 2010-07-27 15:43:08.000000000 -0700 @@ -3,6 +3,7 @@ __author__ = "[email protected] (Travis Miller)" import unittest, os, tempfile, logging + import common from autotest_lib.server import autotest, utils, hosts, server_job, profilers from autotest_lib.client.bin import sysinfo @@ -49,7 +50,6 @@ self.god.stub_function(os, "remove") self.god.stub_function(os, "fdopen") self.god.stub_function(os.path, "exists") - self.god.stub_function(os.path, "isdir") self.god.stub_function(autotest, "open") self.god.stub_function(autotest.global_config.global_config, "get_config_value") @@ -117,7 +117,6 @@ def test_full_client_install(self): self.record_install_prologue() - os.path.isdir.expect_call('source_material').and_return(True) c = autotest.global_config.global_config c.get_config_value.expect_call('PACKAGES', 'serve_packages_from_autoserv', @@ -137,7 +136,6 @@ c.get_config_value.expect_call('PACKAGES', 'fetch_location', type=list, default=[]).and_return([]) - os.path.isdir.expect_call('source_material').and_return(True) c.get_config_value.expect_call('PACKAGES', 'serve_packages_from_autoserv', type=bool).and_return(True) @@ -311,6 +309,7 @@ logger._process_line('AUTOTEST_FETCH_PACKAGE:pkgname.tar.bz2:' '/autotest/dest/:/autotest/fifo3') + class test_autotest_mixin(unittest.TestCase): def setUp(self): # a dummy Autotest and job class for use in the mixin _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
