summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/CoverageMappingTest.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index 35b8626c494..c85da9a0f9c 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -92,6 +92,7 @@ struct CoverageMappingTest : ::testing::Test {
void SetUp() override {
NextFile = 0;
+ ProfileWriter.setOutputSparse(false);
}
unsigned getFile(StringRef Name) {
@@ -154,7 +155,16 @@ struct CoverageMappingTest : ::testing::Test {
}
};
-TEST_F(CoverageMappingTest, basic_write_read) {
+struct MaybeSparseCoverageMappingTest
+ : public CoverageMappingTest,
+ public ::testing::WithParamInterface<bool> {
+ void SetUp() {
+ CoverageMappingTest::SetUp();
+ ProfileWriter.setOutputSparse(GetParam());
+ }
+};
+
+TEST_P(MaybeSparseCoverageMappingTest, basic_write_read) {
addCMR(Counter::getCounter(0), "foo", 1, 1, 1, 1);
addCMR(Counter::getCounter(1), "foo", 2, 1, 2, 2);
addCMR(Counter::getZero(), "foo", 3, 1, 3, 4);
@@ -174,7 +184,7 @@ TEST_F(CoverageMappingTest, basic_write_read) {
}
}
-TEST_F(CoverageMappingTest, expansion_gets_first_counter) {
+TEST_P(MaybeSparseCoverageMappingTest, expansion_gets_first_counter) {
addCMR(Counter::getCounter(1), "foo", 10, 1, 10, 2);
// This starts earlier in "foo", so the expansion should get its counter.
addCMR(Counter::getCounter(2), "foo", 1, 1, 20, 1);
@@ -187,7 +197,7 @@ TEST_F(CoverageMappingTest, expansion_gets_first_counter) {
ASSERT_EQ(3U, OutputCMRs[2].LineStart);
}
-TEST_F(CoverageMappingTest, basic_coverage_iteration) {
+TEST_P(MaybeSparseCoverageMappingTest, basic_coverage_iteration) {
InstrProfRecord Record("func", 0x1234, {30, 20, 10, 0});
ProfileWriter.addRecord(std::move(Record));
readProfCounts();
@@ -210,7 +220,7 @@ TEST_F(CoverageMappingTest, basic_coverage_iteration) {
ASSERT_EQ(CoverageSegment(11, 11, false), Segments[6]);
}
-TEST_F(CoverageMappingTest, uncovered_function) {
+TEST_P(MaybeSparseCoverageMappingTest, uncovered_function) {
readProfCounts();
addCMR(Counter::getZero(), "file1", 1, 2, 3, 4);
@@ -223,7 +233,7 @@ TEST_F(CoverageMappingTest, uncovered_function) {
ASSERT_EQ(CoverageSegment(3, 4, false), Segments[1]);
}
-TEST_F(CoverageMappingTest, uncovered_function_with_mapping) {
+TEST_P(MaybeSparseCoverageMappingTest, uncovered_function_with_mapping) {
readProfCounts();
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);
@@ -238,7 +248,7 @@ TEST_F(CoverageMappingTest, uncovered_function_with_mapping) {
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[2]);
}
-TEST_F(CoverageMappingTest, combine_regions) {
+TEST_P(MaybeSparseCoverageMappingTest, combine_regions) {
InstrProfRecord Record("func", 0x1234, {10, 20, 30});
ProfileWriter.addRecord(std::move(Record));
readProfCounts();
@@ -257,9 +267,11 @@ TEST_F(CoverageMappingTest, combine_regions) {
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]);
}
-TEST_F(CoverageMappingTest, dont_combine_expansions) {
- InstrProfRecord Record("func", 0x1234, {10, 20});
- ProfileWriter.addRecord(std::move(Record));
+TEST_P(MaybeSparseCoverageMappingTest, dont_combine_expansions) {
+ InstrProfRecord Record1("func", 0x1234, {10, 20});
+ InstrProfRecord Record2("func", 0x1234, {0, 0});
+ ProfileWriter.addRecord(std::move(Record1));
+ ProfileWriter.addRecord(std::move(Record2));
readProfCounts();
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);
@@ -277,8 +289,8 @@ TEST_F(CoverageMappingTest, dont_combine_expansions) {
ASSERT_EQ(CoverageSegment(9, 9, false), Segments[3]);
}
-TEST_F(CoverageMappingTest, strip_filename_prefix) {
- InstrProfRecord Record("file1:func", 0x1234, {10});
+TEST_P(MaybeSparseCoverageMappingTest, strip_filename_prefix) {
+ InstrProfRecord Record("file1:func", 0x1234, {0});
ProfileWriter.addRecord(std::move(Record));
readProfCounts();
@@ -292,4 +304,7 @@ TEST_F(CoverageMappingTest, strip_filename_prefix) {
ASSERT_EQ("func", Names[0]);
}
+INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseCoverageMappingTest,
+ ::testing::Bool());
+
} // end anonymous namespace
OpenPOWER on IntegriCloud