dumb-init/tests/test-help-message

21 lines
556 B
Text
Raw Normal View History

#!/bin/sh -u
# dumb-init should say something useful when called with no arguments, and exit
# nonzero.
dumb_init="$1"
status=$($dumb_init > /dev/null 2>&1; echo $?)
if [ "$status" -ne 0 ]; then
2015-08-10 19:32:56 +03:00
msg=$($dumb_init 2>&1 || true)
msg_len=${#msg}
2015-08-10 19:32:56 +03:00
if [ "$msg_len" -le 50 ]; then
echo "Error: Expected dumb-init with no arguments to print a useful message, but it was only ${msg_len} chars long."
exit 1
fi
else
2015-08-10 19:32:56 +03:00
echo "Error: Expected dumb-init with no arguments to return nonzero, but it returned ${status}."
exit 1
fi