blob: 8457aef292f32456c8aa8f4a0fd10cfd50ade576 [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 Bognerc6af3502014-02-04 10:45:02 +000034# 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
Justin Bognerc67f0252014-04-23 21:44:55 +000046# Long file names.
47RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output -
48RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov
49RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov
50
51# Long file names and preserve paths.
52RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output -
53RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov
54RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov
55
Justin Bognerb5bff692014-02-04 06:41:33 +000056# Function summaries. This changes stdout, but not the gcov files.
57RUN: llvm-cov test.c -f | diff -u test_-f.output -
58RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
59RUN: diff -aub test_no_options.h.gcov test.h.gcov
60
61# All blocks. This doesn't affect stdout, only the gcov files.
62RUN: llvm-cov test.c -a | diff -u test_no_options.output -
Yuchen Wu8c6bb5f2013-12-10 01:02:07 +000063RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
64RUN: diff -aub test_-a.h.gcov test.h.gcov
Yuchen Wuaae88012013-11-13 22:50:15 +000065
Justin Bognerb5bff692014-02-04 06:41:33 +000066# Branch probabilities.
67RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
Yuchen Wu342714c2013-12-13 01:15:07 +000068RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
69RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
70
Justin Bognerb5bff692014-02-04 06:41:33 +000071# Function summaries including branch probabilities.
72
73# FIXME: We don't correctly handle calls when -b and -f are used
74# together, so our output differs from gcov. Remove the 'not' from
75# this test once this is fixed.
76RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
77RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
78RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
79
80# Summarize unconditional branches too.
81RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
Yuchen Wu66d93b82013-12-16 22:14:02 +000082RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
83RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
84
Justin Bognerb5bff692014-02-04 06:41:33 +000085# Absolute counts for branches.
86RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
Yuchen Wu73dc3812013-12-18 18:40:15 +000087RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
88RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
89
Justin Bogner93d1edb2014-02-04 06:41:39 +000090# Missing gcda file just gives 0 counts.
91RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
92RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
93RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
94
Justin Bognerb5bff692014-02-04 06:41:33 +000095# Invalid gcno file.
Justin Bognera99a3902014-01-29 21:31:34 +000096RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
Yuchen Wue28da842013-11-14 00:07:15 +000097
Justin Bognerb5bff692014-02-04 06:41:33 +000098# Bad file checksum on gcda.
Justin Bognera99a3902014-01-29 21:31:34 +000099RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
Daniel Jasper87a24d52013-12-04 08:57:17 +0000100
Justin Bognerb5bff692014-02-04 06:41:33 +0000101# Bad function checksum on gcda
Justin Bognera99a3902014-01-29 21:31:34 +0000102RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
Yuchen Wubabe7492013-11-20 04:15:05 +0000103
Reed Kotler59ebf32d2014-02-24 16:33:56 +0000104XFAIL: powerpc64, s390x, mips-, mips64-, sparc