gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21857 - in gnunet/src: namestore transport


From: gnunet
Subject: [GNUnet-SVN] r21857 - in gnunet/src: namestore transport
Date: Sun, 10 Jun 2012 15:25:54 +0200

Author: grothoff
Date: 2012-06-10 15:25:53 +0200 (Sun, 10 Jun 2012)
New Revision: 21857

Modified:
   gnunet/src/namestore/Makefile.am
   gnunet/src/namestore/test_namestore_api.c
   gnunet/src/namestore/test_namestore_api_put.c
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/test_plugin_transport.c
Log:
-more testcase cleanup

Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2012-06-10 13:08:08 UTC (rev 21856)
+++ gnunet/src/namestore/Makefile.am    2012-06-10 13:25:53 UTC (rev 21857)
@@ -112,29 +112,34 @@
  test_namestore_api_sign_verify.c
 test_namestore_api_sign_verify_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_SOURCES = \
  test_namestore_api.c
 test_namestore_api_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_put_SOURCES = \
  test_namestore_api_put.c
 test_namestore_api_put_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_lookup_SOURCES = \
  test_namestore_api_lookup.c
 test_namestore_api_lookup_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_lookup_specific_type_SOURCES = \
  test_namestore_api_lookup_specific_type.c
 test_namestore_api_lookup_specific_type_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
@@ -142,12 +147,14 @@
 test_namestore_api_create_SOURCES = \
  test_namestore_api_create.c
 test_namestore_api_create_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_create_update_SOURCES = \
  test_namestore_api_create_update.c
 test_namestore_api_create_update_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
@@ -155,42 +162,49 @@
 test_namestore_api_remove_SOURCES = \
  test_namestore_api_remove.c
 test_namestore_api_remove_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_remove_not_existing_record_SOURCES = \
  test_namestore_api_remove_not_existing_record.c
 test_namestore_api_remove_not_existing_record_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_zone_to_name_SOURCES = \
  test_namestore_api_zone_to_name.c
 test_namestore_api_zone_to_name_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
 test_namestore_api_zone_iteration_SOURCES = \
  test_namestore_api_zone_iteration.c
 test_namestore_api_zone_iteration_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la  
 
 test_namestore_api_zone_iteration_specific_zone_SOURCES = \
  test_namestore_api_zone_iteration_specific_zone.c
 test_namestore_api_zone_iteration_specific_zone_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la  
 
 test_namestore_api_zone_iteration_stop_SOURCES = \
  test_namestore_api_zone_iteration_stop.c
 test_namestore_api_zone_iteration_stop_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la    
 
 test_namestore_record_serialization_SOURCES = \
  test_namestore_record_serialization.c
 test_namestore_record_serialization_LDADD = \
+  $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la  
 

Modified: gnunet/src/namestore/test_namestore_api.c
===================================================================
--- gnunet/src/namestore/test_namestore_api.c   2012-06-10 13:08:08 UTC (rev 
21856)
+++ gnunet/src/namestore/test_namestore_api.c   2012-06-10 13:25:53 UTC (rev 
21857)
@@ -24,6 +24,7 @@
 #include "platform.h"
 #include "gnunet_common.h"
 #include "gnunet_namestore_service.h"
+#include "gnunet_testing_lib-new.h"
 
 #define TEST_RECORD_TYPE 1234
 #define TEST_RECORD_DATALEN 123
@@ -31,14 +32,12 @@
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
 
-static struct GNUNET_NAMESTORE_Handle * nsh;
+static struct GNUNET_NAMESTORE_Handle *nsh;
 
 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
 
-static struct GNUNET_OS_Process *arm;
+static struct GNUNET_CRYPTO_RsaPrivateKey *privkey;
 
-static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
-
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 
 static struct GNUNET_CRYPTO_ShortHashCode zone;
@@ -46,29 +45,6 @@
 static int res;
 
 
