diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-03-13 20:04:27 -0700 |
---|---|---|
committer | Gerrit Code Review <root@dev.gluster.com> | 2012-03-13 20:04:27 -0700 |
commit | f184969cc6b7c82cc420ec837087fd2ed3b29991 (patch) | |
tree | 3b7fb1ea4a2b0823b742625279d114528cd16595 | |
parent | 0d5fb2dae23b521ada3d050e5c4e0e1ae12a7b5b (diff) | |
parent | 0c59c3ea06c6cd8ac5760888ae7a7ccaf6414226 (diff) |
Merge "Runs parallel untar & rm of the linux kernel"
-rwxr-xr-x | helper_scripts/untar-remove.sh | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/helper_scripts/untar-remove.sh b/helper_scripts/untar-remove.sh new file mode 100755 index 0000000..3b7bad3 --- /dev/null +++ b/helper_scripts/untar-remove.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +function _init () +{ + set -e; + + if [ $# -lt 2 ]; then + echo "Continuing tests with current working directory." + M=$PWD; + else + if [ ! -d $2 ]; then + echo "2nd argument needs to be a valid directory." + exit 42; + else + M=$2; + fi + fi + + if echo $1 | egrep -q '^[0-9]+$'; then + T=$1; + else + echo "First argument was not a number, continuing with default" + T=600; + fi + echo $T + export pid_untar; + export pid_remove; +} + +function run_tests() +{ + old_PWD=$PWD; + cd $M; + + sleep 1; + untar & + sleep 2; + remove_kernel & + + sleep $T; + + cd $old_PWD; +} + +function untar () +{ + cd $M; + while true + do + tar -xjf /opt/qa/tools/linux-2.6.31.1.tar.bz2 & + pid_untar=$!; + wait $pid_untar; + done +} + +function remove_kernel () +{ + while true + do + rm -rf $M/linux-2.6.31.1 & + pid_remove=$!; + wait $pid_remove; + done +} + +function watchdog () +{ + # insurance against hangs during the test + + sleep $1; + + echo "Kicking in watchdog after $1 secs"; +} + + +function finish () +{ + for i in $(jobs -pr) + do + echo "killing jobs" + kill -KILL $i; + sleep 2; + done + + sleep 10; + + rm -rf $M/linux-2.6.31.1 & + cleanup_remove=$!; + wait $cleanup_remove; +} + +function main () +{ + watchdog $T & + + trap finish INT EXIT; + + set -x; + + run_tests; +} + +_init "$@" && main "$@"; |