|
1 | 1 | // Test visualization of branch taken percentages |
2 | 2 |
|
3 | 3 | // RUN: llvm-profdata merge %S/Inputs/branch-showBranchPercentage.proftext -o %t.profdata |
4 | | -// RUN: llvm-cov show --show-branches=percent %S/Inputs/branch-showBranchPercentage.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s |
| 4 | +// RUN: llvm-cov show --show-branches=percent %S/Inputs/branch-showBranchPercentage.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-showBranchPercentage.c |
5 | 5 |
|
6 | | -#include <stdio.h> |
7 | | -#include <stdlib.h> |
8 | | - |
9 | | -extern void __llvm_profile_write_file(void); |
10 | | - |
11 | | -int main(int argc, char *argv[]) |
12 | | -{ |
13 | | - int i = 0; |
14 | | - if (argc < 3) // CHECK: Branch ([[@LINE]]:7): [True: 16.67%, False: 83.33%] |
15 | | - { |
16 | | - __llvm_profile_write_file(); |
17 | | - return 0; |
18 | | - } |
19 | | - |
20 | | - int a = atoi(argv[1]); |
21 | | - int b = atoi(argv[2]); |
22 | | - |
23 | | - // CHECK: Branch ([[@LINE+4]]:8): [True: 20.00%, False: 80.00%] |
24 | | - // CHECK: Branch ([[@LINE+3]]:18): [True: 0.00%, False: 100.00%] |
25 | | - // CHECK: Branch ([[@LINE+2]]:29): [True: 0.00%, False: 100.00%] |
26 | | - // CHECK: Branch ([[@LINE+1]]:40): [True: 40.00%, False: 60.00%] |
27 | | - if ((a == 0 && b == 2) || b == 34 || a == b) |
28 | | - printf("case1\n"); |
29 | | - |
30 | | - b = (a != 0 || a == 2) ? b : b+2; // CHECK: Branch ([[@LINE]]:8): [True: 80.00%, False: 20.00%] |
31 | | - // CHECK: Branch ([[@LINE-1]]:18): [True: 0.00%, False: 100.00%] |
32 | | - b = (a != 0 && a == 1); // CHECK: Branch ([[@LINE]]:8): [True: 80.00%, False: 20.00%] |
33 | | - // CHECK: Branch ([[@LINE-1]]:18): [True: 25.00%, False: 75.00%] |
34 | | - for (i = 0; i < b; i++) { a = 2 + b + b; } |
35 | | - // CHECK: Branch ([[@LINE-1]]:15): [True: 16.67%, False: 83.33%] |
36 | | - |
37 | | - b = a; |
38 | | - |
39 | | - switch (a) |
40 | | - { |
41 | | - case 0: // CHECK: Branch ([[@LINE]]:5): [True: 20.00%, False: 80.00%] |
42 | | - printf("case0\n"); |
43 | | - case 2: // CHECK: Branch ([[@LINE]]:5): [True: 20.00%, False: 80.00%] |
44 | | - printf("case2\n"); |
45 | | - case 3: // CHECK: Branch ([[@LINE]]:5): [True: 0.00%, False: 100.00%] |
46 | | - printf("case3\n"); |
47 | | - default: break; // CHECK: Branch ([[@LINE]]:5): [True: 60.00%, False: 40.00%] |
48 | | - } |
49 | | - |
50 | | - i = 0; |
51 | | - do { |
52 | | - printf("loop\n"); |
53 | | - } while (i++ < 10); // CHECK: Branch ([[@LINE]]:12): [True: 90.91%, False: 9.09%] |
54 | | - |
55 | | - __llvm_profile_write_file(); |
56 | | - |
57 | | - return b; |
58 | | -} |
59 | 6 | // RUN: llvm-profdata merge %S/Inputs/branch-showBranchPercentage.proftext -o %t.profdata |
60 | | -// RUN: llvm-cov show --show-branches=percent %S/Inputs/branch-showBranchPercentage.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -format html -o %t.html.dir |
| 7 | +// RUN: llvm-cov show --show-branches=percent %S/Inputs/branch-showBranchPercentage.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs -format html -o %t.html.dir |
61 | 8 |
|
62 | 9 | // Test html output. |
63 | 10 | // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/branch-showBranchPercentage.c.html %s |
|
0 commit comments