[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8599 - in gnunet/src: . core hello hostlist include testin
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8599 - in gnunet/src: . core hello hostlist include testing |
Date: |
Wed, 17 Jun 2009 20:21:46 -0600 |
Author: grothoff
Date: 2009-06-17 20:21:46 -0600 (Wed, 17 Jun 2009)
New Revision: 8599
Added:
gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
gnunet/src/include/gnunet_testing_lib.h
gnunet/src/testing/
gnunet/src/testing/Makefile.am
gnunet/src/testing/testing.c
gnunet/src/testing/testing_testbed.c
Modified:
gnunet/src/Makefile.am
gnunet/src/core/test_core_api.c
gnunet/src/hello/test_hello.c
gnunet/src/hostlist/Makefile.am
gnunet/src/hostlist/hostlist-server.c
gnunet/src/include/Makefile.am
Log:
testing-design
Modified: gnunet/src/Makefile.am
===================================================================
--- gnunet/src/Makefile.am 2009-06-17 02:54:06 UTC (rev 8598)
+++ gnunet/src/Makefile.am 2009-06-18 02:21:46 UTC (rev 8599)
@@ -18,6 +18,7 @@
resolver \
statistics \
template \
+ testing \
transport \
core \
$(HOSTLIST_DIR) \
Modified: gnunet/src/core/test_core_api.c
===================================================================
--- gnunet/src/core/test_core_api.c 2009-06-17 02:54:06 UTC (rev 8598)
+++ gnunet/src/core/test_core_api.c 2009-06-18 02:21:46 UTC (rev 8599)
@@ -50,7 +50,7 @@
{
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_CORE_Handle *ch;
- struct GNUNET_PeerIdentity id; /* FIXME: this is always all-zeros! */
+ struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
#if START_ARM
Modified: gnunet/src/hello/test_hello.c
===================================================================
--- gnunet/src/hello/test_hello.c 2009-06-17 02:54:06 UTC (rev 8598)
+++ gnunet/src/hello/test_hello.c 2009-06-18 02:21:46 UTC (rev 8599)
@@ -22,10 +22,6 @@
* @brief test for hello.c
* @author Christian Grothoff
*/
-
-/**
- * Testcase for HELLO code.
- */
#include "platform.h"
#include "gnunet_hello_lib.h"
Modified: gnunet/src/hostlist/Makefile.am
===================================================================
--- gnunet/src/hostlist/Makefile.am 2009-06-17 02:54:06 UTC (rev 8598)
+++ gnunet/src/hostlist/Makefile.am 2009-06-18 02:21:46 UTC (rev 8599)
@@ -28,3 +28,19 @@
@LIBCURL_CPPFLAGS@
+
+check_PROGRAMS = \
+ test_gnunet_daemon_hostlist
+
+TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
+
+test_gnunet_daemon_hostlist_SOURCES = \
+ test_gnunet_daemon_hostlist.c
+test_gnunet_daemon_hostlist_LDADD = \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+EXTRA_DIST = \
+ test_gnunet_daemon_hostlist_data_peer1.conf \
+ test_gnunet_daemon_hostlist_data_peer2.conf
+
Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c 2009-06-17 02:54:06 UTC (rev
8598)
+++ gnunet/src/hostlist/hostlist-server.c 2009-06-18 02:21:46 UTC (rev
8599)
@@ -269,7 +269,7 @@
cfg = c;
if (-1 == GNUNET_CONFIGURATION_get_value_number (cfg,
"HOSTLIST",
- "PORT",
+ "HTTPPORT",
&port))
return GNUNET_SYSERR;
daemon_handle = MHD_start_daemon (MHD_USE_IPv6,
Added: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
(rev 0)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c 2009-06-18 02:21:46 UTC
(rev 8599)
@@ -0,0 +1,135 @@
+/*
+ This file is part of GNUnet
+ (C) 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file hostlist/test_gnunet_daemon_hostlist.c
+ * @brief test for gnunet_daemon_hostslist.c
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_arm_lib.h"
+
+#define VERBOSE GNUNET_YES
+
+#define START_ARM GNUNET_YES
+
+struct PeerContext
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+ struct GNUNET_CORE_Handle *ch;
+ struct GNUNET_PeerIdentity id;
+ struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_MessageHeader *hello;
+#if START_ARM
+ pid_t arm_pid;
+#endif
+};
+
+
+
+static void
+setup_peer (struct PeerContext *p, const char *cfgname)
+{
+ p->cfg = GNUNET_CONFIGURATION_create ();
+#if START_ARM
+ p->arm_pid = GNUNET_OS_start_process ("gnunet-service-arm",
+ "gnunet-service-arm",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ "-c", cfgname, NULL);
+ sleep (1); /* allow ARM to start */
+#endif
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ GNUNET_ARM_start_service ("core", p->cfg, sched, TIMEOUT, NULL, NULL);
+ p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL);
+ GNUNET_assert (p->th != NULL);
+ GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p);
+}
+
+
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle *s,
+ char *const *args,
+ const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ GNUNET_assert (ok == 1);
+ OKPP;
+ sched = s;
+ setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf");
+ setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf");
+}
+
+
+static void
+stop_arm (struct PeerContext *p)
+{
+#if START_ARM
+ if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "ARM process %u stopped\n", p->arm_pid);
+#endif
+ GNUNET_CONFIGURATION_destroy (p->cfg);
+}
+
+
+static int
+check ()
+{
+ char *const argv[] = { "test-gnunet-daemon-hostlist",
+ "-c", "test_gnunet_daemon_hostlist.conf",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ NULL
+ };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ ok = 1;
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ argv, "test-gnunet-daemon-hostlist",
+ "nohelp", options, &run, &ok);
+ stop_arm (&p1);
+ stop_arm (&p2);
+ return ok;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+
+ int ret;
+
+ GNUNET_log_setup ("test-gnunet-daemon-hostlist",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL);
+ ret = check ();
+ return 0;
+}
Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am 2009-06-17 02:54:06 UTC (rev 8598)
+++ gnunet/src/include/Makefile.am 2009-06-18 02:21:46 UTC (rev 8599)
@@ -37,6 +37,7 @@
gnunet_signatures.h \
gnunet_statistics_service.h \
gnunet_strings_lib.h \
+ gnunet_testing_lib.h \
gnunet_time_lib.h \
gnunet_transport_service.h \
gnunet_upnp_service.h \
Added: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h (rev 0)
+++ gnunet/src/include/gnunet_testing_lib.h 2009-06-18 02:21:46 UTC (rev
8599)
@@ -0,0 +1,343 @@
+/*
+ This file is part of GNUnet
+ (C) 2008, 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file include/gnunet_testing_lib.h
+ * @brief convenience API for writing testcases for GNUnet
+ * Many testcases need to start and stop gnunetd,
+ * and this library is supposed to make that easier
+ * for TESTCASES. Normal programs should always
+ * use functions from gnunet_{util,arm}_lib.h. This API is
+ * ONLY for writing testcases!
+ * @author Christian Grothoff
+ */
+
+#ifndef GNUNET_TESTING_LIB_H
+#define GNUNET_TESTING_LIB_H
+
+#include "gnunet_util_lib.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+
+/**
+ * Handle for a GNUnet daemon (technically a set of
+ * daemons; the handle is really for the master ARM
+ * daemon) started by the testing library.
+ */
+struct GNUNET_TESTING_Daemon;
+
+
+/**
+ * Prototype of a function that will be called whenever
+ * a daemon was started by the testing library.
+ *
+ * @param cls closure
+ * @param id identifier for the daemon, NULL on error
+ * @param d handle to the daemon, NULL if starting the daemon failed
+ */
+typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls,
+ const struct
GNUNET_PeerIdentity *id,
+ struct GNUNET_TESTING_Daemon
*d);
+
+
+/**
+ * Starts a GNUnet daemon.
+ *
+ * @param service_home directory to use as the service home directory
+ * @param transports transport services that should be loaded
+ * @param applications application services and daemons that should be started
+ * @param port_offset offset to add to all ports for all services
+ * @param hostname name of the machine where to run GNUnet
+ * (use NULL for localhost).
+ * @param cb function to call with the result
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *service_home,
+ const char *transports,
+ const char *applications,
+ uint16_t port_offset,
+ const char *hostname,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls);
+
+
+/**
+ * Prototype of a function that will be called when a
+ * particular operation was completed the testing library.
+ *
+ * @param cls closure
+ * @param success GNUNET_YES on success
+ */
+typedef void (*GNUNET_TESTING_NotifyCompletion)(void *cls,
+ int success);
+
+
+/**
+ * Stops a GNUnet daemon.
+ *
+ * @param d the daemon that should be stopped
+ * @param cb function called once the daemon was stopped
+ * @param cb_cls closure for cb
+ */
+void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void * cb_cls);
+
+
+
+/**
+ * Establish a connection between two GNUnet daemons.
+ *
+ * @param d1 handle for the first daemon
+ * @param d2 handle for the second daemon
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
+ struct GNUNET_TESTING_Daemon *d2,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls);
+
+
+
+/**
+ * Start count gnunetd processes with the same set of
+ * transports and applications. The port numbers will
+ * be computed by adding delta each time (zero
+ * times for the first peer).
+ *
+ * @param total number of daemons to start
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cbe function to call at the end
+ * @param cbe_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost). Additional
+ * hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list.
+ */
+void
+GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int total,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyCompletion cbe,
+ void *cbe_cls,
+ const char *hostname,
+ ...);
+
+
+/**
+ * Handle to an entire testbed of GNUnet peers.
+ */
+struct GNUNET_TESTING_Testbed;
+
+/**
+ * Prototype of a function that will be called when
+ * a testbed is being created.
+ *
+ * @param cls closure
+ * @param tb NULL on error
+ */
+typedef void (*GNUNET_TESTING_NotifyTestbedRunning)(void *cls,
+ struct
GNUNET_TESTING_Testbed *tb);
+
+
+/**
+ * Topologies supported for testbeds.
+ */
+enum GNUNET_TESTING_Topology
+{
+ /**
+ * A clique (everyone connected to everyone else).
+ */
+ GNUNET_TESTING_TOPOLOGY_CLIQUE,
+
+ /**
+ * Small-world network (2d torus plus random links).
+ */
+ GNUNET_TESTING_TOPOLOGY_SMALL_WORLD,
+
+ /**
+ * Ring topology.
+ */
+ GNUNET_TESTING_TOPOLOGY_RING,
+
+ /**
+ * 2-d torus.
+ */
+ GNUNET_TESTING_TOPOLOGY_2D_TORUS,
+
+ /**
+ * Random graph.
+ */
+ GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI,
+
+ /**
+ * All peers are disconnected.
+ */
+ GNUNET_TESTING_TOPOLOGY_NONE
+};
+
+
+
+/**
+ * Start count GNUnet daemons with a particular
+ * topology.
+ *
+ * @param size number of peers the testbed should have
+ * @param topology desired topology (enforced via F2F)
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cte function to call at the end
+ * @param cte_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost). Additional
+ * hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list.
+ */
+void
+GNUNET_TESTING_testbed_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int size,
+ enum GNUNET_TESTING_Topology topology,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyTestbedRunning cte,
+ void *cte_cls,
+ const char *hostname,
+ ...);
+
+
+/**
+ * Start count GNUnet daemons with a particular
+ * topology.
+ *
+ * @param size number of peers the testbed should have
+ * @param topology desired topology (enforced via F2F)
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cte function to call at the end
+ * @param cte_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost).
+ * @param va Additional hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list; va only contains anything if hostname != NULL.
+ */
+void
+GNUNET_TESTING_testbed_start_va (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int size,
+ enum GNUNET_TESTING_Topology topology,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyTestbedRunning cte,
+ void *cte_cls,
+ const char *hostname,
+ va_list ap);
+
+
+/**
+ * Stop all of the daemons started with the start function.
+ *
+ * @param tb handle for the testbed
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_testbed_stop (struct GNUNET_TESTING_Testbed *tb,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls );
+
+
+
+/**
+ * Simulate churn in the testbed by stopping some peers (and possibly
+ * re-starting others if churn is called multiple times). This
+ * function can only be used to create leave-join churn (peers "never"
+ * leave for good). First "voff" random peers that are currently
+ * online will be taken offline; then "von" random peers that are then
+ * offline will be put back online. No notifications will be
+ * generated for any of these operations except for the callback upon
+ * completion. Note that the implementation is at liberty to keep
+ * the ARM service itself (but none of the other services or daemons)
+ * running even though the "peer" is being varied offline.
+ *
+ * @param tb handle for the testbed
+ * @param voff number of peers that should go offline
+ * @param von number of peers that should come back online;
+ * must be zero on first call (since "testbed_start"
+ * always starts all of the peers)
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_testbed_churn (struct GNUNET_TESTING_Testbed *tb,
+ unsigned int voff,
+ unsigned int von,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls);
+
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am (rev 0)
+++ gnunet/src/testing/Makefile.am 2009-06-18 02:21:46 UTC (rev 8599)
@@ -0,0 +1,30 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIB = -lgcov
+endif
+
+lib_LTLIBRARIES = libgnunettesting.la
+
+libgnunettesting_la_SOURCES = \
+ testing.c \
+ testing_testbed.c
+libgnunettesting_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
+
+#check_PROGRAMS = \
+# test_testing
+#
+#TESTS = $(check_PROGRAMS)
+#
+#test_testing_SOURCES = \
+# test_testing.c
+#test_testing_LDADD = \
+# $(top_builddir)/src/testing/libgnunettesting.la \
+# $(top_builddir)/src/util/libgnunetutil.la
+
Added: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c (rev 0)
+++ gnunet/src/testing/testing.c 2009-06-18 02:21:46 UTC (rev 8599)
@@ -0,0 +1,193 @@
+/*
+ This file is part of GNUnet
+ (C) 2008, 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file testing/testing.c
+ * @brief convenience API for writing testcases for GNUnet
+ * Many testcases need to start and stop gnunetd,
+ * and this library is supposed to make that easier
+ * for TESTCASES. Normal programs should always
+ * use functions from gnunet_{util,arm}_lib.h. This API is
+ * ONLY for writing testcases!
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib.h"
+
+/**
+ * Handle for a GNUnet daemon (technically a set of
+ * daemons; the handle is really for the master ARM
+ * daemon) started by the testing library.
+ */
+struct GNUNET_TESTING_Daemon
+{
+};
+
+
+/**
+ * Starts a GNUnet daemon.
+ *
+ * @param service_home directory to use as the service home directory
+ * @param transports transport services that should be loaded
+ * @param applications application services and daemons that should be started
+ * @param port_offset offset to add to all ports for all services
+ * @param hostname name of the machine where to run GNUnet
+ * (use NULL for localhost).
+ * @param cb function to call with the result
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *service_home,
+ const char *transports,
+ const char *applications,
+ uint16_t port_offset,
+ const char *hostname,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls)
+{
+}
+
+
+/**
+ * Stops a GNUnet daemon.
+ *
+ * @param d the daemon that should be stopped
+ * @param cb function called once the daemon was stopped
+ * @param cb_cls closure for cb
+ */
+void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void * cb_cls)
+{
+}
+
+
+/**
+ * Establish a connection between two GNUnet daemons.
+ *
+ * @param d1 handle for the first daemon
+ * @param d2 handle for the second daemon
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
+ struct GNUNET_TESTING_Daemon *d2,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls)
+{
+}
+
+
+/**
+ * Start count GNUnet daemons with a particular
+ * topology.
+ *
+ * @param size number of peers the testbed should have
+ * @param topology desired topology (enforced via F2F)
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cte function to call at the end
+ * @param cte_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost).
+ * @param va Additional hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list; va only contains anything if hostname != NULL.
+ */
+void
+GNUNET_TESTING_testbed_start_va (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int size,
+ enum GNUNET_TESTING_Topology topology,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyTestbedRunning cte,
+ void *cte_cls,
+ const char *hostname,
+ va_list ap)
+{
+}
+
+
+/**
+ * Start count gnunetd processes with the same set of
+ * transports and applications. The port numbers will
+ * be computed by adding delta each time (zero
+ * times for the first peer).
+ *
+ * @param total number of daemons to start
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cbe function to call at the end
+ * @param cbe_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost). Additional
+ * hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list.
+ */
+void
+GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int total,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyCompletion cbe,
+ void *cbe_cls,
+ const char *hostname,
+ ...)
+{
+ va_list va;
+
+ va_start (va, hostname);
+ GNUNET_TESTING_daemons_start_va (sched, cfg,
+ total, service_home_prefix,
+ transports, applications,
+ cb, cb_cls, cbe, cbe_cls, hostname,
+ va);
+ va_end (va);
+}
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Added: gnunet/src/testing/testing_testbed.c
===================================================================
--- gnunet/src/testing/testing_testbed.c (rev 0)
+++ gnunet/src/testing/testing_testbed.c 2009-06-18 02:21:46 UTC (rev
8599)
@@ -0,0 +1,134 @@
+/*
+ This file is part of GNUnet
+ (C) 2008, 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file testing/testing_testbed.c
+ * @brief convenience API for writing testcases for GNUnet
+ * Many testcases need to start and stop gnunetd,
+ * and this library is supposed to make that easier
+ * for TESTCASES. Normal programs should always
+ * use functions from gnunet_{util,arm}_lib.h. This API is
+ * ONLY for writing testcases!
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_arm_service.h"
+#include "gnunet_testing_lib.h"
+
+
+/**
+ * Handle to an entire testbed of GNUnet peers.
+ */
+struct GNUNET_TESTING_Testbed
+{
+};
+
+
+/**
+ * Start count GNUnet daemons with a particular
+ * topology.
+ *
+ * @param size number of peers the testbed should have
+ * @param topology desired topology (enforced via F2F)
+ * @param service_home_prefix path to use as the prefix for the home of the
services
+ * @param transports which transports should all peers use
+ * @param applications which applications should be used?
+ * @param timeout how long is this allowed to take?
+ * @param cb function to call on each daemon that was started
+ * @param cb_cls closure for cb
+ * @param cte function to call at the end
+ * @param cte_cls closure for cbe
+ * @param hostname where to run the peers; can be NULL (to run
+ * everything on localhost). Additional
+ * hosts can be specified using a NULL-terminated list of
+ * varargs, hosts will then be used round-robin from that
+ * list.
+ */
+void
+GNUNET_TESTING_testbed_start (struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ unsigned int size,
+ enum GNUNET_TESTING_Topology topology,
+ const char *service_home_prefix,
+ const char *transports,
+ const char *applications,
+ GNUNET_TESTING_NotifyDaemonRunning cb,
+ void *cb_cls,
+ GNUNET_TESTING_NotifyTestbedRunning cte,
+ void *cte_cls,
+ const char *hostname,
+ ...)
+{
+}
+
+
+/**
+ * Stop all of the daemons started with the start function.
+ *
+ * @param tb handle for the testbed
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_testbed_stop (struct GNUNET_TESTING_Testbed *tb,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls )
+{
+}
+
+
+/**
+ * Simulate churn in the testbed by stopping some peers (and possibly
+ * re-starting others if churn is called multiple times). This
+ * function can only be used to create leave-join churn (peers "never"
+ * leave for good). First "voff" random peers that are currently
+ * online will be taken offline; then "von" random peers that are then
+ * offline will be put back online. No notifications will be
+ * generated for any of these operations except for the callback upon
+ * completion. Note that the implementation is at liberty to keep
+ * the ARM service itself (but none of the other services or daemons)
+ * running even though the "peer" is being varied offline.
+ *
+ * @param tb handle for the testbed
+ * @param voff number of peers that should go offline
+ * @param von number of peers that should come back online;
+ * must be zero on first call (since "testbed_start"
+ * always starts all of the peers)
+ * @param cb function to call at the end
+ * @param cb_cls closure for cb
+ */
+void
+GNUNET_TESTING_testbed_churn (struct GNUNET_TESTING_Testbed *tb,
+ unsigned int voff,
+ unsigned int von,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls)
+{
+}
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8599 - in gnunet/src: . core hello hostlist include testing,
gnunet <=