1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-07 07:46:04 +02:00
zsh/Test/B11kill.ztst
Chris Down 59258252b5 45452: builtins: kill: Add `kill ''` regression test with explicit sigspec
The version without a sigspec can't be added yet because it would still
kill the test runner even in expected-to-fail mode; see workers/45449
for discussion. For the same reason, we use a signal which is non-fatal
by default and unlikely to be sent by someone else, SIGURG, to do the
expected-to-fail case prior to the fix.
2020-02-18 12:59:52 +00:00

70 lines
1.5 KiB
Plaintext

# Tests for the kill builtin.
#
# The exit codes 11 and 19 in this file don't mean anything special; they're
# just exit codes which are specific enough that the failure of `kill` itself
# can be differentiated from exiting due to executing a trap.
%test
# Correct invocation
if zmodload zsh/system &>/dev/null; then
(
trap 'exit 19' TERM
kill $sysparams[pid]
)
else
ZTST_skip='Cannot zmodload zsh/system, skipping kill with no sigspec'
fi
19:kill with no sigspec
if zmodload zsh/system &>/dev/null; then
(
trap 'exit 11' USR1
kill -USR1 $sysparams[pid]
)
else
ZTST_skip='Cannot zmodload zsh/system, skipping kill with sigspec'
fi
11:kill with sigspec
# Incorrect invocation
(
kill a b c
)
3:kill with multiple wrong inputs should increment status
?(eval):kill:2: illegal pid: a
?(eval):kill:2: illegal pid: b
?(eval):kill:2: illegal pid: c
(
kill -INT a b c
)
3:kill with sigspec and wrong inputs should increment status
?(eval):kill:2: illegal pid: a
?(eval):kill:2: illegal pid: b
?(eval):kill:2: illegal pid: c
(
kill
)
1:kill with no arguments
?(eval):kill:2: not enough arguments
(
kill -INT
)
1:kill with sigspec only
?(eval):kill:2: not enough arguments
# Regression tests: `kill ''` should not result in `kill 0`.
(
trap 'exit 11' URG
kill -URG ''
)
1f:kill with empty pid and sigspec should not send signal to current process group
?(eval):kill:3: illegal pid: