def test_unrelated_Oops_string_is_not_detected_as_panic(): # Sounds implausible, but this really happened... line = "2013-11-19 05:47:48,109 backend __init__: INFO RPMTest some-test-rpm-name - /mnt/testarea/tmpnOopsn.sh ['some-test-rpm-name'] \n" detector = PanicDetector(get_conf().get('PANIC_REGEX')) failure_found = detector.feed(line) if failure_found: raise AssertionError('False panic detection: %s' % failure_found)
def setUp(self): self.conf = _conf self.panic_detector = PanicDetector(self.conf["PANIC_REGEX"]) self.should_panic = [ 'Internal error: Oops - BUG: 0 [#2] PREEMPT ARM', # oops.kernel.org examples 'Oops: 0000 [#1] SMP\\', 'Oops[#1]', 'Oops - bad mode' # jbastian example bz:1538906 ] # From bz:1538906 self.test_case_name_oops = 'regression-bz123456789-Oops-when-some-thing-happens-' self.fake_panic = 'I can\'t believe it\'s not a panic' self.acceptable_panic_matches = ['Oops:', 'Oops ', 'Oops[']
class TestPanicDetector(unittest.TestCase): def setUp(self): self.conf = _conf self.panic_detector = PanicDetector(self.conf["PANIC_REGEX"]) self.should_panic = [ 'Internal error: Oops - BUG: 0 [#2] PREEMPT ARM', # oops.kernel.org examples 'Oops: 0000 [#1] SMP\\', 'Oops[#1]', 'Oops - bad mode' # jbastian example bz:1538906 ] # From bz:1538906 self.test_case_name_oops = 'regression-bz123456789-Oops-when-some-thing-happens-' self.fake_panic = 'I can\'t believe it\'s not a panic' self.acceptable_panic_matches = ['Oops:', 'Oops ', 'Oops['] def test_panic_detector_detects_correctly(self): for line in self.should_panic: self.panic_detector.fired = False match = self.panic_detector.feed(line) self.assertTrue(self.panic_detector.fired, "Failed to detect: %r" % (line)) self.assertTrue( match in self.acceptable_panic_matches, "%r is not an acceptable match. Line: %r" % (match, line)) def test_panic_not_detected_for_random_string(self): match = self.panic_detector.feed(self.fake_panic) self.assertFalse( self.panic_detector.fired, "Panic detector erroneously detected: %r" % (self.fake_panic)) self.assertIsNone(match, "feed result ( %r ) wasn't NoneType" % (match)) def test_panic_not_detected_for_test_case_name_containing_oops(self): match = self.panic_detector.feed(self.test_case_name_oops) self.assertFalse( self.panic_detector.fired, "Panic detector erroneously detected: %r" % (self.test_case_name_oops)) self.assertIsNone(match, "feed result ( %r ) wasn't NoneType" % (match))
def setUp(self): self.conf = _conf self.panic_detector = PanicDetector(self.conf["PANIC_REGEX"]) self.should_panic = [ 'Internal error: Oops - BUG: 0 [#2] PREEMPT ARM', # oops.kernel.org examples 'Oops: 0000 [#1] SMP\\', 'Oops[#1]', 'Oops - bad mode', # jbastian example bz:1538906 'kernel BUG at fs/ext4/super.c:1022!' # xifeng example bz:1778643 ] # From bz:1538906 self.should_not_panic = [ 'regression-bz123456789-Oops-when-some-thing-happens-', 'I can\'t believe it\'s not a panic', 'looking for a kernel BUG at my setup!' ] self.acceptable_panic_matches = ['Oops:', 'Oops ', 'Oops[', 'kernel BUG at fs/ext4/super.c:1022!']
class TestPanicDetector(unittest.TestCase): def setUp(self): self.conf = _conf self.panic_detector = PanicDetector(self.conf["PANIC_REGEX"]) self.should_panic = [ 'Internal error: Oops - BUG: 0 [#2] PREEMPT ARM', # oops.kernel.org examples 'Oops: 0000 [#1] SMP\\', 'Oops[#1]', 'Oops - bad mode' # jbastian example bz:1538906 ] # From bz:1538906 self.test_case_name_oops = 'regression-bz123456789-Oops-when-some-thing-happens-' self.fake_panic = 'I can\'t believe it\'s not a panic' self.acceptable_panic_matches = ['Oops:', 'Oops ', 'Oops['] def test_panic_detector_detects_correctly(self): for line in self.should_panic: self.panic_detector.fired = False match = self.panic_detector.feed(line) self.assertTrue(self.panic_detector.fired, "Failed to detect: %r" % (line)) self.assertTrue(match in self.acceptable_panic_matches, "%r is not an acceptable match. Line: %r" % (match, line)) def test_panic_not_detected_for_random_string(self): match = self.panic_detector.feed(self.fake_panic) self.assertFalse(self.panic_detector.fired, "Panic detector erroneously detected: %r" % (self.fake_panic)) self.assertIsNone(match, "feed result ( %r ) wasn't NoneType" % (match)) def test_panic_not_detected_for_test_case_name_containing_oops(self): match = self.panic_detector.feed(self.test_case_name_oops) self.assertFalse(self.panic_detector.fired, "Panic detector erroneously detected: %r" % (self.test_case_name_oops)) self.assertIsNone(match, "feed result ( %r ) wasn't NoneType" % (match))
class TestPanicDetector(unittest.TestCase): def setUp(self): self.conf = _conf self.panic_detector = PanicDetector(self.conf["PANIC_REGEX"]) self.should_panic = [ 'Internal error: Oops - BUG: 0 [#2] PREEMPT ARM', # oops.kernel.org examples 'Oops: 0000 [#1] SMP\\', 'Oops[#1]', 'Oops - bad mode', # jbastian example bz:1538906 'kernel BUG at fs/ext4/super.c:1022!' # xifeng example bz:1778643 ] # From bz:1538906 self.should_not_panic = [ 'regression-bz123456789-Oops-when-some-thing-happens-', 'I can\'t believe it\'s not a panic', 'looking for a kernel BUG at my setup!' ] self.acceptable_panic_matches = ['Oops:', 'Oops ', 'Oops[', 'kernel BUG at fs/ext4/super.c:1022!'] def test_panic_detector_detects_correctly(self): for line in self.should_panic: self.panic_detector.fired = False match = self.panic_detector.feed(line) self.assertTrue(self.panic_detector.fired, "Failed to detect: %r" % (line)) self.assertTrue(match in self.acceptable_panic_matches, "%r is not an acceptable match. Line: %r" % (match, line)) def test_panic_detector_ignores_false_panic(self): for line in self.should_not_panic: match = self.panic_detector.feed(line) self.assertFalse(self.panic_detector.fired, "Panic detector erroneously detected: %r" % (line)) self.assertIsNone(match, "feed result ( %r ) wasn't NoneType" % (match))
def test_general_protection__user_space_is_not_detected_as_panic(): line = "kvm-01-guest19 login: [ 30.165967] traps: bz1172806[2463] general protection fault ip:804b000 sp:5aadc0de error:0 in bz1172806[8048000+5000] \n" detector = PanicDetector(get_conf().get('PANIC_REGEX')) failure_found = detector.feed(line) if failure_found: raise AssertionError('False panic detection: %s' % failure_found)