diff options
author | David Timber <dxdt@dev.snart.me> | 2024-03-22 10:58:42 +0900 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-03-22 11:06:45 +0900 |
commit | 5fc02e2e847608a67d46af04d5f935cd889b23c3 (patch) | |
tree | bace61b3c4836a665e004562f48f441ee359d1c2 /flock_mmap/tests.sh | |
parent | 567496b2b4e68eafb0bc37b7e3ed5acf76afb3a6 (diff) |
Add flock_mmap
Diffstat (limited to 'flock_mmap/tests.sh')
-rwxr-xr-x | flock_mmap/tests.sh | 54 |
1 files changed, 54 insertions, 0 deletions
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 |