diff options
Diffstat (limited to 'test/tools/llvm-cov/llvm-cov.test')
-rw-r--r-- | test/tools/llvm-cov/llvm-cov.test | 96 |
1 files changed, 90 insertions, 6 deletions
diff --git a/test/tools/llvm-cov/llvm-cov.test b/test/tools/llvm-cov/llvm-cov.test index 28738a7..19d3e5d 100644 --- a/test/tools/llvm-cov/llvm-cov.test +++ b/test/tools/llvm-cov/llvm-cov.test @@ -1,10 +1,94 @@ -RUN: cd %p/Inputs -# "cd" is unsupported in lit internal runner. +# Tests for compatibility between llvm-cov and gcov. These work by +# comparing llvm-cov against reference outputs generated by gcov 4.2. + +# "cd" and globbing are unsupported in lit internal runner. REQUIRES: shell -RUN: llvm-cov -gcno=test.gcno -gcda=test.gcda \ -RUN: | diff -aub test.cpp.gcov - +RUN: rm -rf %t +RUN: mkdir %t +RUN: cd %t +RUN: cp %p/Inputs/test* . + +# Basic behaviour with no flags +RUN: llvm-cov test.c | diff -u test_no_options.output - +RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov +RUN: diff -aub test_no_options.h.gcov test.h.gcov + +# Same, but specifying the object directory +RUN: mkdir -p %t/objdir +RUN: cp test.gcno test.gcda %t/objdir +RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output - +RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov +RUN: diff -aub test_objdir.h.gcov test.h.gcov + +# Specifying an object file +RUN: llvm-cov -o objdir/test.o test.c | diff -u test_no_options.output - +RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov +RUN: diff -aub test_objdir.h.gcov test.h.gcov + +# Specifying an object file that could be ambiguous with a directory +RUN: llvm-cov -o objdir/test test.c | diff -u test_no_options.output - +RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov +RUN: diff -aub test_objdir.h.gcov test.h.gcov + +# Preserve paths. This mangles the output filenames. +RUN: mkdir -p %t/srcdir/nested_dir +RUN: cp test.cpp test.h %t/srcdir +RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output - +RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov +RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov + +# Don't preserve paths. Same results as preserve paths, but no mangling. +RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output - +RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov +RUN: diff -aub test_paths.h.gcov test.h.gcov + +# Function summaries. This changes stdout, but not the gcov files. +RUN: llvm-cov test.c -f | diff -u test_-f.output - +RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov +RUN: diff -aub test_no_options.h.gcov test.h.gcov + +# All blocks. This doesn't affect stdout, only the gcov files. +RUN: llvm-cov test.c -a | diff -u test_no_options.output - +RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov +RUN: diff -aub test_-a.h.gcov test.h.gcov + +# Branch probabilities. +RUN: llvm-cov test.c -a -b | diff -u test_-b.output - +RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov +RUN: diff -aub test_-a_-b.h.gcov test.h.gcov + +# Function summaries including branch probabilities. + +# FIXME: We don't correctly handle calls when -b and -f are used +# together, so our output differs from gcov. Remove the 'not' from +# this test once this is fixed. +RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null +RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov +RUN: diff -aub test_-a_-b.h.gcov test.h.gcov + +# Summarize unconditional branches too. +RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output - +RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov +RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov + +# Absolute counts for branches. +RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output - +RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov +RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov + +# Missing gcda file just gives 0 counts. +RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output - +RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov +RUN: diff -aub test_no_gcda.h.gcov test.h.gcov + +# Invalid gcno file. +RUN: not llvm-cov test.c -gcno=test_read_fail.gcno + +# Bad file checksum on gcda. +RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda -RUN: not llvm-cov -gcno=test_read_fail.gcno -gcda=test.gcda +# Bad function checksum on gcda +RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda -XFAIL: powerpc64, s390x +XFAIL: powerpc64, s390x, mips-, mips64-, sparc |