blob: c52a9815229d0ed5c2ada2fd60ae2cccb2ce03e5 [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 Bognerc6af3502014-02-04 10:45:02 +000024# Preserve paths. This mangles the output filenames.
25RUN: mkdir -p %t/srcdir/nested_dir
26RUN: cp test.cpp test.h %t/srcdir
27RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output -
28RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
29RUN: 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.
32RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output -
33RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
34RUN: diff -aub test_paths.h.gcov test.h.gcov
35
Justin Bognerb5bff692014-02-04 06:41:33 +000036# Function summaries. This changes stdout, but not the gcov files.
37RUN: llvm-cov test.c -f | diff -u test_-f.output -
38RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
39RUN: diff -aub test_no_options.h.gcov test.h.gcov
40
41# All blocks. This doesn't affect stdout, only the gcov files.
42RUN: llvm-cov test.c -a | diff -u test_no_options.output -
Yuchen Wu8c6bb5f2013-12-10 01:02:07 +000043RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
44RUN: diff -aub test_-a.h.gcov test.h.gcov
Yuchen Wuaae88012013-11-13 22:50:15 +000045
Justin Bognerb5bff692014-02-04 06:41:33 +000046# Branch probabilities.
47RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
Yuchen Wu342714c2013-12-13 01:15:07 +000048RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
49RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
50
Justin Bognerb5bff692014-02-04 06:41:33 +000051# 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.
56RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
57RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
58RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
59
60# Summarize unconditional branches too.
61RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
Yuchen Wu66d93b82013-12-16 22:14:02 +000062RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
63RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
64
Justin Bognerb5bff692014-02-04 06:41:33 +000065# Absolute counts for branches.
66RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
Yuchen Wu73dc3812013-12-18 18:40:15 +000067RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
68RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
69
Justin Bogner93d1edb2014-02-04 06:41:39 +000070# Missing gcda file just gives 0 counts.
71RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
72RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
73RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
74
Justin Bognerb5bff692014-02-04 06:41:33 +000075# Invalid gcno file.
Justin Bognera99a3902014-01-29 21:31:34 +000076RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
Yuchen Wue28da842013-11-14 00:07:15 +000077
Justin Bognerb5bff692014-02-04 06:41:33 +000078# Bad file checksum on gcda.
Justin Bognera99a3902014-01-29 21:31:34 +000079RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
Daniel Jasper87a24d52013-12-04 08:57:17 +000080
Justin Bognerb5bff692014-02-04 06:41:33 +000081# Bad function checksum on gcda
Justin Bognera99a3902014-01-29 21:31:34 +000082RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
Yuchen Wubabe7492013-11-20 04:15:05 +000083
Venkatraman Govindarajud97acf32014-01-25 22:54:47 +000084XFAIL: powerpc64, s390x, mips, sparc