diff options
author | Philipp Wollermann <philwo@google.com> | 2016-04-01 13:57:27 +0000 |
---|---|---|
committer | Klaus Aehlig <aehlig@google.com> | 2016-04-01 18:24:34 +0000 |
commit | c12c9392c079c874f989efa6134384efb8051610 (patch) | |
tree | ed9f3b97ea791bdc2b23a6f139572563193b7ed7 | |
parent | da46c8d6dbb29b1ab621487c87c60bc1bcba0e6d (diff) |
Fix flaky process_wrapper_test and add some explanatory comments.
--
MOS_MIGRATED_REVID=118775810
-rwxr-xr-x | src/test/shell/bazel/process-wrapper_test.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/test/shell/bazel/process-wrapper_test.sh b/src/test/shell/bazel/process-wrapper_test.sh index 490e8acf62..a46b4500aa 100755 --- a/src/test/shell/bazel/process-wrapper_test.sh +++ b/src/test/shell/bazel/process-wrapper_test.sh @@ -75,15 +75,23 @@ function test_basic_timeout() { assert_stdout "before" } +# Tests that process_wrapper sends a SIGTERM to a process on timeout, but gives +# it a grace period of 10 seconds before killing it with SIGKILL. +# In this variant we expect the trap (that runs on SIGTERM) to exit within the +# grace period, thus printing "beforeafter". function test_timeout_grace() { local code=0 - $process_wrapper 1 2 $OUT $ERR /bin/bash -c \ + $process_wrapper 1 10 $OUT $ERR /bin/bash -c \ 'trap "echo -n before; sleep 1; echo after; exit 0" SIGINT SIGTERM SIGALRM; sleep 10' \ &> $TEST_log || code=$? assert_equals 142 "$code" # SIGNAL_BASE + SIGALRM = 128 + 14 assert_stdout "beforeafter" } +# Tests that process_wrapper sends a SIGTERM to a process on timeout, but gives +# it a grace period of 2 seconds before killing it with SIGKILL. +# In this variant, we expect the process to be killed with SIGKILL, because the +# trap takes longer than the grace period, thus only printing "before". function test_timeout_kill() { local code=0 $process_wrapper 1 2 $OUT $ERR /bin/bash -c \ |