Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: client/common_lib/test.py

Issue 5303005: Add support for saving VM state after test failure (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | client/common_lib/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Shell class for a test, inherited by all individual tests 1 # Shell class for a test, inherited by all individual tests
2 # 2 #
3 # Methods: 3 # Methods:
4 # __init__ initialise 4 # __init__ initialise
5 # initialize run once for each job 5 # initialize run once for each job
6 # setup run once for each new version of the test installed 6 # setup run once for each new version of the test installed
7 # run run the test (wrapped by job.run_test()) 7 # run run the test (wrapped by job.run_test())
8 # 8 #
9 # Data: 9 # Data:
10 # job backreference to the job this test instance is part of 10 # job backreference to the job this test instance is part of
11 # outputdir eg. results/<job>/<testname.tag> 11 # outputdir eg. results/<job>/<testname.tag>
12 # resultsdir eg. results/<job>/<testname.tag>/results 12 # resultsdir eg. results/<job>/<testname.tag>/results
13 # profdir eg. results/<job>/<testname.tag>/profiling 13 # profdir eg. results/<job>/<testname.tag>/profiling
14 # debugdir eg. results/<job>/<testname.tag>/debug 14 # debugdir eg. results/<job>/<testname.tag>/debug
15 # bindir eg. tests/<test> 15 # bindir eg. tests/<test>
16 # src eg. tests/<test>/src 16 # src eg. tests/<test>/src
17 # tmpdir eg. tmp/<tempname>_<testname.tag> 17 # tmpdir eg. tmp/<tempname>_<testname.tag>
18 18
19 import fcntl, getpass, os, re, sys, shutil, tarfile, tempfile, time, traceback 19 import fcntl, getpass, os, re, sys, shutil, tarfile, tempfile, time, traceback
20 import warnings, logging, glob, resource 20 import warnings, logging, glob, resource
21 21
22 from datetime import datetime
22 from autotest_lib.client.common_lib import error 23 from autotest_lib.client.common_lib import error
23 from autotest_lib.client.bin import utils 24 from autotest_lib.client.bin import utils
24 25
25 26
26 class base_test(object): 27 class base_test(object):
27 preserve_srcdir = False 28 preserve_srcdir = False
28 network_destabilizing = False 29 network_destabilizing = False
29 30
30 def __init__(self, job, bindir, outputdir): 31 def __init__(self, job, bindir, outputdir):
31 self.job = job 32 self.job = job
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 p_args, p_dargs = _cherry_pick_args(self.execute, 412 p_args, p_dargs = _cherry_pick_args(self.execute,
412 args, dargs) 413 args, dargs)
413 414
414 _call_test_function(self.execute, *p_args, **p_dargs) 415 _call_test_function(self.execute, *p_args, **p_dargs)
415 except Exception: 416 except Exception:
416 try: 417 try:
417 logging.exception('Exception escaping from test:') 418 logging.exception('Exception escaping from test:')
418 except: 419 except:
419 pass # don't let logging exceptions here interfere 420 pass # don't let logging exceptions here interfere
420 421
422 # Save the VM state immediately after the test failure.
423 # This is a NOOP if the the test isn't running in a VM or
424 # if the VM is not properly configured to save state.
425 now = datetime.now().strftime('%I:%M:%S.%f')
426 checkpoint_name = "%s-%s" % (self.tagged_testname, now)
sosa 2010/11/24 01:02:54 Don't mix "" and ''
sosa 2010/11/24 01:02:54 It may be more useful to get something about the m
thieule 2010/11/24 18:00:45 Done.
thieule 2010/11/24 18:00:45 The qcow2 file is tied to a particular base image.
427 utils.save_vm_state(checkpoint_name)
428
421 # Save the exception while we run our cleanup() before 429 # Save the exception while we run our cleanup() before
422 # reraising it. 430 # reraising it.
423 exc_info = sys.exc_info() 431 exc_info = sys.exc_info()
424 try: 432 try:
425 try: 433 try:
426 if run_cleanup: 434 if run_cleanup:
427 _cherry_pick_call(self.cleanup, *args, **dargs) 435 _cherry_pick_call(self.cleanup, *args, **dargs)
428 except Exception: 436 except Exception:
429 print 'Ignoring exception during cleanup() phase:' 437 print 'Ignoring exception during cleanup() phase:'
430 traceback.print_exc() 438 traceback.print_exc()
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if before_iteration_hook: 690 if before_iteration_hook:
683 mytest.register_before_iteration_hook(before_iteration_hook) 691 mytest.register_before_iteration_hook(before_iteration_hook)
684 if after_iteration_hook: 692 if after_iteration_hook:
685 mytest.register_after_iteration_hook(after_iteration_hook) 693 mytest.register_after_iteration_hook(after_iteration_hook)
686 mytest._exec(args, dargs) 694 mytest._exec(args, dargs)
687 finally: 695 finally:
688 os.chdir(pwd) 696 os.chdir(pwd)
689 if after_test_hook: 697 if after_test_hook:
690 after_test_hook(mytest) 698 after_test_hook(mytest)
691 shutil.rmtree(mytest.tmpdir, ignore_errors=True) 699 shutil.rmtree(mytest.tmpdir, ignore_errors=True)
OLDNEW
« no previous file with comments | « no previous file | client/common_lib/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698