| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
exec 2>&1 |
| 4 |
|
| 5 |
test_no_arguments() { |
| 6 |
( free >"${stdoutF}" 2>"${stderrF}" ) |
| 7 |
rtrn=$? |
| 8 |
|
| 9 |
assertEquals "free exit value" "0" "${rtrn}" |
| 10 |
grep -E '^[[:space:]]+total[[:space:]]+used[[:space:]]+free[[:space:]]+shared[[:space:]]+buff/cache[[:space:]]+available$' "${stdoutF}" > /dev/null |
| 11 |
assertTrue 'header line' $? |
| 12 |
|
| 13 |
grep -E '^Mem:([[:space:]]+[[:digit:]]+){6}$' "${stdoutF}" > /dev/null |
| 14 |
assertTrue 'Mem line' $? |
| 15 |
grep -E '^Swap:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null |
| 16 |
assertTrue 'Swap line' $? |
| 17 |
} |
| 18 |
|
| 19 |
test_total() { |
| 20 |
( free -t >"${stdoutF}" 2>"${stderrF}" ) |
| 21 |
rtrn=$? |
| 22 |
|
| 23 |
assertEquals "free exit value" "0" "${rtrn}" |
| 24 |
grep -E '^[[:space:]]+total[[:space:]]+used[[:space:]]+free[[:space:]]+shared[[:space:]]+buff/cache[[:space:]]+available$' "${stdoutF}" > /dev/null |
| 25 |
assertTrue 'header line' $? |
| 26 |
|
| 27 |
grep -E '^Mem:([[:space:]]+[[:digit:]]+){6}$' "${stdoutF}" > /dev/null |
| 28 |
assertTrue 'Mem line' $? |
| 29 |
grep -E '^Swap:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null |
| 30 |
assertTrue 'Swap line' $? |
| 31 |
grep -E '^Total:([[:space:]]+[[:digit:]]+){3}$' "${stdoutF}" > /dev/null |
| 32 |
assertTrue 'Total line' $? |
| 33 |
} |
| 34 |
|
| 35 |
oneTimeSetUp() { |
| 36 |
# Define global variables for command output. |
| 37 |
stdoutF="${AUTOPKGTEST_TMP}/stdout" |
| 38 |
stderrF="${AUTOPKGTEST_TMP}/stderr" |
| 39 |
} |
| 40 |
|
| 41 |
setUp() { |
| 42 |
# Truncate the output files. |
| 43 |
cp /dev/null "${stdoutF}" |
| 44 |
cp /dev/null "${stderrF}" |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
# shellcheck disable=SC1091 |
| 49 |
. shunit2 |
| 50 |
|