aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar philwo <philwo@google.com>2017-06-21 15:25:10 +0200
committerGravatar Philipp Wollermann <philwo@google.com>2017-06-22 11:49:00 +0200
commit9d9ac15b69530edd83c1b95f98a70efa8f98a27a (patch)
tree92e6b1aa7acfdcab924a0bcb4da70cfe289654f5 /src/test/shell
parent7e9dcfa501fb941cb9a0e42a41d954b3b34fa7a7 (diff)
Use getopt to parse process-wrapper's command-line.
This will allow us to add new and optional flags like selecting a strategy used to spawn / wait for the child process. No one except Bazel should be calling "process-wrapper" and I couldn't find any references, so this breaking change should be fine. PiperOrigin-RevId: 159685867
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/process-wrapper_test.sh19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/test/shell/bazel/process-wrapper_test.sh b/src/test/shell/bazel/process-wrapper_test.sh
index 09c6a088e4..63972acf28 100755
--- a/src/test/shell/bazel/process-wrapper_test.sh
+++ b/src/test/shell/bazel/process-wrapper_test.sh
@@ -41,37 +41,38 @@ function assert_output() {
}
function test_basic_functionality() {
- $process_wrapper -1 0 $OUT $ERR /bin/echo hi there &> $TEST_log || fail
+ $process_wrapper --stdout=$OUT --stderr=$ERR /bin/echo hi there &> $TEST_log || fail
assert_output "hi there" ""
}
function test_to_stderr() {
- $process_wrapper -1 0 $OUT $ERR /bin/bash -c "/bin/echo hi there >&2" &> $TEST_log || fail
+ $process_wrapper --stdout=$OUT --stderr=$ERR /bin/bash -c "/bin/echo hi there >&2" &> $TEST_log || fail
assert_output "" "hi there"
}
function test_exit_code() {
local code=0
- $process_wrapper -1 0 $OUT $ERR /bin/bash -c "exit 71" &> $TEST_log || code=$?
+ $process_wrapper --stdout=$OUT --stderr=$ERR /bin/bash -c "exit 71" &> $TEST_log || code=$?
assert_equals 71 "$code"
}
function test_signal_death() {
local code=0
- $process_wrapper -1 0 $OUT $ERR /bin/bash -c 'kill -ABRT $$' &> $TEST_log || code=$?
+ $process_wrapper --stdout=$OUT --stderr=$ERR /bin/bash -c 'kill -ABRT $$' &> $TEST_log || code=$?
assert_equals 134 "$code" # SIGNAL_BASE + SIGABRT = 128 + 6
}
function test_signal_catcher() {
local code=0
- $process_wrapper 1 2 $OUT $ERR /bin/bash -c \
+ $process_wrapper --timeout=1 --kill_delay=2 --stdout=$OUT --stderr=$ERR /bin/bash -c \
'trap "echo later; exit 0" SIGINT SIGTERM SIGALRM; sleep 10' &> $TEST_log || code=$?
assert_equals 142 "$code" # SIGNAL_BASE + SIGALRM = 128 + 14
assert_stdout "later"
}
function test_basic_timeout() {
- $process_wrapper 1 2 $OUT $ERR /bin/bash -c "echo before; sleep 10; echo after" &> $TEST_log && fail
+ $process_wrapper --timeout=1 --kill_delay=2 --stdout=$OUT --stderr=$ERR /bin/bash -c \
+ "echo before; sleep 10; echo after" &> $TEST_log && fail
assert_stdout "before"
}
@@ -81,7 +82,7 @@ function test_basic_timeout() {
# grace period, thus printing "beforeafter".
function test_timeout_grace() {
local code=0
- $process_wrapper 1 10 $OUT $ERR /bin/bash -c \
+ $process_wrapper --timeout=1 --kill_delay=10 --stdout=$OUT --stderr=$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
@@ -94,7 +95,7 @@ function test_timeout_grace() {
# 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 \
+ $process_wrapper --timeout=1 --kill_delay=2 --stdout=$OUT --stderr=$ERR /bin/bash -c \
'trap "echo before; sleep 10; echo after; exit 0" SIGINT SIGTERM SIGALRM; sleep 10' \
&> $TEST_log || code=$?
assert_equals 142 "$code" # SIGNAL_BASE + SIGALRM = 128 + 14
@@ -103,7 +104,7 @@ function test_timeout_kill() {
function test_execvp_error_message() {
local code=0
- $process_wrapper -1 0 $OUT $ERR /bin/notexisting &> $TEST_log || code=$?
+ $process_wrapper --stdout=$OUT --stderr=$ERR /bin/notexisting &> $TEST_log || code=$?
assert_equals 1 "$code"
assert_contains "\"execvp(/bin/notexisting, ...)\": No such file or directory" "$ERR"
}