1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/bin/bash
# Out-Of-Memory Test
#
# This script is used to test that the lrcalc library does not leak
# memory, even when an out-of-memory event happens in the middle of
# a calculation.
#
# Instructions:
#
# ./configure CFLAGS="-DDEBUG"
# make clean; make
# cd tests
# ./oomtest.sh ../src/lrcalc mult 1 - 1
# ./oomtest.sh ../src/schubmult 2 1 - 2 1
#
# Any output from oomtest.sh will indicate a problem.
verbose=0
if [[ $1 = "-v" ]]; then
verbose=1
shift
fi
if [[ $# = 0 ]]; then
echo "usage: oomtest.sh [-v] command [options ...]" 1>&2
exit 1
fi
failnum=1
while true; do
out=$(ML_FAIL_NUMBER=$failnum "$@" 2>&1)
if [[ $verbose != 0 ]]; then
echo "----"
echo "ML_FAIL_NUMBER=$failnum $@"
echo "$out"
fi
err=""
if [[ -z $out ]]; then
err="no output"
fi;
if [[ -z $err ]]; then
err=$(echo "$out" | grep "malloc called after out-of-memory")
fi
if [[ -z $err ]]; then
err=$(echo "$out" | egrep "Memory balance: [^0]")
fi
if [[ -n $err ]]; then
echo "$failnum: $err"
fi
if [[ -z $err ]]; then
err=$(echo "$out" | grep "out of memory")
fi;
bal=$(echo "$out" | grep "Memory balance: 0")
if [[ -z "$err" && -n $bal ]]; then
break
fi
failnum=$((failnum + 1))
done
|