diff options
author | Craig Small <csmall@enc.com.au> | 2015-06-13 15:04:31 +1000 |
---|---|---|
committer | Craig Small <csmall@enc.com.au> | 2015-06-13 15:04:31 +1000 |
commit | 420cd9c7c23b558491e7aa99f8a258c1421e867c (patch) | |
tree | a95016cf87616ed8538ab5d47f5525bc6e7eed44 /testsuite | |
parent | 26955dd02a2e870f7abf5520ef19603fe2b678fa (diff) | |
download | procps-ng-420cd9c7c23b558491e7aa99f8a258c1421e867c.tar.gz |
Create test process
For the test suite, procps used to use sleep which would just
create a process or two to test the tools against. Some setups
coreutils creates all programs including sleep into one blob which
means a lot of the tests fail, see issue #2
procps has its own sleep program now.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/config/unix.exp | 21 | ||||
-rw-r--r-- | testsuite/pgrep.test/pgrep.exp | 8 | ||||
-rw-r--r-- | testsuite/pkill.test/pkill.exp | 96 | ||||
-rw-r--r-- | testsuite/pwdx.test/pwdx.exp | 14 |
4 files changed, 22 insertions, 117 deletions
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp index 1318e9a..566fc7d 100644 --- a/testsuite/config/unix.exp +++ b/testsuite/config/unix.exp @@ -118,25 +118,24 @@ proc expect_table_dsc { test match_header match_item } { } proc make_testproc { } { - global testproc_path testproc_comm testproc1_pid testproc2_pid sleep_time + global testproc_path testproc_comm testproc1_pid testproc2_pid topdir - # Time to run the whole job - set sleep_time 300 + set testproc_realpath "${topdir}/lib/.libs/test_process" + set testproc_comm "spcorp" set testproc_path [ exec mktemp -u ] - set sleep_path [ exec sh -c "command -v sleep" ] - exec ln -s $sleep_path $testproc_path - set testproc_comm [ exec basename $testproc_path ] + exec ln -s $testproc_realpath $testproc_path spawn readlink $testproc_path expect { - -re "^$sleep_path\\s*$" { } - timeout { perror "test proc does not link to sleep 1" } - eof { perror "test proc does not link to sleep 1" } + -re "^$testproc_realpath\\s*$" { } + timeout { perror "test proc does not link to test process" } + eof { perror "test proc does not link to test process" } } - set testproc1_pid [ exec $testproc_path $sleep_time & ] - set testproc2_pid [ exec $testproc_path $sleep_time & ] + + set testproc1_pid [ exec $testproc_path & ] + set testproc2_pid [ exec $testproc_path & ] } proc kill_testproc { } { diff --git a/testsuite/pgrep.test/pgrep.exp b/testsuite/pgrep.test/pgrep.exp index 7c394dc..ef26783 100644 --- a/testsuite/pgrep.test/pgrep.exp +++ b/testsuite/pgrep.test/pgrep.exp @@ -26,9 +26,9 @@ 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 counts 2 test pids" +spawn $pgrep -c $testproc_comm +expect_pass "$test" "^2\\s*" set test "pgrep with : delimiter" spawn $pgrep -d : $testproc_comm @@ -52,7 +52,7 @@ expect_pass "$test" "^$testproc1_pid\\s+$testproc_comm\\s+$testproc2_pid\\s+$tes set test "pgrep with full command line" spawn $pgrep -a $testproc_comm -expect_pass "$test" "^$testproc1_pid\\s+$testproc_path\\s+$sleep_time\\s+$testproc2_pid\\s+$testproc_path\\s+$sleep_time\\s*$" +expect_pass "$test" "^$testproc1_pid\\s+$testproc_path\\s+$testproc2_pid\\s+$testproc_path\\s*$" set test "pgrep find newest test pid" spawn $pgrep -n $testproc_comm diff --git a/testsuite/pkill.test/pkill.exp b/testsuite/pkill.test/pkill.exp index c583cbe..85ea15a 100644 --- a/testsuite/pkill.test/pkill.exp +++ b/testsuite/pkill.test/pkill.exp @@ -28,101 +28,5 @@ set test "pkill signal option order" spawn $pkill -e $testproc_comm -0 expect_pass "$test" "^$testproc_comm killed \\(pid $testproc1_pid\\)\\s+$testproc_comm killed \\(pid $testproc2_pid\\)\\s*$" -# 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" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc\\s+$testproc2_pid\\s+$testproc\\s*$" -untested "$test" - -set test "pkill find newest test pid" -#spawn $pkill -n $testproc -#expect_pass "$test" "^$testproc2_pid\\s*$" -untested "$test" - -set test "pkill find oldest test pid" -#spawn $pkill -o $testproc -#expect_pass "$test" "^$testproc1_pid\\s*$" -untested "$test" - -set test "pkill matches with parent pid" -#spawn $pkill -P $mypid $testproc -#expect_pass "$test" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc2_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" "^$testproc1_pid\\s+$testproc2_pid\\s*$" -untested "$test" - -set test "pkill matches full string with exact" -#spawn $pkill -x $testproc -#expect_pass "$test" "^$testproc1_pid\\s+$testproc2_pid\\s*$" -untested "$test" - -set test "pkill does not match substring with exact" -#spawn $pkill -x $testproc_trim -#expect_blank $test -untested "$test" - - # Cleanup kill_testproc diff --git a/testsuite/pwdx.test/pwdx.exp b/testsuite/pwdx.test/pwdx.exp index b86631f..39d9583 100644 --- a/testsuite/pwdx.test/pwdx.exp +++ b/testsuite/pwdx.test/pwdx.exp @@ -1,4 +1,6 @@ +make_testproc + set pwdx "${topdir}pwdx" # Run pwdx with no arguments set test "pwdx no args" @@ -11,10 +13,10 @@ spawn $pwdx 0 expect_pass "$test" "\(lt-\)\?pwdx\: invalid process id\: 0" # 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 +set test "pwdx find test process cwd" +set my_pwd [ pwd ] +spawn $pwdx $testproc1_pid +expect_pass "$test" "^$testproc1_pid: $my_pwd" +# Cleanup +kill_testproc |