2014-02-04 14:41:33 +08:00
|
|
|
# Tests for compatibility between llvm-cov and gcov. These work by
|
|
|
|
# comparing llvm-cov against reference outputs generated by gcov 4.2.
|
|
|
|
|
2013-12-03 16:21:14 +08:00
|
|
|
# "cd" and globbing are unsupported in lit internal runner.
|
2013-12-03 15:56:23 +08:00
|
|
|
REQUIRES: shell
|
2014-02-04 14:41:33 +08:00
|
|
|
|
2013-12-03 16:21:14 +08:00
|
|
|
RUN: rm -rf %t
|
|
|
|
RUN: mkdir %t
|
|
|
|
RUN: cd %t
|
2013-12-04 03:05:03 +08:00
|
|
|
RUN: cp %p/Inputs/test* .
|
2013-12-03 16:21:14 +08:00
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# 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
|
|
|
|
|
2014-02-04 14:41:43 +08:00
|
|
|
# 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
|
|
|
|
|
2014-02-18 17:19:48 +08:00
|
|
|
# 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
|
|
|
|
|
2014-05-07 10:11:18 +08:00
|
|
|
# With gcov output disabled
|
|
|
|
RUN: llvm-cov -n test.c | diff -u test_no_output.output -
|
|
|
|
|
2014-05-07 10:11:23 +08:00
|
|
|
# Missing source files. This test is fragile, as it depends on being
|
|
|
|
# run before we copy some sources into place in the next test.
|
|
|
|
RUN: llvm-cov test_paths.cpp 2>/dev/null | diff -u test_missing.output -
|
|
|
|
RUN: diff -aub test_missing.cpp.gcov test.cpp.gcov
|
|
|
|
RUN: diff -aub test_missing.h.gcov test.h.gcov
|
|
|
|
|
2014-02-04 18:45:02 +08:00
|
|
|
# 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
|
|
|
|
|
2014-04-24 05:44:55 +08:00
|
|
|
# Long file names.
|
|
|
|
RUN: llvm-cov -l test_paths.cpp | diff -u test_long_file_names.output -
|
|
|
|
RUN: diff -aub test_paths.cpp.gcov test_paths.cpp##test.cpp.gcov
|
|
|
|
RUN: diff -aub test_paths.h.gcov test_paths.cpp##test.h.gcov
|
|
|
|
|
|
|
|
# Long file names and preserve paths.
|
|
|
|
RUN: llvm-cov -lp -gcno test_paths.gcno -gcda test_paths.gcda srcdir/../test_paths.cpp | diff -u test_long_paths.output -
|
|
|
|
RUN: diff -aub test_paths.cpp.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.cpp.gcov
|
|
|
|
RUN: diff -aub test_paths.h.gcov srcdir#^#test_paths.cpp##srcdir#nested_dir#^#test.h.gcov
|
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Function summaries. This changes stdout, but not the gcov files.
|
|
|
|
RUN: llvm-cov test.c -f | diff -u test_-f.output -
|
2013-12-10 09:02:07 +08:00
|
|
|
RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
|
|
|
|
RUN: diff -aub test_no_options.h.gcov test.h.gcov
|
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# All blocks. This doesn't affect stdout, only the gcov files.
|
|
|
|
RUN: llvm-cov test.c -a | diff -u test_no_options.output -
|
2013-12-10 09:02:07 +08:00
|
|
|
RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
|
|
|
|
RUN: diff -aub test_-a.h.gcov test.h.gcov
|
2013-11-14 06:50:15 +08:00
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# 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
|
2013-12-13 09:15:07 +08:00
|
|
|
RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
|
|
|
|
RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
|
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Summarize unconditional branches too.
|
|
|
|
RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
|
2013-12-17 06:14:02 +08:00
|
|
|
RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
|
|
|
|
RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
|
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Absolute counts for branches.
|
|
|
|
RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
|
2013-12-19 02:40:15 +08:00
|
|
|
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
|
|
|
|
|
2014-02-04 14:41:39 +08:00
|
|
|
# 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
|
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Invalid gcno file.
|
2014-01-30 05:31:34 +08:00
|
|
|
RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
|
2013-11-14 08:07:15 +08:00
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Bad file checksum on gcda.
|
2014-01-30 05:31:34 +08:00
|
|
|
RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
|
2013-12-04 16:57:17 +08:00
|
|
|
|
2014-02-04 14:41:33 +08:00
|
|
|
# Bad function checksum on gcda
|
2014-01-30 05:31:34 +08:00
|
|
|
RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
|
2013-11-20 12:15:05 +08:00
|
|
|
|
2014-02-25 00:33:56 +08:00
|
|
|
XFAIL: powerpc64, s390x, mips-, mips64-, sparc
|