-fixing 2494
authorSree Harsha Totakura <totakura@in.tum.de>
Tue, 10 Jul 2012 15:37:07 +0000 (15:37 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Tue, 10 Jul 2012 15:37:07 +0000 (15:37 +0000)
src/testbed/Makefile.am
src/testbed/test_testbed_api.c
src/testbed/test_testbed_api_hosts.c

index 7ed7b4720bfbfc6c99a18ed6a70f49df469518cc..a4e1b2a01b90c8ec0f46a506847b94c566094db4 100644 (file)
@@ -57,7 +57,8 @@ check_PROGRAMS = \
 
 if ENABLE_TEST_RUN
  TESTS = \
-   test_testbed_api_hosts 
+   test_testbed_api_hosts \
+   test_testbed_api
 endif
 
 test_testbed_api_hosts_SOURCES = \
index 5fab405738634d9d2cc2c1363a76ac97116123fc..6c50c93d7bf3eb52f9aa28d3bc185aff94ce70c3 100644 (file)
  */
 static struct GNUNET_TESTBED_Host *host;
 
+/**
+ * The controller process
+ */
+static struct GNUNET_TESTBED_ControllerProc *cp;
+
 /**
  * The controller handle
  */
@@ -102,6 +107,8 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (NULL != reg_handle)
     GNUNET_TESTBED_cancel_registration (reg_handle);
   GNUNET_TESTBED_controller_disconnect (controller);
+  if (NULL != cp)
+    GNUNET_TESTBED_controller_stop (cp);
   GNUNET_TESTBED_host_destroy (neighbour);
   GNUNET_TESTBED_host_destroy (host);
 }
@@ -163,18 +170,23 @@ registration_comp (void *cls, const char *emsg)
 
 
 /**
- * Main point of test execution
+ * Main run function. 
+ *
+ * @param cls NULL
+ * @param args arguments passed to GNUNET_PROGRAM_run
+ * @param cfgfile the path to configuration file
+ * @param cfg the configuration file handle
  */
 static void
-run (void *cls,
-     const struct GNUNET_CONFIGURATION_Handle *config,
-     struct GNUNET_TESTING_Peer *peer)
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *config)
 {
   uint64_t event_mask;
 
   cfg = config;
   host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
   GNUNET_assert (NULL != host);
+  cp = GNUNET_TESTBED_controller_start (host);
   event_mask = 0;
   event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
   event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
@@ -199,15 +211,20 @@ run (void *cls,
  */
 int main (int argc, char **argv)
 {
-  struct GNUNET_TESTBED_ControllerProc *cp;
-
-  cp = GNUNET_TESTBED_controller_start (NULL);
-  
+  int ret;
+
+  char *const argv2[] = { "test_testbed_api",
+                          "-c", "test_testbed_api.conf",
+                          NULL
+  };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
   result = GNUNET_SYSERR;
-  if (0 != GNUNET_TESTING_peer_run ("test_testbed_api",
-                                    "test_testbed_api.conf",
-                                    &run, NULL))
+  ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
+                           "test_testbed_api", "nohelp", options, &run,
+                           NULL);
+  if ((GNUNET_OK != ret) || (GNUNET_OK != result))
     return 1;
-  GNUNET_TESTBED_controller_stop (cp);
-  return result;
+  return 0;
 }
index 91002f10eacef6120f49b6e85bb608a2add3fb8d..2528e7aff1a5914772092536e65cfdb22c6fdd9c 100644 (file)
@@ -90,7 +90,7 @@ int main (int argc, char **argv)
 {
   int ret;
 
-  char *const argv2[] = { "test_lockmanager_api_hosts",
+  char *const argv2[] = { "test_testbed_api_hosts",
                           "-c", "test_testbed_api.conf",
                           NULL
   };