-static void
-start_arm (const char *cfgname)
-{
-  arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm", "-c", cfgname,
-                               NULL);
-}
-
-
-static void
-stop_arm ()
-{
-  if (NULL != arm)
-  {
-    if (0 != GNUNET_OS_process_kill (arm, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    GNUNET_OS_process_wait (arm);
-    GNUNET_OS_process_destroy (arm);
-    arm = NULL;
-  }
-}
-
-
 /**
  * Re-establish the connection to the service.
  *
@@ -85,10 +61,7 @@
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
-
-  if (NULL != arm)
-    stop_arm();
-
+  GNUNET_SCHEDULER_shutdown ();
   res = 1;
 }
 
@@ -107,13 +80,10 @@
   privkey = NULL;
 
   if (nsh != NULL)
+  {
     GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
-  nsh = NULL;
-
-
-  if (NULL != arm)
-    stop_arm();
-
+    nsh = NULL;
+  }
   res = 0;
 }
 
@@ -138,7 +108,7 @@
 static void 
 put_cont (void *cls, int32_t success, const char *emsg)
 {
-  char * name = cls;
+  const char *name = cls;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
              "Name store added record for `%s': %s\n", name, (success == 
GNUNET_OK) ? "SUCCESS" : "FAIL");
@@ -166,7 +136,7 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_CRYPTO_RsaSignature signature;
@@ -191,13 +161,11 @@
   rd.data_size = TEST_RECORD_DATALEN;
   rd.data = GNUNET_malloc(TEST_RECORD_DATALEN);
   memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
-  start_arm (cfgfile);
-  GNUNET_assert (arm != NULL);
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
   GNUNET_NAMESTORE_record_put (nsh, &pubkey, name,
-                              GNUNET_TIME_UNIT_FOREVER_ABS,
-                              1, &rd, &signature, put_cont, name);
+                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                              1, &rd, &signature, &put_cont, (void*) name);
   GNUNET_free ((void *)rd.data);
 }
 
@@ -205,18 +173,14 @@
 int
 main (int argc, char *argv[])
 {
-  static char *const argv[] = { "test-namestore-api",
-    "-c",
-    "test_namestore_api.conf",
-    NULL
-  };
-  static struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
   res = 1;
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 
"test-namestore-api",
-                      "nohelp", options, &run, &res);
+  if (0 != 
+      GNUNET_TESTING_service_run ("test-namestore-api",
+                                 "namestore",
+                                 "test_namestore_api.conf",
+                                 &run,
+                                 NULL))
+    return 1;
   return res;
 }
 

Modified: gnunet/src/namestore/test_namestore_api_put.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_put.c       2012-06-10 13:08:08 UTC 
(rev 21856)
+++ gnunet/src/namestore/test_namestore_api_put.c       2012-06-10 13:25:53 UTC 
(rev 21857)
@@ -24,21 +24,26 @@
 #include "platform.h"
 #include "gnunet_common.h"
 #include "gnunet_namestore_service.h"
+#include "gnunet_testing_lib-new.h"
 #include "namestore.h"
 
 #define RECORDS 5
+
 #define TEST_RECORD_TYPE 1234
+
 #define TEST_RECORD_DATALEN 123
+
 #define TEST_RECORD_DATA 'a'
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
 
+
 static struct GNUNET_NAMESTORE_Handle * nsh;
 
 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
-static struct GNUNET_OS_Process *arm;
 
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
+
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 
 static struct GNUNET_NAMESTORE_RecordData *s_rd;
@@ -46,27 +51,6 @@
 static int res;
 
 
-static void
-start_arm (const char *cfgname)
-{
-  arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
-                               "gnunet-service-arm", "-c", cfgname,
-                               NULL);
-}
-
-static void
-stop_arm ()
-{
-  if (NULL != arm)
-  {
-    if (0 != GNUNET_OS_process_kill (arm, SIGTERM))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-    GNUNET_OS_process_wait (arm);
-    GNUNET_OS_process_destroy (arm);
-    arm = NULL;
-  }
-}
-
 /**
  * Re-establish the connection to the service.
  *
@@ -81,11 +65,11 @@
   nsh = NULL;
 
   if (privkey != NULL)
+  {
     GNUNET_CRYPTO_rsa_key_free (privkey);
-  privkey = NULL;
-
-  if (NULL != arm)
-    stop_arm();
+    privkey = NULL;
+  }
+  GNUNET_SCHEDULER_shutdown ();
   res = 1;
 }
 
@@ -100,47 +84,48 @@
   }
 
   if (privkey != NULL)
+  {
     GNUNET_CRYPTO_rsa_key_free (privkey);
-  privkey = NULL;
-
+    privkey = NULL;
+  }
   if (nsh != NULL)
+  {
     GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
-  nsh = NULL;
-
- if (NULL != arm)
-    stop_arm();
+    nsh = NULL;
+  }
 }
 
 
 static void
 put_cont (void *cls, int32_t success, const char *emsg)
 {
-  char * name = cls;
+  const char * name = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s': 
%s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Name store added record for `%s': %s\n", 
+             name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
   if (success == GNUNET_OK)
     res = 0;
   else
     res = 1;
-
-  GNUNET_SCHEDULER_add_now(&end, NULL);
+  GNUNET_SCHEDULER_add_now (&end, NULL);
 }
 
 
 static struct GNUNET_NAMESTORE_RecordData *
 create_record (int count)
 {
-  int c;
+  unsigned int c;
   struct GNUNET_NAMESTORE_RecordData * rd;
-  rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
 
+  rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
   for (c = 0; c < RECORDS; c++)
   {
-  rd[c].expiration = GNUNET_TIME_absolute_get();
-  rd[c].record_type = TEST_RECORD_TYPE;
-  rd[c].data_size = TEST_RECORD_DATALEN;
-  rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
-  memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
+    rd[c].expiration = GNUNET_TIME_absolute_get();
+    rd[c].record_type = TEST_RECORD_TYPE;
+    rd[c].data_size = TEST_RECORD_DATALEN;
+    rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
+    memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
   }
   return rd;
 }
@@ -165,70 +150,52 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls, 
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_CRYPTO_RsaSignature *signature;
   const char * s_name = "dummy.dummy.gnunet";
   int c;
+  char *hostkey_file;
 
   delete_existing_db(cfg);
   endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL);
-
   /* load privat key */
-  char *hostkey_file;
   GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
       "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", 
hostkey_file);
   privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file);
