1 # Tests for compatibility between llvm-cov and gcov. These work by
2 # comparing llvm-cov against reference outputs generated by gcov 4.2.
4 # Test fails on Windows where internal shell is used due to path separator
11 RUN: cp %p/Inputs/test* .
13 # Basic behaviour with no flags
14 RUN: llvm-cov gcov test.c | diff -u test_no_options.output -
15 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
16 RUN: diff -aub test_no_options.h.gcov test.h.gcov
18 # Same, but specifying the object directory
19 RUN: mkdir -p %t/objdir
20 RUN: cp test.gcno test.gcda %t/objdir
21 RUN: llvm-cov gcov -o objdir test.c | diff -u test_no_options.output -
22 RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
23 RUN: diff -aub test_objdir.h.gcov test.h.gcov
25 # Specifying an object file
26 RUN: llvm-cov gcov -o objdir/test.o test.c | diff -u test_no_options.output -
27 RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
28 RUN: diff -aub test_objdir.h.gcov test.h.gcov
30 # Specifying an object file that could be ambiguous with a directory
31 RUN: llvm-cov gcov -o objdir/test test.c | diff -u test_no_options.output -
32 RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
33 RUN: diff -aub test_objdir.h.gcov test.h.gcov
35 # With gcov output disabled
36 RUN: llvm-cov gcov -n test.c | diff -u test_no_output.output -
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.
40 RUN: llvm-cov gcov test_paths.cpp 2>/dev/null | diff -u test_missing.output -
41 RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov
42 RUN: diff -aub test_missing.h.gcov test.h.gcov
44 # Preserve paths. This mangles the output filenames.
45 RUN: mkdir -p %t/srcdir/nested_dir
46 RUN: cp test.cpp test.h %t/srcdir
47 RUN: llvm-cov gcov -p test_paths.cpp | diff -u test_preserve_paths.output -
48 RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
49 RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
51 # Don't preserve paths. Same results as preserve paths, but no mangling.
52 RUN: llvm-cov gcov test_paths.cpp | diff -u test_no_preserve_paths.output -
53 RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
54 RUN: diff -aub test_paths.h.gcov test.h.gcov
57 RUN: llvm-cov gcov -l test_paths.cpp | diff -u test_long_file_names.output -
58 RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov
59 RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov
61 # Long file names and preserve paths.
62 RUN: llvm-cov gcov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output -
63 RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov
64 RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov
67 RUN: llvm-cov gcov -x -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_hash.output -
68 RUN: diff -aub test_paths.cpp.gcov test.cpp##a806e5b3093cd6f683da88c0da150daf.gcov
69 RUN: diff -aub test_paths.h.gcov test.h##0cbee7e2421fa4517420ac4f935620ca.gcov
71 # Function summaries. This changes stdout, but not the gcov files.
72 RUN: llvm-cov gcov test.c -f | diff -u test_-f.output -
73 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
74 RUN: diff -aub test_no_options.h.gcov test.h.gcov
76 # All blocks. This doesn't affect stdout, only the gcov files.
77 RUN: llvm-cov gcov test.c -a | diff -u test_no_options.output -
78 RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
79 RUN: diff -aub test_-a.h.gcov test.h.gcov
81 # Branch probabilities.
82 RUN: llvm-cov gcov test.c -a -b | diff -u test_-b.output -
83 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
84 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
86 # Function summaries including branch probabilities.
88 # FIXME: We don't correctly handle calls when -b and -f are used
89 # together, so our output differs from gcov. Remove the 'not' from
90 # this test once this is fixed.
91 RUN: llvm-cov gcov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
92 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
93 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
95 # Summarize unconditional branches too.
96 RUN: llvm-cov gcov test.c -a -b -u | diff -u test_-b.output -
97 RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
98 RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
100 # Absolute counts for branches.
101 RUN: llvm-cov gcov test.c -a -b -c -u | diff -u test_-b.output -
102 RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
103 RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
105 # Missing gcda file just gives 0 counts.
106 RUN: llvm-cov gcov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
107 RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
108 RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
111 RUN: llvm-cov gcov test.c -gcno=test_read_fail.gcno
113 # Bad file checksum on gcda.
114 RUN: llvm-cov gcov test.c -gcda=test_file_checksum_fail.gcda
116 # Bad function checksum on gcda
117 RUN: llvm-cov gcov test.c -gcda=test_func_checksum_fail.gcda
119 # Has arcs from exit blocks
120 RUN: llvm-cov gcov test_exit_block_arcs.c 2>&1 | FileCheck %s -check-prefix=EXIT_BLOCK_ARCS
121 EXIT_BLOCK_ARCS: (main) has arcs from exit block.
123 XFAIL: host-byteorder-big-endian