blob: 82d1273ae61f8ff0e85dee853f747b2e2e2d7b60 [file] [log] [blame]
Justin Bognerb5bff692014-02-04 06:41:33 +00001# Tests for compatibility between llvm-cov and gcov. These work by
2# comparing llvm-cov against reference outputs generated by gcov 4.2.
3
Daniel Jaspercf765e32013-12-03 08:21:14 +00004# "cd" and globbing are unsupported in lit internal runner.
Daniel Jasper80b2ffb2013-12-03 07:56:23 +00005REQUIRES: shell
Justin Bognerb5bff692014-02-04 06:41:33 +00006
Daniel Jaspercf765e32013-12-03 08:21:14 +00007RUN: rm -rf %t
8RUN: mkdir %t
9RUN: cd %t
Yuchen Wuc8e0f812013-12-03 19:05:03 +000010RUN: cp %p/Inputs/test* .
Daniel Jaspercf765e32013-12-03 08:21:14 +000011
Justin Bognerb5bff692014-02-04 06:41:33 +000012# Basic behaviour with no flags
13RUN: llvm-cov test.c | diff -u test_no_options.output -
Yuchen Wu8c6bb5f2013-12-10 01:02:07 +000014RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
15RUN: diff -aub test_no_options.h.gcov test.h.gcov
16
Justin Bognerf69557e2014-02-04 06:41:43 +000017# 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
Justin Bognere9a3e5a2014-02-18 09:19:48 +000024# 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
Justin Bogner1a18d7c2014-05-07 02:11:18 +000034# With gcov output disabled
35RUN: llvm-cov -n test.c | diff -u test_no_output.output -
36
Justin Bognercf27e1b2014-05-07 02:11:23 +000037# Missing source files. This test is fragile, as it depends on being
38# run before we copy some sources into place in the next test.
39RUN: llvm-cov test_paths.cpp 2>/dev/null | diff -u test_missing.output -
40RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov
41RUN: diff -aub test_missing.h.gcov test.h.gcov
42
Justin Bognerc6af3502014-02-04 10:45:02 +000043# Preserve paths. This mangles the output filenames.
44RUN: mkdir -p %t/srcdir/nested_dir
45RUN: cp test.cpp test.h %t/srcdir
46RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output -
47RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
48RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
49
50# Don't preserve paths. Same results as preserve paths, but no mangling.
51RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output -
52RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
53RUN: diff -aub test_paths.h.gcov test.h.gcov
54
Justin Bognerc67f0252014-04-23 21:44:55 +000055# Long file names.
56RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output -
57RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov
58RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov
59
60# Long file names and preserve paths.
61RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output -
62RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov
63RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov
64
Justin Bognerb5bff692014-02-04 06:41:33 +000065# Function summaries. This changes stdout, but not the gcov files.
66RUN: llvm-cov test.c -f | diff -u test_-f.output -
67RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
68RUN: diff -aub test_no_options.h.gcov test.h.gcov
69
70# All blocks. This doesn't affect stdout, only the gcov files.
71RUN: llvm-cov test.c -a | diff -u test_no_options.output -
Yuchen Wu8c6bb5f2013-12-10 01:02:07 +000072RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
73RUN: diff -aub test_-a.h.gcov test.h.gcov
Yuchen Wuaae88012013-11-13 22:50:15 +000074
Justin Bognerb5bff692014-02-04 06:41:33 +000075# Branch probabilities.
76RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
Yuchen Wu342714c2013-12-13 01:15:07 +000077RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
78RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
79
Justin Bognerb5bff692014-02-04 06:41:33 +000080# Function summaries including branch probabilities.
81
82# FIXME: We don't correctly handle calls when -b and -f are used
83# together, so our output differs from gcov. Remove the 'not' from
84# this test once this is fixed.
85RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
86RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
87RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
88
89# Summarize unconditional branches too.
90RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
Yuchen Wu66d93b82013-12-16 22:14:02 +000091RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
92RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
93
Justin Bognerb5bff692014-02-04 06:41:33 +000094# Absolute counts for branches.
95RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
Yuchen Wu73dc3812013-12-18 18:40:15 +000096RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
97RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
98
Justin Bogner93d1edb2014-02-04 06:41:39 +000099# Missing gcda file just gives 0 counts.
100RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
101RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
102RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
103
Justin Bognerb5bff692014-02-04 06:41:33 +0000104# Invalid gcno file.
Justin Bognera99a3902014-01-29 21:31:34 +0000105RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
Yuchen Wue28da842013-11-14 00:07:15 +0000106
Justin Bognerb5bff692014-02-04 06:41:33 +0000107# Bad file checksum on gcda.
Justin Bognera99a3902014-01-29 21:31:34 +0000108RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
Daniel Jasper87a24d52013-12-04 08:57:17 +0000109
Justin Bognerb5bff692014-02-04 06:41:33 +0000110# Bad function checksum on gcda
Justin Bognera99a3902014-01-29 21:31:34 +0000111RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
Yuchen Wubabe7492013-11-20 04:15:05 +0000112
Ulrich Weiganddbb3e3e2014-06-18 15:52:18 +0000113XFAIL: powerpc64-, s390x, mips-, mips64-, sparc