OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 | 6 |
7 from autotest_lib.client.bin import boottool, site_logging, utils | 7 from autotest_lib.client.bin import boottool, site_logging, utils |
8 from autotest_lib.client.bin.job import base_client_job | 8 from autotest_lib.client.bin.job import base_client_job |
| 9 from autotest_lib.client.common_lib import error |
| 10 from datetime import datetime |
9 | 11 |
10 LAST_BOOT_TAG = object() | 12 LAST_BOOT_TAG = object() |
11 | 13 |
12 class site_job(base_client_job): | 14 class site_job(base_client_job): |
13 def __init__(self, *args, **kwargs): | 15 def __init__(self, *args, **kwargs): |
14 base_client_job.__init__(self, *args, **kwargs) | 16 base_client_job.__init__(self, *args, **kwargs) |
15 | 17 |
16 | 18 |
17 def run_test(self, url, *args, **dargs): | 19 def run_test(self, url, *args, **dargs): |
18 log_pauser = site_logging.LogRotationPauser() | 20 log_pauser = site_logging.LogRotationPauser() |
19 try: | 21 try: |
20 log_pauser.begin() | 22 log_pauser.begin() |
21 base_client_job.run_test(self, url, *args, **dargs) | 23 passed = base_client_job.run_test(self, url, *args, **dargs) |
| 24 if not passed: |
| 25 # Save the VM state immediately after the test failure. |
| 26 # This is a NOOP if the the test isn't running in a VM or |
| 27 # if the VM is not properly configured to save state. |
| 28 group, testname = self.pkgmgr.get_package_name(url, 'test') |
| 29 now = datetime.now().strftime('%I:%M:%S.%f') |
| 30 checkpoint_name = '%s-%s' % (testname, now) |
| 31 logging.info('Checkpoint name %s' % checkpoint_name) |
| 32 utils.save_vm_state(checkpoint_name) |
22 finally: | 33 finally: |
23 log_pauser.end() | 34 log_pauser.end() |
24 | 35 |
25 | 36 |
26 def reboot(self, tag=LAST_BOOT_TAG): | 37 def reboot(self, tag=LAST_BOOT_TAG): |
27 if tag == LAST_BOOT_TAG: | 38 if tag == LAST_BOOT_TAG: |
28 tag = self.last_boot_tag | 39 tag = self.last_boot_tag |
29 else: | 40 else: |
30 self.last_boot_tag = tag | 41 self.last_boot_tag = tag |
31 | 42 |
32 self.reboot_setup() | 43 self.reboot_setup() |
33 self.harness.run_reboot() | 44 self.harness.run_reboot() |
34 | 45 |
35 # sync first, so that a sync during shutdown doesn't time out | 46 # sync first, so that a sync during shutdown doesn't time out |
36 utils.system("sync; sync", ignore_status=True) | 47 utils.system("sync; sync", ignore_status=True) |
37 | 48 |
38 utils.system("(sleep 5; reboot) </dev/null >/dev/null 2>&1 &") | 49 utils.system("(sleep 5; reboot) </dev/null >/dev/null 2>&1 &") |
39 self.quit() | 50 self.quit() |
40 | 51 |
41 | 52 |
42 def require_gcc(self): | 53 def require_gcc(self): |
43 return False | 54 return False |
OLD | NEW |