diff options
Diffstat (limited to 'scripts/test')
-rwxr-xr-x | scripts/test/cov-diff | 4 | ||||
-rwxr-xr-x | scripts/test/cov-display | 81 | ||||
-rw-r--r-- | scripts/test/scan-build.sh | 28 |
3 files changed, 93 insertions, 20 deletions
diff --git a/scripts/test/cov-diff b/scripts/test/cov-diff index 33a54802b6..48dbec9d54 100755 --- a/scripts/test/cov-diff +++ b/scripts/test/cov-diff @@ -9,8 +9,8 @@ DIRB="$2" for A in $DIRA/*; do B=$DIRB/`basename $A` - perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$A" > "$A.tmp" - perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$B" > "$B.tmp" + perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/; s/^ *-:(Runs|Programs):.*//;' "$A" > "$A.tmp" + perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/; s/^ *-:(Runs|Programs):.*//;' "$B" > "$B.tmp" diff -u "$A.tmp" "$B.tmp" rm "$A.tmp" "$B.tmp" done diff --git a/scripts/test/cov-display b/scripts/test/cov-display new file mode 100755 index 0000000000..4628cd589b --- /dev/null +++ b/scripts/test/cov-display @@ -0,0 +1,81 @@ +#!/usr/bin/python +import sys, re, os + +none0, some0 = 0,0 +branchTaken0, branchNot0 = 0,0 + +BRANCH = False +FUNC = False + +if sys.argv[1] == '-b': + BRANCH = True + del sys.argv[1] + +if sys.argv[1] == '-f': + FUNC = True + del sys.argv[1] + +def show(name, none, some): + if some+none == 0: + none = 1 + print name, none, some, "%.02f"%(100*(float(some)/(some+none))) + + +file_args = sys.argv[1:] +files = [] +for fn in file_args: + if os.path.isdir(fn): + files.extend(os.path.join(fn, f) for f in os.listdir(fn)) + else: + files.append(fn) + +for fn in files: + none = some = branchTaken = branchNot = 0 + inFunc = "" + for line in open(fn, 'r'): + m = re.match(r'^[^:]*:([^:]*):(.*)', line) + if m: + body = m.group(2).rstrip() + lineno = m.group(1).strip() + else: + body = "" + lineno = "?" + m = re.match(r'^([A-Za-z_][A-Za-z0-9_]*)(?:, *)?\(', body) + if m: + inFunc = "%s:%s %s" %(fn,lineno,m.group(1)) + elif body == "}": + if FUNC and inFunc: + show(inFunc, none, some) + none = some = 0 + inFunc = None + if re.match(r'^ *###', line): + none += 1 + elif re.match(r'^ *\d', line): + some += 1 + else: + m = re.match(r'^branch.*taken (\d+)%', line) + if m: + if int(m.group(1)) == 0: + branchNot += 1 + else: + branchTaken += 1 + + none0 += none + some0 += some + branchTaken0 += branchTaken + branchNot0 += branchNot + if FUNC: + pass + elif BRANCH: + if branchTaken or branchNot: + show(fn, branchNot, branchTaken) + else: + if some or none: + show(fn, none, some) + +if BRANCH: + if branchTaken0 or branchNot0: + show("TOTAL", branchNot0, branchTaken0) +else: + if some0 or none0: + show("TOTAL", none0, some0) diff --git a/scripts/test/scan-build.sh b/scripts/test/scan-build.sh index 623b227fe4..36e69e6d00 100644 --- a/scripts/test/scan-build.sh +++ b/scripts/test/scan-build.sh @@ -3,12 +3,9 @@ # See LICENSE for licensing information # # This script is used for running a bunch of clang scan-build checkers -# on Tor. -# -# It has hardwired paths for Nick's desktop at the moment. +# on Tor. CHECKERS="\ - --use-analyzer=/opt/clang-3.4/bin/clang \ -disable-checker deadcode.DeadStores \ -enable-checker alpha.core.CastSize \ -enable-checker alpha.core.CastToStruct \ @@ -22,28 +19,23 @@ CHECKERS="\ -enable-checker alpha.unix.cstring.NotNullTerminated \ -enable-checker alpha.unix.cstring.OutOfBounds \ -enable-checker alpha.core.FixedAddr \ - -enable-checker security.insecureAPI.strcpy + -enable-checker security.insecureAPI.strcpy \ + -enable-checker alpha.unix.PthreadLock \ + -enable-checker alpha.core.PointerArithm \ + -enable-checker alpha.core.TestAfterDivZero \ " -/opt/clang-3.4/bin/scan-build/scan-build \ +scan-build \ $CHECKERS \ - --use-analyzer=/opt/clang-3.4/bin/clang \ ./configure -/opt/clang-3.4/bin/scan-build/scan-build \ +scan-build \ $CHECKERS \ - --use-analyzer=/opt/clang-3.4/bin/clang \ - make -j2 - + make -j2 -k -# Haven't tried this yet. -# -enable-checker alpha.unix.PthreadLock # This one gives a false positive on every strcmp. # -enable-checker alpha.core.PointerSub -# This one hates it when we stick a nonzero const in a pointer. -# -enable-checker alpha.core.FixedAddr - -# This one crashes sometimes for me. -# -enable-checker alpha.deadcode.IdempotentOperations +# Needs work +# alpha.unix.MallocWithAnnotations ?? |