blob: e20eb4e08692680ed8902b6521f60d059712ae71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
|
#! /bin/sh
# mysql-test-run - originally written by Matt Wagner <matt@mysql.com>
# modified by Sasha Pachev <sasha@mysql.com>
# Sligtly updated by Monty
# Cleaned up again by Matt
# Fixed by Sergei
# :-)
#++
# Access Definitions
#--
DB=test
DBPASSWD=
VERBOSE=""
TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
#++
# Program Definitions
#--
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin
# Standard functions
which ()
{
IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
for file
do
for dir in $PATH
do
if test -f $dir/$file
then
echo "$dir/$file"
continue 2
fi
done
echo "which: no $file in ($PATH)"
exit 1
done
IFS="$save_ifs"
}
# No paths below as we can't be sure where the program is!
BASENAME=`which basename | head -1`
DIFF=`which diff | head -1`
CAT=cat
CUT=cut
TAIL=tail
ECHO=echo # use internal echo if possible
EXPR=expr # use internal if possible
FIND=find
GCOV=`which gcov | head -1`
PRINTF=printf
RM=rm
TIME=time
TR=tr
XARGS=`which xargs | head -1`
SED=sed
# Are we using a source or a binary distribution?
testdir=@testdir@
if [ -d bin/mysqld ] && [ -d mysql-test ] ; then
cd mysql-test
else
if [ -d $testdir/mysql-test ] ; then
cd $testdir
fi
fi
if [ ! -f ./mysql-test-run ] ; then
$ECHO "Can't find the location for the mysql-test-run script"
$ECHO "Go to to the mysql-test directory and execute the script as follows:"
$ECHO "./mysql-test-run."
exit 1
fi
#++
# Misc. Definitions
#--
if [ -d ../sql ] ; then
SOURCE_DIST=1
else
BINARY_DIST=1
fi
#BASEDIR is always one above mysql-test directory
CWD=`pwd`
cd ..
BASEDIR=`pwd`
cd $CWD
MYSQL_TEST_DIR=$BASEDIR/mysql-test
export MYSQL_TEST_DIR
STD_DATA=$MYSQL_TEST_DIR/std_data
hostname=`hostname` # Installed in the mysql privilege table
TESTDIR="$MYSQL_TEST_DIR/t"
TESTSUFFIX=test
TOT_SKIP=0
TOT_PASS=0
TOT_FAIL=0
TOT_TEST=0
USERT=0
SYST=0
REALT=0
MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
SLAVE_LOAD_TMPDIR=../../var/tmp #needs to be same length to test logging
RES_SPACE=" "
MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
myisammrg heap sql"
MASTER_RUNNING=0
MASTER_MYPORT=9306
SLAVE_RUNNING=0
SLAVE_MYPORT=9307
NO_SLAVE=0
EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
USE_RUNNING_SERVER=1
DO_GCOV=""
DO_GDB=""
DO_DDD=""
DO_CLIENT_GDB=""
SLEEP_TIME=2
CHARACTER_SET=latin1
DBUSER=""
while test $# -gt 0; do
case "$1" in
--user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
--force) FORCE=1 ;;
--local) USE_RUNNING_SERVER="" ;;
--tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
--master_port=*) MASTER_MYPORT=`$ECHO "$1" | $SED -e "s;--master_port=;;"` ;;
--slave_port=*) SLAVE_MYPORT=`$ECHO "$1" | $SED -e "s;--slave_port=;;"` ;;
--with-openssl)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \
--ssl-ca=$BASEDIR/SSL/cacert.pem \
--ssl-cert=$BASEDIR/SSL/server-cert.pem \
--ssl-key=$BASEDIR/SSL/server-key.pem"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT \
--ssl-ca=$BASEDIR/SSL/cacert.pem \
--ssl-cert=$BASEDIR/SSL/server-cert.pem \
--ssl-key=$BASEDIR/SSL/server-key.pem" ;;
--skip-innobase)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;;
--skip-bdb)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-bdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-bdb" ;;
--skip-rpl) NO_SLAVE=1 ;;
--skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;;
--do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;;
--record)
RECORD=1;
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--bench)
DO_BENCH=1
NO_SLAVE=1
;;
--big*) # Actually --big-test
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--sleep=*)
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1"
SLEEP_TIME=`$ECHO "$1" | $SED -e "s;--sleep=;;"`
;;
--mysqld=*)
TMP=`$ECHO "$1" | $SED -e "s;--mysqld=;;"`
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $TMP"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $TMP"
;;
--gcov )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Cannot do coverage test without the source - please use source dist"
exit 1
fi
DO_GCOV=1
;;
--gprof )
DO_GPROF=1
;;
--gdb )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --gdb option"
fi
DO_GDB=1
USE_RUNNING_SERVER=""
;;
--client-gdb )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --client-gdb option"
fi
DO_CLIENT_GDB=1
;;
--ddd )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option"
fi
DO_DDD=1
USE_RUNNING_SERVER=""
;;
--skip-*)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $1"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $1"
;;
--debug)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \
--debug=d:t:O,$MYSQL_TEST_DIR/var/log/master.trace"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT \
--debug=d:t:O,$MYSQL_TEST_DIR/var/log/slave.trace"
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --debug"
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
* ) break ;;
esac
shift
done
#++
# mysqld Environment Parameters
#--
MYRUN_DIR=$MYSQL_TEST_DIR/var/run
MASTER_MYDDIR="$MYSQL_TEST_DIR/var/master-data"
MASTER_MYSOCK="$MYSQL_TMP_DIR/mysql-master.sock"
MASTER_MYPID="$MYRUN_DIR/mysqld.pid"
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
SLAVE_MYSOCK="$MYSQL_TMP_DIR/mysql-slave.sock"
SLAVE_MYPID="$MYRUN_DIR/mysqld-slave.pid"
SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
SMALL_SERVER="-O key_buffer_size=1M -O sort_buffer=256K -O max_heap_table_size=1M"
export MASTER_MYPORT
export SLAVE_MYPORT
if [ x$SOURCE_DIST = x1 ] ; then
MY_BASEDIR=$MYSQL_TEST_DIR
else
MY_BASEDIR=$BASEDIR
fi
# Create the directories
# This should be fixed to be not be dependent on the contence of MYSQL_TMP_DIR
# or MYRUN_DIR
# (mkdir -p is not portable)
[ -d $MYSQL_TEST_DIR/var ] || mkdir $MYSQL_TEST_DIR/var
[ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp
[ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run
[ -z "$COLUMNS" ] && COLUMNS=80
E=`$EXPR $COLUMNS - 8`
#DASH72=`$EXPR substr '------------------------------------------------------------------------' 1 $E`
DASH72=`$ECHO '------------------------------------------------------------------------'|$CUT -c 1-$E`
# on source dist, we pick up freshly build executables
# on binary, use what is installed
if [ x$SOURCE_DIST = x1 ] ; then
MYSQLD="$BASEDIR/sql/mysqld"
if [ -e "$BASEDIR/client/.libs/mysqltest" ] ; then
[ -e "$BASEDIR/client/.libs/lt-mysqltest" ] || $BASEDIR/client/mysqltest -V
MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
else
MYSQL_TEST="$BASEDIR/client/mysqltest"
fi
MYSQLADMIN="$BASEDIR/client/mysqladmin"
MYSQL="$BASEDIR/client/mysql"
LANGUAGE="$BASEDIR/sql/share/english/"
CHARSETSDIR="$BASEDIR/sql/share/charsets"
INSTALL_DB="./install_test_db"
else
MYSQLD="$BASEDIR/bin/mysqld"
MYSQL_TEST="$BASEDIR/bin/mysqltest"
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin"
if test -d "$BASEDIR/share/mysql/english"
then
LANGUAGE="$BASEDIR/share/mysql/english/"
CHARSETSDIR="$BASEDIR/share/mysql/charsets"
else
LANGUAGE="$BASEDIR/share/english/"
CHARSETSDIR="$BASEDIR/share/charsets"
fi
fi
# If we should run all tests cases, we will use a local server for that
if [ -z "$1" ]
then
USE_RUNNING_SERVER=""
fi
if [ -n "$USE_RUNNING_SERVER" ]
then
MASTER_MYSOCK="/tmp/mysql.sock"
DBUSER=${DBUSER:-test}
else
DBUSER=${DBUSER:-root} # We want to do FLUSH xxx commands
fi
if [ -w / ]
then
# We are running as root; We need to add the --root argument
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --user=root"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root"
fi
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent -v --tmpdir=$MYSQL_TMP_DIR"
MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
GDB_MASTER_INIT=$MYSQL_TMP_DIR/gdbinit.master
GDB_SLAVE_INIT=$MYSQL_TMP_DIR/gdbinit.slave
GCOV_MSG=$MYSQL_TMP_DIR/mysqld-gcov.out
GCOV_ERR=$MYSQL_TMP_DIR/mysqld-gcov.err
GPROF_DIR=$MYSQL_TMP_DIR/gprof
GPROF_MASTER=$GPROF_DIR/master.gprof
GPROF_SLAVE=$GPROF_DIR/slave.gprof
TIMEFILE="$MYSQL_TMP_DIR/mysqltest-time"
SLAVE_MYSQLD=$MYSQLD #this can be changed later if we are doing gcov
#++
# Function Definitions
#--
wait_for_server_start ()
{
$MYSQLADMIN --no-defaults -u $DBUSER --silent -O connect_timeout=10 -w2 --host=$hostname --port=$1 ping >/dev/null 2>&1
}
prompt_user ()
{
$ECHO $1
read unused
}
# We can't use diff -u as this isn't portable
show_failed_diff ()
{
reject_file=r/$1.reject
result_file=r/$1.result
eval_file=r/$1.eval
if [ -f $eval_file ]
then
result_file=$eval_file
fi
if [ -x "$DIFF" ] && [ -f $reject_file ]
then
echo "Below are the diffs between actual and expected results:"
echo "-------------------------------------------------------"
$DIFF -c -a $result_file $reject_file
echo "-------------------------------------------------------"
echo "Please follow the instructions outlined at"
echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
echo "to find the reason to this problem and how to report this."
fi
}
do_gdb_test ()
{
mysql_test_args="$MYSQL_TEST_ARGS $1"
$ECHO "set args $mysql_test_args < $2" > $GDB_CLIENT_INIT
echo "Set breakpoints ( if needed) and type 'run' in gdb window"
#this xterm should not be backgrounded
xterm -title "Client" -e gdb -x $GDB_CLIENT_INIT $MYSQL_TEST_BIN
}
error () {
$ECHO "Error: $1"
exit 1
}
error_is () {
$TR "\n" " " < $TIMEFILE | $SED -e 's/.* At line \(.*\)\: \(.*\)Command .*$/ \>\> Error at line \1: \2<\</'
}
prefix_to_8() {
$ECHO " $1" | $SED -e 's:.*\(........\)$:\1:'
}
pass_inc () {
TOT_PASS=`$EXPR $TOT_PASS + 1`
}
fail_inc () {
TOT_FAIL=`$EXPR $TOT_FAIL + 1`
}
skip_inc () {
TOT_SKIP=`$EXPR $TOT_SKIP + 1`
}
total_inc () {
TOT_TEST=`$EXPR $TOT_TEST + 1`
}
report_stats () {
if [ $TOT_FAIL = 0 ]; then
$ECHO "All $TOT_TEST tests were successful."
else
xten=`$EXPR $TOT_PASS \* 10000`
raw=`$EXPR $xten / $TOT_TEST`
raw=`$PRINTF %.4d $raw`
whole=`$PRINTF %.2s $raw`
xwhole=`$EXPR $whole \* 100`
deci=`$EXPR $raw - $xwhole`
$ECHO "Failed ${TOT_FAIL}/${TOT_TEST} tests, ${whole}.${deci}% successful."
$ECHO ""
$ECHO "The log files in $MYSQL_TEST_DIR/var/log may give you some hint"
$ECHO "of what when wrong."
$ECHO "If you want to report this error, please read first the documentation at"
$ECHO "http://www.mysql.com/doc/M/y/MySQL_test_suite.html"
fi
}
mysql_install_db () {
$ECHO "Removing Stale Files"
$RM -rf $MASTER_MYDDIR $SLAVE_MYDDIR $SLAVE_MYLOG $MASTER_MYLOG \
$SLAVE_MYERR $MASTER_MYERR
$ECHO "Installing Master Databases"
$INSTALL_DB
if [ $? != 0 ]; then
error "Could not install master test DBs"
exit 1
fi
$ECHO "Installing Slave Databases"
$INSTALL_DB -slave
if [ $? != 0 ]; then
error "Could not install slave test DBs"
exit 1
fi
# Give mysqld some time to die.
sleep $SLEEP_TIME
return 0
}
gprof_prepare ()
{
rm -rf $GPROF_DIR
mkdir -p $GPROF_DIR
}
gprof_collect ()
{
if [ -f $MASTER_MYDDIR/gmon.out ]; then
gprof $MYSQLD $MASTER_MYDDIR/gmon.out > $GPROF_MASTER
echo "Master execution profile has been saved in $GPROF_MASTER"
fi
if [ -f $SLAVE_MYDDIR/gmon.out ]; then
gprof $MYSQLD $SLAVE_MYDDIR/gmon.out > $GPROF_SLAVE
echo "Slave execution profile has been saved in $GPROF_SLAVE"
fi
}
gcov_prepare () {
$FIND $BASEDIR -name \*.gcov \
-or -name \*.da | $XARGS $RM
}
gcov_collect () {
$ECHO "Collecting source coverage info..."
[ -f $GCOV_MSG ] && $RM $GCOV_MSG
[ -f $GCOV_ERR ] && $RM $GCOV_ERR
for d in $MYSQLD_SRC_DIRS; do
cd $BASEDIR/$d
for f in *.h *.cc *.c; do
$GCOV $f 2>>$GCOV_ERR >>$GCOV_MSG
done
cd $MYSQL_TEST_DIR
done
$ECHO "gcov info in $GCOV_MSG, errors in $GCOV_ERR"
}
start_master()
{
[ x$MASTER_RUNNING = 1 ] && return
#run master initialization shell script if one exists
if [ -f "$master_init_script" ] ;
then
/bin/sh $master_init_script
fi
cd $BASEDIR # for gcov
# Remove old berkeley db log files that can confuse the server
$RM -f $MASTER_MYDDIR/log.*
#start master
if [ -z "$DO_BENCH" ]
then
master_args="--no-defaults --log-bin=master-bin \
--server-id=1 \
--basedir=$MY_BASEDIR \
--port=$MASTER_MYPORT \
--exit-info=256 \
--datadir=$MASTER_MYDDIR \
--pid-file=$MASTER_MYPID \
--socket=$MASTER_MYSOCK \
--log=$MASTER_MYLOG \
--character-sets-dir=$CHARSETSDIR \
--default-character-set=$CHARACTER_SET \
--tmpdir=$MYSQL_TMP_DIR \
--language=$LANGUAGE \
--innodb_data_file_path=ibdata1:50M \
$SMALL_SERVER \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
else
master_args="--no-defaults --log-bin=master-bin --server-id=1 \
--basedir=$MY_BASEDIR \
--port=$MASTER_MYPORT \
--datadir=$MASTER_MYDDIR \
--pid-file=$MASTER_MYPID \
--socket=$MASTER_MYSOCK \
--character-sets-dir=$CHARSETSDIR \
--default-character-set=$CHARACTER_SET \
--core \
--tmpdir=$MYSQL_TMP_DIR \
--language=$LANGUAGE \
--innodb_data_file_path=ibdata1:50M \
$SMALL_SERVER \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
fi
if [ x$DO_DDD = x1 ]
then
$ECHO "set args $master_args" > $GDB_MASTER_INIT
ddd --debugger "gdb -x $GDB_MASTER_INIT" $MYSQLD &
prompt_user "Hit enter to continue after you've started the master"
elif [ x$DO_GDB = x1 ]
then
$ECHO "set args $master_args" > $GDB_MASTER_INIT
xterm -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD &
prompt_user "Hit enter to continue after you've started the master"
else
$MYSQLD $master_args >> $MASTER_MYERR 2>&1 &
fi
wait_for_server_start $MASTER_MYPORT
MASTER_RUNNING=1
}
start_slave()
{
[ x$SKIP_SLAVE = x1 ] && return
[ x$SLAVE_RUNNING = 1 ] && return
#run slave initialization shell script if one exists
if [ -f "$slave_init_script" ] ;
then
/bin/sh $slave_init_script
fi
if [ -z "$SLAVE_MASTER_INFO" ] ; then
master_info="--master-user=root \
--master-connect-retry=1 \
--master-host=127.0.0.1 \
--master-password= \
--master-port=$MASTER_MYPORT \
--server-id=2"
else
master_info=$SLAVE_MASTER_INFO
fi
$RM -f $SLAVE_MYDDIR/log.*
slave_args="--no-defaults $master_info \
--exit-info=256 \
--log-bin=slave-bin --log-slave-updates \
--basedir=$MY_BASEDIR \
--datadir=$SLAVE_MYDDIR \
--pid-file=$SLAVE_MYPID \
--port=$SLAVE_MYPORT \
--socket=$SLAVE_MYSOCK \
--log=$SLAVE_MYLOG \
--character-sets-dir=$CHARSETSDIR \
--default-character-set=$CHARACTER_SET \
--core \
--tmpdir=$MYSQL_TMP_DIR \
--language=$LANGUAGE \
--skip-innodb --skip-slave-start \
--slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \
--report-host=127.0.0.1 --report-user=root \
--report-port=$SLAVE_MYPORT \
$SMALL_SERVER \
$EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
if [ x$DO_DDD = x1 ]
then
$ECHO "set args $master_args" > $GDB_SLAVE_INIT
ddd --debugger "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD &
prompt_user "Hit enter to continue after you've started the slave"
elif [ x$DO_GDB = x1 ]
then
$ECHO "set args $slave_args" > $GDB_SLAVE_INIT
xterm -title "Slave" -e gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD &
prompt_user "Hit enter to continue after you've started the slave"
else
$SLAVE_MYSQLD $slave_args >> $SLAVE_MYERR 2>&1 &
fi
wait_for_server_start $SLAVE_MYPORT
SLAVE_RUNNING=1
}
mysql_start () {
$ECHO "Starting MySQL daemon"
start_master
start_slave
cd $MYSQL_TEST_DIR
return 1
}
stop_slave ()
{
if [ x$SLAVE_RUNNING = x1 ]
then
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O shutdown_timeout=10 shutdown
if [ $? != 0 ] && [ -f $SLAVE_MYPID ]
then # try harder!
$ECHO "slave not cooperating with mysqladmin, will try manual kill"
kill `$CAT $SLAVE_MYPID`
sleep $SLEEP_TIME
if [ -f $SLAVE_MYPID ] ; then
$ECHO "slave refused to die. Sending SIGKILL"
kill -9 `$CAT $SLAVE_MYPID`
$RM -f $SLAVE_MYPID
else
$ECHO "slave responded to SIGTERM "
fi
fi
SLAVE_RUNNING=0
fi
}
stop_master ()
{
if [ x$MASTER_RUNNING = x1 ]
then
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O shutdown_timeout=10 shutdown
if [ $? != 0 ] && [ -f $MASTER_MYPID ]
then # try harder!
$ECHO "master not cooperating with mysqladmin, will try manual kill"
kill `$CAT $MASTER_MYPID`
sleep $SLEEP_TIME
if [ -f $MASTER_MYPID ] ; then
$ECHO "master refused to die. Sending SIGKILL"
kill -9 `$CAT $MASTER_MYPID`
$RM -f $MASTER_MYPID
else
$ECHO "master responded to SIGTERM "
fi
fi
MASTER_RUNNING=0
fi
}
mysql_stop ()
{
$ECHO "Ending Tests"
$ECHO "Shutting-down MySQL daemon"
$ECHO ""
stop_master
$ECHO "Master shutdown finished"
stop_slave
$ECHO "Slave shutdown finished"
return 1
}
mysql_restart () {
mysql_stop
mysql_start
return 1
}
mysql_loadstd () {
# cp $STD_DATA/*.frm $STD_DATA/*.MRG $MASTER_MYDDIR/test
return 1
}
run_testcase ()
{
tf=$1
tname=`$BASENAME $tf .test`
master_opt_file=$TESTDIR/$tname-master.opt
slave_opt_file=$TESTDIR/$tname-slave.opt
master_init_script=$TESTDIR/$tname-master.sh
slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ -n "$SKIP_TEST" ] ; then
SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
if [ x$SKIP_THIS_TEST = x1 ] ;
then
return;
fi
fi
if [ -n "$DO_TEST" ] ; then
DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0`
if [ x$DO_THIS_TEST = x0 ] ;
then
return;
fi
fi
if [ x${NO_SLAVE}x$SKIP_SLAVE = x1x0 ] ;
then
USERT=" ...."
SYST=" ...."
REALT=" ...."
timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-24`
RES="$pname $timestr"
skip_inc
$ECHO "$RES$RES_SPACE [ skipped ]"
return
fi
if [ -z "$USE_RUNNING_SERVER" ] ;
then
if [ -f $master_opt_file ] ;
then
EXTRA_MASTER_OPT=`$CAT $master_opt_file`
stop_master
start_master
else
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] ;
then
EXTRA_MASTER_OPT=""
stop_master
start_master
fi
fi
do_slave_restart=0
if [ -f $slave_opt_file ] ;
then
EXTRA_SLAVE_OPT=`$CAT $slave_opt_file`
do_slave_restart=1
else
if [ ! -z "$EXTRA_SLAVE_OPT" ] || [ x$SLAVE_RUNNING != x1 ] ;
then
EXTRA_SLAVE_OPT=""
do_slave_restart=1
fi
fi
if [ -f $slave_master_info_file ] ; then
SLAVE_MASTER_INFO=`$CAT $slave_master_info_file`
do_slave_restart=1
else
if [ ! -z "$SLAVE_MASTER_INFO" ] || [ x$SLAVE_RUNNING != x1 ] ;
then
SLAVE_MASTER_INFO=""
do_slave_restart=1
fi
fi
if [ x$do_slave_restart = x1 ] ; then
stop_slave
start_slave
fi
fi
cd $MYSQL_TEST_DIR
if [ -f $tf ] ; then
$RM -f r/$tname.*reject
mysql_test_args="-R r/$tname.result $EXTRA_MYSQL_TEST_OPT"
if [ -z "$DO_CLIENT_GDB" ] ; then
mytime=`$TIME -p $MYSQL_TEST $mysql_test_args < $tf 2> $TIMEFILE`
else
do_gdb_test "$mysql_test_args" "$tf"
fi
res=$?
if [ $res = 0 ]; then
mytime=`$CAT $TIMEFILE | $TAIL -3 | $TR '\n' ':'`
USERT=`$ECHO $mytime | $CUT -d : -f 2 | $CUT -d ' ' -f 2`
USERT=`prefix_to_8 $USERT`
SYST=`$ECHO $mytime | $CUT -d : -f 3 | $CUT -d ' ' -f 2`
SYST=`prefix_to_8 $SYST`
REALT=`$ECHO $mytime | $CUT -d : -f 1 | $CUT -d ' ' -f 2`
REALT=`prefix_to_8 $REALT`
else
USERT=" ...."
SYST=" ...."
REALT=" ...."
fi
timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-24`
RES="$pname $timestr"
if [ $res = 0 ]; then
total_inc
pass_inc
$ECHO "$RES$RES_SPACE [ pass ]"
else
# why the following ``if'' ? That is why res==1 is special ?
if [ $res = 2 ]; then
skip_inc
$ECHO "$RES$RES_SPACE [ skipped ]"
else
total_inc
fail_inc
$ECHO "$RES$RES_SPACE [ fail ]"
$ECHO
error_is
show_failed_diff $tname
$ECHO
if [ x$FORCE != x1 ] ; then
$ECHO "Aborting. To continue, re-run with '--force'."
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
mysql_stop
fi
exit 1
fi
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
mysql_restart
fi
$ECHO "Resuming Tests"
$ECHO ""
fi
fi
fi
}
######################################################################
# Main script starts here
######################################################################
[ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found"
[ "$DO_GCOV" ] && gcov_prepare
[ "$DO_GPROF" ] && gprof_prepare
# Ensure that no old mysqld test servers are running
if [ -z "$USE_RUNNING_SERVER" ]
then
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
$ECHO "Installing Test Databases"
mysql_install_db
#do not automagically start deamons if we are in gdb or running only one test
#case
if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ]
then
mysql_start
fi
$ECHO "Loading Standard Test Databases"
mysql_loadstd
fi
$ECHO "Starting Tests"
if [ "$DO_BENCH" = 1 ]
then
BENCHDIR=$BASEDIR/sql-bench/
savedir=`pwd`
cd $BENCHDIR
if [ -z "$1" ]
then
./run-all-tests --socket=$MASTER_MYSOCK --user=root
else
if [ -x "./$1" ]
then
./$1 --socket=$MASTER_MYSOCK --user=root
else
echo "benchmark $1 not found"
fi
fi
cd $savedir
mysql_stop
exit
fi
$ECHO
$ECHO " TEST USER SYSTEM ELAPSED RESULT"
$ECHO $DASH72
if [ -z "$1" ] ;
then
if [ x$RECORD = x1 ]; then
$ECHO "Will not run in record mode without a specific test case."
else
for tf in $TESTDIR/*.$TESTSUFFIX
do
run_testcase $tf
done
$RM -f $TIMEFILE # Remove for full test
fi
else
tname=`$BASENAME $1 .test`
tf=$TESTDIR/$tname.$TESTSUFFIX
if [ -f $tf ] ; then
run_testcase $tf
else
$ECHO "Test case $tf does not exist."
fi
fi
$ECHO $DASH72
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
mysql_stop
fi
report_stats
$ECHO
[ "$DO_GCOV" ] && gcov_collect # collect coverage information
[ "$DO_GPROF" ] && gprof_collect # collect coverage information
exit 0
|