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 logging, os, re | 5 import logging, os, re |
6 from autotest_lib.client.bin import site_crash_test, site_log_reader, \ | 6 from autotest_lib.client.bin import site_crash_test, site_log_reader, \ |
7 site_utils, test | 7 site_utils, test |
8 from autotest_lib.client.common_lib import error, utils | 8 from autotest_lib.client.common_lib import error, utils |
9 | 9 |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if announce_match.group(2) != 'handling': | 63 if announce_match.group(2) != 'handling': |
64 raise error.TestFail('Did not announce handling of kcrash') | 64 raise error.TestFail('Did not announce handling of kcrash') |
65 else: | 65 else: |
66 if kcrash_report is not None: | 66 if kcrash_report is not None: |
67 raise error.TestFail('Should not have found kcrash filename') | 67 raise error.TestFail('Should not have found kcrash filename') |
68 if announce_match.group(2) != 'ignoring - no consent': | 68 if announce_match.group(2) != 'ignoring - no consent': |
69 raise error.TestFail('Did not announce ignoring of kcrash') | 69 raise error.TestFail('Did not announce ignoring of kcrash') |
70 return | 70 return |
71 | 71 |
72 if not os.path.exists(kcrash_report): | 72 if not os.path.exists(kcrash_report): |
73 raise error.TestFail('Crash report gone') | 73 raise error.TestFail('Crash report %s gone' % kcrash_report) |
74 report_contents = utils.read_file(kcrash_report) | 74 report_contents = utils.read_file(kcrash_report) |
75 if not 'kernel BUG at fs/proc/breakme.c' in report_contents: | 75 if not 'kernel BUG at fs/proc/breakme.c' in report_contents: |
76 raise error.TestFail('Crash report has unexpected contents') | 76 raise error.TestFail('Crash report has unexpected contents') |
77 | 77 |
78 if not os.path.exists(_KCRASH_FILE): | 78 if not os.path.exists(_KCRASH_FILE): |
79 raise error.TestFail('Could not find %s' % _KCRASH_FILE) | 79 raise error.TestFail('Could not find %s' % _KCRASH_FILE) |
80 kcrash_file_contents = utils.read_file(_KCRASH_FILE) | 80 kcrash_file_contents = utils.read_file(_KCRASH_FILE) |
81 if kcrash_file_contents != '': | 81 if kcrash_file_contents != '': |
82 raise error.TestFail('%s was not properly cleared' % _KCRASH_FILE) | 82 raise error.TestFail('%s was not properly cleared' % _KCRASH_FILE) |
83 | 83 |
84 | 84 |
85 def _test_sender_send_kcrash(self): | 85 def _test_sender_send_kcrash(self): |
86 """Test that crash_sender properly sends the crash report.""" | 86 """Test that crash_sender properly sends the crash report.""" |
87 if not self._consent: | 87 if not self._consent: |
88 return | 88 return |
89 kcrash_report = self._get_kcrash_name() | 89 kcrash_report = self._get_kcrash_name() |
90 if not os.path.exists(kcrash_report): | 90 if not os.path.exists(kcrash_report): |
91 raise error.TestFail('Crash report gone') | 91 raise error.TestFail('Crash report %s gone' % kcrash_report) |
92 result = self._call_sender_one_crash( | 92 result = self._call_sender_one_crash( |
93 report=os.path.basename(kcrash_report)) | 93 report=os.path.basename(kcrash_report)) |
94 if (not result['send_attempt'] or not result['send_success'] or | 94 if (not result['send_attempt'] or not result['send_success'] or |
95 result['report_exists']): | 95 result['report_exists']): |
96 raise error.TestFail('kcrash not sent properly') | 96 raise error.TestFail('kcrash not sent properly') |
97 if result['exec_name'] != 'kernel' or result['report_kind'] != 'kcrash': | 97 if result['exec_name'] != 'kernel' or result['report_kind'] != 'kcrash': |
98 raise error.TestFail('kcrash exec name or report kind wrong') | 98 raise error.TestFail('kcrash exec name or report kind wrong') |
99 if result['report_payload'] != kcrash_report: | 99 if result['report_payload'] != kcrash_report: |
100 raise error.TestFail('Sent the wrong kcrash report') | 100 raise error.TestFail('Sent the wrong kcrash report') |
101 if not self._is_signature_match(result['sig']): | 101 if not self._is_signature_match(result['sig']): |
102 raise error.TestFail('Sent the wrong kcrash signature') | 102 raise error.TestFail('Sent the wrong kcrash signature') |
103 | 103 |
104 | 104 |
105 def run_once(self, is_before, consent): | 105 def run_once(self, is_before, consent): |
106 self._log_reader.set_start_by_reboot(-1) | 106 self._log_reader.set_start_by_reboot(-1) |
107 # We manage consent saving across tests. | 107 # We manage consent saving across tests. |
108 self._automatic_consent_saving = False | 108 self._automatic_consent_saving = False |
109 self._consent = consent | 109 self._consent = consent |
110 if is_before: | 110 if is_before: |
111 self.run_crash_tests(['reporter_startup'], must_run_all=False) | 111 self.run_crash_tests(['reporter_startup'], must_run_all=False) |
112 # Leave crash sending paused for the kernel crash. | 112 # Leave crash sending paused for the kernel crash. |
113 self._leave_crash_sending = False | 113 self._leave_crash_sending = False |
114 else: | 114 else: |
115 self.run_crash_tests(['reporter_startup', | 115 self.run_crash_tests(['reporter_startup', |
116 'reporter_kcrash_storage', | 116 'reporter_kcrash_storage', |
117 'sender_send_kcrash'], | 117 'sender_send_kcrash'], |
118 clear_spool_first=False) | 118 clear_spool_first=False) |
OLD | NEW |