Ejemplo n.º 1
0
 def testGetWithHTTP(self):
     # Yeah, this test is a bad idea, oh well
     url = 'http://www.kernel.org/pub/linux/kernel/README'
     tmppath = utils.get(url)
     f = file(tmppath)
     f.readline()
     self.assertTrue('Linux' in f.readline().split())
Ejemplo n.º 2
0
 def testGetWithDir(self):
     tmpdir = utils.get_tmp_dir()
     origpath = os.path.join(tmpdir, 'testGetWithDir')
     os.mkdir(origpath)
     dstpath = utils.get(origpath)
     self.assertTrue(dstpath.endswith('/'))
     self.assertTrue(os.path.isdir(dstpath))
Ejemplo n.º 3
0
 def testGetWithHTTP(self):
     # Yeah, this test is a bad idea, oh well
     url = 'http://www.kernel.org/pub/linux/kernel/README'
     tmppath = utils.get(url)
     f = file(tmppath)
     f.readline()
     self.assertTrue('Linux' in f.readline().split())
Ejemplo n.º 4
0
 def testGetWithDir(self):
     tmpdir = utils.get_tmp_dir()
     origpath = os.path.join(tmpdir, 'testGetWithDir')
     os.mkdir(origpath)
     dstpath = utils.get(origpath)
     self.assertTrue(dstpath.endswith('/'))
     self.assertTrue(os.path.isdir(dstpath))
Ejemplo n.º 5
0
 def testGetWithOpenFile(self):
     tmpdir = utils.get_tmp_dir()
     tmppath = os.path.join(tmpdir, 'testfile')
     tmpfile = file(tmppath, 'w')
     print >> tmpfile, 'Test string'
     tmpfile.close()
     tmpfile = file(tmppath)
     newtmppath = utils.get(tmpfile)
     self.assertEqual(file(newtmppath).read(), 'Test string\n')
Ejemplo n.º 6
0
 def testGetWithOpenFile(self):
     tmpdir = utils.get_tmp_dir()
     tmppath = os.path.join(tmpdir, 'testfile')
     tmpfile = file(tmppath, 'w')
     print >> tmpfile, 'Test string'
     tmpfile.close()
     tmpfile = file(tmppath)
     newtmppath = utils.get(tmpfile)
     self.assertEqual(file(newtmppath).read(), 'Test string\n')
Ejemplo n.º 7
0
    def get(self, location):
        """
        Get the source material required to install the object.

        Through the utils.get() function, the argument passed will be
        saved in a temporary location on the LocalHost. That location
        is saved in the source_material attribute.

        Args:
                location: the path to the source material. This path
                        may be of any type that the utils.get()
                        function will accept.
        """
        self.source_material= utils.get(location)
Ejemplo n.º 8
0
    def get(self, location):
        """
        Get the source material required to install the object.

        Through the utils.get() function, the argument passed will be
        saved in a temporary location on the LocalHost. That location
        is saved in the source_material attribute.

        Args:
                location: the path to the source material. This path
                        may be of any type that the utils.get()
                        function will accept.
        """
        self.source_material = utils.get(location)
Ejemplo n.º 9
0
    def _do_run(self,
                control_file,
                results_dir,
                host,
                atrun,
                timeout,
                client_disconnect_timeout,
                use_packaging=True):
        try:
            atrun.verify_machine()
        except:
            logging.error("Verify failed on %s. Reinstalling autotest",
                          host.hostname)
            self.install(host)
            atrun.verify_machine()
        debug = os.path.join(results_dir, 'debug')
        try:
            os.makedirs(debug)
        except Exception:
            pass

        delete_file_list = [
            atrun.remote_control_file, atrun.remote_control_file + '.state',
            atrun.manual_control_file, atrun.manual_control_file + '.state'
        ]
        cmd = ';'.join('rm -f ' + control for control in delete_file_list)
        host.run(cmd, ignore_status=True)

        tmppath = utils.get(control_file, local_copy=True)

        # build up the initialization prologue for the control file
        prologue_lines = []

        # Add the additional user arguments
        prologue_lines.append("args = %r\n" % self.job.args)

        # If the packaging system is being used, add the repository list.
        repos = None
        try:
            if use_packaging:
                repos = self.get_fetch_location()
                prologue_lines.append('job.add_repository(%s)\n' % repos)
            else:
                logging.debug('use_packaging is set to False, do not add any '
                              'repository.')
        except global_config.ConfigError, e:
            # If repos is defined packaging is enabled so log the error
            if repos:
                logging.error(e)
