]> granicus.if.org Git - procps-ng/commitdiff
rearranged testsuite
authorCraig Small <csmall@enc.com.au>
Sun, 27 Nov 2011 07:32:10 +0000 (18:32 +1100)
committerCraig Small <csmall@enc.com.au>
Sun, 27 Nov 2011 07:32:10 +0000 (18:32 +1100)
testsuite/Makefile.am
testsuite/config/unix.exp
testsuite/free.test/free.exp [moved from testsuite/procps-ng.test/free.test/free.exp with 100% similarity]
testsuite/pgrep.test/pgrep.exp [moved from testsuite/procps-ng.test/pgrep.test/pgrep.exp with 96% similarity]
testsuite/pmap.test/pmap.exp [new file with mode: 0644]
testsuite/pwdx.test/pwdx.exp [moved from testsuite/procps-ng.test/pwdx.test/pwdx.exp with 100% similarity]
testsuite/w.test/w.exp [new file with mode: 0644]

index e0f2bc00b4e1146874d33544a6526d73ab457e5c..7786ee1b1516ddd7b0effa89eaccc1a54e021945 100644 (file)
@@ -2,4 +2,11 @@ AUTOMAKE_OPTIONS = dejagnu
 export DEJAGNU
 
 DEJATOOL = \
-       procps-ng 
+                  free \
+                  pgrep \
+                  pmap \
+                  pwdx \
+                  w
+               
+       
+
index f11f7933ea5d512e791fcbd0b827beb160ab7d90..57870bceeec2e76f5cc37c478dc9f79d11f9aebb 100644 (file)
@@ -14,9 +14,20 @@ proc pwdx_version {} {
 proc free_load { arg } { }
 proc free_exit {} {}
 proc free_version {} {
-  set tmp [ exec free --version ]
+  global topdir
+  set tmp [ exec ${topdir}free --version ]
+  regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version
+  clone_output "${topdir}free version $version\n"
+}
+
+# w functions
+proc w_load { arg } { }
+proc w_exit {} {}
+proc w_version {} {
+  global topdir
+  set tmp [ exec ${topdir}w -V ]
   regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version
-  clone_output "free version $version\n"
+  clone_output "${topdir}w version $version\n"
 }
 
 #
@@ -45,3 +56,19 @@ proc expect_blank { testname } {
         timeout { pass "$testname" }
     }
 }
+
+proc make_testproc { } {
+    global testproc_path testproc_comm testproc1_pid testproc2_pid
+
+    set testproc_path [ exec mktemp -u ]
+    exec ln -s "/bin/sleep" $testproc_path
+    set testproc1_pid [ exec $testproc_path 600 & ]
+    set testproc2_pid [ exec $testproc_path 600 & ]
+    set testproc_comm [ exec basename $testproc_path ]
+    spawn readlink $testproc_path
+    expect {
+        -re "^/bin/sleep\\s*$" { }
+        timeout { perror "test proc does not link to sleep 1" }
+        eof { perror "test proc does not link to sleep 1" }
+    }
+}
similarity index 96%
rename from testsuite/procps-ng.test/pgrep.test/pgrep.exp
rename to testsuite/pgrep.test/pgrep.exp
index 98c938d4fd222a065a086688dde76d1e1166bace..dedef79349b65b38549d006f833f98f091a1faf7 100644 (file)
@@ -45,8 +45,8 @@ spawn $pgrep -d : $newsleep
 expect_pass "$test" "^${sleep1_pid}:${sleep2_pid}\\s*$"
 
 # FIXME - Need to test against -f flag
-set test "pgrep match against full process name"
-untested $test
+#set test "pgrep match against full process name"
+#untested $test
 
 set test "pgrep with matching gid"
 spawn $pgrep -G $gid $newsleep
@@ -122,4 +122,6 @@ expect_blank $test
 
 
 # Cleanup
+exec kill $sleep1_pid
+exec kill $sleep2_pid
 exec rm $newsleep_path
diff --git a/testsuite/pmap.test/pmap.exp b/testsuite/pmap.test/pmap.exp
new file mode 100644 (file)
index 0000000..2d592ce
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Dejagnu tests for pgrep - part of procps
+#
+set pmap "${topdir}pmap"
+
diff --git a/testsuite/w.test/w.exp b/testsuite/w.test/w.exp
new file mode 100644 (file)
index 0000000..d96787c
--- /dev/null
@@ -0,0 +1,53 @@
+#
+# Dejagnu tests for w - part of procps
+#
+# FIXME - the user lines only go to idle
+set w "${topdir}w"
+
+set w_uptime "\\s+\\d{2}:\\d{2}:\\d{2} up (\\d+ days?,)\\s*\\d+(min|:\\d+), +\\d+ users, +load average: \[0-9.\]+, \[0-9.\]+, \[0-9.\]+\\s+"
+set w_std_header "${w_uptime}USER\\s+TTY\\s+LOGIN@\\s+IDLE\\s+JCPU\\s+PCPU\\s+WHAT\\s+"
+set w_short_header "${w_uptime}USER\\s+TTY\\s+IDLE\\s+WHAT\\s+"
+set w_from_header "${w_uptime}USER\\s+TTY\\s+FROM\\s+LOGIN@\\s+IDLE\\s+JCPU\\s+PCPU\\s+WHAT\\s+"
+set w_fromshort_header "${w_uptime}USER\\s+TTY\\s+FROM\\s+IDLE\\s+WHAT\\s+"
+
+set w_user "\[A-Za-z0-9_-\]+"
+set w_tty "\[a-z0-9/]+"
+set w_from "\[A-Za-z0-9.:-\]+"
+set w_login "\(\\d+\[A-Z\]\[a-z\]{2}\\d+\|\[A-Z\]\[a-z\]{2}\\d+\|\\d+:\\d+\)"
+set w_idle  "\(\\?xdm\\?\|\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
+set w_ival7  "\(\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
+set w_what  "\[A-Za-z0-9_\/\\-\]+"
+set w_std_userlines "\(${w_user}\\s+${w_tty}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\){1,}"
+set w_short_userlines "\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_what}\\s*\){1,}"
+set w_from_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\){1,}"
+set w_fromshort_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_idle}\\s+${w_what}\\s*\){1,}"
+
+set test "w with no arguments"
+spawn $w
+expect_pass "$test" "^${w_std_header}${w_std_userlines}"
+
+
+set test "w with no headers"
+spawn $w -h
+expect_pass "$test" "^${w_std_userlines}"
+
+set test "w with -u flag"
+spawn $w -u
+expect_pass "$test" "^${w_std_header}${w_std_userlines}"
+
+set test "w with short output"
+spawn $w -s
+expect_pass "$test" "^${w_short_header}${w_short_userlines}"
+
+set test "w with from flag"
+spawn $w -f
+expect_pass "$test" "^${w_from_header}${w_from_userlines}"
+
+set test "w with from and short flags"
+spawn $w -fs
+expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
+
+set test "w with short and from flags"
+spawn $w -sf
+expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
+