Merge remote-tracking branch 'csmall/testsuite'

This commit is contained in:
Craig Small 2011-12-01 23:01:27 +11:00
commit 43734fad69
18 changed files with 705 additions and 1 deletions

View File

@ -1,7 +1,7 @@
AM_CPPFLAGS = -include $(top_builddir)/config.h
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = proc ps
SUBDIRS = proc ps testsuite
AM_CFLAGS = -Iproc
AM_LDFLAGS = ./proc/libproc-ng.la

View File

@ -135,10 +135,17 @@ if test "x$enable_w_from" = xyes; then
AC_DEFINE(W_SHOWFROM, 1, [enable w from field by default])
fi
if test x"$DEJAGNU" = x
then
DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
fi
AC_SUBST(DEJAGNU)
AC_CONFIG_FILES([
Makefile
proc/Makefile
proc/libproc-ng.pc
ps/Makefile
testsuite/Makefile
])
AC_OUTPUT

4
testsuite/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.log
*.sum
site.bak
site.exp

32
testsuite/Makefile.am Normal file
View File

@ -0,0 +1,32 @@
AUTOMAKE_OPTIONS = dejagnu
export DEJAGNU
DEJATOOL = \
free \
kill \
pgrep \
pkill \
pmap \
ps \
pwdx \
uptime \
vmstat \
w
EXTRA_DIST = \
free.test/free.exp \
kill.test/kill.exp \
w.test/w.exp \
pgrep.test/pgrep.exp \
pkill.test/pkill.exp \
site.exp \
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 \
global-conf.exp \
sysctl.test/sysctl_read.exp \
vmstat.test/vmstat.exp

85
testsuite/config/unix.exp Normal file
View File

@ -0,0 +1,85 @@
regexp "(.*\/)testsuite" $objdir objdir topdir
proc procps_v_version { tool } {
global topdir
set toolpath ${topdir}${tool}
set tmp [ exec $toolpath -V ]
regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version
clone_output "$toolpath version $version\n"
}
proc free_version {} { procps_v_version free }
proc kill_version {} { procps_v_version kill }
proc pgrep_version {} { procps_v_version pgrep }
proc pkill_version {} { procps_v_version pkill }
proc pmap_version {} { procps_v_version pmap }
proc pwdx_version {} { procps_v_version pwdx }
proc sysctl_version {} { procps_v_version sysctl }
proc uptime_version {} { procps_v_version uptime }
proc vmstat_version {} { procps_v_version vmstat }
proc w_version {} { procps_v_version w }
#
#
# common utilities
proc expect_continue { testname reg } {
expect {
-re "$reg" { }
eof { fail "$testname" }
timeout { fail "$testname" }
}
}
proc expect_pass { testname reg } {
expect {
-re "$reg" { pass "$testname" }
default { fail "$testname" }
}
}
proc expect_blank { testname } {
expect {
-re "\\w" { fail "$testname" }
eof { pass "$testname" }
timeout { pass "$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
global testproc_path testproc_comm testproc1_pid testproc2_pid
set testproc_path [ exec mktemp -u ]
exec ln -s "/bin/sleep" $testproc_path
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" }
}
set testproc1_pid [ exec $testproc_path $sleep_time & ]
set testproc2_pid [ exec $testproc_path $sleep_time & ]
}

View File

@ -0,0 +1,44 @@
#
# Testsuite for free program
#
set free "${topdir}free"
set meminfo [ exec cat /proc/meminfo ]
regexp "MemTotal:\\s+\(\\d+\)" $meminfo -> memtotal_kb
regexp "SwapTotal:\\s+\(\\d+\)" $meminfo -> swaptotal_kb
set test "free with no arguments"
spawn free
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+${memtotal_kb}\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*-\\/\\+ buffers\\/cache:\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal_kb}\\s+\\d+\\s+\\d+\\s*"
set test "free with -b argument"
set memtotal [ expr { $memtotal_kb * 1024 } ]
set swaptotal [ expr { $swaptotal_kb * 1024 } ]
spawn free -b
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+${memtotal}\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*-\\/\\+ buffers\\/cache:\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal}\\s+\\d+\\s+\\d+\\s*"
foreach {arg divisor } {-k 1 -m 1024 -g 1048576 } {
set test "free with $arg argument"
set memtotal [ expr { $memtotal_kb / $divisor } ]
set swaptotal [ expr { $swaptotal_kb / $divisor } ]
spawn free $arg
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+$memtotal\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*-\\/\\+ buffers\\/cache:\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal}\\s+\\d+\\s+\\d+\\s*"
}
set test "free with human readable output"
spawn free -h
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s*-\\/\\+ buffers\\/cache:\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s*Swap:\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s+\[0-9.\]+\[BKMGT\]\\s*"
set test "free with lo and hi memory statistics"
spawn free -l
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+\\d+\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*Low:\\s+\\d+\\s+\\d+\\s+\\d+\\s*High:\\s+\\d+\\s+\\d+\\s+\\d+\\s*-\\/\\+ buffers\\/cache:\\s+\\d+\\s+\\d+\\s*Swap:\\s+\\d+\\s+\\d+\\s+\\d+"
set test "free old argument"
spawn free -o
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+\\d+\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*Swap:\\s+\\d+\\s+\\d+\\s+\\d+"
set test "free with total"
spawn free -t
expect_pass "$test" "^\\s+total\\s+used\\s+free\\s+shared\\s+buffers\\s+cached\\s*Mem:\\s+${memtotal_kb}\\s+\\d+\\s+\\d+\\s+0\\s+\\d+\\s+\\d+\\s*-\\/\\+ buffers\\/cache:\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal_kb}\\s+\\d+\\s+\\d+\\s*Total:\\s+\\d+\\s+\\d+\\s+\\d+\\s*"

