blob: ac835e56999f0434698b9193bd82c3c9f15e2cf3 (
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
|
#! /bin/sh
#++
# Access Definitions
#--
DB=test
USER=test
PASSWD=
#++
# Misc. Definitions
#--
CWD=`pwd`
cd ..
BASEDIR=`pwd`
cd $CWD
MYBIN="$CWD/mybin"
TESTVER=3.23
TESTDIR="$CWD/t/$TESTVER"
TOT_PASS=0
TOT_FAIL=0
TOT_TEST=0
TIME_FORMAT='%U\t%S\t%E\t%P'
DASHBLANK="----\t----\t-------\t----"
[ -z $COLUMNS ] && COLUMNS=80
E=`expr $COLUMNS - 8`
C=0
while [ $C != $E ]
do
DASH72="${DASH72}-"
C=`expr $C + 1`
done
#++
# mysqld Environment Parameters
#--
MYPORT=9306
MYDDIR="$CWD/var/lib"
MYSOCK="$CWD/var/tmp/mysql.sock"
MYPID="$CWD/var/run/mysqld.pid"
MYLOG="$CWD/var/log/mysqld.log"
MYERR="$CWD/var/log/mysqld.err"
#++
# Program Definitions
#--
TIME=/usr/bin/time
MYSQLD="$BASEDIR/sql/mysqld"
MYSQL_TEST="$BASEDIR/client/mysql-test"
MYSQLADMIN="$BASEDIR/client/mysqladmin"
MYSQL_TEST="$MYSQL_TEST --socket=$MYSOCK --database=$DB --user=$USER --password=$PASSWD --silent"
INSTALL_DB="$MYBIN/mysql-test_install_db"
#++
# Terminal Modifications
#--
MOVE_TO_COL="echo -en \\033[300C\\033[20D"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \\033[0;39m"
#++
# Function Definitions
#--
echo_ok() {
$MOVE_TO_COL && $SETCOLOR_NORMAL
echo -n "[ "
$SETCOLOR_SUCCESS
echo -n "ok"
$SETCOLOR_NORMAL
echo " ]"
return 0
}
echo_notok() {
$MOVE_TO_COL && $SETCOLOR_NORMAL
echo -n "[ "
$SETCOLOR_FAILURE
echo -n "not ok"
$SETCOLOR_NORMAL
echo " ]"
return 0
}
echo_pass () {
$MOVE_TO_COL && $SETCOLOR_NORMAL
echo -n "[ "
$SETCOLOR_SUCCESS
echo -n "pass"
$SETCOLOR_NORMAL
echo " ]"
return 0
}
echo_fail () {
$MOVE_TO_COL && $SETCOLOR_NORMAL
echo -n "[ "
$SETCOLOR_FAILURE
echo -n "fail"
$SETCOLOR_NORMAL
echo " ]"
return 0
}
error () {
$SETCOLOR_FAILURE
echo -n "Error: " && $SETCOLOR_NORMAL && echo $1
$SETCOLOR_NORMAL
exit 1
}
pass_inc () {
TOT_PASS=`expr $TOT_PASS + 1`
}
fail_inc () {
TOT_FAIL=`expr $TOT_FAIL + 1`
}
total_inc () {
TOT_TEST=`expr $TOT_TEST + 1`
}
report_stats () {
if [ $TOT_FAIL = 0 ]; then
echo "All tests successful."
else
echo -n "Failed ${TOT_FAIL}/${TOT_TEST} tests, "
xten=`expr $TOT_PASS \* 10000` #
raw=`expr $xten / $TOT_TEST` # My God
raw=`printf %.4d $raw` # This is such a ...
whole=`printf %.2s $raw` # Narttu!!
xwhole=`expr $whole \* 100` # Hynda!!!
deci=`expr $raw - $xwhole` #
echo "${whole}.${deci}% successful."
fi
}
mysql_install_db () {
`$INSTALL_DB`
if [ $? != 0 ]; then
error "Could not install tmp DBs"
exit 1
fi
return 0
}
mysql_start () {
`$MYSQLD --no-defaults \
--skip-networking \
--basedir=$CWD \
--datadir=$MYDDIR \
--pid-file=$MYPID \
--socket=$MYSOCK \
--log=$MYLOG \
--language=english >> $MYERR 2>&1 &`
return 1
}
mysql_stop () {
`$MYSQLADMIN --socket=$MYSOCK -u root shutdown`
return 1
}
mysql_restart () {
mysql_stop
res=$?
[ $res != 1 ] && echo_notok && error "Stopping mysqld"
mysql_start
res=$?
[ $res != 1 ] && echo_notok && error "Starting mysqld"
return 1
}
mysql_loadstd () {
sleep 2
return 1
}
mysql_install_db
$SETCOLOR_NORMAL && echo -n "Starting mysqld for Testing"
mysql_start
res=$?
res=1
[ $res != 1 ] && echo_notok && error "Starting mysqld"
[ $res = 1 ] && echo_ok
$SETCOLOR_NORMAL && echo -n "Loading Standard Test Database"
mysql_loadstd
res=$?
[ $res != 1 ] && echo_notok && error "Loading STD"
[ $res = 1 ] && echo_ok
$SETCOLOR_NORMAL && echo -n "Starting Tests for MySQL $TESTVER Series"
$SETCOLOR_SUCCESS && echo_ok
echo
echo -e " TEST\t\t\tUSER\tSYSTEM\tELAPSED\t%CPU\t RESULT"
echo $DASH72
for tf in $TESTDIR/*.test
do
if [ -f $tf ] ; then
mytime=`$TIME -f $TIME_FORMAT $MYSQL_TEST < $tf 2>&1`
res=$?
tf=`basename $tf`
[ $res = 1 ] && mytime=`echo -ne $mytime | cut -b 39-`
$SETCOLOR_NORMAL && echo -ne "$tf\t$mytime"
[ $res = 1 ] && fail_inc && echo_fail
[ $res != 1 ] && pass_inc && echo_pass
total_inc
if [ $res != 0 ]; then
echo
$SETCOLOR_NORMAL && echo -ne "Restarting mysqld\t$DASHBLANK"
mysql_restart
$SETCOLOR_SUCCESS && echo_ok
$SETCOLOR_NORMAL && echo -ne "Resuming Tests\t\t$DASHBLANK"
$SETCOLOR_SUCCESS && echo_ok
echo
fi
fi
done
echo $DASH72
echo
$SETCOLOR_NORMAL && echo -n "Ending Tests for MySQL $TESTVER Series"
$SETCOLOR_SUCCESS && echo_ok
$SETCOLOR_NORMAL && echo -n "Shutdown mysqld"
mysql_stop
res=$?
res=1
[ $res != 1 ] && echo_notok && error "Shutdown mysqld"
[ $res = 1 ] && echo_ok
$SETCOLOR_NORMAL
echo
report_stats
echo
exit 0
|