Commit 6ed44c2a authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

remove obsolete coverage scripts

git-svn-id: file:///svn/toku/tokudb@43188 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0f9fc070
#!/bin/bash
# measure code coverage of the tokudb tests
tokudb_version=tokudb
tokudb=$tokudb_version
tokudb_checkout_dir=$tokudb
while [ $# -gt 0 ] ; do
arg=$1; shift
if [[ $arg =~ "--tokudb=(.*)" ]] ; then
tokudb_version=${BASH_REMATCH[1]}
tokudb="tokudb-$tokudb_version"
tokudb_checkout_dir="tokudb.branches/$tokudb_version"
fi
done
echo $tokudb
echo $tokudb_checkout_dir
coveragedir=~/svn.coverage.$tokudb.`date +%Y%m%d`
mkdir $coveragedir
cd $coveragedir
svn co -q https://svn.tokutek.com/tokudb/$tokudb_checkout_dir
if [ $tokudb != "tokudb" ] ; then
mv $tokudb_version $tokudb
fi
cd $tokudb
# build tokudb with coverage enable
make -k build-coverage
# run the tests
make -k check-coverage
(cd src/tests;make -k all.recover VGRIND="")
# make -k measure-coverage
rm $coveragedir/raw.test.coverage
for d in newbrt src utils cxx src/range_tree src/lock_tree; do
(cd $d; python ~/bin/gcovsumdir.py -b *.c *.cpp >>$coveragedir/raw.test.coverage)
done
python ~/bin/gcovsumsum.py $coveragedir/raw.test.coverage >$coveragedir/test.coverage
#! /usr/bin/env python
# summarize the code coverage of a collection of named files
import re
import os
import sys
import math
import glob
verbose = 0
dobranches = 0
dofunctions = 0
functions = {}
lines = {}
branches = {}
taken = {}
calls = {}
def add(coverage, fname, m, n):
global verbose
addit = 0
if coverage.has_key(fname):
(oldm, oldn) = coverage[fname]
if verbose: print "old", oldm, oldn, m, n
if m > oldm:
addit = 1
else:
addit = 1
if addit:
if verbose: print "add", fname, m, n
coverage[fname] = (m, n)
return addit
def add_match(coverage, fname, match):
percent = float(match.group(1))
n = int(match.group(2))
m = int(math.ceil((float(percent)/100)*n))
return add(coverage, fname, m, n)
def gcov(gcovargs, fnames):
global verbose
if verbose: print "gcov ", gcovargs, fnames
f = os.popen("gcov " + gcovargs + " " + fnames)
fname = ""
while 1:
b = f.readline()
if b == "": break
if verbose: print ">", b
match = re.match("File \'(.*)\'", b)
if match:
fname = match.group(1)
coverage = lines
else:
match = re.match("Function \'(.*)\'", b)
if match:
fname = match.group(1)
coverage = functions
if fname[0] == '/' or not os.path.exists(fname):
continue
match = re.match("Lines executed:(.*)% of (.*)", b)
if match:
if add_match(coverage, fname, match) and coverage == lines:
cpcmd = "cp " + fname + ".gcov" + " " + fname + ".gcov.best"
if verbose: print "system", cpcmd
os.system(cpcmd)
continue
match = re.match("Branches executed:(.*)% of (.*)", b)
if match:
add_match(branches, fname, match)
continue
match = re.match("Taken.*:(.*)% of (.*)", b)
if match:
add_match(taken, fname, match)
continue
match = re.match("Calls executed:(.*)% of (.*)", b)
if match:
add_match(calls, fname, match)
continue
def usage():
print "gcovsummary.py [-h] [-v] [-b] [-f] FILENAMES"
return 1
def percent(m, n):
return (float(m)/float(n))*100
def main():
global verbose, dobranches, dofunctions
# coverage hashes filenames -> (lines_executes, total_lines) tuples
gcovargs = ""
threshold = 1
i = 1
while i < len(sys.argv):
arg = sys.argv[i]
if arg == "-h" or arg == "--help":
return usage()
elif arg == "-v" or arg == "--verbose":
verbose = 1
elif arg == "-b":
dobranches = 1
gcovargs = gcovargs + " " + arg
elif arg == "-f":
dofunctions = 1
gcovargs = gcovargs + " " + arg
elif arg == "--threshold":
if i+1 < len(sys.argv):
i += 1
threshold = float(sys.argv[i])
else:
gcov(gcovargs, arg)
i += 1
# print a coverage summary
if len(functions) > 0:
fnames = functions.keys()
fnames.sort()
for fname in fnames:
(m,n) = functions[fname]
if float(m)/float(n) <= threshold:
print "%s %d/%d %.2f%%" % (fname, m, n, percent(m, n))
else:
fnames = lines.keys()
fnames.sort()
for fname in fnames:
(m,n) = lines[fname]
if float(m)/float(n) > threshold:
continue
print "%s" % fname
print "\t%s %d/%d %.2f%%" % ("Lines", m, n, percent(m, n))
if branches.has_key(fname):
(m,n) = branches[fname]
print "\t%s %d/%d %.2f%%" % ("Branches", m, n, percent(m, n))
if taken.has_key(fname):
(m,n) = taken[fname]
print "\t%s %d/%d %.2f%%" % ("Taken", m, n, percent(m, n))
if calls.has_key(fname):
(m,n) = calls[fname]
print "\t%s %d/%d %.2f%%" % ("Calls", m, n, percent(m, n))
# rename the best gcov files
fnames = glob.glob("*.best")
for fname in fnames:
if verbose: print "test", fname
match = re.match("(.*)\.gcov\.best", fname)
if match != None:
mvcmd = "mv " + fname + " " + match.group(1) + ".gcov"
if verbose: print "system", mvcmd
os.system(mvcmd)
return 0
sys.exit(main())
#! /usr/bin/env python
import sys
import re
import os.path
verbose = 0
def percent(a, b):
return (float(a)/float(b))*100
def sumarize():
fname = None
cfiles = {}
while 1:
b = sys.stdin.readline()
if b == "":
break
b = b.rstrip('\n')
if verbose: print ">", b
match = re.match("^(\S*)$", b)
if match:
maybe = match.group(1)
# skip test files
match = re.match(".*test|keyrange-|bug|shortcut|manyfiles", maybe)
if match == None:
fname = os.path.basename(maybe)
# print fname
else:
fname = None
else:
match = re.match("\t(.*) (.*)\/(.*) (.*)%", b)
if match and fname:
# print b
type = match.group(1)
m = int(match.group(2))
n = int(match.group(3))
if cfiles.has_key(fname):
h = cfiles[fname]
else:
h = {}
cfiles[fname] = h
if h.has_key(type):
(om,on) = h[type]
if percent(m,n) > percent(om,on):
h[type] = (m,n)
else:
h[type] = (m,n)
summary = {}
keys = cfiles.keys(); keys.sort()
for k in keys:
h = cfiles[k]
print k
ktypes = h.keys(); ktypes.sort()
for t in ktypes:
(m,n) = h[t]
print "\t%s %d/%d %.2f%%" % (t, m, n, percent(m,n))
if summary.has_key(t):
(om,on) = summary[t]; summary[t] = (om+m,on+n)
else:
summary[t] = (m,n)
print
printhash("Summary", summary)
def printhash(s, h):
print s
ktypes = h.keys(); ktypes.sort()
for t in ktypes:
(m,n) = h[t]
print "\t%s %d/%d %.2f%%" % (t, m, n, percent(m,n))
def main():
global verbose
for arg in sys.argv[1:]:
if arg == "-v" or arg == "--verbose":
verbose = 1
sumarize()
sys.exit(main())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment