Skip to content

Commit

Permalink
Add scripts to analyze coverage for a single teuthology run.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdurgin committed Aug 29, 2011
1 parent fb33ef3 commit 0545e2f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
51 changes: 51 additions & 0 deletions coverage/cov-analyze.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -e

usage () {
printf '%s: usage: %s -d WORKING_DIR -o OUT_BASENAME -t TEST_DIR\n' "$(basename "$0")" "$(basename "$0")" 1>&2
echo <<EOF
WORKING_DIR should contain the source, .gcno, and initial lcov files (as created by cov-init.sh)
TEST_DIR should contain the data archived from a teuthology test.
Example:
mkdir coverage
./cov-init.sh ~/teuthology_output/foo coverage
$0 -t ~/teuthology_output/foo -d coverage -o foo
EOF
exit 1
}

OUTPUT_BASENAME=
TEST_DIR=
COV_DIR=

while getopts "d:o:t:" flag
do
case $flag in
d) COV_DIR=$OPTARG;;
o) OUTPUT_BASENAME=$OPTARG;;
t) TEST_DIR=$OPTARG;;
*) usage;;
esac
done

shift $(($OPTIND - 1))

echo $OUTPUT_BASENAME
if [ -z "$OUTPUT_BASENAME" ] || [ -z "$TEST_DIR" ] || [ -z "$COV_DIR" ]; then
usage
fi

cp $COV_DIR/base.lcov "$COV_DIR/${OUTPUT_BASENAME}.lcov"

for remote in `ls $TEST_DIR/remote`; do
echo "processing coverage for $remote..."
cp $TEST_DIR/remote/$remote/coverage/*.gcda $COV_DIR/ceph/src
cp $TEST_DIR/remote/$remote/coverage/_libs/*.gcda $COV_DIR/ceph/src/.libs
lcov -d $COV_DIR/ceph/src -c -o "$COV_DIR/${remote}_full.lcov"
lcov -r "$COV_DIR/${remote}_full.lcov" /usr/include\* -o "$COV_DIR/${remote}.lcov"
lcov -a "$COV_DIR/${remote}.lcov" -a "$COV_DIR/${OUTPUT_BASENAME}.lcov" -o "$COV_DIR/${OUTPUT_BASENAME}_tmp.lcov"
mv "$COV_DIR/${OUTPUT_BASENAME}_tmp.lcov" "$COV_DIR/${OUTPUT_BASENAME}.lcov"
rm "$COV_DIR/${remote}_full.lcov"
find $COV_DIR/ceph/src -name '*.gcda' -type f -delete
done
35 changes: 35 additions & 0 deletions coverage/cov-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e

usage () {
printf '%s: usage: %s TEST_DIR OUTPUT_DIR\n' "$(basename "$0")" "$(basename "$0")" 1>&2
exit 1
}

TEST_DIR=$1
OUTPUT_DIR=$2

if [ -z "$TEST_DIR" ] || [ -z "$OUTPUT_DIR" ]; then
usage
fi

SHA1=`cat $TEST_DIR/ceph-sha1`

mkdir -p $OUTPUT_DIR/ceph

echo "Retrieving source and .gcno files..."
git archive --format tar --remote git://ceph.newdream.net/git/ceph.git $SHA1 | tar xf - -C $OUTPUT_DIR/ceph
wget "http://gitbuilder-gcov-amd64.ceph.newdream.net/output/sha1/$SHA1/ceph.x86_64.tgz" -P $OUTPUT_DIR
tar zxf $OUTPUT_DIR/ceph.x86_64.tgz -C $OUTPUT_DIR
cp $OUTPUT_DIR/usr/local/lib/ceph/coverage/*.gcno $OUTPUT_DIR/ceph/src
mkdir $OUTPUT_DIR/ceph/src/.libs
cp $OUTPUT_DIR/usr/local/lib/ceph/coverage/.libs/*.gcno $OUTPUT_DIR/ceph/src/.libs
rm -rf $OUTPUT_DIR/usr
rm $OUTPUT_DIR/ceph.x86_64.tgz

echo "Initializing lcov files..."
lcov -d $OUTPUT_DIR/ceph/src -z
lcov -d $OUTPUT_DIR/ceph/src -c -i -o $OUTPUT_DIR/base_full.lcov
lcov -r $OUTPUT_DIR/base_full.lcov /usr/include\* -o $OUTPUT_DIR/base.lcov
rm $OUTPUT_DIR/base_full.lcov
echo "Done."

0 comments on commit 0545e2f

Please sign in to comment.