WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 11/11] Xenstore: implement watching of nodes which do

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 11/11] Xenstore: implement watching of nodes which don't exist.
From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Date: Thu, 04 Aug 2005 22:32:06 +1000
Delivery-date: Thu, 04 Aug 2005 12:33:48 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rusty Russell <rusty@xxxxxxxxxxxxxxx>
# Node ID 8899a3f0bc41e03c8346f67de142a8c87df6a95b
# Parent  92fd066729d9656628b4221da64139cedab63f91
Xenstore: implement watching of nodes which don't exist.
Requires permission check every time event is generated.
Requires generalization of permissions: ask arbitrary number of parents whether 
it's OK to tell about node (eg. watching /dir/subdir/x when /dir is deleted: 
root permissions will now determine whether we fire event).
Add test that we don't leak information on whether a file exists or not.

Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/Makefile   Thu Aug  4 12:19:43 2005
@@ -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 xenstored_test
        rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/test.sh
--- a/tools/xenstore/testsuite/test.sh  Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/test.sh  Thu Aug  4 12:19:43 2005
@@ -7,16 +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 --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
-       PID=`./xenstored_test --output-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:
@@ -33,9 +33,27 @@
     fi
 }
 
-for f in testsuite/[0-9]*.sh; do
-    if run_test $f; then
-       echo Test $f passed...
+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]*.test $SLOWTESTS; do
+    case `basename $f` in $MATCH) RUN=1;; esac
+    [ -n "$RUN" ] || continue
+
+    if run_test $f > /dev/null; then
+       echo -n .
     else
        echo Test $f failed, running verbosely...
        run_test $f -x
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/xs_random.c
--- a/tools/xenstore/xs_random.c        Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/xs_random.c        Thu Aug  4 12:19:43 2005
@@ -1105,9 +1105,6 @@
                        data->ops->close(pre);
                }
        }
-       if (data->print_progress)
-               printf("\n");
-
 out:
        data->ops->close(h);    
        return i;
@@ -1185,10 +1182,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);
 }
@@ -1399,8 +1395,6 @@
                        talloc_free(fileh_pre);
                }
        }
-       if (data->print_progress)
-               printf("\n");
 
        fail = NULL;
        if (data->fast)
@@ -1428,10 +1422,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);
 }
@@ -1586,8 +1579,6 @@
                xs_close(tmpxsh);
                file_close(tmpfileh);
        }
-
-       printf("Total %u of %u not aborted\n", tried - aborted, tried);
 out:
        if (xsh)
                xs_close(xsh);
@@ -1608,10 +1599,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);
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c  Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/xs_test.c  Thu Aug  4 12:19:43 2005
@@ -17,6 +17,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -28,15 +29,25 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <sys/mman.h>
+#include <fnmatch.h>
+#include <stdarg.h>
+#include <string.h>
+#include <getopt.h>
+#include <ctype.h>
+#include <sys/time.h>
 #include "utils.h"
 #include "xs_lib.h"
+#include "list.h"
 
 #define XSTEST
 
 static struct xs_handle *handles[10] = { NULL };
 
-static bool timeout = true;
+static unsigned int timeout_ms = 50;
+static bool timeout_suppressed = true;
 static bool readonly = false;
+static bool print_input = false;
+static unsigned int linenum = 0;
 
 struct ringbuf_head
 {
@@ -177,7 +188,7 @@
 static void __attribute__((noreturn)) usage(void)
 {
        barf("Usage:\n"
-            "       xs_test [--readonly] [--notimeout]\n"
+            "       xs_test [--readonly] [--no-timeout] [-x]\n"
             "Reads commands from stdin, one per line:"
             "  dir <path>\n"
             "  read <path>\n"
@@ -197,7 +208,11 @@
             "  abort\n"
             "  introduce <domid> <mfn> <eventchn> <path>\n"
             "  commit\n"
-            "  sleep <seconds>\n"
+            "  sleep <milliseconds>\n"
+            "  expect <pattern>\n"
+            "  notimeout\n"
+            "  readonly\n"
+            "  readwrite\n"
             "  dump\n");
 }
 
@@ -215,7 +230,7 @@
        return off;
 }
 
-static char *arg(char *line, unsigned int num)
+static char *arg(const char *line, unsigned int num)
 {
        static char *args[10];
        unsigned int off, len;
@@ -233,12 +248,64 @@
        return args[num];
 }
 
+struct expect
+{
+       struct list_head list;
+       char *pattern;
+};
+static LIST_HEAD(expects);
+
 static char *command;
-static void __attribute__((noreturn)) failed(int handle)
+
+/* Trim leading and trailing whitespace */
+static void trim(char *str)
+{
+       while (isspace(str[0]))
+               memmove(str, str+1, strlen(str));
+
+       while (strlen(str) && isspace(str[strlen(str)-1]))
+               str[strlen(str)-1] = '\0';
+}
+
+static void output(const char *fmt, ...)
+{
+       char *str;
+       struct expect *i;
+       va_list arglist;
+
+       va_start(arglist, fmt);
+       vasprintf(&str, fmt, arglist);
+       va_end(arglist);
+
+       printf("%s", str);
+       fflush(stdout);
+       trim(str);
+       list_for_each_entry(i, &expects, list) {
+               if (fnmatch(i->pattern, str, 0) == 0) {
+                       list_del(&i->list);
+                       free(i);
+                       return;
+               }
+       }
+       barf("Unexpected output %s\n", str);
+}
+
+static void failed(int handle)
 {
        if (handle)
-               barf_perror("%i: %s", handle, command);
-       barf_perror("%s", command);
+               output("%i: %s failed: %s\n",
+                      handle, command, strerror(errno));
+       else
+               output("%s failed: %s\n", command, strerror(errno));
+}
+
+static void expect(const char *line)
+{
+       struct expect *e = malloc(sizeof(*e));
+
+       e->pattern = strdup(line + argpos(line, 1));
+       trim(e->pattern);
+       list_add(&e->list, &expects);
 }
 
 static void do_dir(unsigned int handle, char *path)
@@ -247,14 +314,16 @@
        unsigned int i, num;
 
        entries = xs_directory(handles[handle], path, &num);
-       if (!entries)
-               failed(handle);
+       if (!entries) {
+               failed(handle);
+               return;
+       }
 
        for (i = 0; i < num; i++)
                if (handle)
-                       printf("%i:%s\n", handle, entries[i]);
+                       output("%i:%s\n", handle, entries[i]);
                else
-                       printf("%s\n", entries[i]);
+                       output("%s\n", entries[i]);
        free(entries);
 }
 
@@ -264,15 +333,17 @@
        unsigned int len;
 
        value = xs_read(handles[handle], path, &len);
-       if (!value)
-               failed(handle);
+       if (!value) {
+               failed(handle);
+               return;
+       }
 
        /* It's supposed to nul terminate for us. */
        assert(value[len] == '\0');
        if (handle)
-               printf("%i:%.*s\n", handle, len, value);
+               output("%i:%.*s\n", handle, len, value);
        else
-               printf("%.*s\n", len, value);
+               output("%.*s\n", len, value);
 }
 
 static void do_write(unsigned int handle, char *path, char *flags, char *data)
@@ -319,8 +390,10 @@
        struct xs_permissions *perms;
 
        perms = xs_get_permissions(handles[handle], path, &num);
-       if (!perms)
-               failed(handle);
+       if (!perms) {
+               failed(handle);
+               return;
+       }
 
        for (i = 0; i < num; i++) {
                char *permstring;
@@ -343,9 +416,9 @@
                }
 
                if (handle)
-                       printf("%i:%i %s\n", handle, perms[i].id, permstring);
+                       output("%i:%i %s\n", handle, perms[i].id, permstring);
                else
-                       printf("%i %s\n", perms[i].id, permstring);
+                       output("%i %s\n", perms[i].id, permstring);
        }
        free(perms);
 }
@@ -396,15 +469,31 @@
 static void do_waitwatch(unsigned int handle)
 {
        char **vec;
+       struct timeval tv = {.tv_sec = timeout_ms/1000,
+                            .tv_usec = (timeout_ms*1000)%1000000 };
+       fd_set set;
+
+       if (xs_fileno(handles[handle]) != -2) {
+               FD_ZERO(&set);
+               FD_SET(xs_fileno(handles[handle]), &set);
+               if (select(xs_fileno(handles[handle])+1, &set,
+                          NULL, NULL, &tv) == 0) {
+                       errno = ETIMEDOUT;
+                       failed(handle);
+                       return;
+               }
+       }
 
        vec = xs_read_watch(handles[handle]);
-       if (!vec)
-               failed(handle);
+       if (!vec) {
+               failed(handle);
+               return;
+       }
 
        if (handle)
-               printf("%i:%s:%s\n", handle, vec[0], vec[1]);
+               output("%i:%s:%s\n", handle, vec[0], vec[1]);
        else
-               printf("%s:%s\n", vec[0], vec[1]);
+               output("%s:%s\n", vec[0], vec[1]);
        free(vec);
 }
 
@@ -459,14 +548,17 @@
        *(int *)((void *)out + 32) = getpid();
        *(u16 *)((void *)out + 36) = atoi(eventchn);
 
+       if (!xs_introduce_domain(handles[handle], atoi(domid),
+                                atol(mfn), atoi(eventchn), path)) {
+               failed(handle);
+               munmap(out, getpagesize());
+               return;
+       }
+       output("handle is %i\n", i);
+
        /* Create new handle. */
        handles[i] = new(struct xs_handle);
        handles[i]->fd = -2;
-
-       if (!xs_introduce_domain(handles[handle], atoi(domid),
-                                atol(mfn), atoi(eventchn), path))
-               failed(handle);
-       printf("handle is %i\n", i);
 
        /* Read in daemon pid. */
        daemon_pid = *(int *)((void *)out + 32);
@@ -514,18 +606,20 @@
                sprintf(subnode, "%s/%s", node, dir[i]);
 
                perms = xs_get_permissions(handles[handle], subnode,&numperms);
-               if (!perms)
+               if (!perms) {
                        failed(handle);
-
-               printf("%s%s: ", spacing, dir[i]);
+                       return;
+               }
+
+               output("%s%s: ", spacing, dir[i]);
                for (j = 0; j < numperms; j++) {
                        char buffer[100];
                        if (!xs_perm_to_string(&perms[j], buffer))
                                barf("perm to string");
-                       printf("%s ", buffer);
+                       output("%s ", buffer);
                }
                free(perms);
-               printf("\n");
+               output("\n");
 
                /* Even directories can have contents. */
                contents = xs_read(handles[handle], subnode, &len);
@@ -533,14 +627,16 @@
                        if (errno != EISDIR)
                                failed(handle);
                } else {
-                       printf(" %s(%.*s)\n", spacing, len, contents);
+                       output(" %s(%.*s)\n", spacing, len, contents);
                        free(contents);
                }                       
 
                /* Every node is a directory. */
                subdirs = xs_directory(handles[handle], subnode, &subnum);
-               if (!subdirs)
+               if (!subdirs) {
                        failed(handle);
+                       return;
+               }
                dump_dir(handle, subnode, subdirs, subnum, depth+1);
                free(subdirs);
        }
@@ -552,8 +648,10 @@
        unsigned int subnum;
 
        subdirs = xs_directory(handles[handle], "/", &subnum);
-       if (!subdirs)
-               failed(handle);
+       if (!subdirs) {
+               failed(handle);
+               return;
+       }
 
        dump_dir(handle, "", subdirs, subnum, 0);
        free(subdirs);
@@ -573,9 +671,30 @@
        exit(1);
 }
 
+static void set_timeout(void)
+{
+       struct itimerval timeout;
+
+       timeout.it_interval.tv_sec = timeout_ms / 1000;
+       timeout.it_interval.tv_usec = (timeout_ms * 1000) % 1000000;
+       setitimer(ITIMER_REAL, &timeout, NULL);
+}
+
+static void disarm_timeout(void)
+{
+       struct itimerval timeout;
+
+       timeout.it_interval.tv_sec = 0;
+       timeout.it_interval.tv_usec = 0;
+       setitimer(ITIMER_REAL, &timeout, NULL);
+}
+
 static void do_command(unsigned int default_handle, char *line)
 {
        char *endp;
+
+       if (print_input)
+               printf("%i> %s", ++linenum, line);
 
        if (strspn(line, " \n") == strlen(line))
                return;
@@ -588,6 +707,7 @@
        else
                handle = default_handle;
 
+       command = arg(line, 0);
        if (!handles[handle]) {
                if (readonly)
                        handles[handle] = xs_daemon_open_readonly();
@@ -596,10 +716,10 @@
                if (!handles[handle])
                        barf_perror("Opening connection to daemon");
        }
-       command = arg(line, 0);
-
-       if (timeout)
-               alarm(1);
+
+       if (!timeout_suppressed)
+               set_timeout();
+       timeout_suppressed = false;
 
        if (streq(command, "dir"))
                do_dir(handle, arg(line, 1));
@@ -644,32 +764,66 @@
                do_release(handle, arg(line, 1));
        else if (streq(command, "dump"))
                dump(handle);
-       else if (streq(command, "sleep"))
-               sleep(atoi(arg(line, 1)));
-       else
+       else if (streq(command, "sleep")) {
+               disarm_timeout();
+               usleep(atoi(arg(line, 1)) * 1000);
+       } else if (streq(command, "expect"))
+               expect(line);
+       else if (streq(command, "notimeout"))
+               timeout_suppressed = true;
+       else if (streq(command, "readonly")) {
+               readonly = true;
+               xs_daemon_close(handles[handle]);
+               handles[handle] = NULL;
+       } else if (streq(command, "readwrite")) {
+               readonly = false;
+               xs_daemon_close(handles[handle]);
+               handles[handle] = NULL;
+       } else
                barf("Unknown command %s", command);
        fflush(stdout);
-       alarm(0);
-}
+       disarm_timeout();
+
+       /* Check expectations. */
+       if (!streq(command, "expect")) {
+               struct expect *i = list_top(&expects, struct expect, list);
+
+               if (i)
+                       barf("Expected '%s', didn't happen\n", i->pattern);
+       }
+}
+
+static struct option options[] = { { "readonly", 0, NULL, 'r' },
+                                  { "no-timeout", 0, NULL, 't' },
+                                  { NULL, 0, NULL, 0 } };
 
 int main(int argc, char *argv[])
 {
+       int opt;
        char line[1024];
 
-       if (argc > 1 && streq(argv[1], "--readonly")) {
-               readonly = true;
-               argc--;
-               argv++;
-       }
-
-       if (argc > 1 && streq(argv[1], "--no-timeout")) {
-               timeout = false;
-               argc--;
-               argv++;
-       }
-
-       if (argc != 1)
+       while ((opt = getopt_long(argc, argv, "xrt", options, NULL)) != -1) {
+               switch (opt) {
+               case 'r':
+                       readonly = true;
+                       break;
+               case 't':
+                       timeout_ms = 0;
+                       break;
+               case 'x':
+                       print_input = true;
+                       break;
+               }
+       }
+
+       if (optind + 1 == argc) {
+               int fd = open(argv[optind], O_RDONLY);
+               if (!fd)
+                       barf_perror("Opening %s", argv[optind]);
+               dup2(fd, STDIN_FILENO);
+       } else if (optind != argc)
                usage();
+       
 
        /* The size of the ringbuffer: half a page minus head structure. */
        ringbuf_datasize = getpagesize() / 2 - sizeof(struct ringbuf_head);
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/01simple.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/01simple.test    Thu Aug  4 12:19:43 2005
@@ -0,0 +1,4 @@
+# Create an entry, read it.
+write /test create contents
+expect contents
+read /test
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/02directory.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/02directory.test Thu Aug  4 12:19:43 2005
@@ -0,0 +1,34 @@
+# Root directory has only tool dir in it.
+expect tool
+dir /
+
+# Create a file.
+write /test create contents
+
+# Directory shows it.
+expect test
+expect tool
+dir /
+
+# Make a new directory, check it's there
+mkdir /dir
+expect dir
+expect test
+expect tool
+dir /
+
+# Check it's empty.
+dir /dir
+
+# Create a file, check it exists.
+write /dir/test2 create contents2
+expect test2
+dir /dir
+expect contents2
+read /dir/test2
+
+# Creating dir over the top should fail.
+expect mkdir failed: File exists
+mkdir /dir
+expect mkdir failed: File exists
+mkdir /dir/test2
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/03write.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/03write.test     Thu Aug  4 12:19:43 2005
@@ -0,0 +1,20 @@
+# Write without create fails.
+expect write failed: No such file or directory
+write /test none contents
+
+# Exclusive write succeeds
+write /test excl contents
+expect contents
+read /test
+
+# Exclusive write fails to overwrite.
+expect write failed: File exists
+write /test excl contents
+
+# Non-exclusive overwrite succeeds.
+write /test none contents2
+expect contents2
+read /test
+write /test create contents3
+expect contents3
+read /test
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/04rm.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/04rm.test        Thu Aug  4 12:19:43 2005
@@ -0,0 +1,18 @@
+# Remove non-existant fails.
+expect rm failed: No such file or directory
+rm /test
+expect rm failed: No such file or directory
+rm /dir/test
+
+# Create file and remove it
+write /test excl contents
+rm /test
+
+# Create directory and remove it.
+mkdir /dir
+rm /dir
+
+# Create directory, create file, remove all.
+mkdir /dir
+write /dir/test excl contents
+rm /dir
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/05filepermissions.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/05filepermissions.test   Thu Aug  4 12:19:43 2005
@@ -0,0 +1,81 @@
+# Fail to get perms on non-existent file.
+expect getperm failed: No such file or directory
+getperm /test
+expect getperm failed: No such file or directory
+getperm /dir/test
+
+# Create file: inherits from root (0 READ)
+write /test excl contents
+expect 0 READ
+getperm /test
+setid 1
+expect 0 READ
+getperm /test
+expect contents
+read /test
+expect write failed: Permission denied
+write /test none contents
+
+# Take away read access to file.
+setid 0
+setperm /test 0 NONE
+setid 1
+expect getperm failed: Permission denied
+getperm /test
+expect read failed: Permission denied
+read /test
+expect write failed: Permission denied
+write /test none contents
+
+# Grant everyone write access to file.
+setid 0
+setperm /test 0 WRITE
+setid 1
+expect getperm failed: Permission denied
+getperm /test
+expect read failed: Permission denied
+read /test
+write /test none contents2
+setid 0
+expect contents2
+read /test
+
+# Grant everyone both read and write access.
+setperm /test 0 READ/WRITE
+setid 1
+expect 0 READ/WRITE
+getperm /test
+expect contents2
+read /test
+write /test none contents3
+expect contents3
+read /test
+
+# Change so that user 1 owns it, noone else can do anything.
+setid 0
+setperm /test 1 NONE
+setid 1
+expect 1 NONE
+getperm /test
+expect contents3
+read /test
+write /test none contents4
+
+# User 2 can do nothing.
+setid 2
+expect setperm failed: Permission denied
+setperm /test 2 NONE
+expect getperm failed: Permission denied
+getperm /test
+expect read failed: Permission denied
+read /test
+expect write failed: Permission denied
+write /test none contents4
+
+# Tools can always access things.
+setid 0
+expect 1 NONE
+getperm /test
+expect contents4
+read /test
+write /test none contents5
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/06dirpermissions.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/06dirpermissions.test    Thu Aug  4 12:19:43 2005
@@ -0,0 +1,119 @@
+# Root directory: owned by tool, everyone has read access.
+expect 0 READ
+getperm /
+
+# Create directory: inherits from root.
+mkdir /dir
+expect 0 READ
+getperm /dir
+setid 1
+expect 0 READ
+getperm /dir
+dir /dir
+expect write failed: Permission denied
+write /dir/test create contents2
+
+# Remove everyone's read access to directoy.
+setid 0
+setperm /dir 0 NONE
+setid 1
+expect dir failed: Permission denied
+dir /dir
+expect read failed: Permission denied
+read /dir/test create contents2
+expect write failed: Permission denied
+write /dir/test create contents2
+
+# Grant everyone write access to directory.
+setid 0
+setperm /dir 0 WRITE
+setid 1
+expect getperm failed: Permission denied
+getperm /dir
+expect dir failed: Permission denied
+dir /dir
+write /dir/test create contents
+setid 0
+expect 1 WRITE
+getperm /dir/test
+setperm /dir/test 0 NONE
+expect contents
+read /dir/test
+
+# Grant everyone both read and write access.
+setperm /dir 0 READ/WRITE
+setid 1
+expect 0 READ/WRITE
+getperm /dir
+expect test
+dir /dir
+write /dir/test2 create contents
+expect contents
+read /dir/test2
+setperm /dir/test2 1 NONE
+
+# Change so that user 1 owns it, noone else can do anything.
+setid 0
+setperm /dir 1 NONE
+expect 1 NONE
+getperm /dir
+expect test
+expect test2
+dir /dir
+write /dir/test3 create contents
+
+# User 2 can do nothing.  Can't even tell if file exists.
+setid 2
+expect setperm failed: Permission denied
+setperm /dir 2 NONE
+expect getperm failed: Permission denied
+getperm /dir
+expect dir failed: Permission denied
+dir /dir
+expect read failed: Permission denied
+read /dir/test
+expect read failed: Permission denied
+read /dir/test2
+expect read failed: Permission denied
+read /dir/test3
+expect read failed: Permission denied
+read /dir/test4
+expect write failed: Permission denied
+write /dir/test none contents
+expect write failed: Permission denied
+write /dir/test create contents
+expect write failed: Permission denied
+write /dir/test excl contents
+expect write failed: Permission denied
+write /dir/test4 none contents
+expect write failed: Permission denied
+write /dir/test4 create contents
+expect write failed: Permission denied
+write /dir/test4 excl contents
+
+# Tools can always access things.
+setid 0
+expect 1 NONE
+getperm /dir
+expect test
+expect test2
+expect test3
+dir /dir
+write /dir/test4 create contents
+
+# Inherited by child.
+mkdir /dir/subdir
+expect 1 NONE
+getperm /dir/subdir
+write /dir/subfile excl contents
+expect 1 NONE
+getperm /dir/subfile
+
+# But for domains, they own it.
+setperm /dir/subdir 2 READ/WRITE
+expect 2 READ/WRITE
+getperm /dir/subdir
+setid 3
+write /dir/subdir/subfile excl contents
+expect 3 READ/WRITE
+getperm /dir/subdir/subfile
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/07watch.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/07watch.test     Thu Aug  4 12:19:43 2005
@@ -0,0 +1,194 @@
+# Watch something, write to it, check watch has fired.
+write /test create contents
+
+1 watch /test token
+2 write /test create contents2
+expect 1:/test:token
+1 waitwatch
+1 ackwatch token
+1 close
+
+# Check that reads don't set it off.
+1 watch /test token
+expect 2:contents2
+2 read /test
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+1 close
+
+# mkdir, setperm and rm should (also tests watching dirs)
+mkdir /dir
+1 watch /dir token
+2 mkdir /dir/newdir
+expect 1:/dir/newdir:token
+1 waitwatch
+1 ackwatch token
+2 setperm /dir/newdir 0 READ
+expect 1:/dir/newdir:token
+1 waitwatch
+1 ackwatch token
+2 rm /dir/newdir
+expect 1:/dir/newdir:token
+1 waitwatch
+1 ackwatch token
+1 close
+2 close
+
+# We don't get a watch from our own commands.
+watch /dir token
+mkdir /dir/newdir
+expect waitwatch failed: Connection timed out
+waitwatch
+close
+
+# ignore watches while doing commands, should work.
+watch /dir token
+1 write /dir/test create contents
+expect contents
+read /dir/test
+expect /dir/test:token
+waitwatch
+ackwatch token
+close
+
+# watch priority test: all simultaneous
+1 watch /dir token1
+3 watch /dir token3
+2 watch /dir token2
+write /dir/test create contents
+expect 3:/dir/test:token3
+3 waitwatch
+3 ackwatch token3
+expect 2:/dir/test:token2
+2 waitwatch
+2 ackwatch token2
+expect 1:/dir/test:token1
+1 waitwatch
+1 ackwatch token1
+1 close
+2 close
+3 close
+
+# If one dies (without acking), the other should still get ack.
+1 watch /dir token1
+2 watch /dir token2
+write /dir/test create contents
+expect 2:/dir/test:token2
+2 waitwatch
+2 close
+expect 1:/dir/test:token1
+1 waitwatch
+1 ackwatch token1
+1 close
+
+# If one dies (without reading at all), the other should still get ack.
+1 watch /dir token1
+2 watch /dir token2
+write /dir/test create contents
+2 close
+expect 1:/dir/test:token1
+1 waitwatch
+1 ackwatch token1
+1 close
+2 close
+
+# unwatch
+1 watch /dir token1
+1 unwatch /dir token1
+1 watch /dir token2
+2 write /dir/test2 create contents
+expect 1:/dir/test2:token2
+1 waitwatch
+1 unwatch /dir token2
+1 close
+2 close
+
+# unwatch while watch pending.  Other watcher still gets the event.
+1 watch /dir token1
+2 watch /dir token2
+write /dir/test create contents
+2 unwatch /dir token2
+expect 1:/dir/test:token1
+1 waitwatch
+1 ackwatch token1
+1 close
+2 close
+
+# unwatch while watch pending.  Should clear this so we get next event.
+1 watch /dir token1
+write /dir/test create contents
+1 unwatch /dir token1
+1 watch /dir/test token2
+write /dir/test none contents2
+expect 1:/dir/test:token2
+1 waitwatch
+1 ackwatch token2
+
+# check we only get notified once.
+1 watch /test token
+2 write /test create contents2
+expect 1:/test:token
+1 waitwatch
+1 ackwatch token
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+1 close
+
+# watches are queued in order.
+1 watch / token
+2 write /test1 create contents
+2 write /test2 create contents
+2 write /test3 create contents
+expect 1:/test1:token
+1 waitwatch
+1 ackwatch token
+expect 1:/test2:token
+1 waitwatch
+1 ackwatch token
+expect 1:/test3:token
+1 waitwatch
+1 ackwatch token
+1 close
+
+# Creation of subpaths should be covered correctly.
+1 watch / token
+2 write /test/subnode create contents2
+2 write /test/subnode/subnode create contents2
+expect 1:/test/subnode:token
+1 waitwatch
+1 ackwatch token
+expect 1:/test/subnode/subnode:token
+1 waitwatch
+1 ackwatch token
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+1 close
+
+# Watch event must have happened before we registered interest.
+1 watch / token
+2 write /test/subnode create contents2
+1 watch / token2 0
+expect 1:/test/subnode:token
+1 waitwatch
+1 ackwatch token
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+1 close
+
+# Rm fires notification on child.
+1 watch /test/subnode token
+2 rm /test
+expect 1:/test/subnode:token
+1 waitwatch
+1 ackwatch token
+
+# Watch should not double-send after we ack, even if we did something in 
between.
+1 watch /test2 token
+2 write /test2/foo create contents2
+expect 1:/test2/foo:token
+1 waitwatch
+expect 1:contents2
+1 read /test2/foo
+1 ackwatch token
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/08transaction.slowtest
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/08transaction.slowtest   Thu Aug  4 12:19:43 2005
@@ -0,0 +1,21 @@
+# Test transaction timeouts.  Take a second each.
+
+mkdir /test
+write /test/entry1 create contents
+
+# Transactions can take as long as the want...
+start /test
+sleep 1100
+rm /test/entry1
+commit
+dir /test
+
+# ... as long as noone is waiting.
+1 start /test
+notimeout
+2 mkdir /test/dir
+1 mkdir /test/dir
+expect 1:dir
+1 dir /test
+expect 1: commit failed: Connection timed out
+1 commit
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/08transaction.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/08transaction.test       Thu Aug  4 12:19:43 2005
@@ -0,0 +1,96 @@
+# Test transactions.
+
+mkdir /test
+
+# Simple transaction: create a file inside transaction.
+1 start /test
+1 write /test/entry1 create contents
+2 dir /test
+expect 1:entry1
+1 dir /test
+1 commit
+expect 2:contents
+2 read /test/entry1
+
+rm /test/entry1
+
+# Create a file and abort transaction.
+1 start /test
+1 write /test/entry1 create contents
+2 dir /test
+expect 1:entry1
+1 dir /test
+1 abort
+2 dir /test
+
+write /test/entry1 create contents
+# Delete in transaction, commit
+1 start /test
+1 rm /test/entry1
+expect 2:entry1
+2 dir /test
+1 dir /test
+1 commit
+2 dir /test
+
+# Delete in transaction, abort.
+write /test/entry1 create contents
+1 start /test
+1 rm /test/entry1
+expect 2:entry1
+2 dir /test
+1 dir /test
+1 abort
+expect 2:entry1
+2 dir /test
+
+# Events inside transactions don't trigger watches until (successful) commit.
+mkdir /test/dir
+1 watch /test token
+2 start /test
+2 mkdir /test/dir/sub
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+2 close
+1 close
+
+1 watch /test token
+2 start /test
+2 mkdir /test/dir/sub
+2 abort
+expect 1: waitwatch failed: Connection timed out
+1 waitwatch
+1 close
+
+1 watch /test token
+2 start /test
+2 mkdir /test/dir/sub
+2 commit
+expect 1:/test/dir/sub:token
+1 waitwatch
+1 ackwatch token
+1 close
+
+# Rm inside transaction works like rm outside: children get notified.
+1 watch /test/dir/sub token
+2 start /test
+2 rm /test/dir
+2 commit
+expect 1:/test/dir/sub:token
+1 waitwatch
+1 ackwatch token
+1 close
+
+# Multiple events from single transaction don't trigger assert
+1 watch /test token
+2 start /test
+2 write /test/1 create contents
+2 write /test/2 create contents
+2 commit
+expect 1:/test/1:token
+1 waitwatch
+1 ackwatch token
+expect 1:/test/2:token
+1 waitwatch
+1 ackwatch token
+1 close
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/09domain.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/09domain.test    Thu Aug  4 12:19:43 2005
@@ -0,0 +1,19 @@
+# Test domain communication.
+
+# Create a domain, write an entry.
+expect handle is 1
+introduce 1 100 7 /my/home
+1 write /entry1 create contents
+expect entry1
+expect tool
+dir /
+close
+
+# Release that domain.
+release 1
+close
+
+# Introduce and release by same connection.
+expect handle is 2
+introduce 1 100 7 /my/home
+release 1
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/10domain-homedir.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/10domain-homedir.test    Thu Aug  4 12:19:43 2005
@@ -0,0 +1,19 @@
+# Test domain "implicit" paths.
+
+# Create a domain, write an entry using implicit path, read using implicit
+mkdir /home
+expect handle is 1
+introduce 1 100 7 /home
+1 write entry1 create contents
+expect contents
+read /home/entry1
+expect entry1
+dir /home
+
+# Place a watch using a relative path: expect relative answer.
+1 mkdir foo
+1 watch foo token
+write /home/foo/bar create contents
+expect 1:foo/bar:token
+1 waitwatch
+1 ackwatch token
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/11domain-watch.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/11domain-watch.test      Thu Aug  4 12:19:43 2005
@@ -0,0 +1,52 @@
+# Test watching from a domain.
+
+# Watch something, write to it, check watch has fired.
+write /test create contents
+mkdir /dir
+
+expect handle is 1
+introduce 1 100 7 /my/home
+1 watch /test token
+write /test create contents2
+expect 1:/test:token
+1 waitwatch
+1 ackwatch token
+1 unwatch /test token
+release 1
+1 close
+
+# ignore watches while doing commands, should work.
+expect handle is 1
+introduce 1 100 7 /my/home
+1 watch /dir token
+write /dir/test create contents
+1 write /dir/test2 create contents2
+1 write /dir/test3 create contents3
+1 write /dir/test4 create contents4
+expect 1:/dir/test:token
+1 waitwatch
+1 ackwatch token
+release 1
+1 close
+
+# unwatch
+expect handle is 1
+introduce 1 100 7 /my/home
+1 watch /dir token1
+1 unwatch /dir token1
+1 watch /dir token2
+write /dir/test2 create contents
+expect 1:/dir/test2:token2
+1 waitwatch
+1 unwatch /dir token2
+release 1
+1 close
+
+# unwatch while watch pending.
+expect handle is 1
+introduce 1 100 7 /my/home
+1 watch /dir token1
+write /dir/test2 create contents
+1 unwatch /dir token1
+release 1
+1 close
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/12readonly.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/12readonly.test  Thu Aug  4 12:19:43 2005
@@ -0,0 +1,41 @@
+# Test that read only connection can't alter store.
+
+write /test create contents
+
+readonly
+expect test
+expect tool
+dir /
+
+expect contents
+read /test
+expect 0 READ
+getperm /test
+watch /test token
+unwatch /test token 
+start /
+commit
+start /
+abort
+
+# These don't work
+expect write failed: Read-only file system
+write /test2 create contents
+expect write failed: Read-only file system
+write /test create contents
+expect setperm failed: Read-only file system
+setperm /test 100 NONE
+expect setperm failed: Read-only file system
+setperm /test 100 NONE
+expect shutdown failed: Read-only file system
+shutdown
+expect introduce failed: Read-only file system
+introduce 1 100 7 /home
+
+# Check that watches work like normal.
+watch / token
+1 readwrite
+1 write /test create contents
+expect /test:token
+waitwatch
+ackwatch token
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/13watch-ack.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/13watch-ack.test Thu Aug  4 12:19:43 2005
@@ -0,0 +1,22 @@
+# 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.
+mkdir /test
+mkdir /test/1
+mkdir /test/2
+mkdir /test/3
+
+# Watch all three, fire event on 2, read watch, fire event on 1 and 3, ack 2.
+1 watch /test/1 token1
+1 watch /test/2 token2
+1 watch /test/3 token3
+2 write /test/2 create contents2
+expect 1:/test/2:token2
+1 waitwatch
+3 write /test/1 create contents1
+4 write /test/3 create contents3
+1 ackwatch token2
+1 close
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/14complexperms.test
--- /dev/null   Thu Aug  4 12:18:42 2005
+++ b/tools/xenstore/testsuite/14complexperms.test      Thu Aug  4 12:19:43 2005
@@ -0,0 +1,99 @@
+# We should not be able to tell the difference between a node which
+# doesn't exist, and a node we don't have permission on, if we don't
+# have permission on it directory.
+
+mkdir /dir
+setperm /dir 0 NONE
+
+# First when it doesn't exist
+setid 1
+expect *Permission denied
+dir /dir/file
+expect *Permission denied
+read /dir/file 
+expect *Permission denied
+write /dir/file none value 
+expect *Permission denied
+write /dir/file create value 
+expect *Permission denied
+write /dir/file excl value 
+expect write failed: Invalid argument
+write /dir/file crap value 
+expect *Permission denied
+mkdir /dir/file 
+expect *Permission denied
+rm /dir/file 
+expect *Permission denied
+rm /dir 
+expect *Permission denied
+getperm /dir/file 
+expect *Permission denied
+setperm /dir/file 0 NONE 
+watch /dir/file token 
+setid 0
+write /dir/file create contents
+rm /dir/file
+setid 1
+expect waitwatch failed: Connection timed out
+waitwatch
+unwatch /dir/file token 
+expect *No such file or directory
+unwatch /dir/file token 
+expect *Permission denied
+start /dir/file
+expect *No such file or directory
+abort
+expect *Permission denied
+start /dir/file
+expect *No such file or directory
+commit
+expect *Permission denied
+introduce 2 100 7 /dir/file
+
+# Now it exists
+setid 0
+write /dir/file create contents
+
+setid 1
+expect *Permission denied
+dir /dir/file
+expect *Permission denied
+read /dir/file 
+expect *Permission denied
+write /dir/file none value 
+expect *Permission denied
+write /dir/file create value 
+expect *Permission denied
+write /dir/file excl value 
+expect write failed: Invalid argument
+write /dir/file crap value 
+expect *Permission denied
+mkdir /dir/file 
+expect *Permission denied
+rm /dir/file 
+expect *Permission denied
+rm /dir 
+expect *Permission denied
+getperm /dir/file 
+expect *Permission denied
+setperm /dir/file 0 NONE 
+watch /dir/file token 
+setid 0
+write /dir/file create contents
+rm /dir/file
+setid 1
+expect waitwatch failed: Connection timed out
+waitwatch
+unwatch /dir/file token 
+expect *No such file or directory
+unwatch /dir/file token 
+expect *Permission denied
+start /dir/file
+expect *No such file or directory
+abort
+expect *Permission denied
+start /dir/file
+expect *No such file or directory
+commit
+expect *Permission denied
+introduce 2 100 7 /dir/file
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/01simple.sh
--- a/tools/xenstore/testsuite/01simple.sh      Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-# Create an entry, read it.
-[ "`echo -e 'write /test create contents\nread /test' | ./xs_test 2>&1`" = 
"contents" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/02directory.sh
--- a/tools/xenstore/testsuite/02directory.sh   Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -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" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/03write.sh
--- a/tools/xenstore/testsuite/03write.sh       Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -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" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/04rm.sh
--- a/tools/xenstore/testsuite/04rm.sh  Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -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`" = "" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/05filepermissions.sh
--- a/tools/xenstore/testsuite/05filepermissions.sh     Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,49 +0,0 @@
-#! /bin/sh
-
-# Fail to get perms on non-existent file.
-[ "`echo -e 'getperm /test' | ./xs_test 2>&1`" = "FATAL: getperm: No such file 
or directory" ]
-[ "`echo -e 'getperm /dir/test' | ./xs_test 2>&1`" = "FATAL: getperm: No such 
file or directory" ]
-
-# Create file: inherits from root (0 READ)
-[ "`echo -e 'write /test excl contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'getperm /test' | ./xs_test 2>&1`" = "0 READ" ]
-[ "`echo -e 'setid 1\ngetperm /test' | ./xs_test 2>&1`" = "0 READ" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "contents" ]
-[ "`echo -e 'setid 1\nwrite /test none contents2' | ./xs_test 2>&1`" = "FATAL: 
write: Permission denied" ]
-
-# Take away read access to file.
-[ "`echo -e 'setperm /test 0 NONE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /test' | ./xs_test 2>&1`" = "FATAL: getperm: 
Permission denied" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 1\nwrite /test none contents2' | ./xs_test 2>&1`" = "FATAL: 
write: Permission denied" ]
-
-# Grant everyone write access to file.
-[ "`echo -e 'setperm /test 0 WRITE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /test' | ./xs_test 2>&1`" = "FATAL: getperm: 
Permission denied" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 1\nwrite /test none contents2' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'read /test' | ./xs_test 2>&1`" = "contents2" ]
-
-# Grant everyone both read and write access.
-[ "`echo -e 'setperm /test 0 READ/WRITE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /test' | ./xs_test 2>&1`" = "0 READ/WRITE" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "contents2" ]
-[ "`echo -e 'setid 1\nwrite /test none contents3' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "contents3" ]
-
-# Change so that user 1 owns it, noone else can do anything.
-[ "`echo -e 'setperm /test 1 NONE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /test' | ./xs_test 2>&1`" = "1 NONE" ]
-[ "`echo -e 'setid 1\nread /test' | ./xs_test 2>&1`" = "contents3" ]
-[ "`echo -e 'setid 1\nwrite /test none contents4' | ./xs_test 2>&1`" = "" ]
-
-# User 2 can do nothing.
-[ "`echo -e 'setid 2\nsetperm /test 2 NONE' | ./xs_test 2>&1`" = "FATAL: 
setperm: Permission denied" ]
-[ "`echo -e 'setid 2\ngetperm /test' | ./xs_test 2>&1`" = "FATAL: getperm: 
Permission denied" ]
-[ "`echo -e 'setid 2\nread /test' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /test none contents4' | ./xs_test 2>&1`" = "FATAL: 
write: Permission denied" ]
-
-# Tools can always access things.
-[ "`echo -e 'getperm /test' | ./xs_test 2>&1`" = "1 NONE" ]
-[ "`echo -e 'read /test' | ./xs_test 2>&1`" = "contents4" ]
-[ "`echo -e 'write /test none contents5' | ./xs_test 2>&1`" = "" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/06dirpermissions.sh
--- a/tools/xenstore/testsuite/06dirpermissions.sh      Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,75 +0,0 @@
-#! /bin/sh
-
-# Root directory: owned by tool, everyone has read access.
-[ "`echo -e 'getperm /' | ./xs_test 2>&1`" = "0 READ" ]
-
-# Create directory: inherits from root.
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'getperm /dir' | ./xs_test 2>&1`" = "0 READ" ]
-[ "`echo -e 'setid 1\ngetperm /dir' | ./xs_test 2>&1`" = "0 READ" ]
-[ "`echo -e 'setid 1\ndir /dir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\nwrite /dir/test create contents2' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-
-# Remove everyone's read access to directoy.
-[ "`echo -e 'setperm /dir 0 NONE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ndir /dir' | ./xs_test 2>&1`" = "FATAL: dir: Permission 
denied" ]
-[ "`echo -e 'setid 1\nread /dir/test create contents2' | ./xs_test 2>&1`" = 
"FATAL: read: Permission denied" ]
-[ "`echo -e 'setid 1\nwrite /dir/test create contents2' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-
-# Grant everyone write access to directory.
-[ "`echo -e 'setperm /dir 0 WRITE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /dir' | ./xs_test 2>&1`" = "FATAL: getperm: 
Permission denied" ]
-[ "`echo -e 'setid 1\ndir /dir' | ./xs_test 2>&1`" = "FATAL: dir: Permission 
denied" ]
-[ "`echo -e 'setid 1\nwrite /dir/test create contents' | ./xs_test 2>&1`" = "" 
]
-[ "`echo -e 'getperm /dir/test' | ./xs_test 2>&1`" = "1 WRITE" ]
-[ "`echo -e 'setperm /dir/test 0 NONE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'read /dir/test' | ./xs_test 2>&1`" = "contents" ]
-
-# Grant everyone both read and write access.
-[ "`echo -e 'setperm /dir 0 READ/WRITE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /dir' | ./xs_test 2>&1`" = "0 READ/WRITE" ]
-[ "`echo -e 'setid 1\ndir /dir' | ./xs_test 2>&1`" = "test" ]
-[ "`echo -e 'setid 1\nwrite /dir/test2 create contents' | ./xs_test 2>&1`" = 
"" ]
-[ "`echo -e 'setid 1\nread /dir/test2' | ./xs_test 2>&1`" = "contents" ]
-[ "`echo -e 'setid 1\nsetperm /dir/test2 1 NONE' | ./xs_test 2>&1`" = "" ]
-
-# Change so that user 1 owns it, noone else can do anything.
-[ "`echo -e 'setperm /dir 1 NONE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'setid 1\ngetperm /dir' | ./xs_test 2>&1`" = "1 NONE" ]
-[ "`echo -e 'setid 1\ndir /dir' | ./xs_test 2>&1 | sort`" = "test
-test2" ]
-[ "`echo -e 'setid 1\nwrite /dir/test3 create contents' | ./xs_test 2>&1`" = 
"" ]
-
-# User 2 can do nothing.  Can't even tell if file exists.
-[ "`echo -e 'setid 2\nsetperm /dir 2 NONE' | ./xs_test 2>&1`" = "FATAL: 
setperm: Permission denied" ]
-[ "`echo -e 'setid 2\ngetperm /dir' | ./xs_test 2>&1`" = "FATAL: getperm: 
Permission denied" ]
-[ "`echo -e 'setid 2\ndir /dir' | ./xs_test 2>&1`" = "FATAL: dir: Permission 
denied" ]
-[ "`echo -e 'setid 2\nread /dir/test' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 2\nread /dir/test2' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 2\nread /dir/test3' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 2\nread /dir/test4' | ./xs_test 2>&1`" = "FATAL: read: 
Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test none contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test create contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test excl contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test4 none contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test4 create contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-[ "`echo -e 'setid 2\nwrite /dir/test4 excl contents' | ./xs_test 2>&1`" = 
"FATAL: write: Permission denied" ]
-
-# Tools can always access things.
-[ "`echo -e 'getperm /dir' | ./xs_test 2>&1`" = "1 NONE" ]
-[ "`echo -e 'dir /dir' | ./xs_test 2>&1 | sort`" = "test
-test2
-test3" ]
-[ "`echo -e 'write /dir/test4 create contents' | ./xs_test 2>&1`" = "" ]
-
-# Inherited by child.
-[ "`echo -e 'mkdir /dir/subdir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'getperm /dir/subdir' | ./xs_test 2>&1`" = "1 NONE" ]
-[ "`echo -e 'write /dir/subfile excl contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'getperm /dir/subfile' | ./xs_test 2>&1`" = "1 NONE" ]
-
-# But for domains, they own it.
-[ "`echo -e 'setperm /dir/subdir 2 READ/WRITE' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'getperm /dir/subdir' | ./xs_test 2>&1`" = "2 READ/WRITE" ]
-[ "`echo -e 'setid 3\nwrite /dir/subdir/subfile excl contents' | ./xs_test 
2>&1`" = "" ]
-[ "`echo -e 'getperm /dir/subdir/subfile' | ./xs_test 2>&1`" = "3 READ/WRITE" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/07watch.sh
--- a/tools/xenstore/testsuite/07watch.sh       Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,159 +0,0 @@
-#! /bin/sh
-
-# Watch something, write to it, check watch has fired.
-[ "`echo -e 'write /test create contents' | ./xs_test 2>&1`" = "" ]
-
-[ "`echo -e '1 watch /test token
-2 write /test create contents2
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/test:token" ]
-
-# Check that reads don't set it off.
-[ "`echo -e '1 watch /test token
-2 read /test
-1 waitwatch' | ./xs_test 2>&1`" = "2:contents2
-1:waitwatch timeout" ]
-
-# mkdir, setperm and rm should (also tests watching dirs)
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e '1 watch /dir token
-2 mkdir /dir/newdir
-1 waitwatch
-1 ackwatch token
-2 setperm /dir/newdir 0 READ
-1 waitwatch
-1 ackwatch token
-2 rm /dir/newdir
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/dir/newdir:token
-1:/dir/newdir:token
-1:/dir/newdir:token" ]
-
-# We don't get a watch from our own commands.
-[ "`echo -e 'watch /dir token
-mkdir /dir/newdir
-waitwatch' | ./xs_test 2>&1`" = "waitwatch timeout" ]
-
-# ignore watches while doing commands, should work.
-[ "`echo -e 'watch /dir token
-1 write /dir/test create contents
-read /dir/test
-waitwatch
-ackwatch token' | ./xs_test 2>&1`" = "contents
-/dir/test:token" ]
-
-# watch priority test: all simultaneous
-[ "`echo -e '1 watch /dir token1
-3 watch /dir token3
-2 watch /dir token2
-write /dir/test create contents
-3 waitwatch
-3 ackwatch token3
-2 waitwatch
-2 ackwatch token2
-1 waitwatch
-1 ackwatch token1' | ./xs_test 2>&1`" = "3:/dir/test:token3
-2:/dir/test:token2
-1:/dir/test:token1" ]
-
-# If one dies (without acking), the other should still get ack.
-[ "`echo -e '1 watch /dir token1
-2 watch /dir token2
-write /dir/test create contents
-2 waitwatch
-2 close
-1 waitwatch
-1 ackwatch token1' | ./xs_test 2>&1`" = "2:/dir/test:token2
-1:/dir/test:token1" ]
-
-# If one dies (without reading at all), the other should still get ack.
-[ "`echo -e '1 watch /dir token1
-2 watch /dir token2
-write /dir/test create contents
-2 close
-1 waitwatch
-1 ackwatch token1' | ./xs_test 2>&1`" = "1:/dir/test:token1" ]
-
-# unwatch
-[ "`echo -e '1 watch /dir token1
-1 unwatch /dir token1
-1 watch /dir token2
-2 write /dir/test2 create contents
-1 waitwatch
-1 unwatch /dir token2' | ./xs_test 2>&1`" = "1:/dir/test2:token2" ]
-
-# unwatch while watch pending.  Next watcher gets the event.
-[ "`echo -e '1 watch /dir token1
-2 watch /dir token2
-write /dir/test create contents
-2 unwatch /dir token2
-1 waitwatch
-1 ackwatch token1' | ./xs_test 2>&1`" = "1:/dir/test:token1" ]
-
-# unwatch while watch pending.  Should clear this so we get next event.
-[ "`echo -e '1 watch /dir token1
-write /dir/test create contents
-1 unwatch /dir token1
-1 watch /dir/test token2
-write /dir/test none contents2
-1 waitwatch
-1 ackwatch token2' | ./xs_test 2>&1`" = "1:/dir/test:token2" ]
-
-# check we only get notified once.
-[ "`echo -e '1 watch /test token
-2 write /test create contents2
-1 waitwatch
-1 ackwatch token
-1 waitwatch' | ./xs_test 2>&1`" = "1:/test:token
-1:waitwatch timeout" ]
-
-# watches are queued in order.
-[ "`echo -e '1 watch / token
-2 write /test1 create contents
-2 write /test2 create contents
-2 write /test3 create contents
-1 waitwatch
-1 ackwatch token
-1 waitwatch
-1 ackwatch token
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/test1:token
-1:/test2:token
-1:/test3:token" ]
-
-# Creation of subpaths should be covered correctly.
-[ "`echo -e '1 watch / token
-2 write /test/subnode create contents2
-2 write /test/subnode/subnode create contents2
-1 waitwatch
-1 ackwatch token
-1 waitwatch
-1 ackwatch token
-1 waitwatch' | ./xs_test 2>&1`" = "1:/test/subnode:token
-1:/test/subnode/subnode:token
-1:waitwatch timeout" ]
-
-# Watch event must have happened before we registered interest.
-[ "`echo -e '1 watch / token
-2 write /test/subnode create contents2
-1 watch / token2 0
-1 waitwatch
-1 ackwatch token
-1 waitwatch' | ./xs_test 2>&1`" = "1:/test/subnode:token
-1:waitwatch timeout" ]
-
-# Rm fires notification on child.
-[ "`echo -e '1 watch /test/subnode token
-2 rm /test
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/subnode:token" ]
-
-# Watch should not double-send after we ack, even if we did something in 
between.
-[ "`echo -e '1 watch /test2 token
-2 write /test2/foo create contents2
-1 waitwatch
-1 read /test2/foo
-1 ackwatch token
-1 waitwatch' | ./xs_test 2>&1`" = "1:/test2/foo:token
-1:contents2
-1:waitwatch timeout" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/08transaction.sh
--- a/tools/xenstore/testsuite/08transaction.sh Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,81 +0,0 @@
-#! /bin/sh
-# Test transactions.
-
-echo mkdir /test | ./xs_test
-
-# Simple transaction: create a file inside transaction.
-[ "`echo -e '1 start /test
-1 write /test/entry1 create contents
-2 dir /test
-1 dir /test
-1 commit
-2 read /test/entry1' | ./xs_test`" = "1:entry1
-2:contents" ]
-echo rm /test/entry1 | ./xs_test
-
-# Create a file and abort transaction.
-[ "`echo -e '1 start /test
-1 write /test/entry1 create contents
-2 dir /test
-1 dir /test
-1 abort
-2 dir /test' | ./xs_test`" = "1:entry1" ]
-
-echo write /test/entry1 create contents | ./xs_test
-# Delete in transaction, commit
-[ "`echo -e '1 start /test
-1 rm /test/entry1
-2 dir /test
-1 dir /test
-1 commit
-2 dir /test' | ./xs_test`" = "2:entry1" ]
-
-# Delete in transaction, abort.
-echo write /test/entry1 create contents | ./xs_test
-[ "`echo -e '1 start /test
-1 rm /test/entry1
-2 dir /test
-1 dir /test
-1 abort
-2 dir /test' | ./xs_test`" = "2:entry1
-2:entry1" ]
-
-# Transactions can take as long as the want...
-[ "`echo -e 'start /test
-sleep 1
-rm /test/entry1
-commit
-dir /test' | ./xs_test --no-timeout`" = "" ]
-
-# ... as long as noone is waiting.
-[ "`echo -e '1 start /test
-2 mkdir /test/dir
-1 mkdir /test/dir
-1 dir /test
-1 commit' | ./xs_test --no-timeout 2>&1`" = "1:dir
-FATAL: 1: commit: Connection timed out" ]
-
-# Events inside transactions don't trigger watches until (successful) commit.
-[ "`echo -e '1 watch /test token
-2 start /test
-2 mkdir /test/dir/sub
-1 waitwatch' | ./xs_test 2>&1`" = "1:waitwatch timeout" ]
-[ "`echo -e '1 watch /test token
-2 start /test
-2 mkdir /test/dir/sub
-2 abort
-1 waitwatch' | ./xs_test 2>&1`" = "1:waitwatch timeout" ]
-[ "`echo -e '1 watch /test token
-2 start /test
-2 mkdir /test/dir/sub
-2 commit
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ]
-
-# Rm inside transaction works like rm outside: children get notified.
-[ "`echo -e '1 watch /test/dir/sub token
-2 start /test
-2 rm /test/dir
-2 commit
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/09domain.sh
--- a/tools/xenstore/testsuite/09domain.sh      Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -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" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 
tools/xenstore/testsuite/10domain-homedir.sh
--- a/tools/xenstore/testsuite/10domain-homedir.sh      Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -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
-write /home/foo/bar create contents
-1 waitwatch
-1 ackwatch token' | ./xs_test 2>&1`" = "handle is 1
-1:foo/bar:token" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/11domain-watch.sh
--- a/tools/xenstore/testsuite/11domain-watch.sh        Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,51 +0,0 @@
-#! /bin/sh
-# Test watching from a domain.
-
-# Watch something, write to it, check watch has fired.
-[ "`echo -e 'write /test create contents' | ./xs_test 2>&1`" = "" ]
-[ "`echo -e 'mkdir /dir' | ./xs_test 2>&1`" = "" ]
-
-[ "`echo -e 'introduce 1 100 7 /my/home
-1 watch /test token
-write /test create contents2
-1 waitwatch
-1 ackwatch token
-1 unwatch /test token
-release 1' | ./xs_test 2>&1`" = "handle is 1
-1:/test:token" ]
-
-# ignore watches while doing commands, should work.
-[ "`echo -e 'introduce 1 100 7 /my/home
-1 watch /dir token
-write /dir/test create contents
-1 read /dir/test
-1 waitwatch
-1 ackwatch token
-release 1' | ./xs_test 2>&1`" = "handle is 1
-1:contents
-1:/dir/test:token" ]
-
-# unwatch
-[ "`echo -e 'introduce 1 100 7 /my/home
-1 watch /dir token1
-1 unwatch /dir token1
-1 watch /dir token2
-2 write /dir/test2 create contents
-1 waitwatch
-1 unwatch /dir token2
-release 1' | ./xs_test 2>&1`" = "handle is 1
-1:/dir/test2:token2" ]
-
-# unwatch while watch pending.
-[ "`echo -e 'introduce 1 100 7 /my/home
-introduce 2 101 8 /my/secondhome
-1 watch /dir token1
-2 watch /dir token2
-write /dir/test create contents
-2 unwatch /dir token2
-1 waitwatch
-1 ackwatch token1
-release 1
-release 2' | ./xs_test 2>&1`" = "handle is 1
-handle is 2
-1:/dir/test:token1" ]
diff -r 92fd066729d9 -r 8899a3f0bc41 tools/xenstore/testsuite/12readonly.sh
--- a/tools/xenstore/testsuite/12readonly.sh    Thu Aug  4 12:18:42 2005
+++ /dev/null   Thu Aug  4 12:19:43 2005
@@ -1,41 +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
-    
-    
-


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 11/11] Xenstore: implement watching of nodes which don't exist., Rusty Russell <=