diff --git a/unittests/ProfileData/CoverageMappingTest.cpp b/unittests/ProfileData/CoverageMappingTest.cpp index 5c148078efa..43a7d490be8 100644 --- a/unittests/ProfileData/CoverageMappingTest.cpp +++ b/unittests/ProfileData/CoverageMappingTest.cpp @@ -118,7 +118,7 @@ struct InputFunctionCoverageData { InputFunctionCoverageData &operator=(InputFunctionCoverageData &&) = delete; }; -struct CoverageMappingTest : ::testing::Test { +struct CoverageMappingTest : ::testing::TestWithParam { StringMap Files; std::vector InputFunctions; std::vector OutputFunctions; @@ -129,7 +129,7 @@ struct CoverageMappingTest : ::testing::Test { std::unique_ptr LoadedCoverage; void SetUp() override { - ProfileWriter.setOutputSparse(false); + ProfileWriter.setOutputSparse(GetParam()); } unsigned getGlobalFileIndex(StringRef Name) { @@ -226,16 +226,7 @@ struct CoverageMappingTest : ::testing::Test { } }; -struct MaybeSparseCoverageMappingTest - : public CoverageMappingTest, - public ::testing::WithParamInterface { - void SetUp() { - CoverageMappingTest::SetUp(); - ProfileWriter.setOutputSparse(GetParam()); - } -}; - -TEST_P(MaybeSparseCoverageMappingTest, basic_write_read) { +TEST_P(CoverageMappingTest, basic_write_read) { startFunction("func", 0x1234); addCMR(Counter::getCounter(0), "foo", 1, 1, 1, 1); addCMR(Counter::getCounter(1), "foo", 2, 1, 2, 2); @@ -260,8 +251,7 @@ TEST_P(MaybeSparseCoverageMappingTest, basic_write_read) { } } -TEST_P(MaybeSparseCoverageMappingTest, - correct_deserialize_for_more_than_two_files) { +TEST_P(CoverageMappingTest, correct_deserialize_for_more_than_two_files) { const char *FileNames[] = {"bar", "baz", "foo"}; static const unsigned N = array_lengthof(FileNames); @@ -286,7 +276,7 @@ TEST_P(MaybeSparseCoverageMappingTest, } } -TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_more_than_two_files) { +TEST_P(CoverageMappingTest, load_coverage_for_more_than_two_files) { InstrProfRecord Record("func", 0x1234, {0}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -308,7 +298,7 @@ TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_more_than_two_files) { } } -TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_several_functions) { +TEST_P(CoverageMappingTest, load_coverage_for_several_functions) { InstrProfRecord RecordFunc1("func1", 0x1234, {10}); NoError(ProfileWriter.addRecord(std::move(RecordFunc1))); InstrProfRecord RecordFunc2("func2", 0x2345, {20}); @@ -339,7 +329,7 @@ TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_several_functions) { } } -TEST_P(MaybeSparseCoverageMappingTest, expansion_gets_first_counter) { +TEST_P(CoverageMappingTest, expansion_gets_first_counter) { startFunction("func", 0x1234); addCMR(Counter::getCounter(1), "foo", 10, 1, 10, 2); // This starts earlier in "foo", so the expansion should get its counter. @@ -355,7 +345,7 @@ TEST_P(MaybeSparseCoverageMappingTest, expansion_gets_first_counter) { ASSERT_EQ(3U, Output.Regions[2].LineStart); } -TEST_P(MaybeSparseCoverageMappingTest, basic_coverage_iteration) { +TEST_P(CoverageMappingTest, basic_coverage_iteration) { InstrProfRecord Record("func", 0x1234, {30, 20, 10, 0}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -378,7 +368,7 @@ TEST_P(MaybeSparseCoverageMappingTest, basic_coverage_iteration) { ASSERT_EQ(CoverageSegment(11, 11, false), Segments[6]); } -TEST_P(MaybeSparseCoverageMappingTest, uncovered_function) { +TEST_P(CoverageMappingTest, uncovered_function) { startFunction("func", 0x1234); addCMR(Counter::getZero(), "file1", 1, 2, 3, 4); loadCoverageMapping(); @@ -390,7 +380,7 @@ TEST_P(MaybeSparseCoverageMappingTest, uncovered_function) { ASSERT_EQ(CoverageSegment(3, 4, false), Segments[1]); } -TEST_P(MaybeSparseCoverageMappingTest, uncovered_function_with_mapping) { +TEST_P(CoverageMappingTest, uncovered_function_with_mapping) { startFunction("func", 0x1234); addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); addCMR(Counter::getCounter(1), "file1", 1, 1, 4, 7); @@ -404,7 +394,7 @@ TEST_P(MaybeSparseCoverageMappingTest, uncovered_function_with_mapping) { ASSERT_EQ(CoverageSegment(9, 9, false), Segments[2]); } -TEST_P(MaybeSparseCoverageMappingTest, combine_regions) { +TEST_P(CoverageMappingTest, combine_regions) { InstrProfRecord Record("func", 0x1234, {10, 20, 30}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -423,8 +413,7 @@ TEST_P(MaybeSparseCoverageMappingTest, combine_regions) { ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]); } -TEST_P(MaybeSparseCoverageMappingTest, - restore_combined_counter_after_nested_region) { +TEST_P(CoverageMappingTest, restore_combined_counter_after_nested_region) { InstrProfRecord Record("func", 0x1234, {10, 20, 40}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -445,7 +434,7 @@ TEST_P(MaybeSparseCoverageMappingTest, // If CodeRegions and ExpansionRegions cover the same area, // only counts of CodeRegions should be used. -TEST_P(MaybeSparseCoverageMappingTest, dont_combine_expansions) { +TEST_P(CoverageMappingTest, dont_combine_expansions) { InstrProfRecord Record1("func", 0x1234, {10, 20}); InstrProfRecord Record2("func", 0x1234, {0, 0}); NoError(ProfileWriter.addRecord(std::move(Record1))); @@ -468,7 +457,7 @@ TEST_P(MaybeSparseCoverageMappingTest, dont_combine_expansions) { } // If an area is covered only by ExpansionRegions, they should be combinated. -TEST_P(MaybeSparseCoverageMappingTest, combine_expansions) { +TEST_P(CoverageMappingTest, combine_expansions) { InstrProfRecord Record("func", 0x1234, {2, 3, 7}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -490,7 +479,7 @@ TEST_P(MaybeSparseCoverageMappingTest, combine_expansions) { EXPECT_EQ(CoverageSegment(5, 5, false), Segments[3]); } -TEST_P(MaybeSparseCoverageMappingTest, strip_filename_prefix) { +TEST_P(CoverageMappingTest, strip_filename_prefix) { InstrProfRecord Record("file1:func", 0x1234, {0}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -505,7 +494,7 @@ TEST_P(MaybeSparseCoverageMappingTest, strip_filename_prefix) { ASSERT_EQ("func", Names[0]); } -TEST_P(MaybeSparseCoverageMappingTest, strip_unknown_filename_prefix) { +TEST_P(CoverageMappingTest, strip_unknown_filename_prefix) { InstrProfRecord Record(":func", 0x1234, {0}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -520,7 +509,7 @@ TEST_P(MaybeSparseCoverageMappingTest, strip_unknown_filename_prefix) { ASSERT_EQ("func", Names[0]); } -TEST_P(MaybeSparseCoverageMappingTest, dont_detect_false_instantiations) { +TEST_P(CoverageMappingTest, dont_detect_false_instantiations) { InstrProfRecord Record1("foo", 0x1234, {10}); InstrProfRecord Record2("bar", 0x2345, {20}); NoError(ProfileWriter.addRecord(std::move(Record1))); @@ -541,7 +530,7 @@ TEST_P(MaybeSparseCoverageMappingTest, dont_detect_false_instantiations) { ASSERT_TRUE(Instantiations.empty()); } -TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_expanded_file) { +TEST_P(CoverageMappingTest, load_coverage_for_expanded_file) { InstrProfRecord Record("func", 0x1234, {10}); NoError(ProfileWriter.addRecord(std::move(Record))); @@ -558,7 +547,7 @@ TEST_P(MaybeSparseCoverageMappingTest, load_coverage_for_expanded_file) { EXPECT_EQ(CoverageSegment(1, 10, false), Segments[1]); } -INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseCoverageMappingTest, +INSTANTIATE_TEST_CASE_P(ParameterizedCovMapTest, CoverageMappingTest, ::testing::Bool()); } // end anonymous namespace