llvm-cov: Implement the preserve-paths flag
[oota-llvm.git] / test / tools / llvm-cov / llvm-cov.test
1 # Tests for compatibility between llvm-cov and gcov. These work by
2 # comparing llvm-cov against reference outputs generated by gcov 4.2.
3
4 # "cd" and globbing are unsupported in lit internal runner.
5 REQUIRES: shell
6
7 RUN: rm -rf %t
8 RUN: mkdir %t
9 RUN: cd %t
10 RUN: cp %p/Inputs/test* .
11
12 # Basic behaviour with no flags
13 RUN: llvm-cov test.c | diff -u test_no_options.output -
14 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
15 RUN: diff -aub test_no_options.h.gcov test.h.gcov
16
17 # Same, but specifying the object directory
18 RUN: mkdir -p %t/objdir
19 RUN: cp test.gcno test.gcda %t/objdir
20 RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output -
21 RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
22 RUN: diff -aub test_objdir.h.gcov test.h.gcov
23
24 # Preserve paths. This mangles the output filenames.
25 RUN: mkdir -p %t/srcdir/nested_dir
26 RUN: cp test.cpp test.h %t/srcdir
27 RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output -
28 RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
29 RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
30
31 # Don't preserve paths. Same results as preserve paths, but no mangling.
32 RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output -
33 RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
34 RUN: diff -aub test_paths.h.gcov test.h.gcov
35
36 # Function summaries. This changes stdout, but not the gcov files.
37 RUN: llvm-cov test.c -f | diff -u test_-f.output -
38 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
39 RUN: diff -aub test_no_options.h.gcov test.h.gcov
40
41 # All blocks. This doesn't affect stdout, only the gcov files.
42 RUN: llvm-cov test.c -a | diff -u test_no_options.output -
43 RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
44 RUN: diff -aub test_-a.h.gcov test.h.gcov
45
46 # Branch probabilities.
47 RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
48 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
49 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
50
51 # Function summaries including branch probabilities.
52
53 # FIXME: We don't correctly handle calls when -b and -f are used
54 # together, so our output differs from gcov. Remove the 'not' from
55 # this test once this is fixed.
56 RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
57 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
58 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
59
60 # Summarize unconditional branches too.
61 RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
62 RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
63 RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
64
65 # Absolute counts for branches.
66 RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
67 RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
68 RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
69
70 # Missing gcda file just gives 0 counts.
71 RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
72 RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
73 RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
74
75 # Invalid gcno file.
76 RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
77
78 # Bad file checksum on gcda.
79 RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
80
81 # Bad function checksum on gcda
82 RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
83
84 XFAIL: powerpc64, s390x, mips, sparc