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
###########################################################################
23
if [ ! -r "$pid_path" ]; then
24
log_debug "No PID-file ($pid_path) found -- not started."
28
new_pid=`cat "$pid_path" 2>/dev/null`
31
log_debug "err_code: $err_code; new_pid: $new_pid."
33
if [ $? -ne 0 -o -z "$new_pid" ]; then
34
log_debug "The process was not started."
38
log_debug "The process was started."
42
###########################################################################
46
if [ -r "$pid_path" ]; then
47
log_debug "PID-file '$pid_path' exists -- not stopped."
51
log_debug "No PID-file ($pid_path) found -- stopped."
55
###########################################################################
58
echo "Usage: $basename <pid file path> <total attempts> started|stopped <test id>"
66
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
68
log_debug "-- $basename: starting --"
69
log_debug "pid_path: '$pid_path'"
70
log_debug "total_attempts: '$total_attempts'"
71
log_debug "event: '$event'"
72
log_debug "test_id: '$test_id'"
73
log_debug "log_file: '$log_file'"
75
###########################################################################
79
check_fn='check_started';
83
check_fn='check_stopped';
87
log_error "Invalid third argument ('started' or 'stopped' expected)."
91
###########################################################################
97
log_debug "cur_attempt: $cur_attempt."
99
if ( eval $check_fn ); then
100
log_info "Success: the process has been $event."
104
[ $cur_attempt -ge $total_attempts ] && break
106
log_debug "Sleeping for 1 second..."
109
cur_attempt=`expr $cur_attempt + 1`
113
log_error "The process has not been $event in $total_attempts secs."