Skip to contentSkip to conversation

Upgrade tests for xenstored

PATCH New Rusty Russell 1 participant 1 message Aug 5, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Upgrade tests for xenstored

xenstored has had a testsuite for some time. This splits the test targets into "make -s check" (the GNU standard) which is designed to run in several seconds or less, with only "<dirname>:" and a seried of "." for output, and "make fullcheck" which is more verbose and complete, and runs in minutes.

I plan to submit a patch to plumb these tests in at the top level soon, with the idea of having a "make -s check" which you can reasonable run every checkin (time make check << time make), and a "make fullcheck" which you can run after significant changes.

This patch speeds up testing by making tests one single "xs_test" script, enhancing xs_test with a simple "expect" command. It also only runs the "high value" tests under "make check", and leaves the rest for "make fullcheck".

tools/xenstore/Makefile +18 -4
diff -r 61cbf8f977ef tools/xenstore/Makefile
@@ -69,10 +69,21 @@
 	rm -f xs_test xenstored_test xs_dom0_test
 	-$(RM) $(PROG_DEP)
 
-check: testsuite-run randomcheck stresstest
+print-dir:
+	@echo -n tools/xenstore: 
+
+print-end:
+	@echo
+
+check: print-dir testsuite-fast randomcheck-fast print-end
+
+fullcheck: testsuite-run randomcheck stresstest
 
 testsuite-run: xen xenstored_test xs_test
-	$(TESTENV) testsuite/test.sh
+	$(TESTENV) testsuite/test.sh && echo
+
+testsuite-fast: xen xenstored_test xs_test
+	@$(TESTENV) testsuite/test.sh --fast
 
 testsuite-clean:
 	rm -rf $(TESTDIR)
@@ -81,9 +92,12 @@
 # fail.
 RANDSEED=$(shell date +%s)
 randomcheck: xs_random xenstored_test
-	$(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED)
-	$(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED)
+	$(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED) && echo
+	$(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED) && echo
 	$(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)
+
+randomcheck-fast: xs_random xenstored_test
+	@$(TESTENV) ./xs_random --fast /tmp/xs_random 10000 $(RANDSEED)
 
 stresstest: xs_stress xs_watch_stress xenstored_test
 	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
tools/xenstore/testsuite/test.sh +22 -10
diff -r 61cbf8f977ef tools/xenstore/testsuite/test.sh
@@ -7,19 +7,16 @@
 {
     rm -rf $XENSTORED_ROOTDIR
     mkdir $XENSTORED_ROOTDIR
-# Weird failures with this.
-    if type valgrind >/dev/null 2>&1; then
+    if [ $VALGRIND -eq 1 ]; then
 	valgrind -q --logfile-fd=3 ./xenstored_test --output-pid --trace-file=testsuite/tmp/trace --no-fork 3>testsuite/tmp/vgout > /tmp/pid 2> testsuite/tmp/xenstored_errors &
 	while [ ! -s /tmp/pid ]; do sleep 0; done
 	PID=`cat /tmp/pid`
 	rm /tmp/pid
     else
-	./xenstored_test --output-pid --trace-file=testsuite/tmp/trace --no-fork > /tmp/pid 2> testsuite/tmp/xenstored_errors &
-	while [ ! -s /tmp/pid ]; do sleep 0; done
-	PID=`cat /tmp/pid`
-	rm /tmp/pid
+	# We don't get error messages from this, though. 
+	PID=`./xenstored_test --output-pid --trace-file=testsuite/tmp/trace`
     fi
-    if sh -e $2 $1; then
+    if ./xs_test $2 $1; then
 	if [ -s testsuite/tmp/vgout ]; then
 	    kill $PID
 	    echo VALGRIND errors:
@@ -36,12 +33,27 @@
     fi
 }
 
