diff options
author | Craig Small <csmall@dropbear.xyz> | 2021-03-29 22:23:03 +1100 |
---|---|---|
committer | Craig Small <csmall@dropbear.xyz> | 2021-03-29 22:23:03 +1100 |
commit | fc97889b2d8e0a96b578fa5b97c6ef649682adb9 (patch) | |
tree | 978b31ff8ad7f977010402faa51604126e35b2f7 | |
parent | 3dd1661a3d91671ca6c977c2e514f47d807be79d (diff) | |
download | procps-ng-fc97889b2d8e0a96b578fa5b97c6ef649682adb9.tar.gz |
build-sys: Handle zero length diskstats in tests
vmstat -d testsuite will fail if your /proc/diskstats is present
but zero length. While this seems buggy behaviour from lxcfs, its
there and its a simple matter to test for it and skip those tests
if we are run on a zero length /proc/diskstats system.
-rw-r--r-- | testsuite/vmstat.test/vmstat.exp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/testsuite/vmstat.test/vmstat.exp b/testsuite/vmstat.test/vmstat.exp index b044903..cd55e52 100644 --- a/testsuite/vmstat.test/vmstat.exp +++ b/testsuite/vmstat.test/vmstat.exp @@ -35,20 +35,23 @@ 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+\((?:hd|sd|vd)\[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)" - } + set fp [open /proc/diskstats ] + if { [ read $fp ] == "" } { + close $fp + unsupported "$test /proc/diskstats empty" + } else { + close $fp + 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 [ regexp "\\s+\\d+\\s+\\d+\\s+\((?:hd|sd|vd)\[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)" + } + } } |