summaryrefslogtreecommitdiffstats
path: root/debian/tests/killall
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 13:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 13:17:27 +0000
commitcbdb8b64f975172ddd5ec6143a7a2d67301594f9 (patch)
tree15e19a7f041df9d31f7bbea67c1a684274fe9d6c /debian/tests/killall
parentAdding upstream version 23.7. (diff)
downloadpsmisc-debian/23.7-1.tar.xz
psmisc-debian/23.7-1.zip
Adding debian version 23.7-1.debian/23.7-1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/killall')
-rw-r--r--debian/tests/killall61
1 files changed, 61 insertions, 0 deletions
diff --git a/debian/tests/killall b/debian/tests/killall
new file mode 100644
index 0000000..6097173
--- /dev/null
+++ b/debian/tests/killall
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+exec 2>&1
+
+test_no_arguments() {
+ ( killall >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "exit value" "1" "${rtrn}"
+ grep -E '^Usage: killall \[OPTION\]' "${stderrF}" > /dev/null
+ assertTrue 'error message' $?
+}
+
+test_list_signals() {
+ ( killall -l >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "exit value" "0" "${rtrn}"
+ grep -qE '^([A-Z12]+\s*)+$' "${stdoutF}"
+ assertTrue 'STDOUT lists signals' $?
+}
+
+test_not_found() {
+ ( killall "${fakeproc}" >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "exit value" "1" "${rtrn}"
+ th_assertNoProcFound 'STDOUT says no process found'
+}
+
+test_all_signals() {
+ allSIGNALS=$(killall -l)
+ for signame in ${allSIGNALS}; do
+ ( killall -"${signame}" "${fakeproc}" >"${stdoutF}" 2>"${stderrF}" )
+ th_assertNoProcFound "STDOUT no process found for -${signame}"
+ ( killall -"SIG${signame}" "${fakeproc}" >"${stdoutF}" 2>"${stderrF}" )
+ th_assertNoProcFound "STDOUT no process found for -SIG${signame}"
+ done
+}
+
+th_assertNoProcFound() {
+ msg=$1
+ grep -qE "^${fakeproc}: no process found$" "${stderrF}"
+ assertTrue "${msg}" $?
+}
+
+oneTimeSetUp() {
+ # Define global variables for command output.
+ stdoutF="${AUTOPKGTEST_TMP}/stdout"
+ stderrF="${AUTOPKGTEST_TMP}/stderr"
+ fakeproc="fakename-test"
+}
+
+setUp() {
+ # Truncate the output files.
+ cp /dev/null "${stdoutF}"
+ cp /dev/null "${stderrF}"
+}
+
+# shellcheck disable=SC1091
+. shunit2