1#!/bin/sh
2
3# Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
7# as published by the Free Software Foundation.
8#
9# This program is also distributed with certain software (including
10# but not limited to OpenSSL) that is licensed under separate terms,
11# as designated in a particular file or component or in included license
12# documentation.  The authors of MySQL hereby grant you an additional
13# permission to link the program and your derivative works with the
14# separately licensed software that they have included with MySQL.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License, version 2.0, for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
24
25if [ ! -x ./ft-test-run.sh ] ; then
26  echo "Usage: ./ft-test-run.sh"
27  exit 1
28fi
29
30BASE=`pwd`
31DATA=$BASE/var
32ROOT=`cd ../..; pwd`
33MYSQLD=$ROOT/sql/mysqld
34MYSQL=$ROOT/client/mysql
35MYSQLADMIN=$ROOT/client/mysqladmin
36SOCK=$DATA/mysql.sock
37PID=$DATA/mysql.pid
38H=../ftdefs.h
39OPTS="--no-defaults --socket=$SOCK --character-sets-dir=$ROOT/share/charsets"
40DELAY=10
41
42stop_myslqd()
43{
44  [ -S $SOCK ] && $MYSQLADMIN $OPTS shutdown
45  [ -f $PID ] && kill `cat $PID` && sleep 15 && [ -f $PID ] && kill -9 `cat $PID`
46}
47
48if [ ! -d t/BEST ] ; then
49  echo "No ./t/BEST directory! Aborting..."
50  exit 1
51fi
52rm -f t/BEST/report.txt
53if [ -w $H ] ; then
54  echo "$H is writeable! Aborting..."
55  exit 1
56fi
57
58stop_myslqd
59rm -rf var > /dev/null 2>&1
60mkdir var
61mkdir var/test
62
63for batch in t/* ; do
64  [ ! -d $batch ] && continue
65  [ $batch -ef t/BEST -a $batch != t/BEST ] && continue
66
67  rm -rf var/test/* > /dev/null 2>&1
68  rm -f $H
69  if [ -f $BASE/$batch/ftdefs.h ] ; then
70    cat $BASE/$batch/ftdefs.h > $H
71    chmod a-wx $H
72  else
73    bk get -q $H
74  fi
75  OPTS="--defaults-file=$BASE/$batch/my.cnf --socket=$SOCK --character-sets-dir=$ROOT/share/charsets"
76  stop_myslqd
77  rm -f $MYSQLD
78  echo "building $batch"
79  echo "============== $batch ===============" >> var/ft_test.log
80  (cd $ROOT; gmake) >> var/ft_test.log 2>&1
81
82  for prog in $MYSQLD $MYSQL $MYSQLADMIN ; do
83    if [ ! -x $prog ] ; then
84      echo "build failed: no $prog"
85      exit 1
86    fi
87  done
88
89  echo "=====================================" >> var/ft_test.log
90  $MYSQLD $OPTS --basedir=$BASE --pid-file=$PID \
91                --language=$ROOT/share/english \
92                --skip-grant-tables --skip-innodb \
93                --skip-networking --tmpdir=$DATA >> var/ft_test.log 2>&1 &
94
95  sleep $DELAY
96  $MYSQLADMIN $OPTS ping
97  if [ $? != 0 ] ; then
98    echo "$MYSQLD refused to start"
99    exit 1
100  fi
101  for test in `cd data; echo *.r|sed "s/\.r//g"` ; do
102    if [ -f $batch/$test.out ] ; then
103      echo "skipping $batch/$test.out"
104      continue
105    fi
106    echo "testing $batch/$test"
107    FT_MODE=`cat $batch/ft_mode 2>/dev/null`
108    ./Ecreate.pl $test "$FT_MODE" | $MYSQL $OPTS --skip-column-names test >var/$test.eval
109    echo "reporting $batch/$test"
110    ./Ereport.pl var/$test.eval data/$test.r > $batch/$test.out || exit
111  done
112  stop_myslqd
113  rm -f $H
114  bk get -q $H
115  if [ ! $batch -ef t/BEST ] ; then
116    echo "comparing $batch"
117    ./Ecompare.pl t/BEST $batch >> t/BEST/report.txt
118  fi
119done
120
121