From 5fc02e2e847608a67d46af04d5f935cd889b23c3 Mon Sep 17 00:00:00 2001 From: David Timber Date: Fri, 22 Mar 2024 10:58:42 +0900 Subject: Add flock_mmap --- flock_mmap/tests.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 flock_mmap/tests.sh (limited to 'flock_mmap/tests.sh') diff --git a/flock_mmap/tests.sh b/flock_mmap/tests.sh new file mode 100755 index 0000000..4cad797 --- /dev/null +++ b/flock_mmap/tests.sh @@ -0,0 +1,54 @@ +#!/bin/sh +LOCK_F="lock" + +setyes () { + echo "[TEST]$TEST_NAME: YES" +} + +setno () { + echo "[TEST]$TEST_NAME: NO" +} + +cleanup () { + kill -TERM $! +} + +TEST_NAME="fcntl(fd, F_SETLK, ...) and close() unlocks the file" +./flock_mmap -fw "$LOCK_F" & sleep 1 +if ./flock_mmap -f "$LOCK_F" +then + setyes +else + setno +fi +cleanup + +TEST_NAME="fcntl(fd, F_SETLK, ...) and holding unlocks the file" +./flock_mmap -fwn "$LOCK_F" & sleep 1 +if ./flock_mmap -f "$LOCK_F" +then + setyes +else + setno +fi +cleanup + +TEST_NAME="flock() and close() unlocks the file*" +./flock_mmap -w "$LOCK_F" & sleep 1 +if ./flock_mmap "$LOCK_F" +then + setyes +else + setno +fi +cleanup + +TEST_NAME="flock() and holding unlocks the file " +./flock_mmap -wn "$LOCK_F" & sleep 1 +if ./flock_mmap "$LOCK_F" +then + setyes +else + setno +fi +cleanup -- cgit