big scheduler refactoring, expect some issues
[oweals/gnunet.git] / src / datastore / test_datastore_api_management.c
index 72760de7af8321ffb5ce3527f083accecc9f7a56..d17d8fbc86be074f94cfc402bdad46c2276bc4fb 100644 (file)
@@ -109,7 +109,6 @@ struct CpsRunContext
   GNUNET_HashCode key;
   int i;
   int found;
-  struct GNUNET_SCHEDULER_Handle *sched;
   const struct GNUNET_CONFIGURATION_Handle *cfg;
   void *data;
   enum RunPhase phase;
@@ -133,8 +132,7 @@ check_success (void *cls,
   GNUNET_assert (GNUNET_OK == success);
   GNUNET_free_non_null (crc->data);
   crc->data = NULL;
-  GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    &run_continuation,
+  GNUNET_SCHEDULER_add_continuation (&run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -170,8 +168,7 @@ check_value (void *cls,
        }
       if (0 == crc->i)
        crc->phase = RP_DONE;
-      GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        &run_continuation,
+      GNUNET_SCHEDULER_add_continuation (&run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
       return;
@@ -204,8 +201,7 @@ check_nothing (void *cls,
   GNUNET_assert (key == NULL);
   if (0 == --crc->i)
     crc->phase = RP_DONE;
-  GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    &run_continuation,
+  GNUNET_SCHEDULER_add_continuation (&run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -307,8 +303,7 @@ run_tests (void *cls,
       GNUNET_free (crc);
       return;
     }
-  GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    &run_continuation,
+  GNUNET_SCHEDULER_add_continuation (&run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -316,7 +311,6 @@ run_tests (void *cls,
 
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *sched,
      char *const *args,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -325,11 +319,10 @@ run (void *cls,
   static GNUNET_HashCode zkey;
 
   crc = GNUNET_malloc(sizeof(struct CpsRunContext));
-  crc->sched = sched;
   crc->cfg = cfg;
   crc->phase = RP_PUT;
   now = GNUNET_TIME_absolute_get ();
-  datastore = GNUNET_DATASTORE_connect (cfg, sched);
+  datastore = GNUNET_DATASTORE_connect (cfg);
   if (NULL ==
       GNUNET_DATASTORE_put (datastore, 0,
                            &zkey, 4, "TEST",
@@ -350,7 +343,7 @@ run (void *cls,
 static int
 check ()
 {
-  pid_t pid;
+  struct GNUNET_OS_Process *proc;
   char cfg_name[128];
   char *const argv[] = { 
     "test-datastore-api-management",
@@ -368,7 +361,7 @@ check ()
                   sizeof (cfg_name),
                   "test_datastore_api_data_%s.conf",
                   plugin_name);
-  pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+  proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
                                  "gnunet-service-arm",
 #if VERBOSE
                                  "-L", "DEBUG",
@@ -377,12 +370,14 @@ check ()
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-datastore-api", "nohelp",
                       options, &run, NULL);
-  if (0 != PLIBC_KILL (pid, SIGTERM))
+  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
     {
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
       ok = 1;
     }
-  GNUNET_OS_process_wait(pid);
+  GNUNET_OS_process_wait (proc);
+  GNUNET_OS_process_close (proc);
+  proc = NULL;
   if (ok != 0)
     fprintf (stderr, "Missed some testcases: %u\n", ok);
   return ok;