blob: 19d3e5db1874aa75db128a4634c7509d3ca0309c [file] [log] [blame]
Stephen Hines36b56882014-04-23 16:57:46 -07001# 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.
NAKAMURA Takumi3f4c0312013-11-14 02:05:41 +00005REQUIRES: shell
Yuchen Wudbb51ff2013-11-14 00:07:15 +00006
Stephen Hines36b56882014-04-23 16:57:46 -07007RUN: rm -rf %t
8RUN: mkdir %t
9RUN: cd %t
10RUN: cp %p/Inputs/test* .
Yuchen Wu86e37f52013-11-13 22:50:15 +000011
Stephen Hines36b56882014-04-23 16:57:46 -070012# Basic behaviour with no flags
13RUN: llvm-cov test.c | diff -u test_no_options.output -
14RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
15RUN: diff -aub test_no_options.h.gcov test.h.gcov
Yuchen Wudbb51ff2013-11-14 00:07:15 +000016
Stephen Hines36b56882014-04-23 16:57:46 -070017# Same, but specifying the object directory
18RUN: mkdir -p %t/objdir
19RUN: cp test.gcno test.gcda %t/objdir
20RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output -
21RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
22RUN: diff -aub test_objdir.h.gcov test.h.gcov
23
24# Specifying an object file
25RUN: llvm-cov -o objdir/test.o test.c | diff -u test_no_options.output -
26RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
27RUN: diff -aub test_objdir.h.gcov test.h.gcov
28
29# Specifying an object file that could be ambiguous with a directory
30RUN: llvm-cov -o objdir/test test.c | diff -u test_no_options.output -
31RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
32RUN: diff -aub test_objdir.h.gcov test.h.gcov
33
34# Preserve paths. This mangles the output filenames.
35RUN: mkdir -p %t/srcdir/nested_dir
36RUN: cp test.cpp test.h %t/srcdir
37RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output -
38RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
39RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
40
41# Don't preserve paths. Same results as preserve paths, but no mangling.
42RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output -
43RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
44RUN: diff -aub test_paths.h.gcov test.h.gcov
45
46# Function summaries. This changes stdout, but not the gcov files.
47RUN: llvm-cov test.c -f | diff -u test_-f.output -
48RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
49RUN: diff -aub test_no_options.h.gcov test.h.gcov
50
51# All blocks. This doesn't affect stdout, only the gcov files.
52RUN: llvm-cov test.c -a | diff -u test_no_options.output -
53RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
54RUN: diff -aub test_-a.h.gcov test.h.gcov
55
56# Branch probabilities.
57RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
58RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
59RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
60
61# Function summaries including branch probabilities.
62
63# FIXME: We don't correctly handle calls when -b and -f are used
64# together, so our output differs from gcov. Remove the 'not' from
65# this test once this is fixed.
66RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
67RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
68RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
69
70# Summarize unconditional branches too.
71RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
72RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
73RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
74
75# Absolute counts for branches.
76RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
77RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
78RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
79
80# Missing gcda file just gives 0 counts.
81RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
82RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
83RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
84
85# Invalid gcno file.
86RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
87
88# Bad file checksum on gcda.
89RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
90
91# Bad function checksum on gcda
92RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
93
94XFAIL: powerpc64, s390x, mips-, mips64-, sparc