From 0865368b78480540349ee883fc2bc7f420c4d0ac Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 31 Jul 2018 23:26:50 +0000 Subject: [gcov] Add tests using switch, one with break clauses and one with fallthrough git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@338453 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/profile/Inputs/instrprof-gcov-switch1.c | 18 ++++++++++++++++++ test/profile/Inputs/instrprof-gcov-switch1.c.gcov | 23 +++++++++++++++++++++++ test/profile/Inputs/instrprof-gcov-switch2.c | 18 ++++++++++++++++++ test/profile/Inputs/instrprof-gcov-switch2.c.gcov | 23 +++++++++++++++++++++++ test/profile/instrprof-gcov-switch.test | 16 ++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 test/profile/Inputs/instrprof-gcov-switch1.c create mode 100644 test/profile/Inputs/instrprof-gcov-switch1.c.gcov create mode 100644 test/profile/Inputs/instrprof-gcov-switch2.c create mode 100644 test/profile/Inputs/instrprof-gcov-switch2.c.gcov create mode 100644 test/profile/instrprof-gcov-switch.test diff --git a/test/profile/Inputs/instrprof-gcov-switch1.c b/test/profile/Inputs/instrprof-gcov-switch1.c new file mode 100644 index 000000000..25544323c --- /dev/null +++ b/test/profile/Inputs/instrprof-gcov-switch1.c @@ -0,0 +1,18 @@ +int main(void) +{ + int i = 22; + + switch (i) { + case 7: + break; + + case 22: + i = 7; + break; + + case 42: + break; + } + + return 0; +} diff --git a/test/profile/Inputs/instrprof-gcov-switch1.c.gcov b/test/profile/Inputs/instrprof-gcov-switch1.c.gcov new file mode 100644 index 000000000..7d136dc98 --- /dev/null +++ b/test/profile/Inputs/instrprof-gcov-switch1.c.gcov @@ -0,0 +1,23 @@ +// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-switch1.c +// CHECK-NEXT: -: 0:Graph:instrprof-gcov-switch1.gcno +// CHECK-NEXT: -: 0:Data:instrprof-gcov-switch1.gcda +// CHECK-NEXT: -: 0:Runs:1 +// CHECK-NEXT: -: 0:Programs:1 +// CHECK-NEXT: -: 1:int main(void) +// CHECK-NEXT: -: 2:{ +// CHECK-NEXT: 2: 3: int i = 22; +// CHECK-NEXT: -: 4: +// CHECK-NEXT: 2: 5: switch (i) { +// CHECK-NEXT: -: 6: case 7: +// CHECK-NEXT: #####: 7: break; +// CHECK-NEXT: -: 8: +// CHECK-NEXT: -: 9: case 22: +// CHECK-NEXT: 1: 10: i = 7; +// CHECK-NEXT: 1: 11: break; +// CHECK-NEXT: -: 12: +// CHECK-NEXT: -: 13: case 42: +// CHECK-NEXT: #####: 14: break; +// CHECK-NEXT: -: 15: } +// CHECK-NEXT: -: 16: +// CHECK-NEXT: 1: 17: return 0; +// CHECK-NEXT: -: 18:} diff --git a/test/profile/Inputs/instrprof-gcov-switch2.c b/test/profile/Inputs/instrprof-gcov-switch2.c new file mode 100644 index 000000000..14e8a84de --- /dev/null +++ b/test/profile/Inputs/instrprof-gcov-switch2.c @@ -0,0 +1,18 @@ +int main(void) +{ + int i = 22; + + switch (i) { + case 7: + break; + + case 22: + i = 7; + + case 42: + i = 22; + break; + } + + return 0; +} diff --git a/test/profile/Inputs/instrprof-gcov-switch2.c.gcov b/test/profile/Inputs/instrprof-gcov-switch2.c.gcov new file mode 100644 index 000000000..67f408606 --- /dev/null +++ b/test/profile/Inputs/instrprof-gcov-switch2.c.gcov @@ -0,0 +1,23 @@ +// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-switch2.c +// CHECK-NEXT: -: 0:Graph:instrprof-gcov-switch2.gcno +// CHECK-NEXT: -: 0:Data:instrprof-gcov-switch2.gcda +// CHECK-NEXT: -: 0:Runs:1 +// CHECK-NEXT: -: 0:Programs:1 +// CHECK-NEXT: -: 1:int main(void) +// CHECK-NEXT: -: 2:{ +// CHECK-NEXT: 3: 3: int i = 22; +// CHECK-NEXT: -: 4: +// CHECK-NEXT: 3: 5: switch (i) { +// CHECK-NEXT: -: 6: case 7: +// CHECK-NEXT: #####: 7: break; +// CHECK-NEXT: -: 8: +// CHECK-NEXT: -: 9: case 22: +// CHECK-NEXT: 1: 10: i = 7; +// CHECK-NEXT: -: 11: +// CHECK-NEXT: -: 12: case 42: +// CHECK-NEXT: 1: 13: i = 22; +// CHECK-NEXT: 1: 14: break; +// CHECK-NEXT: -: 15: } +// CHECK-NEXT: -: 16: +// CHECK-NEXT: 1: 17: return 0; +// CHECK-NEXT: -: 18:} diff --git a/test/profile/instrprof-gcov-switch.test b/test/profile/instrprof-gcov-switch.test new file mode 100644 index 000000000..9c43a93dc --- /dev/null +++ b/test/profile/instrprof-gcov-switch.test @@ -0,0 +1,16 @@ +RUN: mkdir -p %t.d +RUN: cd %t.d + +RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch1.c +RUN: test -f instrprof-gcov-switch1.gcno +RUN: rm -f instrprof-gcov-switch1.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-gcov-switch1.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-switch1.c.gcov %S/Inputs/instrprof-gcov-switch1.c.gcov + +RUN: %clang --coverage -o %t %S/Inputs/instrprof-gcov-switch2.c +RUN: test -f instrprof-gcov-switch2.gcno +RUN: rm -f instrprof-gcov-switch2.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-gcov-switch2.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-switch2.c.gcov %S/Inputs/instrprof-gcov-switch2.c.gcov -- cgit v1.2.3