ia64/xen-unstable

changeset 6772:f1bb1316b26f

Fix up testsuite from recent changes.

(1) Make TESTDIR relative (my directory exceeded 108 chars, breaking sockets)
(2) Make TESTDIR if it doesn't exist
(3) Add dummy xc_domain_getinfo and xc_evtchn_bind_virq for fake libxc
(4) Fix tests broken by b594bb976a743d509f1ffabb5bc698874ab90d8f
(5) domain_cleanup() can be static, as it's not used elsewhere.
(6) With -Werror, "use" unused variable in domain_init() if TESTING
(7) Remove debugging printf on watch without perms.
(8) Loosen timeout in xs_test (valgrind + slow machine == bogus timeouts)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 09:09:13 2005 +0000 (2005-09-13)
parents 1cb7adaa3355
children f804b28871ba
files tools/xenstore/Makefile tools/xenstore/fake_libxc.c tools/xenstore/testsuite/07watch.test tools/xenstore/testsuite/14complexperms.test tools/xenstore/xenstored_core.c tools/xenstore/xenstored_domain.c tools/xenstore/xenstored_domain.h tools/xenstore/xenstored_watch.c tools/xenstore/xs_test.c
line diff
     1.1 --- a/tools/xenstore/Makefile	Tue Sep 13 08:35:41 2005 +0000
     1.2 +++ b/tools/xenstore/Makefile	Tue Sep 13 09:09:13 2005 +0000
     1.3 @@ -20,7 +20,7 @@ BASECFLAGS+= -I.
     1.4  
     1.5  CFLAGS  += $(BASECFLAGS)
     1.6  LDFLAGS += $(PROFILE) -L$(XEN_LIBXC)
     1.7 -TESTDIR  = `pwd`/testsuite/tmp
     1.8 +TESTDIR  = testsuite/tmp
     1.9  TESTFLAGS= -DTESTING
    1.10  TESTENV  = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
    1.11  
    1.12 @@ -80,10 +80,13 @@ check: print-dir testsuite-fast randomch
    1.13  
    1.14  fullcheck: testsuite-run randomcheck stresstest
    1.15  
    1.16 -testsuite-run: xenstored_test xs_test
    1.17 +$(TESTDIR):
    1.18 +	mkdir $@
    1.19 +
    1.20 +testsuite-run: xenstored_test xs_test $(TESTDIR)
    1.21  	$(TESTENV) testsuite/test.sh && echo
    1.22  
    1.23 -testsuite-fast: xenstored_test xs_test
    1.24 +testsuite-fast: xenstored_test xs_test $(TESTDIR)
    1.25  	@$(TESTENV) testsuite/test.sh --fast
    1.26  
    1.27  testsuite-clean:
    1.28 @@ -92,21 +95,21 @@ testsuite-clean:
    1.29  # Make this visible so they can see repeat tests without --fast if they
    1.30  # fail.
    1.31  RANDSEED=$(shell date +%s)
    1.32 -randomcheck: xs_random xenstored_test
    1.33 +randomcheck: xs_random xenstored_test $(TESTDIR)
    1.34  	$(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED) && echo
    1.35  	$(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED) && echo
    1.36  	$(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)
    1.37  
    1.38 -crashme:  xs_crashme xenstored_test
    1.39 +crashme:  xs_crashme xenstored_test $(TESTDIR)
    1.40  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
    1.41  	export $(TESTENV); ./xs_crashme 5000 $(RANDSEED) 2>/dev/null
    1.42  	if [ -n "`cat /tmp/xs_crashme.vglog*`" ]; then echo Valgrind complained; cat /tmp/xs_crashme.vglog*; exit 1; fi
    1.43  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
    1.44  
    1.45 -randomcheck-fast: xs_random xenstored_test
    1.46 +randomcheck-fast: xs_random xenstored_test $(TESTDIR)
    1.47  	@$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED)
    1.48  
    1.49 -stresstest: xs_stress xenstored_test
    1.50 +stresstest: xs_stress xenstored_test $(TESTDIR)
    1.51  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
    1.52  	export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret
    1.53  
     2.1 --- a/tools/xenstore/fake_libxc.c	Tue Sep 13 08:35:41 2005 +0000
     2.2 +++ b/tools/xenstore/fake_libxc.c	Tue Sep 13 09:09:13 2005 +0000
     2.3 @@ -83,6 +83,39 @@ int xc_interface_close(int xc_handle)
     2.4  	return 0;
     2.5  }
     2.6  
     2.7 +int xc_domain_getinfo(int xc_handle __attribute__((unused)),
     2.8 +		      u32 first_domid, unsigned int max_doms,
     2.9 +                      xc_dominfo_t *info)
    2.10 +{
    2.11 +	assert(max_doms == 1);
    2.12 +        info->domid = first_domid;
    2.13 +
    2.14 +        info->dying    = 0;
    2.15 +        info->shutdown = 0;
    2.16 +        info->paused   = 0;
    2.17 +        info->blocked  = 0;
    2.18 +        info->running  = 1;
    2.19 +
    2.20 +        info->shutdown_reason = 0;
    2.21 +
    2.22 +        if ( info->shutdown && (info->shutdown_reason == SHUTDOWN_crash) )
    2.23 +        {
    2.24 +            info->shutdown = 0;
    2.25 +            info->crashed  = 1;
    2.26 +        }
    2.27 +
    2.28 +	return 1;
    2.29 +}
    2.30 +
    2.31 +int xc_evtchn_bind_virq(int xc_handle __attribute__((unused)),
    2.32 +			int virq __attribute__((unused)),
    2.33 +			int *port)
    2.34 +{
    2.35 +	if (port)
    2.36 +		*port = 0;
    2.37 +	return 0;
    2.38 +}
    2.39 +
    2.40  static void send_to_fd(int signo __attribute__((unused)))
    2.41  {
    2.42  	int saved_errno = errno;
     3.1 --- a/tools/xenstore/testsuite/07watch.test	Tue Sep 13 08:35:41 2005 +0000
     3.2 +++ b/tools/xenstore/testsuite/07watch.test	Tue Sep 13 09:09:13 2005 +0000
     3.3 @@ -34,12 +34,13 @@ 1 ackwatch token
     3.4  1 close
     3.5  2 close
     3.6  
     3.7 -# We don't get a watch from our own commands.
     3.8 -watch /dir token
     3.9 -mkdir /dir/newdir
    3.10 -expect waitwatch failed: Connection timed out
    3.11 -waitwatch
    3.12 -close
    3.13 +# Changed in b594bb976a743d509f1ffabb5bc698874ab90d8f
    3.14 +## We don't get a watch from our own commands.
    3.15 +#watch /dir token
    3.16 +#mkdir /dir/newdir
    3.17 +#expect waitwatch failed: Connection timed out
    3.18 +#waitwatch
    3.19 +#close
    3.20  
    3.21  # ignore watches while doing commands, should work.
    3.22  watch /dir token
     4.1 --- a/tools/xenstore/testsuite/14complexperms.test	Tue Sep 13 08:35:41 2005 +0000
     4.2 +++ b/tools/xenstore/testsuite/14complexperms.test	Tue Sep 13 09:09:13 2005 +0000
     4.3 @@ -30,10 +30,8 @@ getperm /dir/file
     4.4  expect *Permission denied
     4.5  setperm /dir/file 0 NONE 
     4.6  watch /dir/file token 
     4.7 -setid 0
     4.8 -write /dir/file create contents
     4.9 -rm /dir/file
    4.10 -setid 1
    4.11 +1 write /dir/file create contents
    4.12 +1 rm /dir/file
    4.13  expect waitwatch failed: Connection timed out
    4.14  waitwatch
    4.15  unwatch /dir/file token 
    4.16 @@ -78,10 +76,8 @@ getperm /dir/file
    4.17  expect *Permission denied
    4.18  setperm /dir/file 0 NONE 
    4.19  watch /dir/file token 
    4.20 -setid 0
    4.21 -write /dir/file create contents
    4.22 -rm /dir/file
    4.23 -setid 1
    4.24 +1 write /dir/file create contents
    4.25 +1 rm /dir/file
    4.26  expect waitwatch failed: Connection timed out
    4.27  waitwatch
    4.28  unwatch /dir/file token 
     5.1 --- a/tools/xenstore/xenstored_core.c	Tue Sep 13 08:35:41 2005 +0000
     5.2 +++ b/tools/xenstore/xenstored_core.c	Tue Sep 13 09:09:13 2005 +0000
     5.3 @@ -1640,8 +1640,10 @@ static void daemonize(void)
     5.4  
     5.5  	/* Session leader so ^C doesn't whack us. */
     5.6  	setsid();
     5.7 +#ifndef TESTING	/* Relative paths for socket names */
     5.8  	/* Move off any mount points we might be in. */
     5.9  	chdir("/");
    5.10 +#endif
    5.11  	/* Discard our parent's old-fashioned umask prejudices. */
    5.12  	umask(0);
    5.13  }
     6.1 --- a/tools/xenstore/xenstored_domain.c	Tue Sep 13 08:35:41 2005 +0000
     6.2 +++ b/tools/xenstore/xenstored_domain.c	Tue Sep 13 09:09:13 2005 +0000
     6.3 @@ -218,6 +218,26 @@ static int destroy_domain(void *_domain)
     6.4  	return 0;
     6.5  }
     6.6  
     6.7 +static void domain_cleanup(void)
     6.8 +{
     6.9 +	xc_dominfo_t dominfo;
    6.10 +	struct domain *domain, *tmp;
    6.11 +	int released = 0;
    6.12 +
    6.13 +	list_for_each_entry_safe(domain, tmp, &domains, list) {
    6.14 +		if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
    6.15 +				      &dominfo) == 1 &&
    6.16 +		    dominfo.domid == domain->domid &&
    6.17 +		    !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
    6.18 +			continue;
    6.19 +		talloc_free(domain->conn);
    6.20 +		released++;
    6.21 +	}
    6.22 +
    6.23 +	if (released)
    6.24 +		fire_watches(NULL, "@releaseDomain", false);
    6.25 +}
    6.26 +
    6.27  /* We scan all domains rather than use the information given here. */
    6.28  void handle_event(int event_fd)
    6.29  {
    6.30 @@ -371,26 +391,6 @@ void do_release(struct connection *conn,
    6.31  	send_ack(conn, XS_RELEASE);
    6.32  }
    6.33  
    6.34 -void domain_cleanup(void)
    6.35 -{
    6.36 -	xc_dominfo_t dominfo;
    6.37 -	struct domain *domain, *tmp;
    6.38 -	int released = 0;
    6.39 -
    6.40 -	list_for_each_entry_safe(domain, tmp, &domains, list) {
    6.41 -		if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
    6.42 -				      &dominfo) == 1 &&
    6.43 -		    dominfo.domid == domain->domid &&
    6.44 -		    !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
    6.45 -			continue;
    6.46 -		talloc_free(domain->conn);
    6.47 -		released++;
    6.48 -	}
    6.49 -
    6.50 -	if (released)
    6.51 -		fire_watches(NULL, "@releaseDomain", false);
    6.52 -}
    6.53 -
    6.54  void do_get_domain_path(struct connection *conn, const char *domid_str)
    6.55  {
    6.56  	struct domain *domain;
    6.57 @@ -457,6 +457,7 @@ int domain_init(void)
    6.58  
    6.59  #ifdef TESTING
    6.60  	eventchn_fd = fake_open_eventchn();
    6.61 +	(void)&st;
    6.62  #else
    6.63  	/* Make sure any existing device file links to correct device. */
    6.64  	if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
     7.1 --- a/tools/xenstore/xenstored_domain.h	Tue Sep 13 08:35:41 2005 +0000
     7.2 +++ b/tools/xenstore/xenstored_domain.h	Tue Sep 13 09:09:13 2005 +0000
     7.3 @@ -28,10 +28,6 @@ void do_introduce(struct connection *con
     7.4  /* domid */
     7.5  void do_release(struct connection *conn, const char *domid_str);
     7.6  
     7.7 -/* Enumerate domains and release connections for non-existant or dying
     7.8 - * domains. */
     7.9 -void domain_cleanup(void);
    7.10 -
    7.11  /* domid */
    7.12  void do_get_domain_path(struct connection *conn, const char *domid_str);
    7.13  
     8.1 --- a/tools/xenstore/xenstored_watch.c	Tue Sep 13 08:35:41 2005 +0000
     8.2 +++ b/tools/xenstore/xenstored_watch.c	Tue Sep 13 09:09:13 2005 +0000
     8.3 @@ -105,7 +105,6 @@ static void add_event(struct connection 
     8.4  	 */
     8.5  	if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) &&
     8.6  	    !check_event_node(node)) {
     8.7 -		fprintf(stderr, "No permission for %s\n", node);
     8.8  		return;
     8.9  	}
    8.10  
     9.1 --- a/tools/xenstore/xs_test.c	Tue Sep 13 08:35:41 2005 +0000
     9.2 +++ b/tools/xenstore/xs_test.c	Tue Sep 13 09:09:13 2005 +0000
     9.3 @@ -43,7 +43,7 @@
     9.4  
     9.5  static struct xs_handle *handles[10] = { NULL };
     9.6  
     9.7 -static unsigned int timeout_ms = 200;
     9.8 +static unsigned int timeout_ms = 500;
     9.9  static bool timeout_suppressed = true;
    9.10  static bool readonly = false;
    9.11  static bool print_input = false;