From 23afed732a48aaa98079c5a03bb16b796f8fba62 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Thu, 1 Dec 2011 22:42:23 +1100 Subject: [PATCH] fixed small tests for pmap and ps checks --- testsuite/config/unix.exp | 21 +++++++++++++--- testsuite/pmap.test/pmap.exp | 43 +++++++++++++++++++++++++++++++++ testsuite/ps.test/ps_output.exp | 2 +- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp index 4ed01a60..eb984b81 100644 --- a/testsuite/config/unix.exp +++ b/testsuite/config/unix.exp @@ -4,7 +4,6 @@ regexp "(.*\/)testsuite" $objdir objdir topdir proc procps_v_version { tool } { global topdir set toolpath ${topdir}${tool} -send_user "$toolpath -V" set tmp [ exec $toolpath -V ] regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version clone_output "$toolpath version $version\n" @@ -35,8 +34,7 @@ proc expect_continue { testname reg } { proc expect_pass { testname reg } { expect { -re "$reg" { pass "$testname" } - eof { fail "$testname" } - timeout { fail "$testname" } + default { fail "$testname" } } } @@ -48,6 +46,23 @@ proc expect_blank { testname } { } } +proc expect_table { test match_header match_items match_footer } { + expect { + -re "$match_header" { + expect { + -re "$match_items" { + expect { + -re "$match_footer" { pass "$test" } + default { fail "$test (footer)" } + } + } + default { fail "$test (items)" } + } + } + default { fail "$test (header)" } + } +} + proc make_testproc { } { # Time to run the whole job set sleep_time 300 diff --git a/testsuite/pmap.test/pmap.exp b/testsuite/pmap.test/pmap.exp index 2d592ce3..5dce21e7 100644 --- a/testsuite/pmap.test/pmap.exp +++ b/testsuite/pmap.test/pmap.exp @@ -2,4 +2,47 @@ # Dejagnu tests for pgrep - part of procps # set pmap "${topdir}pmap" +set mypid [pid] + +set pmap_procname "${mypid}:\\s+\\S+\[^\\r\]+\\s+" +set pmap_std_header $pmap_procname +set pmap_device_header "${pmap_procname}Address\\s+Kbytes\\s+Mode\\s+Offset\\s+Device\\s+Mapping\\s+" +set pmap_ext_header "${pmap_procname}Address\\s+Kbytes\\s+RSS\\s+Anon\\s+Locked\\s+Mode\\s+Mapping\\s+" + +set pmap_std_items "\(\[0-9a-f\]+\\s+\\d+K \[rwx-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+" +set pmap_device_items "\(\[0-9a-f\]+\\s+\\d+ \[rwx-\]{5}\\s+\[0-9a-f\]+\\s+\[0-9a-f\]{3}:\[0-9a-f\]{5}\\s+\\S+\[^\\r\]+\\s*\)+" +set pmap_ext_items "\(\[0-9a-f\]+\\s+\\d+\\s+-\\s+-\\s+- \[rwx-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+" + +set pmap_std_footer "total\\s+\\d+K\\s*\$" +set pmap_device_footer "mapped:\\s+\\d+K\\s+writeable\/private:\\s+\\d+K\\s+shared:\\s+\\d+K\\s*\$" +set pmap_ext_footer "\[ -\]+\\s+total kB\\s+\\d+\\s+-\\s+-\\s+-\\s*\$" + +set test "pmap with no arguments" +spawn $pmap +expect_pass "$test" "^Usage: pmap \\\[-x | -d\\\] \\\[-q\\\] \\\[-A low,high\\\] pid\\.\\.\\.\\s+-x\\s+show details\\s+-d\\s+show offset and device number\\s+-q\\s+quiet; less header/footer info\\s+-V\\s+show the version number\\s+-A\\s+limit results to the given range\\s*" + +set test "pmap standard output" +spawn $pmap $mypid +expect_table $test $pmap_std_header $pmap_std_items $pmap_std_footer + +set test "pmap standard output with quiet" +spawn $pmap -q $mypid +expect_table $test $pmap_procname $pmap_std_items "\$" + +set test "pmap device output" +spawn $pmap -d $mypid +expect_table $test $pmap_device_header $pmap_device_items $pmap_device_footer + + +set test "pmap device output quiet (dq)" +spawn $pmap -dq $mypid +expect_table $test $pmap_procname $pmap_device_items "\$" + +set test "pmap device output quiet (qd)" +spawn $pmap -qd $mypid +expect_table $test $pmap_procname $pmap_device_items "\$" + +set test "pmap extended output" +spawn $pmap -x $mypid +expect_table $test $pmap_ext_header $pmap_ext_items $pmap_ext_footer diff --git a/testsuite/ps.test/ps_output.exp b/testsuite/ps.test/ps_output.exp index 740e026c..abc7bd5e 100644 --- a/testsuite/ps.test/ps_output.exp +++ b/testsuite/ps.test/ps_output.exp @@ -26,7 +26,7 @@ set ps_class "\[A-Z?-\]\\s*" set flag_match { "%cpu,pcpu,%mem,pmem" "%CPU\\s+%CPU\\s+%MEM\\s+%MEM\\s+\(\\d+\.\\d+\\s*\){4}$" "blocked,sig_block,sigmask,caught,sigcatch,sig_catch" "\(BLOCKED\\s+\){3}\(CAUGHT\\s+\){2}CATCHED\\s+\(\[0-9a-f\]+\\s*\){6}$" - "bsdstart,start,lstart" "\\s*START\\s+STARTED\\s+STARTED\\s+\(\\s*\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}\)\\s+\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}:\\d{2}\)\\s+\[A-Z\]\[a-z\]{2} \[A-Z\]\[a-z\]{2} \\d{2} \\d{2}:\\d{2}:\\d{2} \\d{4}\\s*\)+$" + "bsdstart,start,lstart" "\\s*START\\s+STARTED\\s+STARTED\\s+\(\\s*\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}\)\\s+\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}:\\d{2}\)\\s+\[A-Z\]\[a-z\]{2} \[A-Z\]\[a-z\]{2}\\s+\\d+ \\d{2}:\\d{2}:\\d{2} \\d{4}\\s*\)+$" "bsdtime,cputime,etime,etimes" "\\s*TIME\\s+TIME\\s+ELAPSED\\s+ELAPSED\\s*\(\\s*\\d+:\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\s+\(\\d{2}:\)?\\d{2}:\\d{2}\\s+\\d+\\s*\)$" "user,ruser,group,rgroup,uid,ruid,gid,rgid" "\\s*USER\\s+RUSER\\s+GROUP\\s+RGROUP\\s+UID\\s+RUID\\s+GID\\s+RGID\\s+\(\(\\s*\[A-Za-z0-9_-\]+\\s+\){4}\(\\d+\\s+\){4}\\s*\)+$" }