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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#!/bin/sh
#
# DO NOT call this file directly, use make check or make valgrind instead.
#
path=$1
mode=$2
file_tmp=._file_tmp
list_tmp=._list_tmp
sed_tmp=._sed_tmp
#valgrind_opt="--run-libc-freeres=no --show-reachable=yes --gen-suppressions=yes"
valgrind_opt="--run-libc-freeres=no --show-reachable=yes"
valgrind_all=$valgrind_opt" --leak-check=yes "
# Check tinyows binary
if [ ! -x ./tinyows ]; then
echo "No tinyows binary founded, try to run 'make' before !"
exit 1
fi
# Check tinyows binary
if [ $mode -eq 1 ]; then
if [ ! -x `which valgrind` ]; then
echo "No valgrind binary founded !"
exit 1
fi
fi
# Create unit test list
rm -f $list_tmp
for file in `ls $1`; do
if [ -f $1/$file ]; then
echo $1/$file >> $list_tmp
elif [ -f $1 ]; then
echo $1 >> $list_tmp
fi
done
# remove .out and LIST files if any
sed "/.*\.out$/d" $list_tmp > $sed_tmp && mv $sed_tmp $list_tmp
sed "/LIST$/d" $list_tmp > $sed_tmp && mv $sed_tmp $list_tmp
# run into the created list
for unit_id in `cat $list_tmp`; do
option=`cat $unit_id`
export QUERY_STRING="$option"
echo "---"
echo "Run: $unit_id"
echo "Query: $QUERY_STRING"
# Valgrind resume mode
if [ $mode -eq 1 ]; then
valgrind $valgrind_all ./tinyows 2> $file_tmp 1> /dev/null
valgrind_error=`grep ERROR $file_tmp \
| sed -e 's/^==[0-9]\+== ERROR SUMMARY: //g' \
-e 's/from.\+$//' \
-e 's/ errors //'`
valgrind_report=`(grep "definitely lost: 0 bytes in 0 blocks" $file_tmp && grep "indirectly lost: 0 bytes in 0 blocks" $file_tmp && grep "possibly lost: 0 bytes in 0 blocks" $file_tmp && grep "still reachable: 0 bytes in 0 blocks" $file_tmp) | wc -l`
valgrind_noleak=`(grep "All heap blocks were freed -- no leaks are possible" $file_tmp) | wc -l`
echo -n "$unit_id -> $valgrind_error errors "
if [ $valgrind_noleak -eq 1 -o $valgrind_report -eq 4 ] ; then
echo " | No leak detected"
else
echo " | Memory leak detected"
fi
rm -f $file_tmp
# Valgrind error mode
elif [ $mode -eq 2 ]; then
valgrind -v $valgrind_opt ./tinyows
# Valgrind leak mode
elif [ $mode -eq 3 ]; then
valgrind -v $valgrind_all ./tinyows
# Stdout mode
elif [ $mode -eq 4 ]; then
./tinyows
# http mode
elif [ $mode -eq 5 ]; then
echo $unit_id
if [ ! $TINYOWS_CONFIG_FILE ]; then
TINYOWS_CONFIG_FILE=/etc/tinyows.xml
fi
IP=`grep online_resource $TINYOWS_CONFIG_FILE | sed -e 's/.*online_resource="//' -e 's/".*//'`
FIRST_CHAR=`cat $unit_id | sed -e '2,$d' -e 's/\(.\).*/\1/'`
if [ $FIRST_CHAR = '<' ]; then
curl -D /tmp/$unit_id -s -i -H "Content-Type: text/xml" --data @$unit_id $IP
else
QUERY=`cat $unit_id`
curl -D /tmp/$unit_id -s -i "$IP?$QUERY"
fi
# Exception mode
elif [ $mode -eq 6 ]; then
ows_ret=`./tinyows 2> /dev/null | grep ExceptionText`
if [ "$ows_ret" ]; then
echo -n "$unit_id -> "
echo $ows_ret | sed -e 's/<\/ExceptionText>//' -e 's/<ExceptionText>//'
fi
# stderr mode
elif [ $mode -eq 7 ]; then
./tinyows > /dev/null 2> $file_tmp
ows_ret=`cat $file_tmp`
if [ "$ows_ret" ]; then
echo "$unit_id => stderr"
fi
rm -f $file_tmp
# regression test mode
elif [ $mode -eq 8 ]; then
path=`dirname $unit_id`
ows_ret=`./tinyows > $file_tmp && diff $file_tmp $unit_id.out | wc -l`
if [ "$ows_ret" -eq "0" ]; then
echo "$unit_id => OK"
else
echo "$unit_id => ERROR"
fi
rm -f $file_tmp
fi
done
rm -f $list_tmp
|