1#! /bin/sh 2# 3# $Id: test_micro,v 1.51 2008/04/14 02:21:47 david Exp $ 4 5# build_test_micro_posix 6# Build test_micro on a POSIX system. 7build_test_micro_posix() 8{ 9 # See if there's a test_micro binary already. 10 test $clean -eq 0 && test -x test_micro && return 0 11 12 echo 'Compiling test_micro...' 13 rm -f test_micro 14 CC=${CC:-gcc} 15 if [ "$CC" = "gcc" ]; then 16 CC="$CC -O3 -Wall" 17 else 18 CC="$CC -O" 19 fi 20 $CC -I. -I.. -I../include -I../include_auto -I$h/source\ 21 $SRC -o test_micro libdb.a $LIBS || return 1 22} 23 24# build_test_micro_windows 25# Build test_micro on a Windows system. 26build_test_micro_windows() 27{ 28 # See if there's a test_micro binary already. 29 test $clean -eq 0 && test -x test_micro && return 0 30 31 echo 'Compiling test_micro...' 32 rm -f test_micro 33 cl /nologo /o test_micro /DDB_WIN32 /G6 /Ox /MD\ 34 -I.. -I../.. -I../include -I../include_auto $SRC $WINSRC\ 35 libdb*.lib ws2_32.lib advapi32.lib || return 1 36} 37 38# run -- 39# $1: args 40run() 41{ 42 # You can set the MAJOR and MINOR environment variables to limit 43 # the BDB releases on which the tests are run. 44 for i in db-${MAJOR:-[3-9]}.${MINOR:-*}.*; do 45 if [ -f $i/build_unix/libdb.a ] ; then 46 (cd $i/build_unix/ && 47 build_test_micro_posix || exit 1) 48 elif [ -f $i/build_win*/Release/libdb??.lib ] ; then 49 (cd $i/build_win*/Release && 50 build_test_micro_windows || exit 1) 51 fi 52 53 echo "$i run begins: `date`" 54 echo "test_micro $1..." 55 if [ -f $i/build_unix/libdb.a ] ; then 56 (cd $i/build_unix/ && ./test_micro $1 || exit 1) 57 elif [ -f $i/build_win*/Release/libdb??.lib ] ; then 58 (cd $i/build_win*/Release && ./test_micro $1 || exit 1) 59 fi 60 echo "$i run ends: `date`" 61 done 62} 63 64# Get a path to this shellscript. 65t=`dirname $0` 66h=`(cd $t && echo $PWD)` 67 68# We may need to re-compile, create a list of our sources. 69SRC="$h/source/b_curalloc.c $h/source/b_curwalk.c $h/source/b_del.c 70$h/source/b_get.c $h/source/b_inmem.c $h/source/b_load.c 71$h/source/b_open.c $h/source/b_put.c $h/source/b_recover.c 72$h/source/b_txn.c $h/source/b_txn_write.c $h/source/b_uname.c 73$h/source/b_util.c $h/source/b_workload.c $h/source/test_micro.c 74$h/../common/util_arg.c" 75 76WINSRC="$h/../clib/getopt.c" 77 78# Process arguments. 79clean=0 # Rebuild test_micro 80workload=0 # Run workload tests 81start_test=0 # Start test 82end_test=0 # End test 83while : 84 do case "$1" in 85 -c) # Rebuild test_micro. 86 clean=1 87 shift;; 88 -w) # Run workload tests 89 workload=1 90 shift;; 91 [1-9]*-[0-9]*) # Range: -3, 3-, 3-10 92 start_test=`echo $1|sed 's/-.*//'` 93 start_test=${start_test:=1} 94 end_test=`echo $1|sed 's/.*-//'` 95 end_test=${end_test:=0} 96 shift;; 97 [1-9]*) # Specific test 98 start_test="$1" 99 end_test="$1" 100 shift;; 101 *) 102 break;; 103 esac 104done 105test "$#" -ne 0 && { 106 echo 'usage: test_micro [-cw] [# | #- | -# | #-#]' >& 2 107 exit 1 108} 109 110if test $start_test != 0; then 111 cmd="$cmd -s $start_test" 112fi 113if test $end_test != 0; then 114 cmd="$cmd -e $end_test" 115fi 116 117# Create the run directory, and initialize test_micro's arguments. 118t=RUN.`hostname | sed 's/\..*//'` 119[ -d $t ] || mkdir $t 120cmd="$cmd -d `(cd $t && pwd)`" 121 122# Set input file. 123if test "$workload" -eq 1; then 124 cmd="$cmd -i $h/configs/run.workload" 125else 126 cmd="$cmd -i $h/configs/run.std" 127fi 128 129# Flush any I/O, just to get as a clean a timing as we can, ignore errors, 130# sync is privleged on some systems. 131(sync && sleep 1 2>&1) > /dev/null 132 133run "$cmd" 134 135exit 0 136