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. 5REQUIRES: shell 6 7RUN: rm -rf %t 8RUN: mkdir %t 9RUN: cd %t 10RUN: cp %p/Inputs/test* . 11 12# Basic behaviour with no flags 13RUN: llvm-cov test.c | diff -u test_no_options.output - 14RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov 15RUN: diff -aub test_no_options.h.gcov test.h.gcov 16 17# Same, but specifying the object directory 18RUN: mkdir -p %t/objdir 19RUN: cp test.gcno test.gcda %t/objdir 20RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output - 21RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov 22RUN: diff -aub test_objdir.h.gcov test.h.gcov 23 24# Specifying an object file 25RUN: llvm-cov -o objdir/test.o test.c | diff -u test_no_options.output - 26RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov 27RUN: diff -aub test_objdir.h.gcov test.h.gcov 28 29# Specifying an object file that could be ambiguous with a directory 30RUN: llvm-cov -o objdir/test test.c | diff -u test_no_options.output - 31RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov 32RUN: diff -aub test_objdir.h.gcov test.h.gcov 33 34# With gcov output disabled 35RUN: 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. 39RUN: llvm-cov test_paths.cpp 2>/dev/null | diff -u test_missing.output - 40RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov 41RUN: diff -aub test_missing.h.gcov test.h.gcov 42 43# Preserve paths. This mangles the output filenames. 44RUN: mkdir -p %t/srcdir/nested_dir 45RUN: cp test.cpp test.h %t/srcdir 46RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output - 47RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov 48RUN: 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. 51RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output - 52RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov 53RUN: diff -aub test_paths.h.gcov test.h.gcov 54 55# Long file names. 56RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output - 57RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov 58RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov 59 60# Long file names and preserve paths. 61RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output - 62RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov 63RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov 64 65# Function summaries. This changes stdout, but not the gcov files. 66RUN: llvm-cov test.c -f | diff -u test_-f.output - 67RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov 68RUN: diff -aub test_no_options.h.gcov test.h.gcov 69 70# All blocks. This doesn't affect stdout, only the gcov files. 71RUN: llvm-cov test.c -a | diff -u test_no_options.output - 72RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov 73RUN: diff -aub test_-a.h.gcov test.h.gcov 74 75# Branch probabilities. 76RUN: llvm-cov test.c -a -b | diff -u test_-b.output - 77RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov 78RUN: 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. 85RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null 86RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov 87RUN: diff -aub test_-a_-b.h.gcov test.h.gcov 88 89# Summarize unconditional branches too. 90RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output - 91RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov 92RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov 93 94# Absolute counts for branches. 95RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output - 96RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov 97RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov 98 99# Missing gcda file just gives 0 counts. 100RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output - 101RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov 102RUN: diff -aub test_no_gcda.h.gcov test.h.gcov 103 104# Invalid gcno file. 105RUN: llvm-cov test.c -gcno=test_read_fail.gcno 106 107# Bad file checksum on gcda. 108RUN: llvm-cov test.c -gcda=test_file_checksum_fail.gcda 109 110# Bad function checksum on gcda 111RUN: llvm-cov test.c -gcda=test_func_checksum_fail.gcda 112 113XFAIL: powerpc64-, s390x, mips-, mips64-, sparc 114