1 // Basic handling of line counts. 2 // RUN: llvm-profdata merge %S/Inputs/lineExecutionCounts.proftext -o %t.profdata 3 4 // before any coverage // WHOLE-FILE: [[@LINE]]| |// before 5 // FILTER-NOT: [[@LINE-1]]| |// before 6 int main() { // TEXT: [[@LINE]]| 161|int main( 7 int x = 0; // TEXT: [[@LINE]]| 161| int x 8 // TEXT: [[@LINE]]| 161| 9 if (x) { // TEXT: [[@LINE]]| 161| if (x) 10 x = 0; // TEXT: [[@LINE]]| 0| x = 0 11 } else { // TEXT: [[@LINE]]| 161| } else 12 x = 1; // TEXT: [[@LINE]]| 161| x = 1 13 } // TEXT: [[@LINE]]| 161| } 14 // TEXT: [[@LINE]]| 161| 15 for (int i = 0; i < 100; ++i) { // TEXT: [[@LINE]]| 16.2k| for ( 16 x = 1; // TEXT: [[@LINE]]| 16.1k| x = 1 17 } // TEXT: [[@LINE]]| 16.1k| } 18 // TEXT: [[@LINE]]| 161| 19 x = x < 10 ? x + 1 : x - 1; // TEXT: [[@LINE]]| 161| x = 20 x = x > 10 ? // TEXT: [[@LINE]]| 161| x = 21 x - 1: // TEXT: [[@LINE]]| 0| x 22 x + 1; // TEXT: [[@LINE]]| 161| x 23 // TEXT: [[@LINE]]| 161| 24 return 0; // TEXT: [[@LINE]]| 161| return 25 } // TEXT: [[@LINE]]| 161|} 26 // after coverage // WHOLE-FILE: [[@LINE]]| |// after 27 // FILTER-NOT: [[@LINE-1]]| |// after 28 29 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s 30 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s | FileCheck -check-prefixes=TEXT,FILTER %s 31 32 // Test -output-dir. 33 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s 34 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.filtered.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s 35 // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s 36 // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s 37 // 38 // RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -name=main 2>/dev/null > %t.export.json 39 // RUN: FileCheck -input-file %t.export.json %S/Inputs/lineExecutionCounts.json 40 // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())" 41 // 42 // RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata 2>/dev/null -summary-only > %t.export-summary.json 43 // RUN: not grep '"name":"main"' %t.export-summary.json 44 // 45 // Test html output. 46 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s 47 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.filtered.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s 48 // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s 49 // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s 50 // 51 // HTML-WHOLE-FILE: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before 52 // HTML-FILTER-NOT: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before 53 // HTML: <td class='line-number'><a name='L6' href='#L6'><pre>6</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre>int main() { 54 // HTML-WHOLE-FILE: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after 55 // HTML-FILTER-NOT: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after 56 // 57 // Test index creation. 58 // RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s 59 // TEXT-INDEX: Filename 60 // TEXT-INDEX-NEXT: --- 61 // TEXT-INDEX-NEXT: {{.*}}showLineExecutionCounts.cpp 62 // 63 // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s 64 // HTML-INDEX-LABEL: <table> 65 // HTML-INDEX: <td class='column-entry-bold'>Filename</td> 66 // HTML-INDEX: <td class='column-entry-bold'>Function Coverage</td> 67 // HTML-INDEX: <td class='column-entry-bold'>Line Coverage</td> 68 // HTML-INDEX: <td class='column-entry-bold'>Region Coverage</td> 69 // HTML-INDEX: <a href='coverage{{.*}}showLineExecutionCounts.cpp.html'{{.*}}showLineExecutionCounts.cpp</a> 70 // HTML-INDEX: <td class='column-entry-green'> 71 // HTML-INDEX: 100.00% (1/1) 72 // HTML-INDEX: <td class='column-entry-yellow'> 73 // HTML-INDEX: 90.00% (18/20) 74 // HTML-INDEX: <td class='column-entry-red'> 75 // HTML-INDEX: 72.73% (8/11) 76 // HTML-INDEX: <tr class='light-row-bold'> 77 // HTML-INDEX: Totals 78