InputFunctionCoverageData &operator=(InputFunctionCoverageData &&) = delete;
};
-struct CoverageMappingTest : ::testing::Test {
+struct CoverageMappingTest : ::testing::TestWithParam<bool> {
StringMap<unsigned> Files;
std::vector<InputFunctionCoverageData> InputFunctions;
std::vector<OutputFunctionCoverageData> OutputFunctions;
std::unique_ptr<CoverageMapping> LoadedCoverage;
void SetUp() override {
- ProfileWriter.setOutputSparse(false);
+ ProfileWriter.setOutputSparse(GetParam());
}
unsigned getGlobalFileIndex(StringRef Name) {
}
};
-struct MaybeSparseCoverageMappingTest
- : public CoverageMappingTest,
- public ::testing::WithParamInterface<bool> {
- 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);
}
}
-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);
}
}
-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)));
}
}
-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});
}
}
-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.
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)));
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();
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);
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)));
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)));
// 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)));
}
// 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)));
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)));
ASSERT_EQ("func", Names[0]);
}
-TEST_P(MaybeSparseCoverageMappingTest, strip_unknown_filename_prefix) {
+TEST_P(CoverageMappingTest, strip_unknown_filename_prefix) {
InstrProfRecord Record("<unknown>:func", 0x1234, {0});
NoError(ProfileWriter.addRecord(std::move(Record)));
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)));
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)));
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