fix
[oweals/gnunet.git] / src / datastore / test_datastore_api_management.c
index 9c3a602fbda9976c394922a02c8b3c5a4dffd228..d0278094f8a32a9fbdd81604a13df04c550178ca 100644 (file)
@@ -47,6 +47,7 @@ static struct GNUNET_TIME_Absolute now;
 
 static int ok;
 
+static const char* plugin_name;
 
 static size_t
 get_size (int i)
@@ -319,9 +320,11 @@ static int
 check ()
 {
   pid_t pid;
-  char *const argv[] = { "test-datastore-api-management",
+  char cfg_name[128];
+  char *const argv[] = { 
+    "test-datastore-api-management",
     "-c",
-    "test_datastore_api_data.conf",
+    cfg_name,
 #if VERBOSE
     "-L", "DEBUG",
 #endif
@@ -330,12 +333,16 @@ check ()
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
+  GNUNET_snprintf (cfg_name,
+                  sizeof (cfg_name),
+                  "test_datastore_api_data_%s.conf",
+                  plugin_name);
   pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
                                  "gnunet-service-arm",
 #if VERBOSE
                                  "-L", "DEBUG",
 #endif
-                                 "-c", "test_datastore_api_data.conf", NULL);
+                                 "-c", cfg_name, NULL);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-datastore-api", "nohelp",
                       options, &run, NULL);
@@ -355,8 +362,20 @@ main (int argc, char *argv[])
 {
   int ret;
   
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-datastore");
-  GNUNET_log_setup ("test-datastore-api",
+  const char *pos;
+  char dir_name[128];
+
+  /* determine name of plugin to use */
+  plugin_name = argv[0];
+  while (NULL != (pos = strstr(plugin_name, "_")))
+    plugin_name = pos+1;
+
+  GNUNET_snprintf (dir_name,
+                  sizeof (dir_name),
+                  "/tmp/test-gnunet-datastore-%s",
+                  plugin_name);
+  GNUNET_DISK_directory_remove (dir_name);
+  GNUNET_log_setup ("test-datastore-api-management",
 #if VERBOSE
                     "DEBUG",
 #else
@@ -364,10 +383,8 @@ main (int argc, char *argv[])
 #endif
                     NULL);
   ret = check ();
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-datastore");
+  GNUNET_DISK_directory_remove (dir_name);
   return ret;
 }
 
-
-
 /* end of test_datastore_api_management.c */