blob: 9907d426404d907a9d1156b0ebcd24d63967b230 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/bin/sh
exec 2>&1
test_no_arguments() {
( vmstat >"${stdoutF}" 2>"${stderrF}" )
rtrn=$?
assertEquals "vmstat exit value" "0" "${rtrn}"
grep -E '^procs[ -]+memory[ -]+swap[ -]+io[ -]+system[ -]+cpu[ -]+$' "${stdoutF}" > /dev/null
assertTrue 'header line' $?
grep -E '^ +r +b +swpd +free +buff +cache +si +so +bi +bo +in +cs us sy id wa st gu$' "${stdoutF}" >/dev/null
assertTrue 'header second line' $?
grep -E '^([[:space:]]+[[:digit:]]+){18}$' "${stdoutF}" >/dev/null
assertTrue 'value line' $?
}
test_forks() {
( vmstat -f >"${stdoutF}" 2>"${stderrF}" )
rtrn=$?
assertEquals "vmstat -f exit value" "0" "${rtrn}"
grep -E '^[[:space:]]+[[:digit:]]+ forks$' "${stdoutF}" > /dev/null
assertTrue 'fork output' $?
}
test_disk() {
( vmstat -d >"${stdoutF}" 2>"${stderrF}" )
rtrn=$?
assertEquals "vmstat -d exit value" "0" "${rtrn}"
grep -E '^disk[ -]+reads[ -]+writes[ -]+IO[ -]+$' "${stdoutF}" > /dev/null
assertTrue 'header line' $?
grep -E '^ +total +merged +sectors +ms +total +merged +sectors +ms +cur +sec$' "${stdoutF}" >/dev/null
assertTrue 'header second line' $?
grep -E '^[[:alnum:]]+([[:space:]]+[[:digit:]]+){10}$' "${stdoutF}" >/dev/null
assertTrue 'value 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
|