gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25393 - in gnunet/src: fs include testbed


From: gnunet
Subject: [GNUnet-SVN] r25393 - in gnunet/src: fs include testbed
Date: Tue, 11 Dec 2012 14:48:13 +0100

Author: harsha
Date: 2012-12-11 14:48:13 +0100 (Tue, 11 Dec 2012)
New Revision: 25393

Modified:
   gnunet/src/fs/gnunet-fs-profiler.c
   gnunet/src/include/gnunet_testbed_service.h
   gnunet/src/testbed/test_testbed_api_testbed_run.c
   gnunet/src/testbed/testbed_api_test.c
   gnunet/src/testbed/testbed_api_testbed.c
Log:
fix 2689

Modified: gnunet/src/fs/gnunet-fs-profiler.c
===================================================================
--- gnunet/src/fs/gnunet-fs-profiler.c  2012-12-11 13:46:26 UTC (rev 25392)
+++ gnunet/src/fs/gnunet-fs-profiler.c  2012-12-11 13:48:13 UTC (rev 25393)
@@ -124,14 +124,14 @@
 
 
 /**
- * The testbed has been started, now begin the experiment.
+ * Signature of a main function for a testcase.
  *
- * @param cls configuration handle
- * @param tc scheduler context
- */ 
+ * @param cls closure
+ * @param num_peers number of peers in 'peers'
+ * @param peers handle to peers run in the testbed
+ */
 static void
-master_task (void *cls,
-            const struct GNUNET_SCHEDULER_TaskContext *tc)
+test_master (void *cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer 
**peers)
 {
   // const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   // FIXME: enable clients to signal 'completion' before timeout;
@@ -163,7 +163,7 @@
                      cfg,
                      num_peers,
                      0, NULL, NULL,
-                     &master_task, (void *) cfg);
+                     &test_master, (void *) cfg);
 }
 
 

Modified: gnunet/src/include/gnunet_testbed_service.h
===================================================================
--- gnunet/src/include/gnunet_testbed_service.h 2012-12-11 13:46:26 UTC (rev 
25392)
+++ gnunet/src/include/gnunet_testbed_service.h 2012-12-11 13:48:13 UTC (rev 
25393)
@@ -1363,6 +1363,18 @@
 
 
 /**
+ * Signature of a main function for a testcase.
+ *
+ * @param cls closure
+ * @param num_peers number of peers in 'peers'
+ * @param peers handle to peers run in the testbed
+ */
+typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
+                                          unsigned int num_peers,
+                                          struct GNUNET_TESTBED_Peer **peers);
+
+
+/**
  * Convenience method for running a testbed with
  * a single call.  Underlay and overlay topology
  * are configured using the "UNDERLAY" and "OVERLAY"
@@ -1387,8 +1399,8 @@
  *        set in the event_mask as this is the only way get access to the
  *        handle of each peer
  * @param cc_cls closure for cc
- * @param master task to run once the testbed is ready
- * @param master_cls closure for 'task'.
+ * @param test_master this callback will be called once the test is ready
+ * @param test_master_cls closure for 'test_master'.
  */
 void
 GNUNET_TESTBED_run (const char *host_filename,
@@ -1397,8 +1409,8 @@
                     uint64_t event_mask,
                     GNUNET_TESTBED_ControllerCallback cc,
                     void *cc_cls,
-                    GNUNET_SCHEDULER_Task master,
-                    void *master_cls);
+                    GNUNET_TESTBED_TestMaster test_master,
+                    void *test_master_cls);
 
 
 /**
@@ -1442,8 +1454,8 @@
  *        set in the event_mask as this is the only way get access to the
  *        handle of each peer
  * @param cc_cls closure for cc
- * @param test_master task to run once the test is ready
- * @param test_master_cls closure for 'task'.
+ * @param test_master this callback will be called once the test is ready
+ * @param test_master_cls closure for 'test_master'.
  * @param GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int

Modified: gnunet/src/testbed/test_testbed_api_testbed_run.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run.c   2012-12-11 13:46:26 UTC 
(rev 25392)
+++ gnunet/src/testbed/test_testbed_api_testbed_run.c   2012-12-11 13:48:13 UTC 
(rev 25393)
@@ -90,13 +90,14 @@
 
 
 /**
- * Task to be executed when peers are ready
+ * Signature of a main function for a testcase.
  *
- * @param cls NULL
- * @param tc the task context
+ * @param cls closure
+ * @param num_peers number of peers in 'peers'
+ * @param peers handle to peers run in the testbed
  */
 static void
-master_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+test_master (void *cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer 
**peers_)
 {
   result = GNUNET_OK;
   GNUNET_assert (NULL != peers[0]);
@@ -153,7 +154,7 @@
   event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
   event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
   GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, 
&controller_event_cb,
-                      NULL, &master_task, NULL);
+                      NULL, &test_master, NULL);
   abort_task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_SECONDS, 300), &do_abort,

Modified: gnunet/src/testbed/testbed_api_test.c
===================================================================
--- gnunet/src/testbed/testbed_api_test.c       2012-12-11 13:46:26 UTC (rev 
25392)
+++ gnunet/src/testbed/testbed_api_test.c       2012-12-11 13:48:13 UTC (rev 
25393)
@@ -62,59 +62,10 @@
    * Number of peers to start
    */
   unsigned int num_peers;
