autotest: Test new kernel signature generation
BUG=5868
TEST=Ran these tests
Change-Id: I026d3f74b73ae5d437ba4f1fbdfffe600fa497c0
Review URL: http://codereview.chromium.org/4000005
diff --git a/client/bin/site_crash_test.py b/client/bin/site_crash_test.py
index df6ae36..6932821 100644
--- a/client/bin/site_crash_test.py
+++ b/client/bin/site_crash_test.py
@@ -149,6 +149,7 @@
report_kind: kind of report sent (minidump vs kernel)
send_attempt: did the script attempt to send a crash.
send_success: if it attempted, was the crash send successful.
+ sig: signature of the report, if given.
sleep_time: if it attempted, how long did it sleep before
sending (if mocked, how long would it have slept)
"""
@@ -175,6 +176,11 @@
exec_name = exec_name_match.group(1)
else:
exec_name = None
+ sig_match = re.search('Sig: (\S+)', output)
+ if sig_match:
+ sig = sig_match.group(1)
+ else:
+ sig = None
send_success = 'Mocking successful send' in output
return {'exec_name': exec_name,
'report_kind': report_kind,
@@ -182,6 +188,7 @@
'report_payload': report_payload,
'send_attempt': send_attempt,
'send_success': send_success,
+ 'sig': sig,
'sleep_time': sleep_time,
'output': output}
diff --git a/client/site_tests/logging_KernelCrash/logging_KernelCrash.py b/client/site_tests/logging_KernelCrash/logging_KernelCrash.py
index c0b5f7d..1e78819 100644
--- a/client/site_tests/logging_KernelCrash/logging_KernelCrash.py
+++ b/client/site_tests/logging_KernelCrash/logging_KernelCrash.py
@@ -21,32 +21,52 @@
if not self._log_reader.can_find(
'Kernel does not support crash dumping'):
raise error.TestFail(
- 'Could not find kernel crash found message')
+ 'Could not find kernel crash enabling message')
def _get_kcrash_name(self):
- filename_match = re.search(
- r'Collected kernel crash diagnostics into (\S+)',
+ filename_match = re.search(r'Stored kcrash to (\S+)',
self._log_reader.get_logs())
if not filename_match:
return None
return filename_match.group(1)
+ def _is_signature_match(self, signature):
+ return (re.match(r'kernel-write_breakme-[0-9A-F]{8}$', signature) is
+ not None)
+
+
def _test_reporter_kcrash_storage(self):
"""Test that crash_reporter has properly stored the kcrash report."""
if not self._log_reader.can_find('Cleared kernel crash diagnostics'):
raise error.TestFail('Could not find clearing message')
+ announce_match = re.search(
+ r'Received .* from kernel \(signature ([^\)]+)\) \(([^\)]+)\)',
+ self._log_reader.get_logs())
+
+ if not announce_match:
+ raise error.TestFail('Could not find kernel crash announcement')
+
+ if not self._is_signature_match(announce_match.group(1)):
+ raise error.TestFail(
+ 'Kernel crash signature (%s) did not match expected pattern' %
+ announce_match.group(1))
+
kcrash_report = self._get_kcrash_name()
if self._consent:
if kcrash_report is None:
raise error.TestFail(
'Could not find message with kcrash filename')
+ if announce_match.group(2) != 'handling':
+ raise error.TestFail('Did not announce handling of kcrash')
else:
if kcrash_report is not None:
raise error.TestFail('Should not have found kcrash filename')
+ if announce_match.group(2) != 'ignoring':
+ raise error.TestFail('Did not announce ignoring of kcrash')
return
if not os.path.exists(kcrash_report):
@@ -78,6 +98,8 @@
raise error.TestFail('kcrash exec name or report kind wrong')
if result['report_payload'] != kcrash_report:
raise error.TestFail('Sent the wrong kcrash report')
+ if not self._is_signature_match(result['sig']):
+ raise error.TestFail('Sent the wrong kcrash signature')
def run_once(self, is_before, consent):
diff --git a/client/site_tests/logging_UserCrash/logging_UserCrash.py b/client/site_tests/logging_UserCrash/logging_UserCrash.py
index 6e70e81..978bf12 100644
--- a/client/site_tests/logging_UserCrash/logging_UserCrash.py
+++ b/client/site_tests/logging_UserCrash/logging_UserCrash.py
@@ -245,6 +245,8 @@
raise error.TestFail('Sent the wrong minidump payload')
if result['meta_path'] != meta_path:
raise error.TestFail('Used the wrong meta file')
+ if result['sig'] is not None:
+ raise error.TestFail('User crash should not have signature')
# Check version matches.
lsb_release = utils.read_file('/etc/lsb-release')