View File

View File

@ -0,0 +1,42 @@
#
# Dejagnu testsuite for kill - part of procps
#
set kill ${topdir}kill
set test "kill with no arguments"
spawn $kill
expect_pass "$test" "Usage:\\s+kill pid ...\\s+Send SIGTERM to every process listed.\\r\\s+kill signal pid ...\\s+Send a signal to every process listed.\\r\\s+kill -s signal pid ...\\s+Send a signal to every process listed.\\r\\s+kill -l\\s+List all signal names.\\r\\s+kill -L\\s+List all signal names in a nice table.\\r\\s+kill -l signal\\s+Convert between signal numbers and names."
set test "kill list signal names"
spawn $kill -l
expect_pass "$test" "^\(\[A-Z12\]\\s*\)+$"
set test "kill list signal names in table"
spawn $kill -L
expect_pass "$test" "^\(\\s+\\d+ \[A-Z12\]+\)+\\s*$"
set test "kill convert signal name to number"
spawn $kill -l HUP
expect_pass "$test" "^1\\s*"
set test "kill convert signal number to name"
spawn $kill -l 1
expect_pass "$test" "^HUP\\s*"
set test "kill numbered process"
make_testproc
if { [ file isdirectory "/proc/$testproc1_pid" ] && [ file isdirectory "/proc/$testproc2_pid" ] } {
} else {
perror "Could not start test processes"
}
set foo [ exec $kill -KILL $testproc1_pid $testproc2_pid ]
wait
wait
if { [ file exists "/proc/$testproc1_pid" ] || [ file exists "/proc/$testproc2_pid" ] } {
fail "$test"
} else {
pass "$test"
}

View File

