test-run 3.54 KB
Newer Older
1 2 3 4 5 6 7 8 9
#! /bin/sh

# This is slapped together as a quick way to run the tests and
# is not meant for prime time.  Please hack at it and submit
# changes, though, so we can gradually turn it into something
# that will run on all platforms (or incorporate it into the
# standard mysql-test-run).

# All paths below must be relative to $test_data_dir
10
top_builddir=../..
11 12 13
mysql_test_dir=$top_builddir/mysql-test
examples=$top_builddir/libmysqld/examples
mysqltest=$examples/mysqltest
14 15
datadir=$mysql_test_dir/var/master-data
test_data_dir=test
16 17 18 19 20
gdb=0
list=0
run=
tests=
start=
21
clean=1
22 23 24 25 26 27 28 29 30

cr="
"
er="\b\b\b\b\b\b\b\b"

usage () {
    cat <<EOF
usage: $0 [-g|-h|-r] [test-name ...]

31
    -C | --noclean	Do not remove old innodb and bdb files at start.
32 33 34 35 36 37 38 39
    -g | --gdb          run $mysqltest in gdb
    -h | --help         show this help
    -l | --list )       list all available tests
    -r | --run          automatically 'run' program in gdb
    -s t | --start=t    start with test t (skip all tests before t)
EOF
}

40
init_args="--server-arg=--language=$top_builddir/sql/share/english"
41 42 43 44 45 46 47 48 49 50 51 52 53
while test $# -gt 0
do
    arg=
    argset=0
    case "$1" in
        --?*=* ) arg=`echo "$1" | sed -e 's,^[^=][^=]*=,,'`; argset=1 ;;
    esac

    case "$1" in
        -g | --gdb )  gdb=1; shift;;
        -h | --help | -\? ) usage; exit 0;;
        -l | --list ) list=1 ; shift ;;
        -r | --run ) run="${cr}run"; shift;;
54
        --debug)     init_args="$init_args --debug" ; shift ;;
55
        -C | --noclean) clean=0 ; shift ;;
56 57 58 59 60 61 62 63 64 65
        -s | --start=* )
            test $argset -eq 0 && { shift; arg="$1"; }
            start="$arg"
            shift
            ;;
        -* ) usage; exit 1;;
        * ) tests="$tests $1"; shift;;
    esac
done

66 67 68
if test ! -d "$datadir/$test_data_dir"
then
    echo "bad setup (is '$datadir/$test_data_dir'', missing ?)" >&2
69
    exit 1
70
fi
71 72 73 74 75

test -n "$tests" ||
    tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
        sed -e 's,^.*/,,' -e 's,.test$,,'`

76 77 78 79 80 81 82
echo "cleaning data directory '$datadir/$test_data_dir'"
if test $clean = 1
then
  rm -f $datadir/ib_* $datadir/ibdata*
  rm -f $datadir/log.00*
fi
rm -f $datadir/../tmp/*
83 84 85 86
rm -f test-gdbinit

TZ=GMT-3; export TZ

87 88 89
# At least one of the tests needs the following environment variable
MYSQL_TEST_DIR=`( cd $mysql_test_dir ; pwd )` ; export MYSQL_TEST_DIR

90 91 92 93 94 95 96 97 98
skip=1
test -z "$start" && skip=0

for b in $tests
do
    test $list -eq 1 && { echo "  $b"; continue; }
    test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
    test $skip -eq 1 && { echo "skipping '$b'"; continue; }

99 100
    t="t/$b.test"
    r="r/$b.result"
101 102

    # Only test if $t exists; there is no $r for some tests
103 104
    test -f $mysql_test_dir/$t || {
        echo "test '$mysql_test_dir/$t' doesn't exist" >&2
105 106
        continue
    }
107 108 109 110 111 112
    args="$init_args -v --basedir=$mysql_test_dir/ -R $r -x $t --server-arg=--datadir=$datadir"
    if test -f "$mysql_test_dir/t/$b-master.opt" ; then
       args="$args --server-file=t/$b-master.opt"
    fi

    args="$args $test_data_dir"		# Add database last
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    echo "set args $args$run" > test-gdbinit
    #if false && test -n "$run"
    if test -n "$run" -o $gdb -eq 1
    then
        echo -e "$er>>> $b"
    else
        echo -e "$er>>> $b> \c"
        read junk
    fi
    if test $gdb -eq 1
    then
	if [ -x "$top_builddir/libtool" ]; then
	  $top_builddir/libtool gdb -x test-gdbinit -q $mysqltest
	else
	  gdb -x test-gdbinit -q $mysqltest
	fi
        res=$?
        rm -f test-gdbinit
    else
        $mysqltest $args
        res=$?
    fi

136
    test $res -eq 0 -o $res -eq 2 || echo "!!! error: $res"
137
done