# This file is part of GNU Mailutils. -*- Autotest -*- # Copyright (C) 2010-2021 Free Software Foundation, Inc. # # GNU Mailutils is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or (at # your option) any later version. # # GNU Mailutils is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Mailutils. If not, see . AT_BANNER([Locking]) m4_pushdef([LCK_TEST],[ AT_SETUP([$1]) AT_KEYWORDS([lock]) AT_CHECK([touch file lck $2 file ], m4_shift2($@)) AT_CLEANUP ]) # Child holds lock for 4 seconds, master acquires it when child has # released it. LCK_TEST([retries], [--hold=4 --retry=10 --delay=1]) # Child holds lock for 4 seconds, master does two retries with one # second interval and finishes before being able to acquire it. LCK_TEST([conflict with previous locker], [--hold=4 --retry=2 --delay=1], [3]) # Child abandons the lock; master is not able to acquire it. LCK_TEST([abandoned lock], [--abandon --retry=4 --delay=1], [3]) # Child abandons the lock; master asserts that its pid is not active and # acquires it. LCK_TEST([PID check],[--pid-check --abandon --retry=4 --delay=1]) # Child abandons the lock; master waits until it has expired and acquires # it. LCK_TEST([lock expiration], [--abandon --expire=3 --retry=10 --delay=1]) # Default settings correspond to --retry=10 --delay=1 --expire=600 LCK_TEST([default settings], [--hold=2]) AT_SETUP([external locker]) AT_KEYWORDS([lock]) AT_DATA([extlocker], [#!/bin/sh echo "$@" > extlocker.args ]) CWD=$(pwd) m4_pushdef([COND_SKIP],[test -f .skiptest && AT_SKIP_TEST]) AT_CHECK([ if chmod +x extlocker; then :; else touch .skiptest; fi >/dev/null 2>&1 COND_SKIP ], [ignore]) AT_CHECK([COND_SKIP lck -e$CWD/extlocker file cat extlocker.args ], [0], [file ]) AT_CHECK([COND_SKIP lck -e$CWD/extlocker --retry=4 --expire=35 file cat extlocker.args ], [0], [-f35 -r4 file ]) AT_CHECK([COND_SKIP touch file lck -elck file ]) AT_CHECK([COND_SKIP lck -elck file ], [3]) AT_CHECK([COND_SKIP lck -elck -u file ], [0]) AT_CHECK([COND_SKIP lck -elck -u file ], [2]) # Child holds lock for 4 seconds, master acquires it when child has # released it. AT_CHECK([COND_SKIP lck -elck --hold=4 --retry=10 --delay=1 file ]) AT_CHECK([COND_SKIP lck -elck -u file ]) AT_CHECK([COND_SKIP # Child holds lock for 4 seconds, master does two retries with one # second interval and finishes before being able to acquire it. lck -elck --hold=4 --retry=2 --delay=1 file ], [3]) AT_CHECK([COND_SKIP # Master is not able to acquire abandoned lock. lck -elck --retry=4 --delay=1 file ], [3]) AT_CHECK([COND_SKIP # Master waits until lock has expired and acquires it. lck -elck --abandon --expire=3 --retry=10 --delay=1 file ]) m4_popdef([COND_SKIP]) AT_CLEANUP m4_popdef([LCK_TEST])