| 1 | // REQUIRES: linux |
| 2 | // RUN: split-file %s %t |
| 3 | // RUN: %clang_profgen -Wl,--build-id=0x12345678 -fcoverage-mapping -O2 -shared %t/foo.c -o %t/libfoo.so |
| 4 | // RUN: %clang_profgen -Wl,--build-id=0xabcd1234 -fcoverage-mapping -O2 %t/main.c -L%t -lfoo -o %t.main |
| 5 | // RUN: rm -rf %t.profdir |
| 6 | // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw LD_LIBRARY_PATH=%t %run %t.main |
| 7 | // RUN: mkdir -p %t/.build-id/12 %t/.build-id/ab |
| 8 | // RUN: cp %t/libfoo.so %t/.build-id/12/345678.debug |
| 9 | // RUN: cp %t.main %t/.build-id/ab/cd1234.debug |
| 10 | // RUN: llvm-profdata merge -o %t.profdata %t.profdir/default_*.profraw |
| 11 | |
| 12 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t | FileCheck %s |
| 13 | // RUN: llvm-cov show -instr-profile %t.profdata %t/libfoo.so -sources %t/foo.c -object %t.main | FileCheck %s --check-prefix=FOO-ONLY |
| 14 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t -sources %t/foo.c | FileCheck %s --check-prefix=FOO-ONLY |
| 15 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t %t/libfoo.so -sources %t/foo.c | FileCheck %s --check-prefix=FOO-ONLY |
| 16 | |
| 17 | // RUN: rm %t/.build-id/ab/cd1234.debug |
| 18 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t %t.main | FileCheck %s |
| 19 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t | FileCheck %s --check-prefix=FOO-ONLY |
| 20 | // RUN: not llvm-cov show -instr-profile %t.profdata -debug-file-directory %t --check-binary-ids 2>&1 | FileCheck %s --check-prefix=MISSING-BINARY-ID -DFILENAME=%t.profdata |
| 21 | |
| 22 | // RUN: echo "bad" > %t/.build-id/ab/cd1234.debug |
| 23 | // RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t %t.main | FileCheck %s |
| 24 | |
| 25 | // RUN: not llvm-cov show -instr-profile %t.profdata -debug-file-directory %t/empty 2>&1 | FileCheck %s --check-prefix=NODATA |
| 26 | |
| 27 | // CHECK: 1| 1|void foo(void) {} |
| 28 | // CHECK: 2| 1|void bar(void) {} |
| 29 | // CHECK: 3| 1|int main() { |
| 30 | |
| 31 | // FOO-ONLY: 1| 1|void foo(void) {} |
| 32 | // MISSING-BINARY-ID: error: failed to load coverage: '[[FILENAME]]': Missing binary ID: abcd1234 |
| 33 | // NODATA: error: failed to load coverage: '': no coverage data found |
| 34 | |
| 35 | //--- foo.c |
| 36 | void foo(void) {} |
| 37 | |
| 38 | //--- main.c |
| 39 | void foo(void); |
| 40 | void bar(void) {} |
| 41 | int main() { |
| 42 | foo(); |
| 43 | bar(); |
| 44 | return 0; |
| 45 | } |
| 46 | |