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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 """ | 69 """ |
70 autodir = host.get_autodir() | 70 autodir = host.get_autodir() |
71 if autodir: | 71 if autodir: |
72 logging.debug('Using existing host autodir: %s', autodir) | 72 logging.debug('Using existing host autodir: %s', autodir) |
73 return autodir | 73 return autodir |
74 | 74 |
75 for path in Autotest.get_client_autodir_paths(host): | 75 for path in Autotest.get_client_autodir_paths(host): |
76 try: | 76 try: |
77 autotest_binary = os.path.join(path, 'bin', 'autotest') | 77 autotest_binary = os.path.join(path, 'bin', 'autotest') |
78 host.run('test -x %s' % utils.sh_escape(autotest_binary)) | 78 host.run('test -x %s' % utils.sh_escape(autotest_binary)) |
| 79 host.run('test -w %s' % utils.sh_escape(path)) |
79 logging.debug('Found existing autodir at %s', path) | 80 logging.debug('Found existing autodir at %s', path) |
80 return path | 81 return path |
81 except error.AutoservRunError: | 82 except error.AutoservRunError: |
82 logging.debug('%s does not exist on %s', autotest_binary, | 83 logging.debug('%s does not exist on %s', autotest_binary, |
83 host.hostname) | 84 host.hostname) |
84 raise AutodirNotFoundError | 85 raise AutodirNotFoundError |
85 | 86 |
86 | 87 |
87 @classmethod | 88 @classmethod |
88 def get_install_dir(cls, host): | 89 def get_install_dir(cls, host): |
(...skipping 13 matching lines...) Expand all Loading... |
102 return host.get_tmp_dir(parent=install_dir) | 103 return host.get_tmp_dir(parent=install_dir) |
103 return install_dir | 104 return install_dir |
104 | 105 |
105 | 106 |
106 @classmethod | 107 @classmethod |
107 def _find_installable_dir(cls, host): | 108 def _find_installable_dir(cls, host): |
108 client_autodir_paths = cls.get_client_autodir_paths(host) | 109 client_autodir_paths = cls.get_client_autodir_paths(host) |
109 for path in client_autodir_paths: | 110 for path in client_autodir_paths: |
110 try: | 111 try: |
111 host.run('mkdir -p %s' % utils.sh_escape(path)) | 112 host.run('mkdir -p %s' % utils.sh_escape(path)) |
| 113 host.run('test -w %s' % utils.sh_escape(path)) |
112 return path | 114 return path |
113 except error.AutoservRunError: | 115 except error.AutoservRunError: |
114 logging.debug('Failed to create %s', path) | 116 logging.debug('Failed to create %s', path) |
115 raise error.AutoservInstallError( | 117 raise error.AutoservInstallError( |
116 'Unable to find a place to install Autotest; tried %s', | 118 'Unable to find a place to install Autotest; tried %s', |
117 ', '.join(client_autodir_paths)) | 119 ', '.join(client_autodir_paths)) |
118 | 120 |
119 | 121 |
120 def install(self, host=None, autodir=None): | 122 def install(self, host=None, autodir=None): |
121 self._install(host=host, autodir=autodir) | 123 self._install(host=host, autodir=autodir) |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 | 1068 |
1067 @returns: True if the test passes, False otherwise.""" | 1069 @returns: True if the test passes, False otherwise.""" |
1068 at = self._Autotest() | 1070 at = self._Autotest() |
1069 control_file = ('result = job.run_test(%s)\n' | 1071 control_file = ('result = job.run_test(%s)\n' |
1070 'job.set_state("test_result", result)\n') | 1072 'job.set_state("test_result", result)\n') |
1071 test_args = [repr(test_name)] | 1073 test_args = [repr(test_name)] |
1072 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] | 1074 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] |
1073 control_file %= ', '.join(test_args) | 1075 control_file %= ', '.join(test_args) |
1074 at.run(control_file, host=self) | 1076 at.run(control_file, host=self) |
1075 return at.job.get_state('test_result', default=False) | 1077 return at.job.get_state('test_result', default=False) |
OLD | NEW |