From: Craig Small Date: Wed, 16 Mar 2022 07:12:35 +0000 (+1100) Subject: build-sys: Add test for prtstat X-Git-Tag: v23.5rc1~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9476e5c52c01a8dfd95a3d49ff41241166f9cddb;p=psmisc build-sys: Add test for prtstat Added two simple tests for prtstat Updated pslog to check for existing PID --- diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp index 82cffab..27e6382 100644 --- a/testsuite/config/unix.exp +++ b/testsuite/config/unix.exp @@ -11,9 +11,10 @@ proc psmisc_v_version { tool } { clone_output "$toolpath version $version\n" } -proc fuser_version {} { psmisc_v_version fuser } +proc fuser_version {} { psmisc_v_version fuser } proc killall_version {} { psmisc_v_version killall } -proc pslog_version {} { psmisc_v_version pslog } +proc pslog_version {} { psmisc_v_version pslog } +proc prtstat_version {} { psmisc_v_version prtstat } proc expect_pass { testname reg } { expect { diff --git a/testsuite/prtstat.test/prtstat.exp b/testsuite/prtstat.test/prtstat.exp new file mode 100644 index 0000000..025393d --- /dev/null +++ b/testsuite/prtstat.test/prtstat.exp @@ -0,0 +1,18 @@ +# +# Testsuite for prtstat +# + +set prtstat "${topdir}src/prtstat" +set fake_pid "27000" + +set test "prtstat with no arguments" +spawn $prtstat +expect_pass "$test" "^You must provide at least one PID\." + +set test "prtstat pid not found" +if { [ file exists "/proc/$fake_pid" ] } { + untested "$test (PID exists)" +} else { + spawn $prtstat ${fake_pid} + expect_pass "$test" "^Process with pid $fake_pid does not exist\." +} diff --git a/testsuite/pslog.test/pslog.exp b/testsuite/pslog.test/pslog.exp index 060e963..b8d0e01 100644 --- a/testsuite/pslog.test/pslog.exp +++ b/testsuite/pslog.test/pslog.exp @@ -10,6 +10,10 @@ spawn $pslog expect_pass "$test" "^Usage: pslog PID\\.\\.\\." set test "pslog pid not found" -spawn $pslog ${fake_pid} -expect_pass "$test" "opendir: No such file or directory" +if { [ file exists "/proc/$fake_pid" ] } { + untested "$test (PID exists)" +} else { + spawn $pslog ${fake_pid} + expect_pass "$test" "opendir: No such file or directory" +}