]> granicus.if.org Git - procps-ng/commitdiff
fixed pgrep and added ps tests
authorCraig Small <csmall@enc.com.au>
Tue, 29 Nov 2011 11:55:03 +0000 (22:55 +1100)
committerCraig Small <csmall@enc.com.au>
Tue, 29 Nov 2011 11:55:03 +0000 (22:55 +1100)
testsuite/Makefile.am
testsuite/pgrep.test/pgrep.exp
testsuite/ps.test/ps_output.exp [new file with mode: 0644]
testsuite/ps.test/ps_personality.exp [new file with mode: 0644]

index 50676f97e68eb64a828afcab7d819e6eb2bfddcb..3951ec42ac152b4fe9dc6163630081a1e9afca3e 100644 (file)
@@ -5,6 +5,7 @@ DEJATOOL = \
                   free \
                   pgrep \
                   pmap \
+                  ps \
                   pwdx \
                   uptime \
                   vmstat \
@@ -18,6 +19,8 @@ EXTRA_DIST = \
                         config/unix.exp \
                         uptime.test/uptime.exp \
                         pmap.test/pmap.exp \
+                        ps.test/ps_output.exp \
+                        ps.test/ps_personality.exp \
                         pwdx.test/pwdx.exp \
                         free.test/free.exp \
                         global-conf.exp \
index dedef79349b65b38549d006f833f98f091a1faf7..99d1fff17aeb52b4f0db2815f77cd145cb98e21d 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
diff --git a/testsuite/ps.test/ps_output.exp b/testsuite/ps.test/ps_output.exp
new file mode 100644 (file)
index 0000000..740e026
--- /dev/null
@@ -0,0 +1,38 @@
+#
+# Dejagnu tests for ps (output options) - part of procps
+#
+set ps ${topdir}ps/pscommand
+
+set mypid [pid]
+set not_ppid [ expr { $mypid + 1 } ]
+set uid [ exec id -u ]
+set not_uid [ expr { $uid + 1 } ] 
+set gid [ exec id -g ]
+set not_gid [ expr { $gid + 1 } ] 
+set raw_tty [ exec tty ]
+regexp "/dev/(.+)" $raw_tty > tty
+
+# All the fields
+# Cannot do args,cmd,comm
+set ps_digit "\\d+\\s*"
+set ps_state "\[A-Z<sl+\]\\s*"
+#set ps_pct "\\d{1,2}\\.\\d\\s*"
+set ps_pct "\\d"
+set ps_hex "\[0-9a-f\]\\s*"
+set ps_time "\\d{1,3}:\\d{2}\\s*"
+set ps_time "\(\d+-\)?\\\d{1,3}:\\d{2}\\s*"
+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*\)+$"
+    "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*\)+$"
+}
+
+foreach { flag match } $flag_match  {
+  set test "ps with output flag $flag"
+  spawn $ps -o $flag
+  expect_pass "$test" $match
+}
diff --git a/testsuite/ps.test/ps_personality.exp b/testsuite/ps.test/ps_personality.exp
new file mode 100644 (file)
index 0000000..1127f1e
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# check the ps personalities
+#
+set ps ${topdir}ps/pscommand
+
+set pers_match { 
+  bsd       "\\s+PID\\s+TTY\\s+STAT\\s+TIME\\s+COMMAND\\r"
+  linux     "\\s+PID\\s+TTY\\s+TIME\\s+CMD\\r"
+  old       "\\s+PID\\s+TTY\\s+STAT\\s+TIME\\s+COMMAND\\r"
+  }
+
+foreach { pers match } $pers_match  {
+  set test "ps with $pers personality"
+  set  env(PS_PERSONALITY) $pers
+  spawn $ps
+  expect_pass "$test" $match
+}
+