+if [ x$1 = x--fast ]; then
+    VALGRIND=0
+    SLOWTESTS=""
+    shift
+else
+    if type valgrind >/dev/null 2>&1; then
+	VALGRIND=1
+    else
+	echo "WARNING: valgrind not available" >&2
+	VALGRIND=0
+    fi
+    SLOWTESTS=testsuite/[0-9]*.slowtest
+fi
+
 MATCH=${1:-"*"}
-for f in testsuite/[0-9]*.sh; do
+for f in testsuite/[0-9]*.test $SLOWTESTS; do
     case `basename $f` in $MATCH) RUN=1;; esac
     [ -n "$RUN" ] || continue
-    if run_test $f; then
-	echo Test $f passed...
+
+    if run_test $f > /dev/null; then
+	echo -n .
     else
 	echo Test $f failed, running verbosely...
 	run_test $f -x || true
tools/xenstore/xs_random.c +3 -13
diff -r 61cbf8f977ef tools/xenstore/xs_random.c
@@ -1112,9 +1112,6 @@
 			data->ops->close(pre);
 		}
 	}
-	if (data->print_progress)
-		printf("\n");
-
 out:
 	data->ops->close(h);	
 	return i;
@@ -1192,10 +1189,9 @@
 	try = try_simple(NULL, iters, verbose, &data);
 	if (try == iters) {
 		cleanup_xs_ops();
-		printf("Succeeded\n");
 		exit(0);
 	}
-	printf("Failed on iteration %u\n", try + 1);
+	printf("Failed on iteration %u of seed %u\n", try + 1, seed);
 	data.print_progress = false;
 	reduce_problem(try + 1, try_simple, &data);
 }
@@ -1406,8 +1402,6 @@
 			talloc_free(fileh_pre);
 		}
 	}
-	if (data->print_progress)
-		printf("\n");
 
 	fail = NULL;
 	if (data->fast)
@@ -1435,10 +1429,9 @@
 	try = try_diff(NULL, iters, verbose, &data);
 	if (try == iters) {
 		cleanup_xs_ops();
-		printf("Succeeded\n");
 		exit(0);
 	}
-	printf("Failed on iteration %u\n", try + 1);
+	printf("Failed on iteration %u of seed %u\n", try + 1, seed);
 	data.print_progress = false;
 	reduce_problem(try + 1, try_diff, &data);
 }
@@ -1593,8 +1586,6 @@
 		xs_close(tmpxsh);
 		file_close(tmpfileh);
 	}
-
-	printf("Total %u of %u not aborted\n", tried - aborted, tried);
 out:
 	if (xsh)
 		xs_close(xsh);
@@ -1615,10 +1606,9 @@
 	try = try_fail(NULL, iters, verbose, &data);
 	if (try == iters) {
 		cleanup_xs_ops();
-		printf("Succeeded\n");
 		exit(0);
 	}
-	printf("Failed on iteration %u\n", try + 1);
+	printf("Failed on iteration %u of seed %u\n", try + 1, seed);
 	fflush(stdout);
 	data.print_progress = false;
 	reduce_problem(try + 1, try_fail, &data);
tools/xenstore/xs_test.c +214 -145

549 lines not on this page · raw message

