summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorCraig Small <csmall@enc.com.au>2011-12-02 22:41:03 +1100
committerCraig Small <csmall@enc.com.au>2011-12-02 22:41:03 +1100
commit226c1f2a6f254a665f142cd89b44dfc03b7c3a83 (patch)
treeb0ededecfb64c6f4d4d45a85c041771dac5e97b3 /testsuite
parent23afed732a48aaa98079c5a03bb16b796f8fba62 (diff)
downloadprocps-ng-226c1f2a6f254a665f142cd89b44dfc03b7c3a83.tar.gz
Added slabtop tests
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/config/unix.exp40
-rw-r--r--testsuite/slabtop.test/slabtop.exp30
2 files changed, 70 insertions, 0 deletions
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
index eb984b8..b1d28fa 100644
--- a/testsuite/config/unix.exp
+++ b/testsuite/config/unix.exp
@@ -63,6 +63,46 @@ proc expect_table { test match_header match_items match_footer } {
}
}
+proc expect_table_dsc { test match_header match_item } {
+ expect {
+ -re $match_header {}
+ default {
+ fail "$test (header)"
+ return
+ }
+ }
+
+ set do_loop 1
+ set last_value 999999
+ set found_item 0
+ while { $do_loop ==1 } {
+ expect {
+ -re $match_item {
+ set current_value $expect_out(1,string)
+ if { $current_value > $last_value } {
+ fail "$test (sorting $current_value > $last_value)"
+ return
+ } else {
+ set found_item 1
+ set last_value $current_value
+ }
+ }
+ default {
+ if { $found_item == 0 } {
+ fail "$test (items)"
+ } else {
+ pass $test
+ }
+ return
+ }
+ }
+ }
+ #expect {
+ # -re $match_footer { pass $test }
+ # default { fail "$test (footer)" }
+ #}
+}
+
proc make_testproc { } {
# Time to run the whole job
set sleep_time 300
diff --git a/testsuite/slabtop.test/slabtop.exp b/testsuite/slabtop.test/slabtop.exp
new file mode 100644
index 0000000..92ca76c
--- /dev/null
+++ b/testsuite/slabtop.test/slabtop.exp
@@ -0,0 +1,30 @@
+#
+# Dehagnu testing for slabtop - part of procps
+#
+set slabtop ${topdir}slabtop
+
+set avst "Active / Total"
+set used "\\\(% used\\\)\\s+:"
+set pct "\\\(\\d+\\.\\d+%\\\)"
+
+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"
+spawn $slabtop --help
+expect_pass $test "usage: $slabtop \\\[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*"
+ "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*"
+ }
+foreach { flag desc match } $sort_tests {
+ set test "slabtop sorted by $desc"
+ spawn $slabtop -o -s $flag
+ expect_table_dsc $test $slabtop_header $match
+}
+