xref: /llvm-project/llvm/test/tools/llvm-cov/gcov/relative-only.test (revision 44664a54483def1692ea75925bfce0053e76bef0)
1b2c32c90SFangrui Song# Test -r (--relative-only) and -s (--source-prefix).
2*44664a54SFangrui Song# UNSUPPORTED: system-windows
3b2c32c90SFangrui SongRUN: rm -rf %t && mkdir %t && cd %t
4b2c32c90SFangrui SongRUN: cp %S/Inputs/abs-path.gcno %S/Inputs/abs-path.gcda .
5b2c32c90SFangrui Song
6b2c32c90SFangrui SongRUN: llvm-cov gcov abs-path.gcda | FileCheck %s
7b2c32c90SFangrui SongRUN: rm abs-path.c.gcov a.h.gcov
8b2c32c90SFangrui SongCHECK: File '/tmp/c/abs-path.c'
9b2c32c90SFangrui SongCHECK: File '/tmp/h/a.h'
10b2c32c90SFangrui Song
11b2c32c90SFangrui Song# If there is no source file with a relative path, nothing is dumped.
12b2c32c90SFangrui SongRUN: llvm-cov gcov -r abs-path.gcda 2>&1 | count 0
13b2c32c90SFangrui SongRUN: llvm-cov gcov -r -s /t abs-path.gcda 2>&1 | count 0
14b2c32c90SFangrui SongRUN: not ls abs-path.c.gcov 2> /dev/null
15b2c32c90SFangrui Song
16b2c32c90SFangrui Song# -s strips a prefix from filenames and can change filtering of -r.
17b2c32c90SFangrui SongRUN: llvm-cov gcov -r -s /tmp abs-path.gcda | FileCheck %s --check-prefix=STRIP1 --match-full-lines --strict-whitespace
18b2c32c90SFangrui SongRUN: FileCheck %s --check-prefix=STRIP1_C < abs-path.c.gcov
19b2c32c90SFangrui SongRUN: FileCheck %s --check-prefix=STRIP1_H < a.h.gcov
20b2c32c90SFangrui Song
21b2c32c90SFangrui Song# Test full option names.
22b2c32c90SFangrui SongRUN: llvm-cov gcov --relative-only --source-prefix=/tmp abs-path.gcda | FileCheck %s --check-prefix=STRIP1 --match-full-lines --strict-whitespace
23b2c32c90SFangrui Song
24b2c32c90SFangrui Song      STRIP1:File 'c/abs-path.c'
25b2c32c90SFangrui Song STRIP1-NEXT:Lines executed:100.00% of 1
26b2c32c90SFangrui Song STRIP1-NEXT:Creating 'abs-path.c.gcov'
27b2c32c90SFangrui SongSTRIP1-EMPTY:
28b2c32c90SFangrui Song STRIP1-NEXT:File 'h/a.h'
29b2c32c90SFangrui Song STRIP1-NEXT:Lines executed:0.00% of 1
30b2c32c90SFangrui Song STRIP1-NEXT:Creating 'a.h.gcov'
31b2c32c90SFangrui Song
32b2c32c90SFangrui SongSTRIP1_C: 0:Source:c/abs-path.c
33b2c32c90SFangrui SongSTRIP1_H: 0:Source:h/a.h
34b2c32c90SFangrui Song
35b2c32c90SFangrui SongRUN: llvm-cov gcov -r -s /tmp/h abs-path.gcda | FileCheck %s --check-prefix=STRIP2
36b2c32c90SFangrui Song
37b2c32c90SFangrui SongSTRIP2-NOT: File
38b2c32c90SFangrui SongSTRIP2:     File 'a.h'
39