From 1da62b51a5f00a4b84843f3ecc8a495de618afc8 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Tue, 11 Feb 2020 14:11:01 +0000 Subject: [DebugInfo] Print version in error message in decimal Also remove some test duplication and add a test case that shows the maximum version is rejected (this also shows that the value in the error message is actually in decimal, and not just missing an 0x prefix). Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D74403 --- .../DebugInfo/DWARF/DWARFDebugLineTest.cpp | 39 ++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp') diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp index b0fdabb..795b9b4 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -339,37 +339,34 @@ TEST_F(DebugLineBasicFixture, ErrorForReservedLength) { "unit length found of value 0xfffffff0"); } -TEST_F(DebugLineBasicFixture, ErrorForLowVersion) { - if (!setupGenerator()) - return; - - LineTable < = Gen->addLineTable(); - LT.setCustomPrologue( - {{LineTable::Half, LineTable::Long}, {1, LineTable::Half}}); - - generate(); +struct DebugLineUnsupportedVersionFixture : public TestWithParam, + public CommonFixture { + void SetUp() { Version = GetParam(); } - checkGetOrParseLineTableEmitsFatalError( - "parsing line table prologue at offset " - "0x00000000 found unsupported version " - "0x01"); -} + uint16_t Version; +}; -TEST_F(DebugLineBasicFixture, ErrorForHighVersion) { +TEST_P(DebugLineUnsupportedVersionFixture, ErrorForUnsupportedVersion) { if (!setupGenerator()) return; LineTable < = Gen->addLineTable(); LT.setCustomPrologue( - {{LineTable::Half, LineTable::Long}, {6, LineTable::Half}}); + {{LineTable::Half, LineTable::Long}, {Version, LineTable::Half}}); generate(); checkGetOrParseLineTableEmitsFatalError( "parsing line table prologue at offset 0x00000000 found unsupported " - "version 0x06"); + "version " + + std::to_string(Version)); } +INSTANTIATE_TEST_CASE_P(UnsupportedVersionTestParams, + DebugLineUnsupportedVersionFixture, + Values(/*1 below min */ 1, /* 1 above max */ 6, + /* Maximum possible */ 0xffff), ); + TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) { if (!setupGenerator(5)) return; @@ -785,9 +782,9 @@ TEST_F(DebugLineBasicFixture, ParserReportsFirstErrorInEachTableWhenParsing) { EXPECT_FALSE(Recoverable); checkError({"parsing line table prologue at offset 0x00000000 found " - "unsupported version 0x00", + "unsupported version 0", "parsing line table prologue at offset 0x00000006 found " - "unsupported version 0x01"}, + "unsupported version 1"}, std::move(Unrecoverable)); } @@ -843,9 +840,9 @@ TEST_F(DebugLineBasicFixture, EXPECT_FALSE(Recoverable); checkError({"parsing line table prologue at offset 0x00000000 found " - "unsupported version 0x00", + "unsupported version 0", "parsing line table prologue at offset 0x00000006 found " - "unsupported version 0x01"}, + "unsupported version 1"}, std::move(Unrecoverable)); } -- cgit v1.1