summaryrefslogtreecommitdiffstats
path: root/debian/tests/uptime
blob: 3550a8b07b17b34562f63bb4d96ddd70fbe46fe6 (plain)
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
#!/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