test/: support for network mounted crfs volumes

Alex Chiang achiang at hp.com
Wed Apr 9 11:05:44 PDT 2008


Hi Zach,

This is a slightly cleaner version of adding support to the test
suite for remote crfs volumes.

Thanks.

/ac

From: Alex Chiang <achiang at hp.com>
Subject: test/: support for network mounted crfs volumes

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	Wed Apr 09 11:27:38 2008 -0600
@@ -14,7 +14,7 @@ diff -u topdir.md5sum before.md5sum
 # unmount and remount
 cd /
 umount $mountpoint
-mount.crfs localhost $mountpoint
+mount.crfs $host $mountpoint
 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	Wed Apr 09 11:27:18 2008 -0600
@@ -4,7 +4,7 @@ crfsdctl snoop > $tmpdir/snoop &
 crfsdctl snoop > $tmpdir/snoop &
 pid=$!
 sleep 1
-mount.crfs localhost $mountpoint
+mount.crfs $host $mountpoint
 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	Wed Apr 09 11:50:33 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)
+			host="$OPTARG"
+			;;
 		v)
 			valgrind=$(which valgrind) || \
 				fail "-v couldn't find a 'valgrind' command"
@@ -137,17 +140,21 @@ 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 [ "$host" == "" ]; then
+	host="localhost"
+
+	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,37 +178,40 @@ 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 [ "$host" == "localhost" ]; 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 || \
+modprobe crc32c || modprobe libcrc32c || \
 	fail "modprobe crc32c failed"
 
 # I like to see debugging warnings in the console, but
@@ -230,7 +240,7 @@ 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
+run_check mount.crfs $host $mountpoint
 if [ $? != 0 ]; then
 	fail "mounting at $mountpoint failed"
 fi
@@ -238,7 +248,7 @@ fi
 #
 # ok, now run the tests.
 #
-export tmpdir topdir mountpoint
+export tmpdir topdir mountpoint host
 
 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