| 1 | #!/bin/sh |
| 2 | |
| 3 | exec 2>&1 |
| 4 | |
| 5 | test_no_arguments() { |
| 6 | ( uptime >"${stdoutF}" 2>"${stderrF}" ) |
| 7 | rtrn=$? |
| 8 | |
| 9 | assertEquals "uptime exit value" "0" "${rtrn}" |
| 10 | grep -E '^[[:space:]]+[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}' "${stdoutF}" > /dev/null |
| 11 | assertTrue 'time' $? |
| 12 | grep -E ' load average: [[:digit:].]+, [[:digit:].]+, [[:digit:].]+$' "${stdoutF}" > /dev/null |
| 13 | assertTrue 'load average' $? |
| 14 | } |
| 15 | |
| 16 | test_no_header() { |
| 17 | ( w -h >"${stdoutF}" 2>"${stderrF}" ) |
| 18 | rtrn=$? |
| 19 | |
| 20 | assertEquals "w exit value" "0" "${rtrn}" |
| 21 | grep -E '^USER[[:space:]]+TTY[[:space:]]+FROM' "${stdoutF}" > /dev/null |
| 22 | assertFalse 'header line with -h option' $? |
| 23 | } |
| 24 | oneTimeSetUp() { |
| 25 | # Define global variables for command output. |
| 26 | stdoutF="${AUTOPKGTEST_TMP}/stdout" |
| 27 | stderrF="${AUTOPKGTEST_TMP}/stderr" |
| 28 | } |
| 29 | |
| 30 | setUp() { |
| 31 | # Truncate the output files. |
| 32 | cp /dev/null "${stdoutF}" |
| 33 | cp /dev/null "${stderrF}" |
| 34 | } |
| 35 | |
| 36 | |
| 37 | # shellcheck disable=SC1091 |
| 38 | . shunit2 |
| 39 |