-  GNUNET_free (hostkey_file);
-
   GNUNET_assert (privkey != NULL);
+  GNUNET_free (hostkey_file);
   /* get public key */
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
-
-  start_arm (cfgfile);
-  GNUNET_assert (arm != NULL);
-
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
-
   /* create record */
   s_rd = create_record (RECORDS);
-
   signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, 
s_name, s_rd, RECORDS);
-
   GNUNET_break (s_rd != NULL);
   GNUNET_break (s_name != NULL);
-
   GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name,
-                              GNUNET_TIME_UNIT_FOREVER_ABS,
-                              RECORDS, s_rd, signature, put_cont, s_name);
-
+                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                              RECORDS, s_rd, signature, &put_cont, (void*)  
s_name);
   GNUNET_free (signature);
-
   for (c = 0; c < RECORDS; c++)
     GNUNET_free_non_null((void *) s_rd[c].data);
   GNUNET_free (s_rd);
-
 }
 
 
 int
 main (int argc, char *argv[])
 {
-  static char *const argv[] = { "test-namestore-api",
-    "-c",
-    "test_namestore_api.conf",
-    NULL
-  };
-  static struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-
   res = 1;
-  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 
"test-namestore-api",
-                      "nohelp", options, &run, &res);
+  if (0 != GNUNET_TESTING_service_run ("test-namestore-api-put",
+                                      "namestore",
+                                      "test_namestore_api.conf",
+                                      &run,
+                                      NULL))
+    return 1;
   return res;
 }
 

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2012-06-10 13:08:08 UTC (rev 21856)
+++ gnunet/src/transport/Makefile.am    2012-06-10 13:25:53 UTC (rev 21857)
@@ -389,7 +389,7 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la  \
  $(top_builddir)/src/transport/libgnunettransporttesting.la
-  
+
 test_transport_api_bidirectional_connect_SOURCES = \
  test_transport_api_bidirectional_connect.c
 test_transport_api_bidirectional_connect_LDADD = \
@@ -415,7 +415,7 @@
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
-  
+
 test_transport_api_limited_sockets_tcp_SOURCES = \
  test_transport_api_limited_sockets.c
 test_transport_api_limited_sockets_tcp_LDADD = \
@@ -463,7 +463,7 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
- 
+
 test_transport_api_timeout_https_SOURCES = \
  test_transport_api_timeout.c
 test_transport_api_timeout_https_LDADD = \
@@ -471,7 +471,7 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
- 
+
 test_transport_api_reliability_tcp_nat_SOURCES = \
  test_transport_api_reliability.c
 test_transport_api_reliability_tcp_nat_LDADD = \
@@ -495,7 +495,7 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
- 
+
 test_transport_api_udp_SOURCES = \
  test_transport_api.c
 test_transport_api_udp_LDADD = \
@@ -503,7 +503,7 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la  \
  $(top_builddir)/src/transport/libgnunettransporttesting.la
- 
+
 test_transport_api_timeout_udp_SOURCES = \
  test_transport_api_timeout.c
 test_transport_api_timeout_udp_LDADD = \
@@ -535,8 +535,8 @@
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
- 
- test_transport_api_http_nat_SOURCES = \
+
+test_transport_api_http_nat_SOURCES = \
  test_transport_api.c
 test_transport_api_http_nat_LDADD = \
  $(top_builddir)/src/transport/libgnunettransport.la \

Modified: gnunet/src/transport/test_plugin_transport.c
===================================================================
--- gnunet/src/transport/test_plugin_transport.c        2012-06-10 13:08:08 UTC 
(rev 21856)
+++ gnunet/src/transport/test_plugin_transport.c        2012-06-10 13:25:53 UTC 
(rev 21857)
@@ -34,8 +34,6 @@
 #include "gnunet_transport_plugin.h"
 #include "transport.h"
 
-#define VERBOSE GNUNET_NO
-
 /**
  * How long until we give up on transmitting the message?
  */
@@ -253,20 +251,11 @@
     "test_plugin_transport",
     "-c",
     "test_plugin_transport_data.conf",
-    "-L",
-#if VERBOSE
-    "DEBUG",
-#else
-    "WARNING",
-#endif
+    "-L", "WARNING",
     NULL
   };
   GNUNET_log_setup ("test-plugin-transport",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
   ok = 1;                       /* set to fail */
   ret =




reply via email to

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