#!/bin/bash
#
# This runs dwarfgen/libdwarf with a malloc failure
# at the $ct'th call to malloc.
# To expose errors in malloc failure handling.
# Probably any small C file compiled -c will do
# to produce test.o For example just use a .o
# generated by the build of dwarfgen
subj=test.o
ct=0
while [ $ct -lt 500 ]
do
echo '===== START TEST'
rm -f core
rm -f dwarfgen
sed -e "s/FAILCOUNT/$ct/" <fakemalloc.in >fakemalloc.c
echo TEST $ct
grep if fakemalloc.c
make
./dwarfgen -h -t obj -c 0 -o $subj ./dwarfgen >junk.x
cat junk.x
if [ -f core ]
then
echo "CORE FILE EXISTS, test" $ct
fi
rm -f core
echo '===== END TEST'
ct=`expr $ct + 1`
done