1
0
mirror of https://github.com/deajan/obackup.git synced 2024-11-12 19:03:42 +01:00

More waitFor function tests + arg list

This commit is contained in:
deajan 2016-08-18 22:38:28 +02:00
parent f550b03d4d
commit 51b43487e2

View File

@ -240,36 +240,49 @@ function test_SecondPushRun () {
function test_WaitForTaskCompletion () {
# Tests if wait for task completion works correctly
# Standard wait
sleep 3 &
pids="$!"
sleep 5 &
pids="$pids;$!"
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true 0
WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} true 0
assertEquals "WaitForTaskCompletion test 1" "0" $?
# Standard wait with warning
sleep 5 &
pids="$!"
sleep 8 &
pids="$pids;$!"
WaitForTaskCompletion $pids 6 0 ${FUNCNAME[0]} false true 0
WaitForTaskCompletion $pids 6 0 ${FUNCNAME[0]} true 0
assertEquals "WaitForTaskCompletion test 2" "0" $?
# Both pids are killed
sleep 7 &
pids="$!"
sleep 9 &
pids="$pids;$!"
WaitForTaskCompletion $pids 0 5 ${FUNCNAME[0]} false true 0
WaitForTaskCompletion $pids 0 5 ${FUNCNAME[0]} true 0
assertEquals "WaitForTaskCompletion test 3" "2" $?
# One of two pids are killed
sleep 3 &
pids="$!"
sleep 10 &
pids="$pids;$!"
WaitForTaskCompletion $pids 0 7 ${FUNCNAME[0]} false true 0
WaitForTaskCompletion $pids 0 7 ${FUNCNAME[0]} true 0
assertEquals "WaitForTaskCompletion test 4" "1" $?
# Count since script begin, the following should output two warnings and both pids should get killed
sleep 5 &
pids="$!"
sleep 10 &
pids="$pids;$!"
WaitForTaskCompletion $pids 8 15 ${FUNCNAME[0]} false 0
assertEquals "WaitForTaskCompletion test 5" "2" $?
}
. ./shunit2/shunit2