blob: 239108240e0d982d1ed64cd0467c614615143ebb [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 Bognerb5bff692014-02-04 06:41:33 +000024# Function summaries. This changes stdout, but not the gcov files.
25RUN: llvm-cov test.c -f | diff -u test_-f.output -
26RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
27RUN: diff -aub test_no_options.h.gcov test.h.gcov
28
29# All blocks. This doesn't affect stdout, only the gcov files.
30RUN: llvm-cov test.c -a | diff -u test_no_options.output -
Yuchen Wu8c6bb5f2013-12-10 01:02:07 +000031RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
32RUN: diff -aub test_-a.h.gcov test.h.gcov
Yuchen Wuaae88012013-11-13 22:50:15 +000033
Justin Bognerb5bff692014-02-04 06:41:33 +000034# Branch probabilities.
35RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
Yuchen Wu342714c2013-12-13 01:15:07 +000036RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
37RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
38
Justin Bognerb5bff692014-02-04 06:41:33 +000039# 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.
44RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
45RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
46RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
47
48# Summarize unconditional branches too.
49RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
Yuchen Wu66d93b82013-12-16 22:14:02 +000050RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
51RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
52
Justin Bognerb5bff692014-02-04 06:41:33 +000053# Absolute counts for branches.
54RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
Yuchen Wu73dc3812013-12-18 18:40:15 +000055RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
56RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
57
Justin Bogner93d1edb2014-02-04 06:41:39 +000058# Missing gcda file just gives 0 counts.
59RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
60RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
61RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
62
Justin Bognerb5bff692014-02-04 06:41:33 +000063# Invalid gcno file.
Justin Bognera99a3902014-01-29 21:31:34 +000064RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
Yuchen Wue28da842013-11-14 00:07:15 +000065
Justin Bognerb5bff692014-02-04 06:41:33 +000066# Bad file checksum on gcda.
Justin Bognera99a3902014-01-29 21:31:34 +000067RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
Daniel Jasper87a24d52013-12-04 08:57:17 +000068
Justin Bognerb5bff692014-02-04 06:41:33 +000069# Bad function checksum on gcda
Justin Bognera99a3902014-01-29 21:31:34 +000070RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
Yuchen Wubabe7492013-11-20 04:15:05 +000071
Venkatraman Govindarajud97acf32014-01-25 22:54:47 +000072XFAIL: powerpc64, s390x, mips, sparc