Merge remote-tracking branch 'csmall/testsuite'
This commit is contained in:
commit
be55207672
@ -1,7 +1,7 @@
|
|||||||
AM_CPPFLAGS = -include $(top_builddir)/config.h
|
AM_CPPFLAGS = -include $(top_builddir)/config.h
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
SUBDIRS = proc ps
|
SUBDIRS = proc ps testsuite
|
||||||
|
|
||||||
AM_CFLAGS = -Iproc
|
AM_CFLAGS = -Iproc
|
||||||
AM_LDFLAGS = ./proc/libproc-ng.la
|
AM_LDFLAGS = ./proc/libproc-ng.la
|
||||||
|
@ -135,10 +135,17 @@ if test "x$enable_w_from" = xyes; then
|
|||||||
AC_DEFINE(W_SHOWFROM, 1, [enable w from field by default])
|
AC_DEFINE(W_SHOWFROM, 1, [enable w from field by default])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test x"$DEJAGNU" = x
|
||||||
|
then
|
||||||
|
DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
|
||||||
|
fi
|
||||||
|
AC_SUBST(DEJAGNU)
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
proc/Makefile
|
proc/Makefile
|
||||||
proc/libproc-ng.pc
|
proc/libproc-ng.pc
|
||||||
ps/Makefile
|
ps/Makefile
|
||||||
|
testsuite/Makefile
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
4
testsuite/.gitignore
vendored
Normal file
4
testsuite/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*.log
|
||||||
|
*.sum
|
||||||
|
site.bak
|
||||||
|
site.exp
|
14
testsuite/Makefile.am
Normal file
14
testsuite/Makefile.am
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
AUTOMAKE_OPTIONS = dejagnu
|
||||||
|
export DEJAGNU
|
||||||
|
|
||||||
|
DEJATOOL = \
|
||||||
|
free \
|
||||||
|
pgrep \
|
||||||
|
pmap \
|
||||||
|
pwdx \
|
||||||
|
uptime \
|
||||||
|
vmstat \
|
||||||
|
w
|
||||||
|
|
||||||
|
|
||||||
|
|
84
testsuite/config/unix.exp
Normal file
84
testsuite/config/unix.exp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
regexp "(.*\/)testsuite" $objdir objdir topdir
|
||||||
|
|
||||||
|
proc pwdx_load { arg } { }
|
||||||
|
proc pwdx_exit {} {}
|
||||||
|
proc pwdx_version {} {
|
||||||
|
global topdir
|
||||||
|
set tmp [ exec pwdx -V ]
|
||||||
|
regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version
|
||||||
|
clone_output "${topdir}pwdx version $version\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# free functions
|
||||||
|
proc free_load { arg } { }
|
||||||
|
proc free_exit {} {}
|
||||||
|
proc 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
# uptime functions
|
||||||
|
proc uptime_load { arg } { }
|
||||||
|
proc uptime_exit {} {}
|
||||||
|
proc uptime_version {} {
|
||||||
|
global topdir
|
||||||
|
set tmp [ exec ${topdir}uptime -V ]
|
||||||
|
regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version
|
||||||
|
clone_output "${topdir}uptime 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 "${topdir}w version $version\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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" }
|
||||||
|
eof { fail "$testname" }
|
||||||
|
timeout { fail "$testname" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc expect_blank { testname } {
|
||||||
|
expect {
|
||||||
|
-re "\\w" { fail "$testname" }
|
||||||
|
eof { pass "$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" }
|
||||||
|
}
|
||||||
|
}
|
44
testsuite/free.test/free.exp
Normal file
44
testsuite/free.test/free.exp
Normal 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*"
|
||||||
|
|
0
testsuite/global-conf.exp
Normal file
0
testsuite/global-conf.exp
Normal file
127
testsuite/pgrep.test/pgrep.exp
Normal file
127
testsuite/pgrep.test/pgrep.exp
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
set newsleep_path [ exec mktemp -u ]
|
||||||
|
exec ln -s "/bin/sleep" $newsleep_path
|
||||||
|
set sleep1_pid [ exec $newsleep_path 600 & ]
|
||||||
|
set sleep2_pid [ exec $newsleep_path 600 & ]
|
||||||
|
set newsleep [ exec basename $newsleep_path ]
|
||||||
|
set newsleep_len [ string length $newsleep ]
|
||||||
|
set newsleep_trim [ string range $newsleep 0 [ expr { $newsleep_len - 2 } ] ]
|
||||||
|
set sleep1_sid [ exec ps --no-headers -o sid $sleep1_pid ]
|
||||||
|
|
||||||
|
spawn readlink $newsleep_path
|
||||||
|
expect {
|
||||||
|
-re "^/bin/sleep\\s*$" { }
|
||||||
|
timeout { fail "sleep symlink broken in prgrep tests" }
|
||||||
|
eof { fail "sleep symlink broken in prgrep tests" }
|
||||||
|
}
|
||||||
|
|
||||||
|
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 $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
# In Debian only
|
||||||
|
#set test "pgrep counts 2 test pids"
|
||||||
|
#spawn $pgrep -c $newsleep
|
||||||
|
#expect_pass "$test" "^2\\s*"
|
||||||
|
|
||||||
|
set test "pgrep with : delimiter"
|
||||||
|
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 with matching gid"
|
||||||
|
spawn $pgrep -G $gid $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep with not matching gid"
|
||||||
|
spawn $pgrep -G $not_gid $newsleep
|
||||||
|
expect_blank $test
|
||||||
|
|
||||||
|
set test "pgrep with process name"
|
||||||
|
spawn $pgrep -l $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$newsleep\\s+$sleep2_pid\\s+$newsleep\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep find newest test pid"
|
||||||
|
spawn $pgrep -n $newsleep
|
||||||
|
expect_pass "$test" "^$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep find oldest test pid"
|
||||||
|
spawn $pgrep -o $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep matches with parent pid"
|
||||||
|
spawn $pgrep -P $mypid $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep doesn't match with bogus parent pid"
|
||||||
|
spawn $pgrep -P $not_ppid $newsleep
|
||||||
|
expect_blank "$test"
|
||||||
|
|
||||||
|
set test "pgrep matches with its own sid"
|
||||||
|
spawn $pgrep -s $sleep1_sid $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep doesn't match with bogus sid"
|
||||||
|
spawn $pgrep -s 1 $newsleep
|
||||||
|
expect_blank "$test"
|
||||||
|
|
||||||
|
set test "pgrep matches on tty"
|
||||||
|
spawn $pgrep -t $tty $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep doesn't match with bogus tty"
|
||||||
|
spawn $pgrep -t glass $newsleep
|
||||||
|
expect_blank "$test"
|
||||||
|
|
||||||
|
set test "pgrep with matching euid"
|
||||||
|
spawn $pgrep -u $uid $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep with not matching euid"
|
||||||
|
spawn $pgrep -u $not_uid $newsleep
|
||||||
|
expect_blank $test
|
||||||
|
|
||||||
|
set test "pgrep with matching uid"
|
||||||
|
spawn $pgrep -U $uid $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep with not matching uid"
|
||||||
|
spawn $pgrep -U $not_uid $newsleep
|
||||||
|
expect_blank $test
|
||||||
|
|
||||||
|
set test "pgrep matches on substring"
|
||||||
|
spawn $pgrep $newsleep_trim
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep matches full string with exact"
|
||||||
|
spawn $pgrep -x $newsleep
|
||||||
|
expect_pass "$test" "^$sleep1_pid\\s+$sleep2_pid\\s*$"
|
||||||
|
|
||||||
|
set test "pgrep does not match substring with exact"
|
||||||
|
spawn $pgrep -x $newsleep_trim
|
||||||
|
expect_blank $test
|
||||||
|
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
exec kill $sleep1_pid
|
||||||
|
exec kill $sleep2_pid
|
||||||
|
exec rm $newsleep_path
|
5
testsuite/pmap.test/pmap.exp
Normal file
5
testsuite/pmap.test/pmap.exp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# Dejagnu tests for pgrep - part of procps
|
||||||
|
#
|
||||||
|
set pmap "${topdir}pmap"
|
||||||
|
|
31
testsuite/pwdx.test/pwdx.exp
Normal file
31
testsuite/pwdx.test/pwdx.exp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
set pwdx "${topdir}pwdx"
|
||||||
|
# Run pwdx with no arguments
|
||||||
|
set test "pwdx no args"
|
||||||
|
spawn pwdx
|
||||||
|
expect {
|
||||||
|
-re "^Usage: pwdx pid\.\.\." { pass "$test" }
|
||||||
|
eof { fail "$test" }
|
||||||
|
timeout { fail "$test" }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run pwdx with pid 1 which is not reachable
|
||||||
|
set test "pwdx pid 1 should give permission denied"
|
||||||
|
spawn pwdx 1
|
||||||
|
expect {
|
||||||
|
-re "^1: Permission denied" { pass "$test" }
|
||||||
|
eof { fail "$test" }
|
||||||
|
timeout { fail "$test" }
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 {
|
||||||
|
-re "^$sleep_pid: $sleep_pwd" { pass "$test" }
|
||||||
|
eof { fail "$test" }
|
||||||
|
timeout { fail "$test" }
|
||||||
|
}
|
||||||
|
|
8
testsuite/uptime.test/uptime.exp
Normal file
8
testsuite/uptime.test/uptime.exp
Normal 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*$"
|
36
testsuite/vmstat.test/vmstat.exp
Normal file
36
testsuite/vmstat.test/vmstat.exp
Normal 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
53
testsuite/w.test/w.exp
Normal 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}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user