diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 13:17:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 13:17:26 +0000 |
commit | a4dc4fbcc1b131061dcccd5cdcc2395d9a2ba784 (patch) | |
tree | bc531e7e083fff1668bb4e79e9692d8cc47aea95 /testsuite/fuser.test | |
parent | Initial commit. (diff) | |
download | psmisc-upstream.tar.xz psmisc-upstream.zip |
Adding upstream version 23.7.upstream/23.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/fuser.test')
-rw-r--r-- | testsuite/fuser.test/fuser.exp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/testsuite/fuser.test/fuser.exp b/testsuite/fuser.test/fuser.exp new file mode 100644 index 0000000..aac5947 --- /dev/null +++ b/testsuite/fuser.test/fuser.exp @@ -0,0 +1,61 @@ +# +# Testsuite for fuser +# +proc cleanup { } { + global test_file + exec rm $test_file +} + +set fuser "${topdir}src/fuser" +set test_file [ exec mktemp ] + +set verbose_header "\\s+USER\\s+PID ACCESS COMMAND\\s*" + +set test "fuser with no arguments" +spawn $fuser +expect_pass "$test" "^No process specification given\\s*Usage: fuser" + +set test "fuser no args, no proc" +spawn $fuser $test_file +expect_nothing "$test" + +set test "fuser -a no proc" +spawn $fuser -a $test_file +expect_pass "$test" "^${test_file}:\\s*$" + +set test "fuser -v, no proc" +spawn $fuser $test_file +expect_nothing "$test" + +set test "fuser -av, no proc" +spawn $fuser -av $test_file +expect_pass "$test" "^${verbose_header}${test_file}:\\s*$" + +set test "fuser -va, no proc" +spawn $fuser -av $test_file +expect_pass "$test" "^${verbose_header}${test_file}:\\s*$" + +set test "fuser -l" +spawn $fuser -l +expect_pass "$test" "^(\[A-Z12\]+\\s*)+$" + +# Create test process to make named unix socket +# Needs a sleep otherwise the socket won't be +# available before the file exists comes along +set testsocket_path [ exec mktemp -u -p /tmp ] +make_socketproc ${testsocket_path} +sleep 1 + +if {[file exists ${testsocket_path} ]} { + set test "fuser find socket from path" + spawn sh -c "$fuser -v $testsocket_path" + expect_pass "$test" "$socketproc_pid F" + + set test "fuser find socket from mount" + spawn sh -c "$fuser -mv /tmp" + expect_pass "$test" "$socketproc_pid F" +} else { + unsupported "fuser tests using named sockets" +} +kill_socketproc + |