OSDN Git Service

[lldb] Skip scoped enum checks with Dwarf <4
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 7 Jan 2021 01:10:20 +0000 (17:10 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 7 Jan 2021 01:13:33 +0000 (17:13 -0800)
The scoped enum tests depend on DW_AT_enum_class which was added in
Dwarf 4.

I made part of the test conditional on the Dwarf version instead of
splitting it into a separate test and using the decorator to avoid the
overhead of setting up the test.

lldb/test/API/python_api/type/TestTypeList.py

index ff560de..359dfe8 100644 (file)
@@ -145,25 +145,26 @@ class TypeAndTypeListTestCase(TestBase):
         self.DebugSBType(myint_type)
         self.assertTrue(myint_arr_element_type == myint_type)
 
-        # Test enum methods.
-        enum_type = target.FindFirstType('EnumType')
-        self.assertTrue(enum_type)
-        self.DebugSBType(enum_type)
-        self.assertFalse(enum_type.IsScopedEnumerationType())
-
-        scoped_enum_type = target.FindFirstType('ScopedEnumType')
-        self.assertTrue(scoped_enum_type)
-        self.DebugSBType(scoped_enum_type)
-        self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
-        int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
-        self.assertTrue(int_scoped_enum_type)
-        self.DebugSBType(int_scoped_enum_type)
-        self.assertEquals(int_scoped_enum_type.GetName(), 'int')
-
-        enum_uchar = target.FindFirstType('EnumUChar')
-        self.assertTrue(enum_uchar)
-        self.DebugSBType(enum_uchar)
-        int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
-        self.assertTrue(int_enum_uchar)
-        self.DebugSBType(int_enum_uchar)
-        self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
+        # Test enum methods. Requires DW_AT_enum_class which was added in Dwarf 4.
+        if configuration.dwarf_version >= 4:
+            enum_type = target.FindFirstType('EnumType')
+            self.assertTrue(enum_type)
+            self.DebugSBType(enum_type)
+            self.assertFalse(enum_type.IsScopedEnumerationType())
+
+            scoped_enum_type = target.FindFirstType('ScopedEnumType')
+            self.assertTrue(scoped_enum_type)
+            self.DebugSBType(scoped_enum_type)
+            self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+            int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+            self.assertTrue(int_scoped_enum_type)
+            self.DebugSBType(int_scoped_enum_type)
+            self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+            enum_uchar = target.FindFirstType('EnumUChar')
+            self.assertTrue(enum_uchar)
+            self.DebugSBType(enum_uchar)
+            int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+            self.assertTrue(int_enum_uchar)
+            self.DebugSBType(int_enum_uchar)
+            self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')