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