def setUp(self): """Setup the OutputParser.""" self.parser = UBSANParser() self.ubsan1_repr = [ Message( os.path.abspath('files/ubsan1.cpp'), 4, 5, "signed integer overflow: 2147483647 + 1 cannot be " "represented in type 'int'", "UndefinedBehaviorSanitizer"), ] self.ubsan2_repr = [ Message( os.path.abspath('files/ubsan2.cpp'), 13, 10, "load of value 7, which is not a valid value for type " "'enum E'", "UndefinedBehaviorSanitizer"), Message( os.path.abspath('files/ubsan2.cpp'), 21, 7, "load of value 2, which is not a valid value for type 'bool'", "UndefinedBehaviorSanitizer"), ]
class UBSANOutputParserTestCase(unittest.TestCase): """ Tests the output of the OutputParser, which converts an Undefined Behaviour Sanitizer output file to zero or more Message object. """ def setUp(self): """Setup the OutputParser.""" self.parser = UBSANParser() self.ubsan1_repr = [ Message( os.path.abspath('files/ubsan1.cpp'), 4, 5, "signed integer overflow: 2147483647 + 1 cannot be " "represented in type 'int'", "UndefinedBehaviorSanitizer"), ] self.ubsan2_repr = [ Message( os.path.abspath('files/ubsan2.cpp'), 13, 10, "load of value 7, which is not a valid value for type " "'enum E'", "UndefinedBehaviorSanitizer"), Message( os.path.abspath('files/ubsan2.cpp'), 21, 7, "load of value 2, which is not a valid value for type 'bool'", "UndefinedBehaviorSanitizer"), ] def test_empty1(self): """Test an empty output file.""" messages = self.parser.parse_messages_from_file('empty1.out') self.assertEqual(messages, []) def test_empty2(self): """Test an output file that only contains empty lines.""" messages = self.parser.parse_messages_from_file('empty2.out') self.assertEqual(messages, []) def test_absolute_path(self): """Test for absolute paths in Messages.""" for tfile in ['abs.out', 'ubsan1.out']: messages = self.parser.parse_messages_from_file(tfile) self.assertNotEqual(len(messages), 0) for message in messages: self.assertTrue(os.path.isabs(message.path)) def test_ubsan1(self): """ Test the generated Messages of ubsan1.out. """ messages = self.parser.parse_messages_from_file('ubsan1.out') self.assertEqual(len(messages), len(self.ubsan1_repr)) for message in messages: self.assertIn(message, self.ubsan1_repr) def test_ubsan2(self): """ Test the generated Messages of ubsan1.out. """ messages = self.parser.parse_messages_from_file('ubsan2.out') self.assertEqual(len(messages), len(self.ubsan2_repr)) for message in messages: self.assertIn(message, self.ubsan2_repr)
class UBSANOutputParserTestCase(unittest.TestCase): """ Tests the output of the OutputParser, which converts an Undefined Behaviour Sanitizer output file to zero or more Message object. """ def setUp(self): """Setup the OutputParser.""" self.parser = UBSANParser() def test_empty1(self): """Test an empty output file.""" messages = self.parser.parse_messages_from_file('empty1.out') self.assertEqual(messages, []) def test_empty2(self): """Test an output file that only contains empty lines.""" messages = self.parser.parse_messages_from_file('empty2.out') self.assertEqual(messages, []) def test_absolute_path(self): """Test for absolute paths in Messages.""" for tfile in ['abs.out', 'ubsan1.out']: messages = self.parser.parse_messages_from_file(tfile) self.assertNotEqual(len(messages), 0) for message in messages: self.assertTrue(os.path.isabs(message.path)) def test_ubsan1(self): """ Test the generated Messages of ubsan1.out. """ messages = self.parser.parse_messages_from_file('ubsan1.out') self.assertEqual(len(messages), len(self.ubsan1_repr)) for message in messages: self.assertIn(message, self.ubsan1_repr) def test_ubsan2(self): """ Test the generated Messages of ubsan1.out. """ messages = self.parser.parse_messages_from_file('ubsan2.out') self.assertEqual(len(messages), len(self.ubsan2_repr)) for message in messages: self.assertIn(message, self.ubsan2_repr)
def setUp(self): """Setup the OutputParser.""" self.parser = UBSANParser()