OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 __author__ = "raphtee@google.com (Travis Miller)" | 3 __author__ = "raphtee@google.com (Travis Miller)" |
4 | 4 |
5 import unittest, os, tempfile, logging | 5 import unittest, os, tempfile, logging |
6 | 6 |
7 import common | 7 import common |
8 from autotest_lib.server import autotest, utils, hosts, server_job, profilers | 8 from autotest_lib.server import autotest, utils, hosts, server_job, profilers |
9 from autotest_lib.client.bin import sysinfo | 9 from autotest_lib.client.bin import sysinfo |
10 from autotest_lib.client.common_lib import utils as client_utils, packages | 10 from autotest_lib.client.common_lib import utils as client_utils, packages |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 '/job/tmp/file1') | 224 '/job/tmp/file1') |
225 self.host.send_file.expect_call( | 225 self.host.send_file.expect_call( |
226 "/job/tmp/file1", "autodir/control.None.autoserv.init.state") | 226 "/job/tmp/file1", "autodir/control.None.autoserv.init.state") |
227 os.remove.expect_call("/job/tmp/file1") | 227 os.remove.expect_call("/job/tmp/file1") |
228 | 228 |
229 self.host.send_file.expect_call("temp", run_obj.remote_control_file) | 229 self.host.send_file.expect_call("temp", run_obj.remote_control_file) |
230 os.path.abspath.expect_call('temp').and_return('control_file') | 230 os.path.abspath.expect_call('temp').and_return('control_file') |
231 os.path.abspath.expect_call('control').and_return('control') | 231 os.path.abspath.expect_call('control').and_return('control') |
232 os.remove.expect_call("temp") | 232 os.remove.expect_call("temp") |
233 | 233 |
234 run_obj.execute_control.expect_call(timeout=30, | 234 run_obj.execute_control.expect_call(ignore_aborts=False, |
| 235 timeout=30, |
235 client_disconnect_timeout=1800) | 236 client_disconnect_timeout=1800) |
236 | 237 |
237 # run and check output | 238 # run and check output |
238 self.base_autotest.run(control, timeout=30) | 239 self.base_autotest.run(control, timeout=30) |
239 self.god.check_playback() | 240 self.god.check_playback() |
240 | 241 |
241 | 242 |
242 def _stub_get_client_autodir_paths(self): | 243 def _stub_get_client_autodir_paths(self): |
243 def mock_get_client_autodir_paths(cls, host): | 244 def mock_get_client_autodir_paths(cls, host): |
244 return ['/some/path', '/another/path'] | 245 return ['/some/path', '/another/path'] |
245 self.god.stub_with(autotest.Autotest, 'get_client_autodir_paths', | 246 self.god.stub_with(autotest.Autotest, 'get_client_autodir_paths', |
246 classmethod(mock_get_client_autodir_paths)) | 247 classmethod(mock_get_client_autodir_paths)) |
247 | 248 |
248 | 249 |
| 250 def _stub_get_client_autodir_real_path(self): |
| 251 def mock_get_client_autodir_real_path(cls, host): |
| 252 return '/shiny/path' |
| 253 self.god.stub_with(autotest.Autotest, 'get_client_autodir_real_path', |
| 254 classmethod(mock_get_client_autodir_real_path)) |
| 255 |
| 256 |
249 def _expect_failed_run(self, command): | 257 def _expect_failed_run(self, command): |
250 (self.host.run.expect_call(command) | 258 (self.host.run.expect_call(command) |
251 .and_raises(error.AutoservRunError('dummy', object()))) | 259 .and_raises(error.AutoservRunError('dummy', object()))) |
252 | 260 |
253 | 261 |
254 def test_get_installed_autodir(self): | 262 def test_get_installed_autodir(self): |
255 self._stub_get_client_autodir_paths() | 263 self._stub_get_client_autodir_paths() |
256 self.host.get_autodir.expect_call().and_return(None) | 264 self.host.get_autodir.expect_call().and_return(None) |
257 self._expect_failed_run('test -x /some/path/bin/autotest') | 265 self._expect_failed_run('test -x /some/path/bin/autotest') |
258 self.host.run.expect_call('test -x /another/path/bin/autotest') | 266 self.host.run.expect_call('test -x /another/path/bin/autotest') |
259 | 267 |
260 autodir = autotest.Autotest.get_installed_autodir(self.host) | 268 autodir = autotest.Autotest.get_installed_autodir(self.host) |
261 self.assertEquals(autodir, '/another/path') | 269 self.assertEquals(autodir, '/another/path') |
262 | 270 |
263 | 271 |
264 def test_get_install_dir(self): | 272 def test_get_install_dir(self): |
265 self._stub_get_client_autodir_paths() | 273 self._stub_get_client_autodir_paths() |
| 274 self._stub_get_client_autodir_real_path() |
266 self.host.get_autodir.expect_call().and_return(None) | 275 self.host.get_autodir.expect_call().and_return(None) |
267 self._expect_failed_run('test -x /some/path/bin/autotest') | 276 self._expect_failed_run('test -x /some/path/bin/autotest') |
268 self._expect_failed_run('test -x /another/path/bin/autotest') | 277 self._expect_failed_run('test -x /another/path/bin/autotest') |
269 self._expect_failed_run('mkdir -p /some/path') | 278 self.host.run.expect_call('mkdir -p /shiny/path') |
270 self.host.run.expect_call('mkdir -p /another/path') | 279 self.host.run.expect_call('mkdir -p /some/path') |
| 280 |
| 281 result = client_utils.CmdResult() |
| 282 result.exit_status = 0 |
| 283 self.host.run.expect_call('mount | grep -q /some/path', |
| 284 ignore_status=True).and_return(result) |
| 285 self.host.run.expect_call('umount /some/path') |
| 286 self.host.run.expect_call('mount --bind /shiny/path /some/path') |
| 287 self.host.run.expect_call('mount -o remount,exec /some/path') |
271 | 288 |
272 install_dir = autotest.Autotest.get_install_dir(self.host) | 289 install_dir = autotest.Autotest.get_install_dir(self.host) |
273 self.assertEquals(install_dir, '/another/path') | 290 self.assertEquals(install_dir, '/some/path') |
274 | 291 |
275 | 292 |
276 def test_client_logger_process_line_log_copy_collection_failure(self): | 293 def test_client_logger_process_line_log_copy_collection_failure(self): |
277 collector = autotest.log_collector.expect_new(self.host, '', '') | 294 collector = autotest.log_collector.expect_new(self.host, '', '') |
278 logger = autotest.client_logger(self.host, '', '') | 295 logger = autotest.client_logger(self.host, '', '') |
279 collector.collect_client_job_results.expect_call().and_raises( | 296 collector.collect_client_job_results.expect_call().and_raises( |
280 Exception('log copy failure')) | 297 Exception('log copy failure')) |
281 logging.exception.expect_call(mock.is_string_comparator()) | 298 logging.exception.expect_call(mock.is_string_comparator()) |
282 logger._process_line('AUTOTEST_TEST_COMPLETE:/autotest/fifo1') | 299 logger._process_line('AUTOTEST_TEST_COMPLETE:/autotest/fifo1') |
283 | 300 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 364 |
348 | 365 |
349 def test_fails_with_exception(self): | 366 def test_fails_with_exception(self): |
350 self.assertEqual(False, self.mixin.run_test('sleeptest')) | 367 self.assertEqual(False, self.mixin.run_test('sleeptest')) |
351 self.assert_("job.run_test('sleeptest')\n" in self.control_file) | 368 self.assert_("job.run_test('sleeptest')\n" in self.control_file) |
352 self.assertEqual(self.mixin, self.host) | 369 self.assertEqual(self.mixin, self.host) |
353 | 370 |
354 | 371 |
355 if __name__ == "__main__": | 372 if __name__ == "__main__": |
356 unittest.main() | 373 unittest.main() |
OLD | NEW |