3
###########################################################################
5
# NOTE: this script returns 0 (success) even in case of failure (except for
6
# usage-error). This is because this script is executed under
7
# mysql-test-run[.pl] and it's better to examine particular problem in log
8
# file, than just having said that the test case has failed.
10
###########################################################################
12
basename=`basename "$0"`
13
dirname=`dirname "$0"`
15
###########################################################################
19
###########################################################################
22
echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout> <test id>"
33
log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
35
log_debug "-- $basename: starting --"
36
log_debug "client_exe: '$client_exe'"
37
log_debug "socket_path: '$socket_path'"
38
log_debug "username: '$username'"
39
log_debug "password: '$password'"
41
log_debug "total_timeout: '$total_timeout'"
42
log_debug "test_id: '$test_id'"
43
log_debug "log_file: '$log_file'"
45
###########################################################################
47
if [ -z "$client_exe" ]; then
48
log_error "Invalid path to client executable ($client_exe)."
52
if [ ! -x "$client_exe" ]; then
53
log_error "Client by path '$client_exe' is not available."
57
if [ -z "$socket_path" ]; then
58
log_error "Invalid socket patch ($socket_path)."
62
###########################################################################
64
client_args="--silent --socket=$socket_path --connect_timeout=1 "
66
[ -n "$username" ] && client_args="$client_args --user=$username "
67
[ -n "$password" ] && client_args="$client_args --password=$password "
68
[ -n "$db" ] && client_args="$client_args $db"
70
log_debug "client_args: '$client_args'"
72
###########################################################################
78
log_debug "cur_attempt: $cur_attempt."
80
if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
81
log_info "Success: server is ready to accept connection on socket."
85
[ $cur_attempt -ge $total_timeout ] && break
89
cur_attempt=`expr $cur_attempt + 1`
93
log_error "Server does not accept connections after $total_timeout seconds."