| OLD | NEW |
| 1 # Copyright 2007 Google Inc. Released under the GPL v2 | 1 # Copyright 2007 Google Inc. Released under the GPL v2 |
| 2 | 2 |
| 3 import re, os, sys, traceback, subprocess, time, pickle, glob, tempfile | 3 import re, os, sys, traceback, subprocess, time, pickle, glob, tempfile |
| 4 import logging, getpass | 4 import logging, getpass |
| 5 from autotest_lib.server import installable_object, prebuild, utils | 5 from autotest_lib.server import installable_object, prebuild, utils |
| 6 from autotest_lib.client.common_lib import base_job, log, error, autotemp | 6 from autotest_lib.client.common_lib import base_job, log, error, autotemp |
| 7 from autotest_lib.client.common_lib import global_config, packages | 7 from autotest_lib.client.common_lib import global_config, packages |
| 8 from autotest_lib.client.common_lib import utils as client_utils | 8 from autotest_lib.client.common_lib import utils as client_utils |
| 9 | 9 |
| 10 AUTOTEST_SVN = 'svn://test.kernel.org/autotest/trunk/client' | 10 AUTOTEST_SVN = 'svn://test.kernel.org/autotest/trunk/client' |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 cls.install_in_tmpdir = flag | 54 cls.install_in_tmpdir = flag |
| 55 | 55 |
| 56 | 56 |
| 57 @classmethod | 57 @classmethod |
| 58 def get_client_autodir_paths(cls, host): | 58 def get_client_autodir_paths(cls, host): |
| 59 return global_config.global_config.get_config_value( | 59 return global_config.global_config.get_config_value( |
| 60 'AUTOSERV', 'client_autodir_paths', type=list) | 60 'AUTOSERV', 'client_autodir_paths', type=list) |
| 61 | 61 |
| 62 | 62 |
| 63 @classmethod | 63 @classmethod |
| 64 def get_client_autodir_real_path(cls, host): |
| 65 return global_config.global_config.get_config_value( |
| 66 'AUTOSERV', 'client_autodir_real_path', type=str) |
| 67 |
| 68 |
| 69 @classmethod |
| 64 def get_installed_autodir(cls, host): | 70 def get_installed_autodir(cls, host): |
| 65 """ | 71 """ |
| 66 Find where the Autotest client is installed on the host. | 72 Find where the Autotest client is installed on the host. |
| 67 @returns an absolute path to an installed Autotest client root. | 73 @returns an absolute path to an installed Autotest client root. |
| 68 @raises AutodirNotFoundError if no Autotest installation can be found. | 74 @raises AutodirNotFoundError if no Autotest installation can be found. |
| 69 """ | 75 """ |
| 70 autodir = host.get_autodir() | 76 autodir = host.get_autodir() |
| 71 if autodir: | 77 if autodir: |
| 72 logging.debug('Using existing host autodir: %s', autodir) | 78 logging.debug('Using existing host autodir: %s', autodir) |
| 73 return autodir | 79 return autodir |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 install_dir = cls._find_installable_dir(host) | 105 install_dir = cls._find_installable_dir(host) |
| 100 | 106 |
| 101 if cls.install_in_tmpdir: | 107 if cls.install_in_tmpdir: |
| 102 return host.get_tmp_dir(parent=install_dir) | 108 return host.get_tmp_dir(parent=install_dir) |
| 103 return install_dir | 109 return install_dir |
| 104 | 110 |
| 105 | 111 |
| 106 @classmethod | 112 @classmethod |
| 107 def _find_installable_dir(cls, host): | 113 def _find_installable_dir(cls, host): |
| 108 client_autodir_paths = cls.get_client_autodir_paths(host) | 114 client_autodir_paths = cls.get_client_autodir_paths(host) |
| 115 client_autodir_real_path = utils.sh_escape( |
| 116 cls.get_client_autodir_real_path(host)) |
| 109 for path in client_autodir_paths: | 117 for path in client_autodir_paths: |
| 110 try: | 118 try: |
| 111 host.run('mkdir -p %s' % utils.sh_escape(path)) | 119 path = utils.sh_escape(path) |
| 120 # Since ChromeOS uses tmpfs (in memory fs) we don't want to let |
| 121 # Autotest use it for running tests and storing results. As an |
| 122 # additional wrinkle all fs are mounted noexec. To work around |
| 123 # this we need to setup a mount point and remount it as exec. |
| 124 host.run('mkdir -p ' + client_autodir_real_path) |
| 125 host.run('mkdir -p ' + path) |
| 126 |
| 127 # Check for existing mount and unmount if exists. |
| 128 result = host.run('mount | grep -q ' + path, ignore_status=True) |
| 129 if result.exit_status == 0: |
| 130 host.run('umount ' + path) |
| 131 |
| 132 host.run('mount --bind %s %s' % (client_autodir_real_path, |
| 133 path)) |
| 134 host.run('mount -o remount,exec ' + path) |
| 112 return path | 135 return path |
| 113 except error.AutoservRunError: | 136 except error.AutoservRunError: |
| 114 logging.debug('Failed to create %s', path) | 137 logging.debug('Failed to create %s', path) |
| 115 raise error.AutoservInstallError( | 138 raise error.AutoservInstallError( |
| 116 'Unable to find a place to install Autotest; tried %s', | 139 'Unable to find a place to install Autotest; tried %s', |
| 117 ', '.join(client_autodir_paths)) | 140 ', '.join(client_autodir_paths)) |
| 118 | 141 |
| 119 | 142 |
| 120 def install(self, host=None, autodir=None): | 143 def install(self, host=None, autodir=None): |
| 121 self._install(host=host, autodir=autodir) | 144 self._install(host=host, autodir=autodir) |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 | 1095 |
| 1073 @returns: True if the test passes, False otherwise.""" | 1096 @returns: True if the test passes, False otherwise.""" |
| 1074 at = self._Autotest() | 1097 at = self._Autotest() |
| 1075 control_file = ('result = job.run_test(%s)\n' | 1098 control_file = ('result = job.run_test(%s)\n' |
| 1076 'job.set_state("test_result", result)\n') | 1099 'job.set_state("test_result", result)\n') |
| 1077 test_args = [repr(test_name)] | 1100 test_args = [repr(test_name)] |
| 1078 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] | 1101 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] |
| 1079 control_file %= ', '.join(test_args) | 1102 control_file %= ', '.join(test_args) |
| 1080 at.run(control_file, host=self) | 1103 at.run(control_file, host=self) |
| 1081 return at.job.get_state('test_result', default=False) | 1104 return at.job.get_state('test_result', default=False) |
| OLD | NEW |