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. 6 REQUIRES: shell 7 8 RUN: rm -rf %t 9 RUN: mkdir %t 10 RUN: cd %t 11 RUN: cp %p/Inputs/test* . 12 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 17 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 24 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 29 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 34 35 # With gcov output disabled 36 RUN: 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. 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 43 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 50 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 55 56 # Long file names. 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 60 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 65 66 # Function summaries. This changes stdout, but not the gcov files. 67 RUN: llvm-cov gcov test.c -f | diff -u test_-f.output - 68 RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov 69 RUN: diff -aub test_no_options.h.gcov test.h.gcov 70 71 # All blocks. This doesn't affect stdout, only the gcov files. 72 RUN: llvm-cov gcov test.c -a | diff -u test_no_options.output - 73 RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov 74 RUN: diff -aub test_-a.h.gcov test.h.gcov 75 76 # Branch probabilities. 77 RUN: llvm-cov gcov test.c -a -b | diff -u test_-b.output - 78 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov 79 RUN: 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. 86 RUN: llvm-cov gcov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null 87 RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov 88 RUN: diff -aub test_-a_-b.h.gcov test.h.gcov 89 90 # Summarize unconditional branches too. 91 RUN: llvm-cov gcov test.c -a -b -u | diff -u test_-b.output - 92 RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov 93 RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov 94 95 # Absolute counts for branches. 96 RUN: llvm-cov gcov test.c -a -b -c -u | diff -u test_-b.output - 97 RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov 98 RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov 99 100 # Missing gcda file just gives 0 counts. 101 RUN: llvm-cov gcov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output - 102 RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov 103 RUN: diff -aub test_no_gcda.h.gcov test.h.gcov 104 105 # Invalid gcno file. 106 RUN: llvm-cov gcov test.c -gcno=test_read_fail.gcno 107 108 # Bad file checksum on gcda. 109 RUN: llvm-cov gcov test.c -gcda=test_file_checksum_fail.gcda 110 111 # Bad function checksum on gcda 112 RUN: llvm-cov gcov test.c -gcda=test_func_checksum_fail.gcda 113 114 # Has arcs from exit blocks 115 RUN: llvm-cov gcov test_exit_block_arcs.c 2>&1 | FileCheck %s -check-prefix=EXIT_BLOCK_ARCS 116 EXIT_BLOCK_ARCS: (main) has arcs from exit block. 117 118 XFAIL: powerpc64-, s390x, mips-, mips64-, sparc 119