1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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
|