summaryrefslogtreecommitdiffstats
path: root/debian/tests
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
parentAdding upstream version 23.7. (diff)
downloadpsmisc-cbdb8b64f975172ddd5ec6143a7a2d67301594f9.tar.xz
psmisc-cbdb8b64f975172ddd5ec6143a7a2d67301594f9.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')
-rw-r--r--debian/tests/control3
-rw-r--r--debian/tests/fuser71
-rw-r--r--debian/tests/killall61
-rw-r--r--debian/tests/version10
4 files changed, 145 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..8974337
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: version fuser killall
+Depends: @, shunit2
+
diff --git a/debian/tests/fuser b/debian/tests/fuser
new file mode 100644
index 0000000..bf18235
--- /dev/null
+++ b/debian/tests/fuser
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+exec 2>&1
+
+test_no_arguments() {
+ ( fuser >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "fuser exit value" "1" "${rtrn}"
+ grep -E '^No process specification given$' "${stderrF}" > /dev/null
+ assertTrue 'error message' $?
+}
+
+test_no_process() {
+ ( fuser "${testF}" >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "fuser exit value" "1" "${rtrn}"
+ assertFalse "unexpected output to stderr" "[ -s '${stderrF}' ]"
+}
+
+test_a_no_process() {
+ ( fuser -a "${testF}" >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "fuser exit value" "1" "${rtrn}"
+ grep -qE "^${testF}:$" "${stderrF}"
+ assertTrue 'File matches no process' $?
+}
+
+test_my_cwd() {
+ myCWD=$(readlink "/proc/${myPID}/cwd" )
+ ( fuser "${myCWD}" >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "fuser exit value" "0" "${rtrn}"
+ grep -qE "${myPID}" "${stdoutF}"
+ assertTrue 'STDOUT has my PID' $?
+ grep -qE "^${myCWD}:.*c" "${stderrF}"
+ assertTrue 'STDERR has my path and c' $?
+}
+
+test_my_exe() {
+ myEXE=$(readlink "/proc/${myPID}/exe" )
+ ( fuser "${myEXE}" >"${stdoutF}" 2>"${stderrF}" )
+ rtrn=$?
+
+ assertEquals "fuser exit value" "0" "${rtrn}"
+ grep -qE "${myPID}" "${stdoutF}"
+ assertTrue 'STDOUT has my PID' $?
+ grep -qE "^${myEXE}:.*e" "${stderrF}"
+ assertTrue 'STDERR has my path and e' $?
+}
+oneTimeSetUp() {
+ # Define global variables for command output.
+ stdoutF="${AUTOPKGTEST_TMP}/stdout"
+ stderrF="${AUTOPKGTEST_TMP}/stderr"
+ testF="${AUTOPKGTEST_TMP}/test-file"
+ touch "${testF}"
+ myPID=$$
+}
+
+setUp() {
+ # Truncate the output files.
+ cp /dev/null "${stdoutF}"
+ cp /dev/null "${stderrF}"
+}
+
+
+# shellcheck disable=SC1091
+. shunit2
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
diff --git a/debian/tests/version b/debian/tests/version
new file mode 100644
index 0000000..b7700bc
--- /dev/null
+++ b/debian/tests/version
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+BINARIES='killall pslog prtstat pstree fuser peekfd'
+
+for bin in $BINARIES ; do \
+ $bin --version 2>&1 | egrep "^$bin \(PSmisc\) [0-9.]+$" ; \
+done
+