124ee64baSJustin Bogner // Basic handling of line counts. 224ee64baSJustin Bogner // RUN: llvm-profdata merge %S/Inputs/lineExecutionCounts.proftext -o %t.profdata 3e82d89ccSAlex Lorenz 46b1f5f89SYing Yi // before any coverage // WHOLE-FILE: [[@LINE]]| |// before 56b1f5f89SYing Yi // FILTER-NOT: [[@LINE-1]]| |// before 66b1f5f89SYing Yi int main() { // TEXT: [[@LINE]]| 161|int main( 76b1f5f89SYing Yi int x = 0; // TEXT: [[@LINE]]| 161| int x 86b1f5f89SYing Yi // TEXT: [[@LINE]]| 161| 9846b985aSVedant Kumar if (x) { // TEXT: [[@LINE]]| 161| if (x) 106b1f5f89SYing Yi x = 0; // TEXT: [[@LINE]]| 0| x = 0 116b1f5f89SYing Yi } else { // TEXT: [[@LINE]]| 161| } else 126b1f5f89SYing Yi x = 1; // TEXT: [[@LINE]]| 161| x = 1 136b1f5f89SYing Yi } // TEXT: [[@LINE]]| 161| } 146b1f5f89SYing Yi // TEXT: [[@LINE]]| 161| 156b1f5f89SYing Yi for (int i = 0; i < 100; ++i) { // TEXT: [[@LINE]]| 16.2k| for ( 166b1f5f89SYing Yi x = 1; // TEXT: [[@LINE]]| 16.1k| x = 1 176b1f5f89SYing Yi } // TEXT: [[@LINE]]| 16.1k| } 186b1f5f89SYing Yi // TEXT: [[@LINE]]| 161| 196b1f5f89SYing Yi x = x < 10 ? x + 1 : x - 1; // TEXT: [[@LINE]]| 161| x = 206b1f5f89SYing Yi x = x > 10 ? // TEXT: [[@LINE]]| 161| x = 216b1f5f89SYing Yi x - 1: // TEXT: [[@LINE]]| 0| x 226b1f5f89SYing Yi x + 1; // TEXT: [[@LINE]]| 161| x 236b1f5f89SYing Yi // TEXT: [[@LINE]]| 161| 246b1f5f89SYing Yi return 0; // TEXT: [[@LINE]]| 161| return 256b1f5f89SYing Yi } // TEXT: [[@LINE]]| 161|} 266b1f5f89SYing Yi // after coverage // WHOLE-FILE: [[@LINE]]| |// after 276b1f5f89SYing Yi // FILTER-NOT: [[@LINE-1]]| |// after 287949a8b8SAlex Lorenz 299edfeac9SSean Eveson // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s 309edfeac9SSean Eveson // 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 317937ef37SVedant Kumar 327937ef37SVedant Kumar // Test -output-dir. 339edfeac9SSean Eveson // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s 34*fa8ef35eSSean Eveson // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.filtered.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s 35c1561cb2SVedant Kumar // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s 36*fa8ef35eSSean Eveson // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s 379cbad2c2SVedant Kumar // 38a59334daSVedant Kumar // RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -name=main 2>/dev/null > %t.export.json 39a59334daSVedant Kumar // RUN: FileCheck -input-file %t.export.json %S/Inputs/lineExecutionCounts.json 40a59334daSVedant Kumar // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())" 414c01092aSVedant Kumar // 424c01092aSVedant Kumar // Test html output. 439edfeac9SSean Eveson // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s 44*fa8ef35eSSean Eveson // 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 454c01092aSVedant Kumar // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s 46*fa8ef35eSSean Eveson // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s 474c01092aSVedant Kumar // 485a0e92b0SVedant Kumar // HTML-WHOLE-FILE: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before 495a0e92b0SVedant Kumar // HTML-FILTER-NOT: <td class='line-number'><a name='L[[@LINE-45]]' href='#L[[@LINE-45]]'><pre>[[@LINE-45]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before 505a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre>int main() { 515a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> int x = 0 525a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> 53bae83970SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> if (x) 545a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre> 555a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre><span class='red'> }</span> 565a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> x = 1; 575a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> } 585a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> 595a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>16.2k</pre></td><td class='code'><pre> for (int i = 0; i < 100; ++i) 605a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>16.1k</pre></td><td class='code'><pre> x = 1; 615a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>16.1k</pre></td><td class='code'><pre> } 625a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> 635a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> x = x < 10 645a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> x = x > 10 65bae83970SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre> <span class='red'>x - 1</span>: 665a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> x + 1; 675a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> 685a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre> return 0; 695a0e92b0SVedant Kumar // HTML: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre>} 705a0e92b0SVedant Kumar // HTML-WHOLE-FILE: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after 715a0e92b0SVedant Kumar // HTML-FILTER-NOT: <td class='line-number'><a name='L[[@LINE-45]]' href='#L[[@LINE-45]]'><pre>[[@LINE-45]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after 72a59334daSVedant Kumar // 73a59334daSVedant Kumar // Test index creation. 74a59334daSVedant Kumar // RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s 75a59334daSVedant Kumar // TEXT-INDEX: Filename 76a59334daSVedant Kumar // TEXT-INDEX-NEXT: --- 77a59334daSVedant Kumar // TEXT-INDEX-NEXT: {{.*}}showLineExecutionCounts.cpp 78a59334daSVedant Kumar // 79a59334daSVedant Kumar // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s 80a59334daSVedant Kumar // HTML-INDEX-LABEL: <table> 817b9e9bb4SVedant Kumar // HTML-INDEX: <td class='column-entry-left'>Filename</td> 82a59334daSVedant Kumar // HTML-INDEX: <td class='column-entry'>Function Coverage</td> 83a59334daSVedant Kumar // HTML-INDEX: <td class='column-entry'>Line Coverage</td> 847b9e9bb4SVedant Kumar // HTML-INDEX: <td class='column-entry'>Region Coverage</td> 85a59334daSVedant Kumar // HTML-INDEX: <a href='coverage{{.*}}showLineExecutionCounts.cpp.html'{{.*}}showLineExecutionCounts.cpp</a> 86a59334daSVedant Kumar // HTML-INDEX: <td class='column-entry-green'> 87a59334daSVedant Kumar // HTML-INDEX: 100.00% (1/1) 88a59334daSVedant Kumar // HTML-INDEX: <td class='column-entry-yellow'> 89b7fdaf2cSVedant Kumar // HTML-INDEX: 90.00% (18/20) 907b9e9bb4SVedant Kumar // HTML-INDEX: <td class='column-entry-red'> 91bae83970SVedant Kumar // HTML-INDEX: 72.73% (8/11) 92a59334daSVedant Kumar // HTML-INDEX: TOTALS 93