-
-  /**
-   * counter for loading peers
-   */
-  unsigned int peer_cnt;
-
-  /**
-   * Followed by peers list
-   */
-  struct GNUNET_TESTBED_Peer *peers[0];
 };
 
 
 /**
- * Controller event callback
- *
- * @param cls NULL
- * @param event the controller event
- */
-static void
-controller_event_cb (void *cls,
-                     const struct GNUNET_TESTBED_EventInformation *event)
-{
-  struct TestRunContext *rc = cls;
-
-  if ((NULL != rc->cc) && (0 != (rc->event_mask & (1LL << event->type))))
-    rc->cc (rc->cc_cls, event);
-  if (rc->peer_cnt == rc->num_peers)
-    return;
-  GNUNET_assert (GNUNET_TESTBED_ET_PEER_START == event->type);
-  GNUNET_assert (NULL == rc->peers[rc->peer_cnt]);
-  GNUNET_assert (NULL != event->details.peer_start.peer);
-  rc->peers[rc->peer_cnt++] = event->details.peer_start.peer;
-}
-
-
-/**
- * Task to be executed when peers are ready
- *
- * @param cls NULL
- * @param tc the task context
- */
-static void
-master_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct TestRunContext *rc = cls;
-
-  GNUNET_assert (rc->peer_cnt == rc->num_peers);
-  rc->test_master (rc->test_master_cls, rc->num_peers, rc->peers);
-}
-
-
-/**
  * Main run function.
  *
  * @param cls NULL
@@ -127,12 +78,9 @@
      const struct GNUNET_CONFIGURATION_Handle *config)
 {
   struct TestRunContext *rc = cls;
-  uint64_t event_mask;
-  
-  event_mask = rc->event_mask;
-  event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
-  GNUNET_TESTBED_run (NULL, config, rc->num_peers, event_mask,
-                      &controller_event_cb, rc, &master_task, rc);
+
+  GNUNET_TESTBED_run (NULL, config, rc->num_peers, rc->event_mask,
+                      rc->cc, rc->cc_cls, rc->test_master, 
rc->test_master_cls);
 }
 
 

Modified: gnunet/src/testbed/testbed_api_testbed.c
===================================================================
--- gnunet/src/testbed/testbed_api_testbed.c    2012-12-11 13:46:26 UTC (rev 
25392)
+++ gnunet/src/testbed/testbed_api_testbed.c    2012-12-11 13:48:13 UTC (rev 
25393)
@@ -163,14 +163,14 @@
   void *cc_cls;
 
   /**
-   * Master task to call when testbed initialization is done
+   * TestMaster callback to call when testbed initialization is done
    */
-  GNUNET_SCHEDULER_Task master;
-
+  GNUNET_TESTBED_TestMaster test_master;
+  
   /**
-   * The closure for the master task
+   * The closure for the TestMaster callback
    */
-  void *master_cls;
+  void *test_master_cls;
 
   /**
    * The head element of DLL operations
@@ -493,9 +493,8 @@
     GNUNET_TESTBED_operation_done (rc->topology_operation);
     rc->topology_operation = NULL;
   }
-  if (NULL != rc->master)
-    GNUNET_SCHEDULER_add_continuation (rc->master, rc->master_cls,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  if (NULL != rc->test_master)
+    rc->test_master (rc->test_master_cls, rc->num_peers, rc->peers);
 }
 
 
@@ -645,7 +644,7 @@
   }
 
 call_cc:
-  if ((0 != (rc->event_mask && (1LL << event->type))) && (NULL != rc->cc))
+  if ((0 != (rc->event_mask & (1LL << event->type))) && (NULL != rc->cc))
     rc->cc (rc->cc_cls, event);
   if (GNUNET_TESTBED_ET_PEER_START != event->type)
     return;
@@ -809,6 +808,7 @@
   event_mask = rc->event_mask;
   event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
   event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
+  event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
   if (rc->topology < GNUNET_TESTBED_TOPOLOGY_NONE)
     event_mask |= GNUNET_TESTBED_ET_CONNECT;
   rc->c =
@@ -909,15 +909,16 @@
  *          set in the event_mask as this is the only way get access to the
  *          handle of each peer
  * @param cc_cls closure for cc
- * @param master task to run once the testbed is ready
- * @param master_cls
+ * @param test_master this callback will be called once the test is ready
+ * @param test_master_cls closure for 'test_master'.
  */
 void
 GNUNET_TESTBED_run (const char *host_filename,
                     const struct GNUNET_CONFIGURATION_Handle *cfg,
                     unsigned int num_peers, uint64_t event_mask,
                     GNUNET_TESTBED_ControllerCallback cc, void *cc_cls,
-                    GNUNET_SCHEDULER_Task master, void *master_cls)
+                    GNUNET_TESTBED_TestMaster test_master,
+                    void *test_master_cls)
 {
   struct RunContext *rc;
   char *topology;
@@ -945,11 +946,10 @@
   rc->cfg = GNUNET_CONFIGURATION_dup (cfg);
   rc->num_peers = num_peers;
   rc->event_mask = event_mask;
-  rc->event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
   rc->cc = cc;
   rc->cc_cls = cc_cls;
-  rc->master = master;
-  rc->master_cls = master_cls;
+  rc->test_master = test_master;
+  rc->test_master_cls = test_master_cls;
   rc->state = RC_INIT;
   rc->topology = GNUNET_TESTBED_TOPOLOGY_NONE;  
   if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (rc->cfg, "testbed",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]