diff options
author | Frederic Riss <friss@apple.com> | 2019-10-08 19:52:01 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2019-10-08 19:52:01 +0000 |
commit | b56e3a1723e3e390f4b73bb466a3f6cd91458ca2 (patch) | |
tree | 0321e54d42b13eb874e5d6f55dec93a8a1f9a4fd /lldb/packages/Python/lldbsuite/test | |
parent | 303657a6c6f440f1855f6680c8bb1c8a7b815535 (diff) | |
download | bcm5719-llvm-b56e3a1723e3e390f4b73bb466a3f6cd91458ca2.tar.gz bcm5719-llvm-b56e3a1723e3e390f4b73bb466a3f6cd91458ca2.zip |
Add test coverage to printing of enums and fix display of unsigned values
TestCPP11EnumTypes.py should have covered all our bases when it comes
to typed enums, but it missed the regression introduced in r374066.
The reason it didn't catch it is somewhat funny: the test was copied
over from another test that recompiled a source file with a different
base type every time, but neither the test source nor the python code
was adapted for testing enums. As a result, this test was just running
8 times the exact same checks on the exact same binary.
This commit fixes the coverage and addresses the issue revealed by
the new tests.
llvm-svn: 374108
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py | 66 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp | 20 |
2 files changed, 57 insertions, 29 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py index 8157b1c2575..a250dfdd398 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -19,8 +19,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as int8_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int8_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int8_t"'}) + self.image_lookup_for_enum_type(True) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -28,8 +28,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as int16_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int16_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int16_t"'}) + self.image_lookup_for_enum_type(True) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -37,8 +37,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as int32_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int32_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int32_t"'}) + self.image_lookup_for_enum_type(True) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -46,8 +46,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as int64_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int64_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DSIGNED_ENUM_CLASS_TYPE=int64_t"'}) + self.image_lookup_for_enum_type(True) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -55,8 +55,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as uint8_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint8_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint8_t"'}) + self.image_lookup_for_enum_type(False) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -64,8 +64,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as uint16_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint16_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint16_t"'}) + self.image_lookup_for_enum_type(False) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -73,8 +73,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as uint32_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint32_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint32_t"'}) + self.image_lookup_for_enum_type(False) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') @skipIf(dwarf_version=['<', '4']) @@ -82,8 +82,8 @@ class CPP11EnumTypesTestCase(TestBase): """Test C++11 enumeration class types as uint64_t types.""" self.build( dictionary={ - 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint64_t"'}) - self.image_lookup_for_enum_type() + 'CFLAGS_EXTRAS': '"-DUNSIGNED_ENUM_CLASS_TYPE=uint64_t"'}) + self.image_lookup_for_enum_type(False) def setUp(self): # Call super's setUp(). @@ -91,7 +91,7 @@ class CPP11EnumTypesTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') - def image_lookup_for_enum_type(self): + def image_lookup_for_enum_type(self, is_signed): """Test C++11 enumeration class types.""" exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -125,16 +125,28 @@ class CPP11EnumTypesTestCase(TestBase): 'kNumDays', '}']) - enum_values = ['-4', - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday', - 'Sunday', - 'kNumDays', - '5'] + if is_signed: + enum_values = ['-4', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + 'Sunday', + 'kNumDays', + '5'] + else: + enum_values = ['199', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + 'Sunday', + 'kNumDays', + '208'] bkpt = self.target().FindBreakpointByID(bkpt_id) for enum_value in enum_values: diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp index 31d130cce90..e00fc2df460 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp @@ -11,7 +11,8 @@ int main (int argc, char const *argv[]) { - typedef int16_t enum_integer_t; +#ifdef SIGNED_ENUM_CLASS_TYPE + typedef SIGNED_ENUM_CLASS_TYPE enum_integer_t; enum class DayType : enum_integer_t { Monday = -3, Tuesday, @@ -23,10 +24,25 @@ int main (int argc, char const *argv[]) kNumDays }; enum_integer_t day_value; +#else + typedef UNSIGNED_ENUM_CLASS_TYPE enum_integer_t; + enum class DayType : enum_integer_t { + Monday = 200, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday, + kNumDays + }; + enum_integer_t day_value; +#endif + for (day_value = (enum_integer_t)DayType::Monday - 1; day_value <= (enum_integer_t)DayType::kNumDays + 1; ++day_value) { DayType day = (DayType)day_value; printf("day as int is %i\n", (int)day); // Set break point at this line. } - return 0; + return 0; // Break here for char tests } |