tools/xenstore/testsuite/01simple.sh deleted +0 -4
diff -r 61cbf8f977ef tools/xenstore/testsuite/01simple.sh
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-# Create an entry, read it.
-[ "`echo -e 'write /test create contents\nread /test' | ./xs_test 2>&1`" = "contents" ]
tools/xenstore/testsuite/02directory.sh deleted +0 -32
diff -r 61cbf8f977ef tools/xenstore/testsuite/02directory.sh
@@ -1,32 +0,0 @@
-#! /bin/sh
-
-# Root directory has only tool dir in it.
-[ "`echo -e 'dir /' | ./xs_test 2>&1`" = "tool" ]
-
-# Create a file.
-[ "`echo -e 'write /test create contents' | ./xs_test 2>&1`" = "" ]
-
-# Directory shows it.
-[ "`echo -e 'dir /' | ./xs_test 2>&1 | sort`" = "test
-tool" ]
-
-# Make a new directory.
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-
-# Check it's there.
-DIR="`echo -e 'dir /' | ./xs_test 2>&1 | sort`"
-[ "$DIR" = "dir
-test
-tool" ]
-
-# Check it's empty.
-[ "`echo -e 'dir /dir' | ./xs_test 2>&1`" = "" ]
-
-# Create a file, check it exists.
-[ "`echo -e 'write /dir/test2 create contents2' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'dir /dir' | ./xs_test 2>&1`" = "test2" ]
-[ "`echo -e 'read /dir/test2' | ./xs_test 2>&1`" = "contents2" ]
-
-# Creating dir over the top should fail.
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "FATAL: mkdir: File exists" ]
-[ "`echo -e 'mkdir /dir/test2' | ./xs_test 2>&1`" = "FATAL: mkdir: File exists" ]
tools/xenstore/testsuite/03write.sh deleted +0 -17
diff -r 61cbf8f977ef tools/xenstore/testsuite/03write.sh
@@ -1,17 +0,0 @@
-#! /bin/sh
-
-# Write without create fails.
-[ "`echo -e 'write /test none contents' | ./xs_test 2>&1`" = "FATAL: write: No such file or directory" ]
-
-# Exclusive write succeeds
-[ "`echo -e 'write /test excl contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'read /test' | ./xs_test 2>&1`" = "contents" ]
-
-# Exclusive write fails to overwrite.
-[ "`echo -e 'write /test excl contents' | ./xs_test 2>&1`" = "FATAL: write: File exists" ]
-
-# Non-exclusive overwrite succeeds.
-[ "`echo -e 'write /test none contents2' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'read /test' | ./xs_test 2>&1`" = "contents2" ]
-[ "`echo -e 'write /test create contents3' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'read /test' | ./xs_test 2>&1`" = "contents3" ]
tools/xenstore/testsuite/04rm.sh deleted +0 -18
diff -r 61cbf8f977ef tools/xenstore/testsuite/04rm.sh
@@ -1,18 +0,0 @@
-#! /bin/sh
-
-# Remove non-existant fails.
-[ "`echo -e 'rm /test' | ./xs_test 2>&1`" = "FATAL: rm: No such file or directory" ]
-[ "`echo -e 'rm /dir/test' | ./xs_test 2>&1`" = "FATAL: rm: No such file or directory" ]
-
-# Create file and remove it
-[ "`echo -e 'write /test excl contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'rm /test' | ./xs_test 2>&1`" = "" ]
-
-# Create directory and remove it.
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'rm /dir' | ./xs_test 2>&1`" = "" ]
-
-# Create directory, create file, remove all.
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'write /dir/test excl contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'rm /dir' | ./xs_test 2>&1`" = "" ]
tools/xenstore/testsuite/05filepermissions.sh deleted +0 -49

49 lines not on this page · raw message

tools/xenstore/testsuite/06dirpermissions.sh deleted +0 -75

75 lines not on this page · raw message

tools/xenstore/testsuite/07watch.sh deleted +0 -181

181 lines not on this page · raw message

tools/xenstore/testsuite/08transaction.sh deleted +0 -93

93 lines not on this page · raw message

tools/xenstore/testsuite/09domain.sh deleted +0 -16
diff -r 61cbf8f977ef tools/xenstore/testsuite/09domain.sh
@@ -1,16 +0,0 @@
-#! /bin/sh
-# Test domain communication.
-
-# Create a domain, write an entry.
-[ "`echo -e 'introduce 1 100 7 /my/home
-1 write /entry1 create contents
-dir /' | ./xs_test 2>&1 | sort`" = "entry1
-handle is 1
-tool" ]
-
-# Release that domain.
-[ "`echo -e 'release 1' | ./xs_test`" = "" ]
-
-# Introduce and release by same connection.
-[ "`echo -e 'introduce 1 100 7 /my/home
-release 1' | ./xs_test 2>&1`" = "handle is 1" ]
tools/xenstore/testsuite/10domain-homedir.sh deleted +0 -20
diff -r 61cbf8f977ef tools/xenstore/testsuite/10domain-homedir.sh
@@ -1,20 +0,0 @@
-#! /bin/sh
-# Test domain "implicit" paths.
-
-# Create a domain, write an entry using implicit path, read using implicit
-[ "`echo -e 'mkdir /home
-introduce 1 100 7 /home
-1 write entry1 create contents
-read /home/entry1
-dir /home' | ./xs_test 2>&1`" = "handle is 1
-contents
-entry1" ]
-
-# Place a watch using a relative path: expect relative answer.
-[ "`echo 'introduce 1 100 7 /home
-1 mkdir foo
-1 watch foo token
-async write /home/foo/bar create contents
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "handle is 1
-1:foo/bar:token" ]
tools/xenstore/testsuite/11domain-watch.sh deleted +0 -55

55 lines not on this page · raw message

tools/xenstore/testsuite/12readonly.sh deleted +0 -38
diff -r 61cbf8f977ef tools/xenstore/testsuite/12readonly.sh
@@ -1,38 +0,0 @@
-#! /bin/sh
-# Test that read only connection can't alter store.
-
-[ "`echo 'write /test create contents' | ./xs_test 2>&1`" = "" ]
-
-# These are all valid.
-[ "`echo dir / | ./xs_test --readonly 2>&1 | sort`" = "test
-tool" ]
-
-[ "`echo 'read /test
-getperm /test
-watch /test token
-unwatch /test token 
-start /
-commit
-start /
-abort' | ./xs_test --readonly 2>&1`" = "contents
-0 READ" ]
-
-# These don't work
-[ "`echo 'write /test2 create contents' | ./xs_test --readonly 2>&1`" = "FATAL: write: Read-only file system" ]
-[ "`echo 'write /test create contents' | ./xs_test --readonly 2>&1`" = "FATAL: write: Read-only file system" ]
-[ "`echo 'setperm /test 100 NONE' | ./xs_test --readonly 2>&1`" = "FATAL: setperm: Read-only file system" ]
-[ "`echo 'setperm /test 100 NONE' | ./xs_test --readonly 2>&1`" = "FATAL: setperm: Read-only file system" ]
-[ "`echo 'shutdown' | ./xs_test --readonly 2>&1`" = "FATAL: shutdown: Read-only file system" ]
-[ "`echo 'introduce 1 100 7 /home' | ./xs_test --readonly 2>&1`" = "FATAL: introduce: Read-only file system" ]
-
-# Check that watches work like normal.
-set -m
-[ "`echo 'watch / token
-waitwatch
-ackwatch token' | ./xs_test --readonly 2>&1`" = "/test:token" ] &
-
-[ "`echo 'write /test create contents' | ./xs_test 2>&1`" = "" ]
-if wait; then :; else
-    echo Readonly wait test failed: $?
-    exit 1
-fi
tools/xenstore/testsuite/13watch-ack.sh deleted +0 -23
diff -r 61cbf8f977ef tools/xenstore/testsuite/13watch-ack.sh
@@ -1,23 +0,0 @@
-#! /bin/sh
-
-# This demonstrates a bug where an xs_acknowledge_watch returns
-# EINVAL, because the daemon doesn't track what watch event it sent
-# and relies on it being the "first" watch which has an event.
-# Watches firing after the first event is sent out will change this.
-
-# Create three things to watch.
-echo mkdir /test | ./xs_test
-echo mkdir /test/1 | ./xs_test
-echo mkdir /test/2 | ./xs_test
-echo mkdir /test/3 | ./xs_test
-
-# Watch all three, fire event on 2, read watch, fire event on 1 and 3, ack 2.
-[ "`echo '1 watch /test/1 token1 0
-1 watch /test/2 token2 0
-1 watch /test/3 token3 0
-2 async write /test/2 create contents2
-3 async write /test/1 create contents1
-4 async write /test/3 create contents3
-1 waitwatch
-1 ackwatch token2
-1 close' | ./xs_test 2>&1`" = "1:/test/2:token2" ]
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman