-fixes
[oweals/gnunet.git] / src / fs / fs_test_lib.h
index 524c1f3cc39a09652295110f6f7944d879b626bf..81125cafc12c0bd6b7c70dd4f021c4abfd427c50 100644 (file)
@@ -4,7 +4,7 @@
 
      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
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -41,28 +41,32 @@ struct GNUNET_FS_TestDaemon;
 /**
  * Start daemons for testing.
  *
- * @param sched scheduler to use
+ * @param template_cfg_file configuration template to use
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
  * @param total number of daemons to start
  * @param daemons array of 'total' entries to be initialized
  *                (array must already be allocated, will be filled)
- * @param cont function to call when done
+ * @param cont function to call when done; note that if 'cont'
+ *             is called with reason "TIMEOUT", then starting the
+ *             daemons has failed and the client MUST NOT call
+ *             'GNUNET_FS_TEST_daemons_stop'!
  * @param cont_cls closure for cont
  */
 void
-GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
-                             struct GNUNET_TIME_Relative timeout,
-                             unsigned int total,
-                             struct GNUNET_FS_TestDaemon **daemons,
-                             GNUNET_SCHEDULER_Task cont,
-                             void *cont_cls);
+GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
+                              struct GNUNET_TIME_Relative timeout,
+                              unsigned int total,
+                              struct GNUNET_FS_TestDaemon **daemons,
+                              GNUNET_SCHEDULER_Task cont, void *cont_cls);
+
+
+struct GNUNET_FS_TEST_ConnectContext;
 
 
 /**
  * Connect two daemons for testing.
  *
- * @param sched scheduler to use
  * @param daemon1 first daemon to connect
  * @param daemon2 second first daemon to connect
  * @param timeout if this operation cannot be completed within the
@@ -70,26 +74,54 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
  * @param cont function to call when done
  * @param cont_cls closure for cont
  */
+struct GNUNET_FS_TEST_ConnectContext *
+GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
+                                struct GNUNET_FS_TestDaemon *daemon2,
+                                struct GNUNET_TIME_Relative timeout,
+                                GNUNET_SCHEDULER_Task cont, void *cont_cls);
+
+
+/**
+ * Cancel connect operation.
+ *
+ * @param cc operation to cancel
+ */
 void
-GNUNET_FS_TEST_daemons_connect (struct GNUNET_SCHEDULER_Handle *sched,
-                               struct GNUNET_FS_TestDaemon *daemon1,
-                               struct GNUNET_FS_TestDaemon *daemon2,
-                               struct GNUNET_TIME_Relative timeout,
-                               GNUNET_SCHEDULER_Task cont,
-                               void *cont_cls);
+GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext
+                                       *cc);
+
 
+/**
+ * Obtain peer group used for testing.
+ *
+ * @param daemons array with the daemons (must contain at least one)
+ * @return peer group
+ */
+struct GNUNET_TESTING_PeerGroup *
+GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons);
+
+
+
+/**
+ * Obtain peer configuration used for testing.
+ *
+ * @param daemons array with the daemons
+ * @param off which configuration to get
+ * @return peer configuration
+ */
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
+                                  unsigned int off);
 
 /**
  * Stop daemons used for testing.
  *
- * @param sched scheduler to use
  * @param total number of daemons to stop
  * @param daemons array with the daemons (values will be clobbered)
  */
 void
-GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
-                            unsigned int total,
-                            struct GNUNET_FS_TestDaemon **daemons);
+GNUNET_FS_TEST_daemons_stop (unsigned int total,
+                             struct GNUNET_FS_TestDaemon **daemons);
 
 
 /**
@@ -98,15 +130,14 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
  * @param cls closure (user defined)
  * @param uri a URI, NULL for errors
  */
-typedef void 
-(*GNUNET_FS_TEST_UriContinuation)(void *cls,
-                                 const struct GNUNET_FS_Uri *uri);
+typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls,
+                                                const struct GNUNET_FS_Uri *
+                                                uri);
 
 
 /**
  * Publish a file at the given daemon.
  *
- * @param sched scheduler to use
  * @param daemon where to publish
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
@@ -120,22 +151,16 @@ typedef void
  * @param cont_cls closure for cont
  */
 void
-GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
-                       struct GNUNET_FS_TestDaemon *daemon,
-                       struct GNUNET_TIME_Relative timeout,
-                       uint32_t anonymity,
-                       int do_index,
-                       uint64_t size,
-                       uint32_t seed,
-                       unsigned int verbose,
-                       GNUNET_FS_TEST_UriContinuation cont,
-                       void *cont_cls);
+GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
+                        struct GNUNET_TIME_Relative timeout, uint32_t anonymity,
+                        int do_index, uint64_t size, uint32_t seed,
+                        unsigned int verbose,
+                        GNUNET_FS_TEST_UriContinuation cont, void *cont_cls);
 
 
 /**
  * Perform test download.
  *
- * @param sched scheduler to use
  * @param daemon which peer to download from
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
@@ -147,15 +172,11 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
  * @param cont_cls closure for cont
  */
 void
-GNUNET_FS_TEST_download (struct GNUNET_SCHEDULER_Handle *sched,
-                        struct GNUNET_FS_TestDaemon *daemon,
-                        struct GNUNET_TIME_Relative timeout,
-                        uint32_t anonymity,
-                        uint32_t seed,
-                        const struct GNUNET_FS_Uri *uri,
-                        unsigned int verbose,
-                        GNUNET_SCHEDULER_Task cont,
-                        void *cont_cls);
+GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
+                         struct GNUNET_TIME_Relative timeout,
+                         uint32_t anonymity, uint32_t seed,
+                         const struct GNUNET_FS_Uri *uri, unsigned int verbose,
+                         GNUNET_SCHEDULER_Task cont, void *cont_cls);