| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [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 | |
| 4 | # "cd" and globbing are unsupported in lit internal runner. |
| NAKAMURA Takumi | 3f4c031 | 2013-11-14 02:05:41 +0000 | [diff] [blame] | 5 | REQUIRES: shell |
| Yuchen Wu | dbb51ff | 2013-11-14 00:07:15 +0000 | [diff] [blame] | 6 | |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 7 | RUN: rm -rf %t |
| 8 | RUN: mkdir %t |
| 9 | RUN: cd %t |
| 10 | RUN: cp %p/Inputs/test* . |
| Yuchen Wu | 86e37f5 | 2013-11-13 22:50:15 +0000 | [diff] [blame] | 11 | |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 12 | # Basic behaviour with no flags |
| 13 | RUN: llvm-cov test.c | diff -u test_no_options.output - |
| 14 | RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov |
| 15 | RUN: diff -aub test_no_options.h.gcov test.h.gcov |
| Yuchen Wu | dbb51ff | 2013-11-14 00:07:15 +0000 | [diff] [blame] | 16 | |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [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 | |
| 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 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 34 | # With gcov output disabled |
| 35 | RUN: llvm-cov -n test.c | diff -u test_no_output.output - |
| 36 | |
| 37 | # Missing source files. This test is fragile, as it depends on being |
| 38 | # run before we copy some sources into place in the next test. |
| 39 | RUN: llvm-cov test_paths.cpp 2>/dev/null | diff -u test_missing.output - |
| 40 | RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov |
| 41 | RUN: diff -aub test_missing.h.gcov test.h.gcov |
| 42 | |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 43 | # Preserve paths. This mangles the output filenames. |
| 44 | RUN: mkdir -p %t/srcdir/nested_dir |
| 45 | RUN: cp test.cpp test.h %t/srcdir |
| 46 | RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output - |
| 47 | RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov |
| 48 | RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov |
| 49 | |
| 50 | # Don't preserve paths. Same results as preserve paths, but no mangling. |
| 51 | RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output - |
| 52 | RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov |
| 53 | RUN: diff -aub test_paths.h.gcov test.h.gcov |
| 54 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 55 | # Long file names. |
| 56 | RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output - |
| 57 | RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov |
| 58 | RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov |
| 59 | |
| 60 | # Long file names and preserve paths. |
| 61 | RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output - |
| 62 | RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov |
| 63 | RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov |
| 64 | |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 65 | # Function summaries. This changes stdout, but not the gcov files. |
| 66 | RUN: llvm-cov test.c -f | diff -u test_-f.output - |
| 67 | RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov |
| 68 | RUN: diff -aub test_no_options.h.gcov test.h.gcov |
| 69 | |
| 70 | # All blocks. This doesn't affect stdout, only the gcov files. |
| 71 | RUN: llvm-cov test.c -a | diff -u test_no_options.output - |
| 72 | RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov |
| 73 | RUN: diff -aub test_-a.h.gcov test.h.gcov |
| 74 | |
| 75 | # Branch probabilities. |
| 76 | RUN: llvm-cov test.c -a -b | diff -u test_-b.output - |
| 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 | # Function summaries including branch probabilities. |
| 81 | |
| 82 | # FIXME: We don't correctly handle calls when -b and -f are used |
| 83 | # together, so our output differs from gcov. Remove the 'not' from |
| 84 | # this test once this is fixed. |
| 85 | RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null |
| 86 | RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov |
| 87 | RUN: diff -aub test_-a_-b.h.gcov test.h.gcov |
| 88 | |
| 89 | # Summarize unconditional branches too. |
| 90 | RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output - |
| 91 | RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov |
| 92 | RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov |
| 93 | |
| 94 | # Absolute counts for branches. |
| 95 | RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output - |
| 96 | RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov |
| 97 | RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov |
| 98 | |
| 99 | # Missing gcda file just gives 0 counts. |
| 100 | RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output - |
| 101 | RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov |
| 102 | RUN: diff -aub test_no_gcda.h.gcov test.h.gcov |
| 103 | |
| 104 | # Invalid gcno file. |
| 105 | RUN: not llvm-cov test.c -gcno=test_read_fail.gcno |
| 106 | |
| 107 | # Bad file checksum on gcda. |
| 108 | RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda |
| 109 | |
| 110 | # Bad function checksum on gcda |
| 111 | RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda |
| 112 | |
| 113 | XFAIL: powerpc64, s390x, mips-, mips64-, sparc |