Ejemplo n.º 10
0
    def _do_run(self, control_file, results_dir, host, atrun, timeout,
                client_disconnect_timeout):
        try:
            atrun.verify_machine()
        except:
            logging.error("Verify failed on %s. Reinstalling autotest",
                          host.hostname)
            self.install(host)
        atrun.verify_machine()
        debug = os.path.join(results_dir, 'debug')
        try:
            os.makedirs(debug)
        except Exception:
            pass

        delete_file_list = [
            atrun.remote_control_file, atrun.remote_control_file + '.state',
            atrun.manual_control_file, atrun.manual_control_file + '.state'
        ]
        cmd = ';'.join('rm -f ' + control for control in delete_file_list)
        host.run(cmd, ignore_status=True)

        tmppath = utils.get(control_file)

        # build up the initialization prologue for the control file
        prologue_lines = []

        # Add the additional user arguments
        prologue_lines.append("args = %r\n" % self.job.args)

        # If the packaging system is being used, add the repository list.
        repos = None
        try:
            c = global_config.global_config
            repos = c.get_config_value("PACKAGES", 'fetch_location', type=list)
            repos.reverse()  # high priority packages should be added last
            pkgmgr = packages.PackageManager('autotest',
                                             hostname=host.hostname,
                                             repo_urls=repos)
            prologue_lines.append('job.add_repository(%s)\n' % repos)
        except global_config.ConfigError, e:
            # If repos is defined packaging is enabled so log the error
            if repos:
                logging.error(e)
Ejemplo n.º 11
0
    def _do_run(self, control_file, results_dir, host, atrun, timeout,
                client_disconnect_timeout):
        try:
            atrun.verify_machine()
        except:
            logging.error("Verify failed on %s. Reinstalling autotest",
                          host.hostname)
            self.install(host)
        atrun.verify_machine()
        debug = os.path.join(results_dir, 'debug')
        try:
            os.makedirs(debug)
        except Exception:
            pass

        delete_file_list = [atrun.remote_control_file,
                            atrun.remote_control_file + '.state',
                            atrun.manual_control_file,
                            atrun.manual_control_file + '.state']
        cmd = ';'.join('rm -f ' + control for control in delete_file_list)
        host.run(cmd, ignore_status=True)

        tmppath = utils.get(control_file)

        # build up the initialization prologue for the control file
        prologue_lines = []

        # Add the additional user arguments
        prologue_lines.append("args = %r\n" % self.job.args)

        # If the packaging system is being used, add the repository list.
        repos = None
        try:
            c = global_config.global_config
            repos = c.get_config_value("PACKAGES", 'fetch_location', type=list)
            repos.reverse()  # high priority packages should be added last
            pkgmgr = packages.PackageManager('autotest', hostname=host.hostname,
                                             repo_urls=repos)
            prologue_lines.append('job.add_repository(%s)\n' % repos)
        except global_config.ConfigError, e:
            # If repos is defined packaging is enabled so log the error
            if repos:
                logging.error(e)
Ejemplo n.º 12
0
    def _do_run(self, control_file, results_dir, host, atrun, timeout,
                client_disconnect_timeout, job_tag):
        try:
            atrun.verify_machine()
        except:
            logging.error("Verify failed on %s. Reinstalling autotest",
                          host.hostname)
            self.install(host)
        atrun.verify_machine()
        debug = os.path.join(results_dir, 'debug')
        try:
            os.makedirs(debug)
        except Exception:
            pass

        delete_file_list = [atrun.remote_control_file,
                            atrun.remote_control_file + '.state',
                            atrun.manual_control_file,
                            atrun.manual_control_file + '.state']
        cmd = ';'.join('rm -f ' + control for control in delete_file_list)
        host.run(cmd, ignore_status=True)

        tmppath = utils.get(control_file)

        # build up the initialization prologue for the control file
        prologue_lines = []
        prologue_lines.append("job.default_boot_tag(%r)\n"
                              % host.job.last_boot_tag)
        prologue_lines.append("job.default_test_cleanup(%r)\n"
                              % host.job.run_test_cleanup)
        if job_tag:
            prologue_lines.append("job.default_tag(%r)\n" % job_tag)

        # If the packaging system is being used, add the repository list.
        try:
            c = global_config.global_config
            repos = c.get_config_value("PACKAGES", 'fetch_location', type=list)
            pkgmgr = packages.PackageManager('autotest', hostname=host.hostname,
                                             repo_urls=repos)
            prologue_lines.append('job.add_repository(%s)\n'
                                  % pkgmgr.repo_urls)
        except global_config.ConfigError, e:
            pass
Ejemplo n.º 13
0
 def testGetWithString(self):
     path = utils.get('/tmp loves rabbits!')
     self.assertTrue(file(path).readline().startswith('/tmp loves'))
Ejemplo n.º 14
0
 def testGetWithPath(self):
     path = utils.get('/proc/cpuinfo')
     self.assertTrue(file(path).readline().startswith('processor'))
Ejemplo n.º 15
0
 def testGetWithString(self):
     path = utils.get('/tmp loves rabbits!')
     self.assertTrue(file(path).readline().startswith('/tmp loves'))
Ejemplo n.º 16
0
 def testGetWithPath(self):
     path = utils.get('/proc/cpuinfo')
     self.assertTrue(file(path).readline().startswith('processor'))