summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorCraig Small <csmall@dropbear.xyz>2020-04-28 19:40:07 +1000
committerCraig Small <csmall@dropbear.xyz>2020-05-11 16:59:18 +1000
commit557fda8f980c9b12bcdad995077d774fb6b17cb1 (patch)
treebaffdeebbe3c57054b8bd671e707c201abe0b4a7 /testsuite
parent89392e67a94303fea234e6c1b2c1b298e2eade48 (diff)
downloadprocps-ng-557fda8f980c9b12bcdad995077d774fb6b17cb1.tar.gz
build-sys: Enable testing of sigqueue
The referenced commits enavled both pkill and kill to send an integer to the killed or signalled process. The test_process now will report on the integer if sent and the testsuite changes take advantage of this new feature. Another process make/destroy set had to be made as using spawn instead of exec changes both the SID and TTY for the underlying process, making other tests fail. References: commit 7d55409b82602dac540c011000c9c5abedb5158a commit 2b804a532a90a98bccc5255a728da9076a5e4f4f
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/config/unix.exp33
-rw-r--r--testsuite/kill.test/kill.exp41
-rw-r--r--testsuite/pkill.test/pkill.exp17
3 files changed, 67 insertions, 24 deletions
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
index 61a329e..4156c3b 100644
--- a/testsuite/config/unix.exp
+++ b/testsuite/config/unix.exp
@@ -52,6 +52,17 @@ proc expect_pass { testname reg } {
}
}
+proc expect_pipeproc_pass { testname reg } {
+ global pipeproc_spawnid
+
+ expect {
+ -i $pipeproc_spawnid
+ -re "$reg" { pass "$testname" }
+ default { fail "$testname" }
+ timeout { fail "$testname (timeout)" }
+ }
+}
+
proc expect_blank { testname } {
expect {
-re "\\w" { fail "$testname" }
@@ -60,6 +71,14 @@ proc expect_blank { testname } {
}
}
+proc expect_blank_continue { testname } {
+ expect {
+ -re "\\w" { fail "$testname" }
+ eof { }
+ timeout { pass "$testname (timeout)" }
+ }
+}
+
proc expect_table { test match_header match_items match_footer } {
expect {
-re "$match_header" {
@@ -117,6 +136,15 @@ proc expect_table_dsc { test match_header match_item } {
#}
}
+proc make_pipeproc { } {
+ global pipeproc_pid pipeproc_spawnid topdir
+
+ set testproc_realpath "${topdir}/lib/test_process"
+
+ set pipeproc_pid [ spawn $testproc_realpath ]
+ set pipeproc_spawnid $spawn_id
+
+}
proc make_testproc { } {
global testproc_path testproc_comm testproc_arg_str testproc1_pid testproc2_pid topdir
@@ -157,6 +185,11 @@ proc kill_testproc { } {
file delete $testproc_path
}
+proc kill_pipeproc { } {
+ global pipeproc_pid
+ kill_process $pipeproc_pid
+}
+
proc get_tty {} {
if { [catch { set raw_tty [ exec tty ] } msg]} {
warning "No TTY found"
diff --git a/testsuite/kill.test/kill.exp b/testsuite/kill.test/kill.exp
index 1948517..2032e0e 100644
--- a/testsuite/kill.test/kill.exp
+++ b/testsuite/kill.test/kill.exp
@@ -45,26 +45,21 @@ set test "kill convert signal number to name with space"
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"
-#}
-#exec $kill -KILL $testproc1_pid
-#wait
-#if { [ file exists "/proc/$testproc1_pid" ] } {
-# exec kill $testproc2_pid
-# fail "$test (proc 1 exists)"
-#} else {
-# exec $kill -KILL $testproc2_pid
-# wait
-# if { [ file exists "/proc/$testproc2_pid" ] } {
-# exec kill $testproc2_pid
-# fail "$test (proc 2 exists)"
-# } else {
-# pass "$test"
-# }
-#}
-## Cleanup
-#exec rm $testproc_path
+make_pipeproc
+
+set test "kill with SIGUSR1"
+spawn $kill -USR1 $pipeproc_pid
+expect_blank_continue "$test"
+expect_pipeproc_pass "$test" "SIG SIGUSR1"
+
+set test "kill with long SIGUSR2"
+spawn $kill -s SIGUSR2 $pipeproc_pid
+expect_blank_continue "$test"
+expect_pipeproc_pass "$test" "SIG SIGUSR2"
+
+set test "kill with queued int"
+spawn $kill -USR1 -q 42 $pipeproc_pid
+expect_blank_continue "$test"
+expect_pipeproc_pass "$test" "SIG SIGUSR1 value=42"
+
+kill_pipeproc
diff --git a/testsuite/pkill.test/pkill.exp b/testsuite/pkill.test/pkill.exp
index 76e5c0c..573df6e 100644
--- a/testsuite/pkill.test/pkill.exp
+++ b/testsuite/pkill.test/pkill.exp
@@ -18,7 +18,6 @@ expect_pass "$test" "^\(lt-\)\?pkill: no matching criteria specified\\s*"
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 find both test pids"
spawn $pkill -0 -e $testproc_comm
@@ -34,3 +33,19 @@ expect_pass "$test" "invalid option -- '0'"
# Cleanup
kill_testproc
+
+make_pipeproc
+
+set test "pkill with SIGUSR1"
+spawn $pkill -USR1 -e $testproc_comm
+expect_pipeproc_pass "$test" "SIG SIGUSR1"
+
+set test "pkill with SIGUSR2"
+spawn $pkill -USR2 -e $testproc_comm
+expect_pipeproc_pass "$test" "SIG SIGUSR2"
+
+set test "pkill with queued int"
+spawn $pkill -USR1 -e -q 42 $testproc_comm
+expect_pipeproc_pass "$test" "SIG SIGUSR1 value=42"
+
+kill_pipeproc