-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathar_test.sh
executable file
·92 lines (78 loc) · 1.46 KB
/
ar_test.sh
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
#!/bin/bash
# runs MySQL tests in all source directories
# prints usage information
usage ()
{
echo "$VERSION"
echo "
ar_test copies MySQL test files from t to archive folder
Usage: `basename $0` [-v] [-d dirname] [test ...]
Options:
-d directory, contains test files
-v print version
-h print this help
"
}
# error exit
error()
{
printf "$@" >&2
exit $E_CDERROR
}
# creates defaults values
initialize()
{
MACHINE_HOME_DIR=$HOME
TESTDIR=$MACHINE_HOME_DIR/src/tests
TESTS_TO_MOVE=""
OLD_PWD=`pwd`
VERSION="ar_test v0.2 (Dec 09 2014)"
}
# parses arguments/sets values to defaults
parse()
{
while getopts "vhd:" Option
do
case $Option in
v) echo "$VERSION"; shift;;
h) usage; exit 0;;
d) TESTDIR="$OPTARG"; shift;;
*) usage; exit 0;;
esac
done
TESTS_TO_MOVE="$@"
}
# copies test to source directories
copy()
{
if [[ "xx" = x"$TESTS_TO_MOVE"x ]]
then
cp "$TESTDIR"/t/* "$TESTDIR"/archive 2>/dev/null
else
for test in $TESTS_TO_MOVE
do
cp "$TESTDIR/t/$test".{test,opt,init,sql,cfg,cnf} "$TESTDIR"/archive 2>/dev/null
done
fi
}
# removes tests and results from MySQL sources directories
cleanup()
{
if [[ "xx" = x"$TESTS_TO_MOVE"x ]]
then
rm "$TESTDIR"/t/* 2>/dev/null
rm "$TESTDIR"/r/*/* 2>/dev/null
else
for test in $TESTS_TO_MOVE
do
rm "$TESTDIR/t/$test".{test,opt,init,sql} 2>/dev/null
rm "$TESTDIR/r/"*"/$test".{test,opt,init,sql} 2>/dev/null
done
fi
}
E_CDERROR=65
initialize
parse $@
copy
cleanup
exit 0