test/: support for network mounted crfs volumes
Alex Chiang
achiang at hp.com
Sat Apr 5 08:56:33 PDT 2008
Add support to test suite for network mounted crfs volumes.
Usage example:
[root at canola crfs]# ./tests/run.sh -m /mnt/crfs -r 10.76.9.101
The argument to -r is the IP address of the machine running crfsd.
If -r is specified, then do not require -f or -z.
Signed-off-by: Alex Chiang <achiang at hp.com>
---
diff -r 57067590d58d tests/complex/untar-md5-around-remount.sh
--- a/tests/complex/untar-md5-around-remount.sh Fri Apr 04 15:48:51 2008 -0700
+++ b/tests/complex/untar-md5-around-remount.sh Sat Apr 05 09:41:51 2008 -0600
@@ -14,7 +14,11 @@ diff -u topdir.md5sum before.md5sum
# unmount and remount
cd /
umount $mountpoint
-mount.crfs localhost $mountpoint
+if [ "$remote" == "" ]; then
+ mount.crfs localhost $mountpoint
+else
+ mount.crfs $remote $mountpoint
+fi
cd -
# and find and verify the files after mounting again
diff -r 57067590d58d tests/ctl/snoop.sh
--- a/tests/ctl/snoop.sh Fri Apr 04 15:48:51 2008 -0700
+++ b/tests/ctl/snoop.sh Sat Apr 05 09:44:28 2008 -0600
@@ -4,7 +4,11 @@ crfsdctl snoop > $tmpdir/snoop &
crfsdctl snoop > $tmpdir/snoop &
pid=$!
sleep 1
-mount.crfs localhost $mountpoint
+if [ "$remote" == "" ]; then
+ mount.crfs localhost $mountpoint
+else
+ mount.crfs $remote $mountpoint
+fi
cd -
kill $pid
diff -r 57067590d58d tests/run.sh
--- a/tests/run.sh Fri Apr 04 15:48:51 2008 -0700
+++ b/tests/run.sh Sat Apr 05 09:47:20 2008 -0600
@@ -99,7 +99,7 @@ cleanup() {
}
trap cleanup EXIT
-while getopts ":df:k:m:o:pv" opt; do
+while getopts ":df:k:m:o:pr:v" opt; do
case $opt in
d)
debugging=1
@@ -119,6 +119,9 @@ while getopts ":df:k:m:o:pv" opt; do
p)
printk=1
;;
+ r)
+ remote="$OPTARG"
+ ;;
v)
valgrind=$(which valgrind) || \
fail "-v couldn't find a 'valgrind' command"
@@ -137,17 +140,19 @@ if [ -z "$outdir" ]; then
echo "defaulting to output dir $outdir"
fi
-if [ -z "$fsfile" ]; then
- fail "please specify a path to write the fs volume to with -f"
-fi
-
if [ -z "$mountpoint" ]; then
fail "please specify a mount point with -m"
fi
-if [ -z "$sizek" ]; then
- echo "no fs size given with -k, defaulting to 128M"
- sizek=$((128 * 1024))
+if [ "$remote" == "" ]; then
+ if [ -z "$fsfile" ]; then
+ fail "please specify a path to write the fs volume to with -f"
+ fi
+
+ if [ -z "$sizek" ]; then
+ echo "no fs size given with -k, defaulting to 128M"
+ sizek=$((128 * 1024))
+ fi
fi
if module_inserted crfs; then
@@ -171,34 +176,37 @@ if check_mounted "$mountpoint"; then
fail "Some file system is already mounted on $mountpoint"
fi
+# XXX: this might give a false negative if we are running tests remotely
if listening; then
lsof -n -i | grep $addrport
fail "lsof -n -i thinks that something is on our port on localhost"
fi
-run_check mkfs.crfs -f $fsfile -n $(($sizek / 4))
-
-# XXX need to check that this starts
-echo "starting crfsd and giving it 5 seconds to listen on our port"
+if [ "$remote" == "" ]; then
+ run_check mkfs.crfs -f $fsfile -n $(($sizek / 4))
+
+ # XXX need to check that this starts
+ echo "starting crfsd and giving it 5 seconds to listen on our port"
cat > $tmpdir/crfsd.conf << EOF
btrfs_volume = $fsfile
listen_ipv4 = 127.0.0.1
log_dir = $outdir
verbose_debug_logging = 1
EOF
-run_check crfsd -c $tmpdir/crfsd.conf
-if [ $? != 0 ]; then
- fail "failed to start up crfsd"
-fi
-
-count=0
-while ! listening; do
- if [ $count == 5 ]; then
- fail "crfsd didn't listen after 5 seconds"
- fi
- sleep 1
- count=$((count + 1))
-done
+ run_check crfsd -c $tmpdir/crfsd.conf
+ if [ $? != 0 ]; then
+ fail "failed to start up crfsd"
+ fi
+
+ count=0
+ while ! listening; do
+ if [ $count == 5 ]; then
+ fail "crfsd didn't listen after 5 seconds"
+ fi
+ sleep 1
+ count=$((count + 1))
+ done
+fi
#sigh
modprobe crc32c || \
@@ -230,7 +238,11 @@ fi
# run our mount command directly because 'mount -t crfs' will look for
# mount.crfs in /sbin and we don't want to have to write there.
#
-run_check mount.crfs localhost $mountpoint
+if [ "$remote" == "" ]; then
+ run_check mount.crfs localhost $mountpoint
+else
+ run_check mount.crfs $remote $mountpoint
+fi
if [ $? != 0 ]; then
fail "mounting at $mountpoint failed"
fi
@@ -238,7 +250,7 @@ fi
#
# ok, now run the tests.
#
-export tmpdir topdir mountpoint
+export tmpdir topdir mountpoint remote
for t in $topdir/tests/{basic,moderate,complex,ctl}/*.sh; do
(cd $mountpoint && set -x -e && . $t) || \
More information about the crfs-devel
mailing list