llvm-cov: Implement the object-directory 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 # Function summaries. This changes stdout, but not the gcov files.
25 RUN: llvm-cov test.c -f | diff -u test_-f.output -
26 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
27 RUN: diff -aub test_no_options.h.gcov test.h.gcov
28
29 # All blocks. This doesn't affect stdout, only the gcov files.
30 RUN: llvm-cov test.c -a | diff -u test_no_options.output -
31 RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
32 RUN: diff -aub test_-a.h.gcov test.h.gcov
33
34 # Branch probabilities.
35 RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
36 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
37 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
38
39 # Function summaries including branch probabilities.
40
41 # FIXME: We don't correctly handle calls when -b and -f are used
42 # together, so our output differs from gcov. Remove the 'not' from
43 # this test once this is fixed.
44 RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
45 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
46 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
47
48 # Summarize unconditional branches too.
49 RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
50 RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
51 RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
52
53 # Absolute counts for branches.
54 RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
55 RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
56 RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
57
58 # Missing gcda file just gives 0 counts.
59 RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
60 RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
61 RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
62
63 # Invalid gcno file.
64 RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
65
66 # Bad file checksum on gcda.
67 RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
68
69 # Bad function checksum on gcda
70 RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
71
72 XFAIL: powerpc64, s390x, mips, sparc