~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to libmysqld/examples/test-run

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# Copyright (C) 2001, 2006 MySQL AB
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; version 2 of the License.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
17
 
 
18
# This is slapped together as a quick way to run the tests and
 
19
# is not meant for prime time.  Please hack at it and submit
 
20
# changes, though, so we can gradually turn it into something
 
21
# that will run on all platforms (or incorporate it into the
 
22
# standard mysql-test-run).
 
23
 
 
24
# All paths below must be relative to $test_data_dir
 
25
top_builddir=../..
 
26
mysql_test_dir=$top_builddir/mysql-test
 
27
examples=$top_builddir/libmysqld/examples
 
28
mysqltest=$examples/mysqltest_embedded
 
29
datadir=$mysql_test_dir/var/master-data
 
30
test_data_dir=test
 
31
gdb=0
 
32
list=0
 
33
run=
 
34
tests=
 
35
start=
 
36
clean=1
 
37
 
 
38
cr="
 
39
"
 
40
er="\b\b\b\b\b\b\b\b"
 
41
 
 
42
usage () {
 
43
    cat <<EOF
 
44
usage: $0 [-g|-h|-r] [test-name ...]
 
45
 
 
46
    -C | --noclean      Do not remove old innodb and bdb files at start.
 
47
    -g | --gdb          run $mysqltest in gdb
 
48
    -h | --help         show this help
 
49
    -l | --list )       list all available tests
 
50
    -r | --run          automatically 'run' program in gdb
 
51
    -s t | --start=t    start with test t (skip all tests before t)
 
52
EOF
 
53
}
 
54
 
 
55
init_args="--server-arg=--language=$top_builddir/sql/share/english"
 
56
while test $# -gt 0
 
57
do
 
58
    arg=
 
59
    argset=0
 
60
    case "$1" in
 
61
        --?*=* ) arg=`echo "$1" | sed -e 's,^[^=][^=]*=,,'`; argset=1 ;;
 
62
    esac
 
63
 
 
64
    case "$1" in
 
65
        -g | --gdb )  gdb=1; shift;;
 
66
        -h | --help | -\? ) usage; exit 0;;
 
67
        -l | --list ) list=1 ; shift ;;
 
68
        -r | --run ) run="${cr}run"; shift;;
 
69
        --debug)     init_args="$init_args --debug" ; shift ;;
 
70
        -C | --noclean) clean=0 ; shift ;;
 
71
        -s | --start=* )
 
72
            test $argset -eq 0 && { shift; arg="$1"; }
 
73
            start="$arg"
 
74
            shift
 
75
            ;;
 
76
        -* ) usage; exit 1;;
 
77
        * ) tests="$tests $1"; shift;;
 
78
    esac
 
79
done
 
80
 
 
81
if test ! -d "$datadir/$test_data_dir"
 
82
then
 
83
    echo "bad setup (is '$datadir/$test_data_dir'', missing ?)" >&2
 
84
    exit 1
 
85
fi
 
86
 
 
87
test -n "$tests" ||
 
88
    tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
 
89
        sed -e 's,^.*/,,' -e 's,.test$,,'`
 
90
 
 
91
echo "cleaning data directory '$datadir/$test_data_dir'"
 
92
if test $clean = 1
 
93
then
 
94
  rm -f $datadir/ib_* $datadir/ibdata*
 
95
  rm -f $datadir/log.00*
 
96
  rm -f $datadir/test/*.db
 
97
fi
 
98
rm -f $datadir/../tmp/*
 
99
rm -f test-gdbinit
 
100
 
 
101
TZ=GMT-3; export TZ
 
102
 
 
103
# At least one of the tests needs the following environment variable
 
104
MYSQL_TEST_DIR=`( cd $mysql_test_dir ; pwd )` ; export MYSQL_TEST_DIR
 
105
 
 
106
skip=1
 
107
test -z "$start" && skip=0
 
108
 
 
109
for b in $tests
 
110
do
 
111
    test $list -eq 1 && { echo "  $b"; continue; }
 
112
    test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
 
113
    test $skip -eq 1 && { echo "skipping '$b'"; continue; }
 
114
 
 
115
    t="t/$b.test"
 
116
    r="r/$b.result"
 
117
 
 
118
    # Only test if $t exists; there is no $r for some tests
 
119
    test -f $mysql_test_dir/$t || {
 
120
        echo "test '$mysql_test_dir/$t' doesn't exist" >&2
 
121
        continue
 
122
    }
 
123
    args="$init_args -v --basedir=$mysql_test_dir/ -R $r -x $t --server-arg=--datadir=$datadir"
 
124
    if test -f "$mysql_test_dir/t/$b-master.opt" ; then
 
125
       args="$args --server-file=t/$b-master.opt"
 
126
    fi
 
127
 
 
128
    args="$args $test_data_dir"         # Add database last
 
129
    echo "set args $args$run" > test-gdbinit
 
130
    #if false && test -n "$run"
 
131
    if test -n "$run" -o $gdb -eq 1
 
132
    then
 
133
        echo -e "$er>>> $b"
 
134
    else
 
135
        echo -e "$er>>> $b> \c"
 
136
        read junk
 
137
    fi
 
138
    if test $gdb -eq 1
 
139
    then
 
140
        if [ -x "$top_builddir/libtool" ]; then
 
141
          $top_builddir/libtool gdb -x test-gdbinit -q $mysqltest
 
142
        else
 
143
          gdb -x test-gdbinit -q $mysqltest
 
144
        fi
 
145
        res=$?
 
146
        rm -f test-gdbinit
 
147
    else
 
148
        $mysqltest $args
 
149
        res=$?
 
150
    fi
 
151
 
 
152
    test $res -eq 0 -o $res -eq 2 || echo "!!! error: $res"
 
153
done