summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorCraig Small <csmall@dropbear.xyz>2022-04-26 22:04:05 +1000
committerCraig Small <csmall@dropbear.xyz>2022-04-26 22:04:05 +1000
commit9c5397a941bb80e9adb66b2be410247349df1d57 (patch)
tree871fc8f770c26d28131a2145054440a92069d0ed /testsuite
parent1f085f5a9f036625696bfa370779232f8f0b769c (diff)
downloadprocps-ng-9c5397a941bb80e9adb66b2be410247349df1d57.tar.gz
testsuite: Add check for shared memory
Created a test process test_shm that allocates a shared memory segment and prints the segment ID. pmap testsuite runs pmap to check that the segment is found. The value returned by shmget() is the same value that is printed in the fifth column /proc/<PID>/maps Signed-off-by: Craig Small <csmall@dropbear.xyz>
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/config/unix.exp21
-rw-r--r--testsuite/pmap.test/pmap.exp5
2 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
index 08c446f..a43dbae 100644
--- a/testsuite/config/unix.exp
+++ b/testsuite/config/unix.exp
@@ -186,6 +186,27 @@ proc make_testproc { } {
set testproc2_pid [ exec $testproc_path & ]
}
+proc make_testshm_proc { } {
+ global testshmproc_pid testshm_spawnid topdir shmid
+
+ set testshm_realpath "${topdir}/lib/test_shm"
+
+ set testshmproc_pid [ spawn $testshm_realpath ]
+ set testshmproc_spawnid $spawn_id
+ expect {
+ -i $testshmproc_spawnid
+ -re "^SHMID: (\\d+)" { set shmid $expect_out(1,string) }
+ default { fail "spawning testshm" }
+ }
+
+}
+
+proc kill_testshm_proc { } {
+ global testshmproc_pid
+
+ kill_process $testshmproc_pid
+}
+
proc kill_testproc { } {
global testproc_path testproc1_pid testproc2_pid
diff --git a/testsuite/pmap.test/pmap.exp b/testsuite/pmap.test/pmap.exp
index 5a9e603..3b7e50e 100644
--- a/testsuite/pmap.test/pmap.exp
+++ b/testsuite/pmap.test/pmap.exp
@@ -66,3 +66,8 @@ set test "pmap XX with unreachable process"
spawn $pmap -XX 1
expect_pass $test "$pmap_initname\$"
+set test "pmap finding shm"
+make_testshm_proc
+spawn $pmap $testshmproc_pid
+expect_pass $test "\[ shmid=0x$shmid \]"
+kill_testshm_proc