@ -0,0 +1,117 @@
#
# Dejagnu tests for pgrep - part of procps
#
set mypid [pid]
set not_ppid [ expr { $mypid + 1 } ]
set pgrep "${topdir}pgrep"
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
make_testproc
set testproc_len [ string length $testproc_comm ]
set testproc_trim [ string range $testproc_comm 0 [ expr { $testproc_len - 2 } ] ]
set testproc1_sid [ string trim [ exec ps --no-headers -o sid $testproc1_pid ] ]
set test "pgprep with no arguments"
spawn $pgrep
expect_pass "$test" "^pgrep: No matching criteria specified\\s*"
set test "pgrep find both test pids"
spawn $pgrep $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
# In Debian only
#set test "pgrep counts 2 test pids"
#spawn $pgrep -c $testproc_comm
#expect_pass "$test" "^2\\s*"
set test "pgrep with : delimiter"
spawn $pgrep -d : $testproc_comm
expect_pass "$test" "^${testproc1_pid}:${testproc2_pid}\\s*$"
# FIXME - Need to test against -f flag
set test "pgrep match against full process name"
untested $test
set test "pgrep with matching gid"
spawn $pgrep -G $gid $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep with not matching gid"
spawn $pgrep -G $not_gid $testproc_comm
expect_blank $test
set test "pgrep with process name"
spawn $pgrep -l $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc_comm\\s+$testproc2_pid\\s+$testproc_comm\\s*$"
set test "pgrep find newest test pid"
spawn $pgrep -n $testproc_comm
expect_pass "$test" "^$testproc2_pid\\s*$"
set test "pgrep find oldest test pid"
spawn $pgrep -o $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s*$"
set test "pgrep matches with parent pid"
spawn $pgrep -P $mypid $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep doesn't match with bogus parent pid"
spawn $pgrep -P $not_ppid $testproc_comm
expect_blank "$test"
set test "pgrep matches with its own sid"
spawn $pgrep -s $testproc1_sid $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep doesn't match with bogus sid"
spawn $pgrep -s 1 $testproc_comm
expect_blank "$test"
set test "pgrep matches on tty"
spawn $pgrep -t $tty $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep doesn't match with bogus tty"
spawn $pgrep -t glass $testproc_comm
expect_blank "$test"
set test "pgrep with matching euid"
spawn $pgrep -u $uid $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep with not matching euid"
spawn $pgrep -u $not_uid $testproc_comm
expect_blank $test
set test "pgrep with matching uid"
spawn $pgrep -U $uid $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep with not matching uid"
spawn $pgrep -U $not_uid $testproc_comm
expect_blank $test
set test "pgrep matches on substring"
spawn $pgrep $testproc_trim
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep matches full string with exact"
spawn $pgrep -x $testproc_comm
expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$"
set test "pgrep does not match substring with exact"
spawn $pgrep -x $testproc_trim
expect_blank $test
# Cleanup
exec kill $testproc1_pid
exec kill $testproc2_pid
exec rm $testproc_path

View File

@ -0,0 +1,127 @@
#
# Dejagnu tests for pkill - part of procps
#
set mypid [pid]
set not_ppid [ expr { $mypid + 1 } ]
set pkill "${topdir}pkill"
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
make_testproc
set testproc_len [ string length $testproc_comm ]
set testproc_trim [ string range $testproc_comm 0 [ expr { $testproc_len - 2 } ] ]
set testproc1_sid [ exec ps --no-headers -o sid $testproc1_pid ]
set test "pkill with no arguments"
spawn $pkill
expect_pass "$test" "^pkill: No matching criteria specified\\s*"
set test "pkill find both test pids"
#spawn $pkill $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
# In Debian only
#set test "pkill counts 2 test pids"
#spawn $pkill -c $testproc
#expect_pass "$test" "^2\\s*"
set test "pkill with matching gid"
#spawn $pkill -G $gid $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill with not matching gid"
#spawn $pkill -G $not_gid $testproc
#expect_blank $test
untested "$test"
set test "pkill with process name"
#spawn $pkill -l $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$testproc\\s+$sleep2_pid\\s+$testproc\\s*$"
untested "$test"
set test "pkill find newest test pid"
#spawn $pkill -n $testproc
#expect_pass "$test" "^$sleep2_pid\\s*$"
untested "$test"
set test "pkill find oldest test pid"
#spawn $pkill -o $testproc
#expect_pass "$test" "^$sleep1_pid\\s*$"
untested "$test"
set test "pkill matches with parent pid"
#spawn $pkill -P $mypid $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill doesn't match with bogus parent pid"
#spawn $pkill -P $not_ppid $testproc
#expect_blank "$test"
untested "$test"
set test "pkill matches with its own sid"
#spawn $pkill -s $sleep1_sid $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill doesn't match with bogus sid"
#spawn $pkill -s 1 $testproc
#expect_blank "$test"
untested "$test"
set test "pkill matches on tty"
#spawn $pkill -t $tty $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill doesn't match with bogus tty"
#spawn $pkill -t glass $testproc
#expect_blank "$test"
untested "$test"
set test "pkill with matching euid"
#spawn $pkill -u $uid $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill with not matching euid"
#spawn $pkill -u $not_uid $testproc
#expect_blank $test
untested "$test"
set test "pkill with matching uid"
#spawn $pkill -U $uid $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill with not matching uid"
#spawn $pkill -U $not_uid $testproc
#expect_blank $test
untested "$test"
set test "pkill matches on substring"
#spawn $pkill $testproc_trim
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill matches full string with exact"
#spawn $pkill -x $testproc
#expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
untested "$test"
set test "pkill does not match substring with exact"
#spawn $pkill -x $testproc_trim
#expect_blank $test
untested "$test"
# Cleanup
exec kill $testproc1_pid
exec kill $testproc2_pid
exec rm $testproc_path

