Detect crashes while running native tests in APK.

Adding signal handlers (for fatal signals) to output a marker indicating
that the test crashed.
BUG=125059

TEST=


Review URL: https://chromiumcodereview.appspot.com/10310046

git-svn-id: http://src.chromium.org/svn/trunk/src/build@136050 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
nileshagrawal@chromium.org 2012-05-09 16:59:12 +00:00
Родитель ca9c4be795
Коммит c566fff619
4 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@ -193,8 +193,7 @@ def RunTests(device, test_suite, gtest_filter, test_arguments, rebaseline,
if test_suite in _TEST_SUITES:
logging.critical('(Remember to include the path: out/Release/%s)',
test_suite)
return TestResults.FromOkAndFailed([], [BaseTestResult(test_suite, '')],
False, False)
return TestResults.FromRun(failed=[BaseTestResult(test_suite, '')])
fully_qualified_test_suites = [test_suite]
else:
fully_qualified_test_suites = FullyQualifiedTestSuites(apk)

Просмотреть файл

@ -271,10 +271,9 @@ class SingleTestRunner(BaseTestRunner):
logging.info('*' * 80)
if executed_names == all_tests:
break
self.test_results = TestResults.FromOkAndFailed(list(executed_results -
failed_results),
list(failed_results),
False, False)
self.test_results = TestResults.FromRun(
ok=list(executed_results - failed_results),
failed=list(failed_results))
def RunTests(self):
"""Runs all tests (in rebaseline mode, runs each test in isolation).

Просмотреть файл

@ -129,11 +129,15 @@ class TestPackage(object):
"""
ok_tests = []
failed_tests = []
crashed_tests = []
timed_out = False
overall_fail = False
re_run = re.compile('\[ RUN \] ?(.*)\r\n')
# APK tests rely on the END tag.
re_end = re.compile('\[ END \] ?(.*)\r\n')
# Signal handlers are installed before starting tests
# to output the CRASHED marker when a crash happens.
re_crash = re.compile('\[ CRASHED \](.*)\r\n')
re_fail = re.compile('\[ FAILED \] ?(.*)\r\n')
re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n')
re_ok = re.compile('\[ OK \] ?(.*)\r\n')
@ -152,16 +156,22 @@ class TestPackage(object):
if self.dump_debug_info:
self.dump_debug_info.TakeScreenshot('_Test_Start_Run_')
full_test_name = p.match.group(1)
found = p.expect([re_ok, re_fail, pexpect.EOF, pexpect.TIMEOUT],
found = p.expect([re_ok, re_fail, re_crash, pexpect.EOF, pexpect.TIMEOUT],
timeout=self.timeout)
if found == 0: # re_ok
ok_tests += [BaseTestResult(full_test_name.replace('\r', ''),
p.before)]
continue
if found == 2: # re_crash
crashed_tests += [BaseTestResult(full_test_name.replace('\r', ''),
p.before)]
overall_fail = True
break
# The test failed.
failed_tests += [BaseTestResult(full_test_name.replace('\r', ''),
p.before)]
if found >= 2:
# The test crashed / bailed out (i.e., didn't print OK or FAIL).
if found >= 3:
# The test bailed out (i.e., didn't print OK or FAIL).
if found == 3: # pexpect.TIMEOUT
logging.error('Test terminated after %d second timeout.',
self.timeout)
@ -177,5 +187,7 @@ class TestPackage(object):
'\npexpect.after: %s'
% (p.before,
p.after))]
return TestResults.FromOkAndFailed(ok_tests, failed_tests,
timed_out, overall_fail)
# Create TestResults and return
return TestResults.FromRun(ok=ok_tests, failed=failed_tests,
crashed=crashed_tests, timed_out=timed_out,
overall_fail=overall_fail)

Просмотреть файл

@ -61,10 +61,12 @@ class TestResults(object):
self.overall_fail = False
@staticmethod
def FromOkAndFailed(ok, failed, timed_out, overall_fail):
def FromRun(ok=None, failed=None, crashed=None, timed_out=False,
overall_fail=False):
ret = TestResults()
ret.ok = ok
ret.failed = failed
ret.ok = ok or []
ret.failed = failed or []
ret.crashed = crashed or []
ret.timed_out = timed_out
ret.overall_fail = overall_fail
return ret