| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Copyright 2018 Norbert Preining |
| 4 |
# License: GPL3+ |
| 5 |
# |
| 6 |
# test cafeobj with with memo on/off and sbcl/acl |
| 7 |
# against a set of .mod files from a given directory (first argument) |
| 8 |
# Usage: |
| 9 |
# run-all-checks PATH-TO-DIR-WITH-MOD-FILES |
| 10 |
# Generates lots of .log files for each combination and test |
| 11 |
# Generates a file |
| 12 |
# result.YYYYMMDDHHMMSS.csv |
| 13 |
# containing the results |
| 14 |
|
| 15 |
timeout=10m |
| 16 |
|
| 17 |
dn=$(dirname $0) |
| 18 |
|
| 19 |
if [ "$1" = "-no-run" ] ; then |
| 20 |
runco=false |
| 21 |
shift |
| 22 |
else |
| 23 |
runco=true |
| 24 |
fi |
| 25 |
|
| 26 |
output=results.$(date '+%Y%m%d%H%M%S').csv |
| 27 |
if [ -r $output ] ; then |
| 28 |
echo "$output already present, exiting" >&2 |
| 29 |
exit 1 |
| 30 |
fi |
| 31 |
|
| 32 |
echo "test,sbcl,,,,acl,,," > $output |
| 33 |
echo ",memo on,,memo off,,memo on,,memo off," >> $output |
| 34 |
echo ",result,time,result,time,result,time,result,time" >> $output |
| 35 |
|
| 36 |
if [ ! -d "$1" ] ; then |
| 37 |
echo "Not a directory: $1" >&2 |
| 38 |
exit 1 |
| 39 |
fi |
| 40 |
|
| 41 |
function shipout_run_data { |
| 42 |
testname=$1 |
| 43 |
if [ ! -r $testname.sbcl.memo-off.log ] ; then |
| 44 |
return |
| 45 |
fi |
| 46 |
declare -A ret |
| 47 |
declare -A tim |
| 48 |
for e in sbcl acl ; do |
| 49 |
for m in on off ; do |
| 50 |
ret[${e},${m}]=$(get_exit_status $testname.$e.memo-$m.log) |
| 51 |
tim[${e},${m}]=$(get_elapsed_time $testname.$e.memo-$m.log) |
| 52 |
if [ -n "${ret[${e},${m}]}" ] ; then |
| 53 |
set $(echo ${ret[${e},${m}]} | sed -e 's/:/ /') |
| 54 |
# echo "e=$e, m=$m ret=${ret[${e},${m}]}, 1=$1, 2=$2" |
| 55 |
if [ "$1" = "OK" ] ; then |
| 56 |
ret[${e},${m}]="OK" |
| 57 |
else |
| 58 |
ret[${e},${m}]="$1 ($2)" |
| 59 |
fi |
| 60 |
fi |
| 61 |
done |
| 62 |
done |
| 63 |
echo "$testname,${ret[sbcl,on]},${tim[sbcl,on]},${ret[sbcl,off]},${tim[sbcl,off]},${ret[acl,on]},${tim[acl,on]},${ret[acl,off]},${tim[acl,off]}" >> $output |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
function get_exit_status { |
| 68 |
local result |
| 69 |
local errtype |
| 70 |
if grep -q "Command exited with non-zero status 124" $1 ; then |
| 71 |
result="ERROR" |
| 72 |
errtype="timeout" |
| 73 |
elif grep -q "more bytes of heap" $1 ; then |
| 74 |
# ACL heap error |
| 75 |
result="ERROR" |
| 76 |
errtype="heap" |
| 77 |
elif grep -q "Heap exhausted" $1 ; then |
| 78 |
# SBCL heap error |
| 79 |
result="ERROR" |
| 80 |
errtype="heap" |
| 81 |
elif grep -q "Stack overflow" $1 ; then |
| 82 |
# ACL stack |
| 83 |
result="ERROR" |
| 84 |
errtype="stack" |
| 85 |
elif grep -q "Control stack exhausted" $1 ; then |
| 86 |
result="ERROR" |
| 87 |
errtype="stack" |
| 88 |
elif grep -q "Caught an exception" $1 ; then |
| 89 |
result="ERROR" |
| 90 |
errtype="unknown" |
| 91 |
elif grep -q "Leaving CafeOBJ" $1 ; then |
| 92 |
result=OK |
| 93 |
else |
| 94 |
result=ERROR |
| 95 |
errtype=??? |
| 96 |
fi |
| 97 |
echo "$result:$errtype" |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
function get_elapsed_time { |
| 102 |
# 22.52user 1.95system 0:24.47elapsed 99%CPU (0avgtext+0avgdata 17612maxresident)k |
| 103 |
# 0inputs+9845072outputs (0major+1788minor)pagefaults 0swaps |
| 104 |
# format of elapsed time is [hours:]minutes:seconds[.subseconds] |
| 105 |
elapsedTime=$(tail -5 $1 | grep elapsed | awk '{print$3}' | sed -e 's/elapsed$//') |
| 106 |
echo "$elapsedTime" |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
for i in "$1"/*.mod ; do |
| 111 |
bn=`basename "$i" .mod` |
| 112 |
echo -n "$bn: " |
| 113 |
echo -n "sbcl/memo-off " |
| 114 |
$runco && /usr/bin/time timeout $timeout $dn/cafeobj-memo off $i sbcl > $bn.sbcl.memo-off.log 2>&1 |
| 115 |
echo -n "sbcl/memo-on " |
| 116 |
$runco && /usr/bin/time timeout $timeout $dn/cafeobj-memo on $i sbcl > $bn.sbcl.memo-on.log 2>&1 |
| 117 |
echo -n "acl/memo-off " |
| 118 |
$runco && /usr/bin/time timeout $timeout $dn/cafeobj-memo off $i acl-standalone > $bn.acl.memo-off.log 2>&1 |
| 119 |
echo -n "acl/memo-on " |
| 120 |
$runco && /usr/bin/time timeout $timeout $dn/cafeobj-memo on $i acl-standalone > $bn.acl.memo-on.log 2>&1 |
| 121 |
shipout_run_data $bn |
| 122 |
echo "done" |
| 123 |
done |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
# vim:set tabstop=2 expandtab: # |