• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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# Test fails on Windows where internal shell is used due to path separator
5# mismatches.
6REQUIRES: shell
7
8RUN: rm -rf %t
9RUN: mkdir %t
10RUN: cd %t
11RUN: cp %p/Inputs/test* .
12
13# Basic behaviour with no flags
14RUN: llvm-cov gcov test.c | diff -u test_no_options.output -
15RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
16RUN: diff -aub test_no_options.h.gcov test.h.gcov
17
18# Same, but specifying the object directory
19RUN: mkdir -p %t/objdir
20RUN: cp test.gcno test.gcda %t/objdir
21RUN: llvm-cov gcov -o objdir test.c | diff -u test_no_options.output -
22RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
23RUN: diff -aub test_objdir.h.gcov test.h.gcov
24
25# Specifying an object file
26RUN: llvm-cov gcov -o objdir/test.o test.c | diff -u test_no_options.output -
27RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
28RUN: diff -aub test_objdir.h.gcov test.h.gcov
29
30# Specifying an object file that could be ambiguous with a directory
31RUN: llvm-cov gcov -o objdir/test test.c | diff -u test_no_options.output -
32RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
33RUN: diff -aub test_objdir.h.gcov test.h.gcov
34
35# With gcov output disabled
36RUN: llvm-cov gcov -n test.c | diff -u test_no_output.output -
37
38# Missing source files. This test is fragile, as it depends on being
39# run before we copy some sources into place in the next test.
40RUN: llvm-cov gcov test_paths.cpp 2>/dev/null | diff -u test_missing.output -
41RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov
42RUN: diff -aub test_missing.h.gcov test.h.gcov
43
44# Preserve paths. This mangles the output filenames.
45RUN: mkdir -p %t/srcdir/nested_dir
46RUN: cp test.cpp test.h %t/srcdir
47RUN: llvm-cov gcov -p test_paths.cpp | diff -u test_preserve_paths.output -
48RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
49RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
50
51# Don't preserve paths. Same results as preserve paths, but no mangling.
52RUN: llvm-cov gcov test_paths.cpp | diff -u test_no_preserve_paths.output -
53RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
54RUN: diff -aub test_paths.h.gcov test.h.gcov
55
56# Long file names.
57RUN: llvm-cov gcov -l test_paths.cpp | diff -u test_long_file_names.output -
58RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov
59RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov
60
61# Long file names and preserve paths.
62RUN: llvm-cov gcov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output -
63RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov
64RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov
65
66# Function summaries. This changes stdout, but not the gcov files.
67RUN: llvm-cov gcov test.c -f | diff -u test_-f.output -
68RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
69RUN: diff -aub test_no_options.h.gcov test.h.gcov
70
71# All blocks. This doesn't affect stdout, only the gcov files.
72RUN: llvm-cov gcov test.c -a | diff -u test_no_options.output -
73RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
74RUN: diff -aub test_-a.h.gcov test.h.gcov
75
76# Branch probabilities.
77RUN: llvm-cov gcov test.c -a -b | diff -u test_-b.output -
78RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
79RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
80
81# Function summaries including branch probabilities.
82
83# FIXME: We don't correctly handle calls when -b and -f are used
84# together, so our output differs from gcov. Remove the 'not' from
85# this test once this is fixed.
86RUN: llvm-cov gcov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
87RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
88RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
89
90# Summarize unconditional branches too.
91RUN: llvm-cov gcov test.c -a -b -u | diff -u test_-b.output -
92RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
93RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
94
95# Absolute counts for branches.
96RUN: llvm-cov gcov test.c -a -b -c -u | diff -u test_-b.output -
97RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
98RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
99
100# Missing gcda file just gives 0 counts.
101RUN: llvm-cov gcov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
102RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
103RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
104
105# Invalid gcno file.
106RUN: llvm-cov gcov test.c -gcno=test_read_fail.gcno
107
108# Bad file checksum on gcda.
109RUN: llvm-cov gcov test.c -gcda=test_file_checksum_fail.gcda
110
111# Bad function checksum on gcda
112RUN: llvm-cov gcov test.c -gcda=test_func_checksum_fail.gcda
113
114# Has arcs from exit blocks
115RUN: llvm-cov gcov test_exit_block_arcs.c 2>&1 | FileCheck %s -check-prefix=EXIT_BLOCK_ARCS
116EXIT_BLOCK_ARCS: (main) has arcs from exit block.
117
118XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
119