+2005-09-29 Erez Zadok <ezk@cs.sunysb.edu>
+
+ * README.attrcache: document test-attrcache script.
+
+ * scripts/Makefile.am (noinst_SCRIPTS): build test-attrcache
+ script.
+
+ * configure.in: build scripts/test-attrcache script and chmod it
+ so it can be executed in place.
+
+ * scripts/test-attrcache.in: script to test the NFS attribute
+ cache using Amd.
+
2005-09-26 Erez Zadok <ezk@cs.sunysb.edu>
* hlfsd/stubs.c (nfsproc_getattr_2_svc, nfsproc_lookup_2_svc,
kernel. Then copy the new nfs.h and nfsmount.h from /sys/nfs/ to
/usr/include/nfs/, and finally rebuild am-utils from scratch.
+** Testing
+
+When you build am-utils, a script named scripts/test-attrcache is built,
+which can be used to test the NFS attribute cache behavior of the current
+OS. You can run this script as root as follows:
+
+# make install
+# cd scripts
+# sh test-attrcache
+
+If you run this script on an OS whose status is known (and not listed
+above), please report it to am-utils@am-utils.org, so we can record it in
+this file.
+
Sincerely,
Erez.
dnl
dnl AC_CONFIG_AUX_DIR(m4)
AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.115 $)
+AC_REVISION($Revision: 1.116 $)
AC_COPYRIGHT([Copyright (c) 1997-2005 Erez Zadok])
dnl find out system type
AC_MSG_NOTICE(*** SYSTEM TYPES ***)
scripts/ctl-amd \
scripts/ctl-hlfsd \
scripts/expn \
- scripts/fixrmtab \
scripts/fix-amd-map \
+ scripts/fixrmtab \
scripts/lostaltmail \
scripts/redhat-ctl-amd \
+ scripts/test-attrcache \
scripts/wait4amd \
scripts/wait4amd2die \
)
AC_OUTPUT
+# chmod some scripts that are built but not installed
+test -f scripts/test-attrcache && chmod +x scripts/test-attrcache
dnl ======================================================================
dnl ######################################################################
--- /dev/null
+#!/bin/sh
+# Script to test the attribute cache behavior of the local OS client.
+# If this script fails, it means that Amd cannot turn off the attrcache
+# reliably on this host, and Amd therefore may not run reliably. See
+# the README.attrcache file distributed with this am-utils.
+# -Erez Zadok, September 29, 2005
+
+# set PATH (must install am-utils first)
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH}
+export PATH
+
+# test if amd is running
+amq -p > /dev/null 2>&1
+if test $? = 0
+then
+ echo "### Amd already running... please shutdown Amd first"
+ exit 1
+fi
+
+mapfile="/tmp/amd.testmap.$$"
+logfile="/var/log/amd"
+delay=1
+a=/a
+
+CreateMap1 () {
+ echo "### Creating correct map"
+ cat - >$mapfile <<EOF
+a type:=link;fs:=/tmp/a
+EOF
+}
+
+CreateMap2 () {
+ echo "### Creating weird map"
+ cat - >$mapfile <<EOF
+a type:=link;fs:=/tmp/b
+EOF
+}
+
+StopAMD () {
+ ctl-amd stop
+# do not delete files we may need to use to debug Amd
+# rm -f /tmp/a /tmp/b $mapfile $logfile
+}
+
+touch /tmp/a
+touch /tmp/b
+
+CreateMap1
+echo amd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync
+amd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync
+sleep 3 # give amd chance to start properly
+amq
+inode_a=`ls -lLi /tmp/a | awk '{print $1}'`
+inode_b=`ls -lLi /tmp/b | awk '{print $1}'`
+ls -lLi $a/a
+ls -lLi $a/b
+ls -l $mapfile
+
+# how many times to try until we call it a success...
+maxtry=10
+while test $maxtry -gt 0
+do
+ echo "$maxtry tries left ..."
+ let maxtry=maxtry-1
+ amq
+ CreateMap1
+ sleep $delay
+
+ ls -l $mapfile
+ echo "### looking at a... should get a"
+ ino=`ls -lLi $a/a | awk '{print $1}'`
+ if test -z "$ino"
+ then
+ ls -li $a/a
+ amq
+ amq -m
+ stat $a
+ echo "a link does not exist!"
+ StopAMD
+ exit 1
+ fi
+ if test $ino -ne $inode_a
+ then
+ ls -li $a/a
+ amq
+ amq -m
+ stat $a
+ echo "a link does not point to A!"
+ StopAMD
+ exit 1
+ fi
+
+# Here is the main trick we try: force amd to flush one entry, then
+# change the amd map on disk, and then see if the kernel will have
+# flushed the attribute cache; if it did, then Amd will see the
+# correctly changed map entry.
+
+ amq -u $a/a
+ sleep $delay
+ stat $a
+
+ CreateMap2
+ sleep $delay
+
+ ls -l $mapfile
+ echo "### looking at a... should get b"
+ ino=`ls -lLi $a/a | awk '{print $1}'`
+ if test -z "$ino"
+ then
+ ls -li $a/a
+ amq
+ amq -m
+ stat $a
+ echo "a link does not exist!"
+ StopAMD
+ exit 1
+ fi
+ if test $ino -ne $inode_b
+ then
+ ls -li $a/a
+ amq
+ amq -m
+ stat $a
+ echo "a link does not point to B!"
+ StopAMD
+ exit 1
+ fi
+
+ amq -u $a/a
+ sleep $delay
+ stat $a
+done
+StopAMD