LIBS=${LIBS:-"-lpthread"}
WINBUILDDIR="Win32/Release"
CYGWIN=0
HOSTOS="`uname -o 2>/dev/null||uname -s 2>/dev/null`"
if test `echo "$HOSTOS"|grep -i cygwin|wc -l` -gt 0;then
CYGWIN=1
fi
build_test_micro_posix()
{
test $clean -eq 0 && test -x test_micro && return 0
echo 'Compiling test_micro on posix system...'
rm -f test_micro
CC=${CC:-gcc}
if [ "$CC" = "gcc" ]; then
CC="$CC -O3 -Wall"
else
CC="$CC -O"
fi
$CC -I. -I../src/dbinc -I../src/dbinc_auto -I.. -I../src -I$h/source \
$SRC -o test_micro ./libdb.a $LIBS || return 1
}
build_test_micro_windows()
{
test $clean -eq 0 && test -x test_micro && return 0
echo 'Compiling test_micro on windows ...'
rm -f test_micro
cl /nologo /o test_micro /DDB_WIN32 /G6 /Ox /MD\
-I./ -I../ -I../src/ -I$h/source/ -I../src/dbinc -I../src/dbinc_auto \
$SRC $WINSRC ./$WINBUILDDIR/libdb*.lib ./Release/libdb*.lib \
ws2_32.lib advapi32.lib
}
run()
{
echo Versions db-${MAJOR:-[3-9]}.${MINOR:-*}.*
for i in db-${MAJOR:-[3-9]}.${MINOR:-*}.*; do
major=`echo $i|sed "s/db-//g"|cut -d . -f 1`
minor=`echo $i|sed "s/db-//g"|cut -d . -f 2`
if test $major -gt "4";then
WINBUILDDIR="Win32/Release"
elif test $major -lt "4";then
WINBUILDDIR="Release"
elif test "X$minor" = "X" -o "$minor" -lt "8";then
WINBUILDDIR="Release"
else
WINBUILDDIR="Win32/Release"
fi
if [ -f $i/$variant/libdb.a ] ; then
(cd $i/$variant/ &&
build_test_micro_posix || exit 1)
elif [ -f $i/build_windows/${WINBUILDDIR}/libdb??.lib ] ; then
(cd $i/build_windows &&
build_test_micro_windows || exit 1)
fi
echo "$i run begins: `date`"
echo "test_micro $1..."
if [ -f $i/$variant/libdb.a ] ; then
(cd $i/$variant/ && ./test_micro $1 || exit 1)
if [ -f $t/gmon.out ] ; then
mv $t/gmon.out $i/$variant
gprof $i/$variant/.libs/lt-test_micro $i/$variant/gmon.out > $i/$variant/gprof.out
fi
elif [ -f $i/build_windows/${WINBUILDDIR}/libdb??.lib ] ; then
(cd $i/build_windows/ && ./test_micro $1 || exit 1)
fi
echo "$i run ends: `date`"
done
}
t=`dirname $0`
h=`(cd $t && pwd)`
if [ "$CYGWIN" = "1" ];then
h="`cygpath -m -a \"$h\"`"
fi
SRC="$h/source/b_curalloc.c $h/source/b_curwalk.c $h/source/b_del.c
$h/source/b_get.c $h/source/b_inmem.c $h/source/b_load.c $h/source/b_latch.c
$h/source/b_open.c $h/source/b_put.c $h/source/b_recover.c
$h/source/b_txn.c $h/source/b_txn_write.c $h/source/b_uname.c
$h/source/b_util.c $h/source/b_workload.c $h/source/test_micro.c
$h/../../src/common/util_arg.c"
WINSRC="$h/../../src/clib/getopt.c"
clean=0 workload=0 start_test=0 end_test=0 variant=build_unix
while :
do case "$1" in
-c) clean=1
shift;;
-w) workload=1
shift;;
[1-9]*-[0-9]*) start_test=`echo $1|sed 's/-.*//'`
start_test=${start_test:=1}
end_test=`echo $1|sed 's/.*-//'`
end_test=${end_test:=0}
shift;;
[1-9]*) start_test="$1"
end_test="$1"
shift;;
-v) variant=$2 shift; shift;;
*)
break;;
esac
done
test "$#" -ne 0 && {
echo 'usage: test_micro [-cw] [# | #- | -# | #-#]' >& 2
exit 1
}
if test $start_test != 0; then
cmd="$cmd -s $start_test"
fi
if test $end_test != 0; then
cmd="$cmd -e $end_test"
fi
t=RUN.`hostname | sed 's/\..*//'`
[ -d $t ] || mkdir $t
if [ "$CYGWIN" = "1" ];then
cmd="$cmd -d `(cd $t && cygpath -m -a \"$PWD\")`"
else
cmd="$cmd -d `(cd $t && pwd)`"
fi
if test "$workload" -eq 1; then
cmd="$cmd -i $h/configs/run.workload"
else
cmd="$cmd -i $h/configs/run.std"
fi
(sync && sleep 1 2>&1) > /dev/null
run "$cmd"
exit 0