From db602e1d44392b8f0cabf688277fd1d52a3dc5f7 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Sun, 4 Dec 2011 22:08:23 +1100 Subject: [PATCH] slabtop check has optional spaces at start of line There is a race condition between expect script consuming the output from slabtop. There were a sequences of lines that looked like ^\d+ ... \s* with the last \s* consuming the first space on the start of the line. However if the line takes too long to print, then expect stops there and the space at the start of the subsquent line does not match. The solution is a \s* at the start ofthe line. --- testsuite/slabtop.test/slabtop.exp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/testsuite/slabtop.test/slabtop.exp b/testsuite/slabtop.test/slabtop.exp index c1a3fbf3..99f74790 100644 --- a/testsuite/slabtop.test/slabtop.exp +++ b/testsuite/slabtop.test/slabtop.exp @@ -7,6 +7,9 @@ set avst "Active / Total" set used "\\\(% used\\\)\\s+:" set pct "\\\(\\d+\\.\\d+%\\\)" +if { [ file readable "/proc/slabinfo" ] == 0 } { + unsupported "slabtop tests disabled as /proc/slabinfo is unreadable" +} else { set slabtop_header "^ $avst Objects $used \\d+ / \\d+ ${pct}\\s+$avst Slabs $used \\d+ / \\d+ ${pct}\\s+$avst Caches $used \\d+ / \\d+ ${pct}\\s+$avst Size $used \\d+\\.\\d+K / \\d+\\.\\d+K ${pct}\\s+Minimum / Average / Maximum Object : \\d+\\.\\d+K / \\d+\\.\\d+K / \\d+\\.\\d+K\\s+OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME\\s+" set test "slabtop help" @@ -14,17 +17,17 @@ spawn $slabtop --help expect_pass $test "usage: \\S+ \\\[options\\\]" set sort_tests { - "a" "active objects" "^\\d+\\s+(\\d+)\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" + "a" "active objects" "^\\s*\\d+\\s+(\\d+)\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" "b" "objects per slab" "^\\s*\\d+\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+(\\d+)\\s+\\d+K\\s+\\S\[^\r\]+\\s*" - "c" "cache size" "^\\d+\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+(\\d+)K\\s+\\S\[^\r\]+\\s*" - "l" "number of slabs" "^\\d+\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+(\\d+)\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" - "o" "object count" "^(\\d+)\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" - "s" "object size" "^\\d+\\s+\\d+\\s+\\d+%\\s+(\\d+\\.\\d+)K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" - "u" "utilisation" "^\\d+\\s+\\d+\\s+(\\d+)%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" + "c" "cache size" "^\\s*\\d+\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+(\\d+)K\\s+\\S\[^\r\]+\\s*" + "l" "number of slabs" "^\\s*\\d+\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+(\\d+)\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" + "o" "object count" "^\\s*(\\d+)\\s+\\d+\\s+\\d+%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" + "s" "object size" "^\\s*\\d+\\s+\\d+\\s+\\d+%\\s+(\\d+\\.\\d+)K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" + "u" "utilisation" "^\\s*\\d+\\s+\\d+\\s+(\\d+)%\\s+\\d+\\.\\d+K\\s+\\d+\\s+\\d+\\s+\\d+K\\s+\\S\[^\r\]+\\s*" } foreach { flag desc match } $sort_tests { set test "slabtop sorted by $desc" spawn $slabtop -o -s $flag expect_table_dsc $test $slabtop_header $match } - +}