From 51b43487e27e0676ed93524768b246c891e862f0 Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 18 Aug 2016 22:38:28 +0200 Subject: [PATCH] More waitFor function tests + arg list --- dev/tests/run_tests.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/dev/tests/run_tests.sh b/dev/tests/run_tests.sh index c13e92d..476fcfd 100755 --- a/dev/tests/run_tests.sh +++ b/dev/tests/run_tests.sh @@ -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