MH_TEST_DIR="@abs_builddir@/test/testdir" \
auxexecdir="$(auxexecdir)" bindir="$(bindir)" \
mandir="$(mandir)" sysconfdir="$(sysconfdir)" \
+ supported_locks="$(supported_locks)" \
MULTIBYTE_ENABLED=$(MULTIBYTE_ENABLED) \
ICONV_ENABLED=$(ICONV_ENABLED) \
$(TESTS_SHELL) ## Keep at end of TESTS_ENVIRONMENT.
test/inc/test-deb359167 test/inc/test-eom-align \
test/inc/test-inc-scanout test/inc/test-msgchk \
test/inc/test-pop \
- test/install-mh/test-install-mh test/manpages/test-manpages \
+ test/install-mh/test-install-mh \
+ test/locking/test-datalocking test/locking/test-spoollocking \
+ test/manpages/test-manpages \
test/mhbuild/test-forw test/mhbuild/test-utf8-body \
test/mhlist/test-mhlist test/mhmail/test-mhmail \
test/mhparam/test-mhparam test/mhpath/test-mhpath \
$(SED) -e 's,%mts%,$(MTS),' \
-e 's,%mailspool%,$(mailspool),' \
-e 's,%smtpservers%,$(smtpservers),' \
+ -e 's,%default_locking%,$(default_locking),' \
+ -e 's,%supported_locks%,$(supported_locks),' \
< $(srcdir)/etc/mts.conf.in > $@
etc/mhn.defaults: $(srcdir)/etc/mhn.defaults.sh $(MHNSEARCHPROG)
# are kept. If this is empty, the user's login name is used.
mmdflfil:
+#
+# The locking algorithm to use on the spool file. Valid settings are:
+#
+# fcntl Locking using the fcntl() function
+# dot "Dot" locking using an external lock file
+# flock Locking using the flock() function (if supported by OS)
+# lockf Locking using the lockf() function (if supported by OS)
+#
+# Locking algorithms supported on this installation are:
+#
+# %supported_locks%
+#
+# The default spool locking configured on this system is %default_locking%;
+# change the line below to get a different value
+#spoollocking: %default_locking%
+
# Hardcoded POP server name (prevents inc'ing from local mail spool).
#pophost: localhost
AC_DEFINE_UNQUOTED([DEFAULT_LOCKING], ["$with_locking"],
[The default lock type for the mail spool file])
+AC_SUBST([default_locking], [$with_locking])
AC_MSG_RESULT([$with_locking])
+supported_locks="fcntl dot"
+AS_IF([test x"$ac_cv_func_flock" = x"yes"],
+ [supported_locks="$supported_locks flock"])
+AS_IF([test x"$ac_cv_func_lockf" = x"yes"],
+ [supported_locks="$supported_locks lockf"])
+AC_SUBST([supported_locks])
+
dnl Should we use a locking directory?
AC_ARG_ENABLE([lockdir],
[AS_HELP_STRING([--enable-lockdir=dir], [Store dot-lock files in "dir"])], [
test -z "$bindir" && bindir="@bindir@"
test -z "$mandir" && mandir="@mandir@"
test -z "$sysconfdir" && sysconfdir="@sysconfdir@"
+test -z "$supported_locks" && supported_locks="@supported_locks@"
test -z "$MULTIBYTE_ENABLED" && MULTIBYTE_ENABLED="@MULTIBYTE_ENABLED@"
test -z "$ICONV_ENABLED" && ICONV_ENABLED="@ICONV_ENABLED@"
export MH_TEST_DIR auxexecdir bindir mandir sysconfdir
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test the locking of nmh metadata
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+#
+# Set things up so we have a "cur" sequence
+#
+
+show +inbox 1 -nocheckmime -showproc cat > /dev/null
+
+#
+# mark read & writes sequences files, so use it to exercise the locking code
+# for each locking algorithm
+#
+
+for locktype in $supported_locks
+do
+ mv -f ${MH} ${MH}.old
+ sed -e '/^datalocking:/d' < ${MH}.old > ${MH}
+ rm -f ${MH}.old
+
+ echo "datalocking: $locktype" >> ${MH}
+
+ mark 2 4 6 -sequence test -add
+
+ run_test 'mark -list' 'cur: 1
+test: 2 4 6'
+
+ mark all -sequence test -delete
+
+done
+
+exit ${failed:-0}
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test the locking of nmh spool file
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+testmessage="$MH_TEST_DIR/testmessage"
+
+cat > "$testmessage" <<EOM
+Received: From somewhere
+From: No Such User <nosuch@example.com>
+To: Some Other User <someother@example.com>
+Subject: Hello, how are you?
+Date: Sun, 17 Dec 2006 12:13:14 -0500
+
+This is a test; will it work?
+EOM
+
+#
+# invoke "inc" for each locking algorithm
+#
+
+for locktype in $supported_locks
+do
+ mv -f ${MHMTSCONF} ${MHMTSCONF}.backup
+ sed -e '/^datalocking:/d' < ${MHMTSCONF}.backup > ${MHMTSCONF}
+ rm -f ${MHMTSCONF}.backup
+
+ echo "spoollocking: $locktype" >> ${MHMTSCONF}
+
+ run_test "inc -notruncate -width 80 -file $testmessage" \
+"Incorporating new mail into inbox...
+
+ 11+ 12/17 No Such User Hello, how are you?<<This is a test; will it wor
+$testmessage not zero'd"
+
+ rmm 11
+
+done
+
+rm -f "$testmessage"
+
+exit ${failed:-0}