diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:34:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:34:44 +0000 |
commit | b08293e544fb5eb5e004f02139e4aa06660395b6 (patch) | |
tree | 4b00360b4f034158a87d15d0d6dd797c42270717 /debian/tests | |
parent | Adding upstream version 2:4.0.4. (diff) | |
download | procps-b08293e544fb5eb5e004f02139e4aa06660395b6.tar.xz procps-b08293e544fb5eb5e004f02139e4aa06660395b6.zip |
Adding debian version 2:4.0.4-4.debian/2%4.0.4-4debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests')
-rw-r--r-- | debian/tests/control | 2 | ||||
-rw-r--r-- | debian/tests/free | 50 | ||||
-rw-r--r-- | debian/tests/pgrep | 56 | ||||
-rw-r--r-- | debian/tests/pmap | 59 | ||||
-rw-r--r-- | debian/tests/ps | 53 | ||||
-rw-r--r-- | debian/tests/pwdx | 42 | ||||
-rw-r--r-- | debian/tests/uptime | 39 | ||||
-rw-r--r-- | debian/tests/version | 10 | ||||
-rw-r--r-- | debian/tests/vmstat | 58 | ||||
-rw-r--r-- | debian/tests/w | 37 |
10 files changed, 406 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..df0aa57 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,2 @@ +Tests: version free pgrep pmap ps pwdx uptime vmstat w +Depends: @, shunit2 diff --git a/debian/tests/free b/debian/tests/free new file mode 100644 index 0000000..f44ea43 --- /dev/null +++ b/debian/tests/free @@ -0,0 +1,50 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( free >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "free exit value" "0" "${rtrn}" + grep -E '^[[:space:]]+total[[:space:]]+used[[:space:]]+free[[:space:]]+shared[[:space:]]+buff/cache[[:space:]]+available$' "${stdoutF}" > /dev/null + assertTrue 'header line' $? + + grep -E '^Mem:([[:space:]]+[[:digit:]]+){6}$' "${stdoutF}" > /dev/null + assertTrue 'Mem line' $? + grep -E '^Swap:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null + assertTrue 'Swap line' $? +} + +test_total() { + ( free -t >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "free exit value" "0" "${rtrn}" + grep -E '^[[:space:]]+total[[:space:]]+used[[:space:]]+free[[:space:]]+shared[[:space:]]+buff/cache[[:space:]]+available$' "${stdoutF}" > /dev/null + assertTrue 'header line' $? + + grep -E '^Mem:([[:space:]]+[[:digit:]]+){6}$' "${stdoutF}" > /dev/null + assertTrue 'Mem line' $? + grep -E '^Swap:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null + assertTrue 'Swap line' $? + grep -E '^Total:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null + assertTrue 'Total line' $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/pgrep b/debian/tests/pgrep new file mode 100644 index 0000000..d39400e --- /dev/null +++ b/debian/tests/pgrep @@ -0,0 +1,56 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( pgrep >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pgrep exit value" "2" "${rtrn}" + grep -E '^pgrep: no matching criteria specified' "${stderrF}" > /dev/null + assertTrue 'no matching line' $? +} + +test_count() { + ( pgrep -c "$fakeproc}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pgrep -c exit value" "1" "${rtrn}" + grep '^0$' "${stderrF}" > /dev/null + assertFalse 'count 0 of missing process' $? +} + +test_user_procs() { + myUID=$(awk '$1 == "Uid:" { print $2}' "/proc/${myPID}/status" 2>/dev/null) + if [ -z "${myUID:-}" ];then + startSkipping + myUID=0 + fi + + ( pgrep -u "${myUID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pgrep exit value" "0" "${rtrn}" + + grep "^${myPID}$" "${stderrF}" > /dev/null + assertFalse "User ${myUID} doesn't match PID ${myPID}" $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" + fakeproc='fakename-test' + myPID=$$ +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/pmap b/debian/tests/pmap new file mode 100644 index 0000000..60fdeaf --- /dev/null +++ b/debian/tests/pmap @@ -0,0 +1,59 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( pmap >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pmap exit value" "1" "${rtrn}" + grep 'Usage:' "${stderrF}" > /dev/null + assertTrue 'usage message' $? +} + +test_my_pid() { + ( pmap "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pmap exit value" "0" "${rtrn}" + + grep -E "^${myPID}: " "${stdoutF}" > /dev/null + assertTrue 'pmap header' $? + + grep -E "^[[:space:]]+total +[[:digit:]]+K$" "${stdoutF}" > /dev/null + assertTrue 'pmap total' $? +} + +test_device_format() { + ( pmap -d "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pmap exit value" "0" "${rtrn}" + + grep -E "^${myPID}: " "${stdoutF}" > /dev/null + assertTrue 'pmap header' $? + + grep -E "^Address +Kbytes +Mode +Offset +Device +Mapping$" "${stdoutF}" > /dev/null + assertTrue 'pmap header' $? + + grep -E "^mapped: [[:digit:]]+K +writeable/private: [[:digit:]]+K +shared: [[:digit:]]+K$" "${stdoutF}" > /dev/null + assertTrue 'pmap total' $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" + myPID=$$ +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/ps b/debian/tests/ps new file mode 100644 index 0000000..e9cc83b --- /dev/null +++ b/debian/tests/ps @@ -0,0 +1,53 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( ps >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "ps exit value" "0" "${rtrn}" + grep -E '^[[:space:]]+PID[[:space:]]+TTY[[:space:]]+TIME[[:space:]]+CMD' "${stdoutF}" > /dev/null + assertTrue 'header line' $? +} + +test_pid() { + ( ps -o pid "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "ps exit value" "0" "${rtrn}" + grep -E '^[[:space:]]+PID$' "${stdoutF}" > /dev/null + assertTrue 'header line' $? + grep -E "^[[:space:]]+${myPID}$" "${stdoutF}" > /dev/null + assertTrue 'pid line' $? +} + +test_exe() { + ( ps -o exe "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "ps exit value" "0" "${rtrn}" + + myEXE=$(readlink "/proc/${myPID}/exe" 2>/dev/null) + [ -z "${myEXE:-}" ] && startSkipping + grep -E "^${myEXE}$" "${stdoutF}" > /dev/null + assertTrue 'exe line' $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" + myPID=$$ +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/pwdx b/debian/tests/pwdx new file mode 100644 index 0000000..0f8639f --- /dev/null +++ b/debian/tests/pwdx @@ -0,0 +1,42 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( pwdx >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pwdx exit value" "1" "${rtrn}" + grep 'Usage:' "${stderrF}" > /dev/null + assertTrue 'usage message' $? +} + +test_my_pid() { + ( pwdx "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "pwdx exit value" "0" "${rtrn}" + + myCWD=$(readlink "/proc/${myPID}/cwd" 2>/dev/null) + [ -z "${myCWD:-}" ] && startSkipping + grep -E "^${myPID}: ${myCWD}" "${stdoutF}" > /dev/null + assertTrue 'pwdx output' $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" + myPID=$$ +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/uptime b/debian/tests/uptime new file mode 100644 index 0000000..3550a8b --- /dev/null +++ b/debian/tests/uptime @@ -0,0 +1,39 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( uptime >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "uptime exit value" "0" "${rtrn}" + grep -E '^[[:space:]]+[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}' "${stdoutF}" > /dev/null + assertTrue 'time' $? + grep -E ' load average: [[:digit:].]+, [[:digit:].]+, [[:digit:].]+$' "${stdoutF}" > /dev/null + assertTrue 'load average' $? +} + +test_no_header() { + ( w -h >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "w exit value" "0" "${rtrn}" + grep -E '^USER[[:space:]]+TTY[[:space:]]+FROM' "${stdoutF}" > /dev/null + assertFalse 'header line with -h option' $? +} +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" +} + +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..213eb0b --- /dev/null +++ b/debian/tests/version @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +BINARIES='ps free pgrep pmap pwdx skill slabtop tload uptime vmstat w watch pkill snice' + +for bin in $BINARIES ; do \ + $bin --version | grep -E "^$bin from procps-ng [0-9.]+$" ; \ +done + diff --git a/debian/tests/vmstat b/debian/tests/vmstat new file mode 100644 index 0000000..9907d42 --- /dev/null +++ b/debian/tests/vmstat @@ -0,0 +1,58 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( vmstat >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "vmstat exit value" "0" "${rtrn}" + + grep -E '^procs[ -]+memory[ -]+swap[ -]+io[ -]+system[ -]+cpu[ -]+$' "${stdoutF}" > /dev/null + assertTrue 'header line' $? + grep -E '^ +r +b +swpd +free +buff +cache +si +so +bi +bo +in +cs us sy id wa st gu$' "${stdoutF}" >/dev/null + assertTrue 'header second line' $? + grep -E '^([[:space:]]+[[:digit:]]+){18}$' "${stdoutF}" >/dev/null + assertTrue 'value line' $? +} + +test_forks() { + ( vmstat -f >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "vmstat -f exit value" "0" "${rtrn}" + + grep -E '^[[:space:]]+[[:digit:]]+ forks$' "${stdoutF}" > /dev/null + assertTrue 'fork output' $? +} + +test_disk() { + ( vmstat -d >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "vmstat -d exit value" "0" "${rtrn}" + + grep -E '^disk[ -]+reads[ -]+writes[ -]+IO[ -]+$' "${stdoutF}" > /dev/null + assertTrue 'header line' $? + grep -E '^ +total +merged +sectors +ms +total +merged +sectors +ms +cur +sec$' "${stdoutF}" >/dev/null + assertTrue 'header second line' $? + grep -E '^[[:alnum:]]+([[:space:]]+[[:digit:]]+){10}$' "${stdoutF}" >/dev/null + assertTrue 'value line' $? +} + +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + diff --git a/debian/tests/w b/debian/tests/w new file mode 100644 index 0000000..6a4c15f --- /dev/null +++ b/debian/tests/w @@ -0,0 +1,37 @@ +#!/bin/sh + +exec 2>&1 + +test_no_arguments() { + ( w >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "w exit value" "0" "${rtrn}" + grep -E '^USER[[:space:]]+TTY[[:space:]]+FROM' "${stdoutF}" > /dev/null + assertTrue 'header line' $? +} + +test_no_header() { + ( w -h >"${stdoutF}" 2>"${stderrF}" ) + rtrn=$? + + assertEquals "w exit value" "0" "${rtrn}" + grep -E '^USER[[:space:]]+TTY[[:space:]]+FROM' "${stdoutF}" > /dev/null + assertFalse 'header line with -h option' $? +} +oneTimeSetUp() { + # Define global variables for command output. + stdoutF="${AUTOPKGTEST_TMP}/stdout" + stderrF="${AUTOPKGTEST_TMP}/stderr" +} + +setUp() { + # Truncate the output files. + cp /dev/null "${stdoutF}" + cp /dev/null "${stderrF}" +} + + +# shellcheck disable=SC1091 +. shunit2 + |