generic/733: add F_OFD_GETLK/F_UNLCK testing
PATCH v3 1/1 generic/733: add F_OFD_GETLK/F_UNLCK testing
F_UNLCK can be used with F_OFD_GETLK to get the locks from particular fd. This patch adds a new test, generic/733, to check that functionality.
The following options are added to t_ofd_locks:
-u selects F_UNLCK for testing
-G sets the unix socket name for fd receive
-S sets the unix socket name for fd send
Test works as follows:
- locker process sets the lock and sends an fd via unix socket
- lock-tester process receives an fd and uses F_UNLCK to check the lock
Changes in v3:
- use generic/733, as 732 is already taken.
CC Murphy Zhou <[email protected]>
CC Jeff Layton <[email protected]>
CC Zorro Lang <[email protected]>
Signed-off-by Stas Sergeev <[email protected]>
--- common/ofdlk | 61 +++++++++++++++ common/rc | 7 ++ src/t_ofd_locks.c | 169 +++++++++++++++++++++++++++++++++++++++--- tests/generic/478 | 59 +-------------- tests/generic/733 | 60 +++++++++++++++ tests/generic/733.out | 16 ++++ 6 files changed, 303 insertions(+), 69 deletions(-) create mode 100644 common/ofdlk create mode 100755 tests/generic/733 create mode 100644 tests/generic/733.out
common/ofdlk new file +61 -0
@@ -0,0 +1,61 @@ +# +# Common functions for OFD lock tests +# + +mk_ofdlk_sem() +{ + SEMID=$(ipcmk -S 2 | cut -d ":" -f 2 | tr -d '[:space:]') + if [ -z "$SEMID" ]; then + echo "ipcmk failed" + exit 1 + fi + SEMKEY=$(ipcs -s | grep $SEMID | cut -d " " -f 1) + if [ -z "$SEMKEY" ]; then + echo "ipcs failed" + exit 1 + fi +} + +rm_ofdlk_sem() +{ + ipcrm -s $SEMID 2>/dev/null +} + +do_test() +{ + local soptions + local goptions + # print options and getlk output for debug + echo $* >> $seqres.full 2>&1 + mk_ofdlk_sem + soptions="$1 -K $SEMKEY" + goptions="$2 -K $SEMKEY" + # -s : do setlk + $here/src/t_ofd_locks $soptions $TEST_DIR/testfile & + # -g : do getlk + $here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \ + tee -a $seqres.full + wait $! + rm_ofdlk_sem + + mk_ofdlk_sem + # add -F to clone with CLONE_FILES + soptions="$1 -F -K $SEMKEY" + goptions="$2 -K $SEMKEY" + # with -F, new locks are always file to place + $here/src/t_ofd_locks $soptions $TEST_DIR/testfile & + $here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \ + tee -a $seqres.full + wait $! + rm_ofdlk_sem + + mk_ofdlk_sem + # add -d to dup and close + soptions="$1 -d -K $SEMKEY" + goptions="$2 -K $SEMKEY" + $here/src/t_ofd_locks $soptions $TEST_DIR/testfile & + $here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \ + tee -a $seqres.full + wait $! + rm_ofdlk_sem +}
common/rc +7 -0
@@ -4242,6 +4242,13 @@ _require_ofd_locks() [ $? -eq 22 ] && _notrun "Require OFD locks support" } +_require_ofd_getlk_unlck() +{ + _require_ofd_locks + $here/src/t_ofd_locks -t -gu $TEST_DIR/ofd_testfile > /dev/null 2>&1 + [ $? -eq 22 ] && _notrun "Require OFD locks F_OFD_GETLK/F_UNLCK extension" +} + _require_test_lsattr() { local testio=$(lsattr -d $TEST_DIR 2>&1)
src/t_ofd_locks.c +158 -11
231 lines not on this page · raw message
tests/generic/478 +1 -58
71 lines not on this page · raw message
tests/generic/733 new file +60 -0
60 lines not on this page · raw message
tests/generic/733.out new file +16 -0
@@ -0,0 +1,16 @@ +QA output created by 733 +get wrlck +get wrlck +get wrlck +lock could be placed +lock could be placed +lock could be placed +get rdlck +get rdlck +get rdlck +get rdlck +get rdlck +get rdlck +lock could be placed +lock could be placed +lock could be placed
Signature · 1 line
2.40.1