procps/testsuite/vmstat.test/vmstat.exp
Craig Small 5a34ff0a99 Check for presence of disks in vmstat
vmstat -d or vmstat -p would crash mysteriously under different
circumstances. The problem was eventually tracked down to /sys not
being mounted which meant is_disk() always returned false.
The partition would then be attempted to be linked to a non-existent
disk causing a segfault.

vmstat will now not link to a disk if none exists.
The change in testing will skip those tests when /sys/block doesn't
exist.

Many thanks to Daniel Schepler for his analysis and suggestions.

Bug-Debian: http://bugs.debian.org/736628
2014-01-29 22:22:11 +11:00

49 lines
1.8 KiB
Plaintext

#
# Dejagnu tests for vmstat - part of procps
set vmstat "${topdir}vmstat"
# Run vmstat with no arguments
set test "vmstat with no arguments"
spawn $vmstat
expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
set test "vmstat with -a flag"
spawn $vmstat -a
expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
set test "vmstat fork option"
spawn $vmstat -f
expect_pass "$test" "^\\s+\\d+ forks\\s*$"
if { [ file readable "/proc/slabinfo" ] == 0 } {
unsupported "slabinfo (-m option) test disabled as /proc/slabinfo is unreadable"
} else {
set test "vmstat slabinfo (-m option)"
spawn $vmstat -m
expect_pass "$test" "^Cache\\s+Num\\s+Total\\s+Size\\s+Pages\\s+\(\[\(\)A-Za-z0-9_-\]+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*\){1,}"
}
set test "vmstat disk information (-d option)"
if { [ file readable "/sys/block" ] == 0 } {
unsupported "$test /sys/block not readable"
} else {
spawn $vmstat -d
expect_pass "$test" "^disk\[ -\]+reads\[ -\]+writes\[ -\]+IO\[ -\]+\\s+total\\s+merged\\s+sectors\\s+ms\\s+total\\s+merged\\s+sectors\\s+ms\\s+cur\\s+sec\\s+"
}
# Need a partition
set diskstats [ exec cat /proc/diskstats ]
if { [ file readable "/sys/block" ] == 0 } {
unsupported "vmstat partition /sys/block not readable"
} else {
if [ regexp "\\s+\\d+\\s+\\d+\\s+\(\[a-z\]+\\d+\)\\s+\[0-9\]\[0-9\]+" $diskstats line partition == 1 ] {
set test "vmstat partition (using $partition)"
spawn $vmstat -p $partition
expect_pass "$test" "^${partition}\\s+reads"
} else {
unsupported "vmstat partition (cannot find partition)"
}
}