-fixes
[oweals/gnunet.git] / src / include / gnunet_testing_lib-new.h
index 31bc2234ab4136f0e1dd1b6cb509cf1725a6f89e..97be8211c166ad852668753be5c0077665f36c58 100644 (file)
@@ -44,6 +44,7 @@ extern "C"
 #endif
 #endif
 
+#define GNUNET_TESTING_HOSTKEYFILESIZE 914
 
 /**
  * Handle for a system on which GNUnet peers are executed;
@@ -58,21 +59,51 @@ struct GNUNET_TESTING_System;
 struct GNUNET_TESTING_Peer;
 
 
+/**
+ * Create a system handle.  There must only be one system handle per operating
+ * system.  Uses a default range for allowed ports.  Ports are still tested for
+ * availability.
+ *
+ * @param testdir only the directory name without any path. This is used for all
+ *          service homes; the directory will be created in a temporary location
+ *          depending on the underlying OS
+ * @param controller hostname of the controlling host, service configurations
+ *        are modified to allow control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL for
+ *          localhost
+ * @return handle to this system, NULL on error
+ */
+struct GNUNET_TESTING_System *
+GNUNET_TESTING_system_create (const char *testdir,
+                             const char *controller,
+                             const char *hostname);
+
+
 /**
  * Create a system handle.  There must only be one system
- * handle per operating system.
+ * handle per operating system.  Use this function directly
+ * if multiple system objects are created for the same host
+ * (only really useful when testing --- or to make the port
+ * range configureable).
  *
- ** @param testdir only the directory name without any path. This is used for
+ * @param testdir only the directory name without any path. This is used for
  *          all service homes; the directory will be created in a temporary
  *          location depending on the underlying OS
  * @param controller hostname of the controlling host, 
  *        service configurations are modified to allow 
  *        control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL for
+ *          localhost
+ * @param lowport lowest port number this system is allowed to allocate (inclusive)
+ * @param highport highest port number this system is allowed to allocate (exclusive)
  * @return handle to this system, NULL on error
  */
 struct GNUNET_TESTING_System *
-GNUNET_TESTING_system_create (const char *testdir,
-                             const char *controller);
+GNUNET_TESTING_system_create_with_portrange (const char *testdir,
+                                            const char *controller,
+                                            const char *hostname,
+                                            uint16_t lowport,
+                                            uint16_t highport);
 
 
 /**
@@ -137,9 +168,11 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
 
 
 /**
- * Create a new configuration using the given configuration
- * as a template; ports and paths will be modified to select
- * available ports on the local system.  If we run
+ * Create a new configuration using the given configuration as a template;
+ * ports and paths will be modified to select available ports on the local
+ * system. The default configuration will be available in PATHS section under
+ * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PATHS
+ * section to the temporary directory specific to this configuration. If we run
  * out of "*port" numbers, return SYSERR.
  *
  * This is primarily a helper function used internally
@@ -165,7 +198,8 @@ GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system,
  *            changes in port numbers and paths)
  * @param key_number number of the hostkey to use for the peer
  * @param id identifier for the daemon, will be set, can be NULL
- * @param emsg set to error message (set to NULL on success), can be NULL
+ * @param emsg set to freshly allocated error message (set to NULL on success), 
+ *          can be NULL
  * @return handle to the peer, NULL on error
  */
 struct GNUNET_TESTING_Peer *
@@ -176,6 +210,17 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
                               char **emsg);
 
 
+/**
+ * Obtain the peer identity from a peer handle.
+ *
+ * @param peer peer handle for which we want the peer's identity
+ * @param id identifier for the daemon, will be set
+ */
+void
+GNUNET_TESTING_peer_get_identity (const struct GNUNET_TESTING_Peer *peer,
+                                 struct GNUNET_PeerIdentity *id);
+
+
 /**
  * Start the peer. 
  *
@@ -213,21 +258,11 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer);
  * 
  * @param cls closure
  * @param cfg configuration of the peer that was started
+ * @param peer identity of the peer that was created
  */
 typedef void (*GNUNET_TESTING_TestMain)(void *cls,
-                                       const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Signature of the 'main' function for a (single-peer) testcase that
- * is run using 'GNUNET_TESTING_system_run_restartable'.
- * 
- * @param cls closure
- * @param cfg configuration of the peer that was started
- */
-typedef void (*GNUNET_TESTING_RestartableTestMain)(void *cls,
                                        const struct GNUNET_CONFIGURATION_Handle *cfg,
-                    const struct GNUNET_TESTING_Peer *peer);
+                                       struct GNUNET_TESTING_Peer *peer);
 
 
 /**
@@ -282,21 +317,6 @@ GNUNET_TESTING_service_run (const char *testdir,
                            void *tm_cls);
 
 
-/**
- * See GNUNET_TESTING_service_run.
- * The only difference is that we handle the GNUNET_TESTING_Peer to
- * the RestartableTestMain, so that the peer can be destroyed and re-created
- * to simulate failure in tests.
- */
-int
-GNUNET_TESTING_service_run_restartable (const char *testdir,
-                           const char *service_name,
-                           const char *cfgfilename,
-                           GNUNET_TESTING_RestartableTestMain tm,
-                           void *tm_cls);
-
-
-
 /**
  * Sometimes we use the binary name to determine which specific
  * test to run.  In those cases, the string after the last "_"