aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/xenstore/Makefile17
-rw-r--r--tools/xenstore/fake_libxc.c33
-rw-r--r--tools/xenstore/testsuite/07watch.test13
-rw-r--r--tools/xenstore/testsuite/14complexperms.test12
-rw-r--r--tools/xenstore/xenstored_core.c2
-rw-r--r--tools/xenstore/xenstored_domain.c41
-rw-r--r--tools/xenstore/xenstored_domain.h4
-rw-r--r--tools/xenstore/xenstored_watch.c1
-rw-r--r--tools/xenstore/xs_test.c2
9 files changed, 78 insertions, 47 deletions
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 3ed0d7cff0..1e5313ff79 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -20,7 +20,7 @@ BASECFLAGS+= -I.
CFLAGS += $(BASECFLAGS)
LDFLAGS += $(PROFILE) -L$(XEN_LIBXC)
-TESTDIR = `pwd`/testsuite/tmp
+TESTDIR = testsuite/tmp
TESTFLAGS= -DTESTING
TESTENV = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
@@ -80,10 +80,13 @@ check: print-dir testsuite-fast randomcheck-fast print-end
fullcheck: testsuite-run randomcheck stresstest
-testsuite-run: xenstored_test xs_test
+$(TESTDIR):
+ mkdir $@
+
+testsuite-run: xenstored_test xs_test $(TESTDIR)
$(TESTENV) testsuite/test.sh && echo
-testsuite-fast: xenstored_test xs_test
+testsuite-fast: xenstored_test xs_test $(TESTDIR)
@$(TESTENV) testsuite/test.sh --fast
testsuite-clean:
@@ -92,21 +95,21 @@ testsuite-clean:
# Make this visible so they can see repeat tests without --fast if they
# fail.
RANDSEED=$(shell date +%s)
-randomcheck: xs_random xenstored_test
+randomcheck: xs_random xenstored_test $(TESTDIR)
$(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)
-crashme: xs_crashme xenstored_test
+crashme: xs_crashme xenstored_test $(TESTDIR)
rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
export $(TESTENV); ./xs_crashme 5000 $(RANDSEED) 2>/dev/null
if [ -n "`cat /tmp/xs_crashme.vglog*`" ]; then echo Valgrind complained; cat /tmp/xs_crashme.vglog*; exit 1; fi
rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
-randomcheck-fast: xs_random xenstored_test
+randomcheck-fast: xs_random xenstored_test $(TESTDIR)
@$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED)
-stresstest: xs_stress xenstored_test
+stresstest: xs_stress xenstored_test $(TESTDIR)
rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret
diff --git a/tools/xenstore/fake_libxc.c b/tools/xenstore/fake_libxc.c
index 50e1db717c..a435d65bd0 100644
--- a/tools/xenstore/fake_libxc.c
+++ b/tools/xenstore/fake_libxc.c
@@ -83,6 +83,39 @@ int xc_interface_close(int xc_handle)
return 0;
}
+int xc_domain_getinfo(int xc_handle __attribute__((unused)),
+ u32 first_domid, unsigned int max_doms,
+ xc_dominfo_t *info)
+{
+ assert(max_doms == 1);
+ info->domid = first_domid;
+
+ info->dying = 0;
+ info->shutdown = 0;
+ info->paused = 0;
+ info->blocked = 0;
+ info->running = 1;
+
+ info->shutdown_reason = 0;
+
+ if ( info->shutdown && (info->shutdown_reason == SHUTDOWN_crash) )
+ {
+ info->shutdown = 0;
+ info->crashed = 1;
+ }
+
+ return 1;
+}
+
+int xc_evtchn_bind_virq(int xc_handle __attribute__((unused)),
+ int virq __attribute__((unused)),
+ int *port)
+{
+ if (port)
+ *port = 0;
+ return 0;
+}
+
static void send_to_fd(int signo __attribute__((unused)))
{
int saved_errno = errno;
diff --git a/tools/xenstore/testsuite/07watch.test b/tools/xenstore/testsuite/07watch.test
index 7b19c57227..f95888d8bb 100644
--- a/tools/xenstore/testsuite/07watch.test
+++ b/tools/xenstore/testsuite/07watch.test
@@ -34,12 +34,13 @@ expect 1:/dir/newdir: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
+# Changed in b594bb976a743d509f1ffabb5bc698874ab90d8f
+## 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
diff --git a/tools/xenstore/testsuite/14complexperms.test b/tools/xenstore/testsuite/14complexperms.test
index 97ff76e6de..4290a0db6f 100644
--- a/tools/xenstore/testsuite/14complexperms.test
+++ b/tools/xenstore/testsuite/14complexperms.test
@@ -30,10 +30,8 @@ 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
+1 write /dir/file create contents
+1 rm /dir/file
expect waitwatch failed: Connection timed out
waitwatch
unwatch /dir/file token
@@ -78,10 +76,8 @@ 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
+1 write /dir/file create contents
+1 rm /dir/file
expect waitwatch failed: Connection timed out
waitwatch
unwatch /dir/file token
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index c43e6372c0..bce4d17e8d 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -1640,8 +1640,10 @@ static void daemonize(void)
/* Session leader so ^C doesn't whack us. */
setsid();
+#ifndef TESTING /* Relative paths for socket names */
/* Move off any mount points we might be in. */
chdir("/");
+#endif
/* Discard our parent's old-fashioned umask prejudices. */
umask(0);
}
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 1d53288797..e09acee6df 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -218,6 +218,26 @@ static int destroy_domain(void *_domain)
return 0;
}
+static void domain_cleanup(void)
+{
+ xc_dominfo_t dominfo;
+ struct domain *domain, *tmp;
+ int released = 0;
+
+ list_for_each_entry_safe(domain, tmp, &domains, list) {
+ if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
+ &dominfo) == 1 &&
+ dominfo.domid == domain->domid &&
+ !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
+ continue;
+ talloc_free(domain->conn);
+ released++;
+ }
+
+ if (released)
+ fire_watches(NULL, "@releaseDomain", false);
+}
+
/* We scan all domains rather than use the information given here. */
void handle_event(int event_fd)
{
@@ -371,26 +391,6 @@ void do_release(struct connection *conn, const char *domid_str)
send_ack(conn, XS_RELEASE);
}
-void domain_cleanup(void)
-{
- xc_dominfo_t dominfo;
- struct domain *domain, *tmp;
- int released = 0;
-
- list_for_each_entry_safe(domain, tmp, &domains, list) {
- if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
- &dominfo) == 1 &&
- dominfo.domid == domain->domid &&
- !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
- continue;
- talloc_free(domain->conn);
- released++;
- }
-
- if (released)
- fire_watches(NULL, "@releaseDomain", false);
-}
-
void do_get_domain_path(struct connection *conn, const char *domid_str)
{
struct domain *domain;
@@ -457,6 +457,7 @@ int domain_init(void)
#ifdef TESTING
eventchn_fd = fake_open_eventchn();
+ (void)&st;
#else
/* Make sure any existing device file links to correct device. */
if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
diff --git a/tools/xenstore/xenstored_domain.h b/tools/xenstore/xenstored_domain.h
index 332eae65e8..a896e1a3af 100644
--- a/tools/xenstore/xenstored_domain.h
+++ b/tools/xenstore/xenstored_domain.h
@@ -28,10 +28,6 @@ void do_introduce(struct connection *conn, struct buffered_data *in);
/* domid */
void do_release(struct connection *conn, const char *domid_str);
-/* Enumerate domains and release connections for non-existant or dying
- * domains. */
-void domain_cleanup(void);
-
/* domid */
void do_get_domain_path(struct connection *conn, const char *domid_str);
diff --git a/tools/xenstore/xenstored_watch.c b/tools/xenstore/xenstored_watch.c
index b413f4c697..e40318ee2f 100644
--- a/tools/xenstore/xenstored_watch.c
+++ b/tools/xenstore/xenstored_watch.c
@@ -105,7 +105,6 @@ static void add_event(struct connection *conn,
*/
if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) &&
!check_event_node(node)) {
- fprintf(stderr, "No permission for %s\n", node);
return;
}
diff --git a/tools/xenstore/xs_test.c b/tools/xenstore/xs_test.c
index fa41600086..58445b9f25 100644
--- a/tools/xenstore/xs_test.c
+++ b/tools/xenstore/xs_test.c
@@ -43,7 +43,7 @@
static struct xs_handle *handles[10] = { NULL };
-static unsigned int timeout_ms = 200;
+static unsigned int timeout_ms = 500;
static bool timeout_suppressed = true;
static bool readonly = false;
static bool print_input = false;