forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic coverage report scripts
Summary: Ultimate goals of the coverage report are: * Report the coverage for all files (done in this diff) * Report the coverage for recently updated files (not fully finished) * Report is available in html form (done in this diff, but need some extra work to integrate it in Jenkin) Task link: https://our.intern.facebook.com/intern/tasks/?s=1154818042&t=2604914 Test Plan: Ran: coverage/coverage_test.sh The sample output can be found here: https://phabricator.fb.com/P2433892 Reviewers: dhruba, emayanke CC: leveldb Differential Revision: https://reviews.facebook.net/D11943
- Loading branch information
Kai Liu
committed
Aug 13, 2013
1 parent
03bd446
commit 9f6b8f0
Showing
5 changed files
with
253 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
build_config.mk | ||
*.a | ||
*.o | ||
*.arc | ||
*.d | ||
*.dylib* | ||
*.gcda | ||
*.gcno | ||
*.o | ||
*.so | ||
*.so.* | ||
*_test | ||
*.arc | ||
*.d | ||
db_bench | ||
db_repl_stress | ||
db_stress | ||
ldb | ||
leveldb_server | ||
leveldb_shell | ||
manifest_dump | ||
sst_dump | ||
util/build_version.cc | ||
db_repl_stress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
# Exit on error. | ||
set -e | ||
|
||
if [ -n "$USE_CLANG" ]; then | ||
echo "Error: Coverage test is supported only for gcc." | ||
exit 1 | ||
fi | ||
|
||
ROOT=".." | ||
# Fetch right version of gcov | ||
if [ -d /mnt/gvfs/third-party -a -z "$CXX" ]; then | ||
source $ROOT/fbcode.gcc471.sh | ||
GCOV=$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1/cc6c9dc/bin/gcov | ||
else | ||
GCOV=$(which gcov) | ||
fi | ||
|
||
COVERAGE_DIR=$(mktemp -t -d rocksdb_coverage_XXXX) | ||
mkdir -p $COVERAGE_DIR | ||
|
||
# Find all gcno files to generate the coverage report | ||
|
||
GCNO_FILES=`find $ROOT -name "*.gcno"` | ||
$GCOV --preserve-paths --relative-only --no-output $GCNO_FILES 2>/dev/null | | ||
# Parse the raw gcov report to more human readable form. | ||
python $ROOT/coverage/parse_gcov_output.py | | ||
# Write the output to both stdout and report file. | ||
tee $COVERAGE_DIR/coverage_report_all.txt && | ||
echo -e "Generated coverage report for all files: $COVERAGE_DIR/coverage_report_all.txt\n" | ||
|
||
# TODO: we also need to get the files of the latest commits. | ||
# Get the most recently committed files. | ||
LATEST_FILES=` | ||
git show --pretty="format:" --name-only HEAD | | ||
grep -v "^$" | | ||
paste -s -d,` | ||
RECENT_REPORT=$COVERAGE_DIR/coverage_report_recent.txt | ||
|
||
echo -e "Recently updated files: $LATEST_FILES\n" > $RECENT_REPORT | ||
$GCOV --preserve-paths --relative-only --no-output $GCNO_FILES 2>/dev/null | | ||
python $ROOT/coverage/parse_gcov_output.py -interested-files $LATEST_FILES | | ||
tee -a $RECENT_REPORT && | ||
echo -e "Generated coverage report for recently updated files: $RECENT_REPORT\n" | ||
|
||
# Generate the html report. If we cannot find lcov in this machine, we'll simply | ||
# skip this step. | ||
echo "Generating the html coverage report..." | ||
set +e | ||
LCOV=$(which lcov 2>/dev/null) | ||
if [ -z $LCOV ] | ||
then | ||
echo "Skip: Cannot find lcov to generate the html report." | ||
exit 0 | ||
fi | ||
|
||
set -e | ||
|
||
(cd $ROOT; lcov --no-external \ | ||
--capture \ | ||
--directory $PWD \ | ||
--gcov-tool $GCOV \ | ||
--output-file $COVERAGE_DIR/coverage.info &>/dev/null) | ||
|
||
genhtml $COVERAGE_DIR/coverage.info -o $COVERAGE_DIR &>/dev/null | ||
|
||
echo "HTML Coverage report is generated in $COVERAGE_DIR" |
Oops, something went wrong.