- Tests did not clean up: TEST_HOME with namestore db was not removed after test
[oweals/gnunet.git] / src / namestore / test_namestore_api_lookup_public.c
index 10bfefbed90ab476e59efae139de14a199fa912e..096e5e0553d0d5321826f6e0fe1676d928b41278 100644 (file)
@@ -51,6 +51,7 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
 
 static struct GNUNET_NAMECACHE_QueueEntry *ncqe;
 
+static char *directory;
 
 static void
 cleanup ()
@@ -70,6 +71,11 @@ cleanup ()
     GNUNET_free (privkey);
     privkey = NULL;
   }
+  if (NULL != directory)
+  {
+      GNUNET_DISK_directory_remove (directory);
+      GNUNET_free (directory);
+  }
   GNUNET_SCHEDULER_shutdown ();
 }
 
@@ -193,6 +199,9 @@ run (void *cls,
   char *hostkey_file;
   const char * name = "dummy.dummy.gnunet";
 
+  directory = NULL;
+  GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory);
+
   endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
                                                &endbadly, NULL);
   GNUNET_asprintf (&hostkey_file,
@@ -206,10 +215,11 @@ run (void *cls,
   GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
 
 
-  rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us;
+  rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000;
   rd.record_type = TEST_RECORD_TYPE;
   rd.data_size = TEST_RECORD_DATALEN;
   rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
+  rd.flags = 0;
   memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
 
   nsh = GNUNET_NAMESTORE_connect (cfg);
@@ -233,14 +243,13 @@ main (int argc, char *argv[])
 {
   res = 1;
   if (0 !=
-      GNUNET_TESTING_service_run ("test-namestore-api",
-                                 "namestore",
-                                 "test_namestore_api.conf",
-                                 &run,
-                                 NULL))
+      GNUNET_TESTING_peer_run ("test-namestore-api",
+                               "test_namestore_api.conf",
+                               &run,
+                               NULL))
     return 1;
   return res;
 }
 
 
-/* end of test_namestore_api.c */
+/* end of test_namestore_api_lookup_public.c */