View File

@ -0,0 +1,48 @@
#
# 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

View File

@ -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}\\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*\)+$"
}
foreach { flag match } $flag_match {
set test "ps with output flag $flag"
spawn $ps -o $flag
expect_pass "$test" $match
}

View File

@ -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
}

View File

@ -0,0 +1,20 @@
set pwdx "${topdir}pwdx"
# Run pwdx with no arguments
set test "pwdx no args"
spawn $pwdx
expect_pass "$test" "^Usage: pwdx pid\.\.\."
# Run pwdx with pid 1 which is not reachable
set test "pwdx pid 1 should give permission denied"
spawn $pwdx 1
expect_pass "$test" "^1: Permission denied"
# Run pwdx with existing pid
set test "pwdx finds sleep in cwd"
set sleep_pid [ exec sleep 600 & ]
set sleep_pwd [ pwd ]
spawn $pwdx $sleep_pid
expect_pass "$test" "^$sleep_pid: $sleep_pwd"
exec kill $sleep_pid

View File

@ -0,0 +1,25 @@
#
# Dejagnu tests for sysctl (read only) - part of procps
#
set sysctl ${topdir}sysctl
set hostname [ exec cat "/proc/sys/kernel/hostname" ]
set test "sysctl with no arguments"
spawn $sysctl
expect_pass "$test" "^usage:\\s+\(lt-\)?sysctl \\\[-n\\\] \\\[-e\\\] variable \\.\\.\\.\\s+"
set test "sysctl reading a variable using slash delimiter"
spawn $sysctl kernel/hostname
expect_pass "$test" "kernel.hostname = ${hostname}"
set test "sysctl reading a variable using dot delimiter"
spawn $sysctl kernel.hostname
expect_pass "$test" "kernel.hostname = ${hostname}"
set test "sysctl reading a variable suppress key"
spawn $sysctl -n kernel.hostname
expect_pass "$test" "${hostname}"
set test "sysctl reading a variable suppress value"
spawn $sysctl -N kernel.hostname
expect_pass "$test" "kernel.hostname"

View File

@ -0,0 +1,8 @@
#
# Dejagnu tests for uptime - part of procps
#
set uptime "${topdir}uptime"
set test "uptime"
spawn $uptime
expect_pass "$test" "^\\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*$"

View File

@ -0,0 +1,36 @@
#
# Dejagnu tests for vmstat - part of procps
set vmstat "${topdir}vmstat"
# Run vmstat with no arguments
set test "vmstat with no arguments"
spawn $vmstat
expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa\\s*\(\\s+\\d+\){16}\\s*$"
set test "vmstat with -a flag"
spawn $vmstat -a
expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa\\s*\(\\s+\\d+\){16}\\s*$"
set test "vmstat fork option"
spawn $vmstat -f
expect_pass "$test" "^\\s+\\d+ forks\\s*$"
set test "vmstat slabinfo (-m option)"
spawn $vmstat -m
expect_pass "$test" "^Cache\\s+Num\\s+Total\\s+Size\\s+Pages\\s+\(\[\(\)A-Za-z0-9_-\]+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*\){1,}"
set test "vmstat disk information (-d option)"
spawn $vmstat -d
expect_pass "$test" "^disk\[ -\]+reads\[ -\]+writes\[ -\]+IO\[ -\]+\\s+total\\s+merged\\s+sectors\\s+ms\\s+total\\s+merged\\s+sectors\\s+ms\\s+cur\\s+sec\\s+"
# Need a partition
set diskstats [ exec cat /proc/diskstats ]
regexp "\\s+\\d+\\s+\\d+\\s+\(\[a-z\]+\\d+\)" $diskstats -> partition
set test "vmstat partition"
spawn $vmstat -p $partition
expect_pass "$test" "^${partition}\\s+reads"
#\\s+read sectors\\s+writes\\s+requested writes"
#\(\\s+\\d+\){4}\\s*$"

53
testsuite/w.test/w.exp Normal file
View File

@ -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}"