Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 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 | |
Daniel Jasper | cf765e3 | 2013-12-03 08:21:14 +0000 | [diff] [blame] | 4 | # "cd" and globbing are unsupported in lit internal runner. |
Daniel Jasper | 80b2ffb | 2013-12-03 07:56:23 +0000 | [diff] [blame] | 5 | REQUIRES: shell |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 6 | |
Daniel Jasper | cf765e3 | 2013-12-03 08:21:14 +0000 | [diff] [blame] | 7 | RUN: rm -rf %t |
| 8 | RUN: mkdir %t |
| 9 | RUN: cd %t |
Yuchen Wu | c8e0f81 | 2013-12-03 19:05:03 +0000 | [diff] [blame] | 10 | RUN: cp %p/Inputs/test* . |
Daniel Jasper | cf765e3 | 2013-12-03 08:21:14 +0000 | [diff] [blame] | 11 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 12 | # Basic behaviour with no flags |
| 13 | RUN: llvm-cov test.c | diff -u test_no_options.output - |
Yuchen Wu | 8c6bb5f | 2013-12-10 01:02:07 +0000 | [diff] [blame] | 14 | RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov |
| 15 | RUN: diff -aub test_no_options.h.gcov test.h.gcov |
| 16 | |
Justin Bogner | f69557e | 2014-02-04 06:41:43 +0000 | [diff] [blame] | 17 | # Same, but specifying the object directory |
| 18 | RUN: mkdir -p %t/objdir |
| 19 | RUN: cp test.gcno test.gcda %t/objdir |
| 20 | RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output - |
| 21 | RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov |
| 22 | RUN: diff -aub test_objdir.h.gcov test.h.gcov |
| 23 | |
Justin Bogner | e9a3e5a | 2014-02-18 09:19:48 +0000 | [diff] [blame] | 24 | # Specifying an object file |
| 25 | RUN: llvm-cov -o objdir/test.o test.c | diff -u test_no_options.output - |
| 26 | RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov |
| 27 | RUN: diff -aub test_objdir.h.gcov test.h.gcov |
| 28 | |
| 29 | # Specifying an object file that could be ambiguous with a directory |
| 30 | RUN: llvm-cov -o objdir/test test.c | diff -u test_no_options.output - |
| 31 | RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov |
| 32 | RUN: diff -aub test_objdir.h.gcov test.h.gcov |
| 33 | |
Justin Bogner | c6af350 | 2014-02-04 10:45:02 +0000 | [diff] [blame] | 34 | # Preserve paths. This mangles the output filenames. |
| 35 | RUN: mkdir -p %t/srcdir/nested_dir |
| 36 | RUN: cp test.cpp test.h %t/srcdir |
| 37 | RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output - |
| 38 | RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov |
| 39 | RUN: 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. |
| 42 | RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output - |
| 43 | RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov |
| 44 | RUN: diff -aub test_paths.h.gcov test.h.gcov |
| 45 | |
Justin Bogner | c67f025 | 2014-04-23 21:44:55 +0000 | [diff] [blame^] | 46 | # Long file names. |
| 47 | RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output - |
| 48 | RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov |
| 49 | RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov |
| 50 | |
| 51 | # Long file names and preserve paths. |
| 52 | RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output - |
| 53 | RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov |
| 54 | RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov |
| 55 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 56 | # Function summaries. This changes stdout, but not the gcov files. |
| 57 | RUN: llvm-cov test.c -f | diff -u test_-f.output - |
| 58 | RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov |
| 59 | RUN: diff -aub test_no_options.h.gcov test.h.gcov |
| 60 | |
| 61 | # All blocks. This doesn't affect stdout, only the gcov files. |
| 62 | RUN: llvm-cov test.c -a | diff -u test_no_options.output - |
Yuchen Wu | 8c6bb5f | 2013-12-10 01:02:07 +0000 | [diff] [blame] | 63 | RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov |
| 64 | RUN: diff -aub test_-a.h.gcov test.h.gcov |
Yuchen Wu | aae8801 | 2013-11-13 22:50:15 +0000 | [diff] [blame] | 65 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 66 | # Branch probabilities. |
| 67 | RUN: llvm-cov test.c -a -b | diff -u test_-b.output - |
Yuchen Wu | 342714c | 2013-12-13 01:15:07 +0000 | [diff] [blame] | 68 | RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov |
| 69 | RUN: diff -aub test_-a_-b.h.gcov test.h.gcov |
| 70 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 71 | # 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. |
| 76 | RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null |
| 77 | RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov |
| 78 | RUN: diff -aub test_-a_-b.h.gcov test.h.gcov |
| 79 | |
| 80 | # Summarize unconditional branches too. |
| 81 | RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output - |
Yuchen Wu | 66d93b8 | 2013-12-16 22:14:02 +0000 | [diff] [blame] | 82 | RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov |
| 83 | RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov |
| 84 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 85 | # Absolute counts for branches. |
| 86 | RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output - |
Yuchen Wu | 73dc381 | 2013-12-18 18:40:15 +0000 | [diff] [blame] | 87 | RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov |
| 88 | RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov |
| 89 | |
Justin Bogner | 93d1edb | 2014-02-04 06:41:39 +0000 | [diff] [blame] | 90 | # Missing gcda file just gives 0 counts. |
| 91 | RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output - |
| 92 | RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov |
| 93 | RUN: diff -aub test_no_gcda.h.gcov test.h.gcov |
| 94 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 95 | # Invalid gcno file. |
Justin Bogner | a99a390 | 2014-01-29 21:31:34 +0000 | [diff] [blame] | 96 | RUN: not llvm-cov test.c -gcno=test_read_fail.gcno |
Yuchen Wu | e28da84 | 2013-11-14 00:07:15 +0000 | [diff] [blame] | 97 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 98 | # Bad file checksum on gcda. |
Justin Bogner | a99a390 | 2014-01-29 21:31:34 +0000 | [diff] [blame] | 99 | RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda |
Daniel Jasper | 87a24d5 | 2013-12-04 08:57:17 +0000 | [diff] [blame] | 100 | |
Justin Bogner | b5bff69 | 2014-02-04 06:41:33 +0000 | [diff] [blame] | 101 | # Bad function checksum on gcda |
Justin Bogner | a99a390 | 2014-01-29 21:31:34 +0000 | [diff] [blame] | 102 | RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda |
Yuchen Wu | babe749 | 2013-11-20 04:15:05 +0000 | [diff] [blame] | 103 | |
Reed Kotler | 59ebf32d | 2014-02-24 16:33:56 +0000 | [diff] [blame] | 104 | XFAIL: powerpc64, s390x, mips-, mips64-, sparc |