diff options
author | anozdrin@mysql.com <> | 2005-10-01 01:14:50 +0400 |
---|---|---|
committer | anozdrin@mysql.com <> | 2005-10-01 01:14:50 +0400 |
commit | d3c0fd2bcefcae14e597df6725de07e848f652f2 (patch) | |
tree | ae2d126f149e3a5b22bc6f216d72f8c332064d07 /mysql-test/t/kill_n_check.sh | |
parent | c73e03ff22713c8c89c3f8ef6a1b8f21e393a1d3 (diff) | |
download | mariadb-git-d3c0fd2bcefcae14e597df6725de07e848f652f2.tar.gz |
WL#2789 "Instance Manager: test using mysql-test-run testing framework"
Add Instance Manager tests.
Diffstat (limited to 'mysql-test/t/kill_n_check.sh')
-rwxr-xr-x | mysql-test/t/kill_n_check.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/mysql-test/t/kill_n_check.sh b/mysql-test/t/kill_n_check.sh new file mode 100755 index 00000000000..7fe30c4774c --- /dev/null +++ b/mysql-test/t/kill_n_check.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +if [ $# -ne 2 ]; then + echo "Usage: kill_n_check.sh <pid file path> killed|restarted" + exit 0 +fi + +pid_path="$1" +expected_result="$2" + +if [ -z "$pid_path" -o ! -r "$pid_path" ]; then + echo "Error: invalid PID path ($pid_path) or PID file does not exist." + exit 0 +fi + +if [ "$expected_result" != "killed" -a \ + "$expected_result" != "restarted" ]; then + echo "Error: expected result must be either 'killed' or 'restarted'." + exit 0 +fi + +# echo "PID path: '$pid_path'" + +original_pid=`cat "$pid_path"` + +# echo "Original PID: $original_pid" + +echo "Killing the process..." + +kill -9 $original_pid + +echo "Sleeping..." + +sleep 3 + +new_pid="" + +[ -r "$pid_path" ] && new_pid=`cat "$pid_path"` + +# echo "New PID: $new_pid" + +if [ "$expected_result" == "restarted" ]; then + + if [ -z "$new_pid" ]; then + echo "Error: the process was killed." + exit 0 + fi + + if [ "$original_pid" -eq "$new_pid" ]; then + echo "Error: the process was not restarted." + exit 0 + fi + + echo "Success: the process was restarted." + exit 0 + +else # $expected_result == killed + + if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then + echo "Error: the process was restarted." + exit 0 + fi + + echo "Success: the process was killed." + exit 0 +fi |