-cleaning up VERBOSE and check nonsense in util tests
authorChristian Grothoff <christian@grothoff.org>
Wed, 13 Jun 2012 15:18:35 +0000 (15:18 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 13 Jun 2012 15:18:35 +0000 (15:18 +0000)
23 files changed:
src/util/test_client.c
src/util/test_common_logging_runtime_loglevels.c
src/util/test_connection.c
src/util/test_connection_addressing.c
src/util/test_connection_receive_cancel.c
src/util/test_connection_timeout.c
src/util/test_connection_timeout_no_connect.c
src/util/test_connection_transmit_cancel.c
src/util/test_getopt.c
src/util/test_os_network.c
src/util/test_os_priority.c
src/util/test_os_start_process.c
src/util/test_peer.c
src/util/test_plugin.c
src/util/test_scheduler.c
src/util/test_scheduler_delay.c
src/util/test_server.c
src/util/test_server_disconnect.c
src/util/test_server_with_client.c
src/util/test_server_with_client_unix.c
src/util/test_service.c
src/util/test_strings.c
src/util/test_time.c

index 54881b2dd1542cb97a01436df670541d208f46a7..7d7ec8cff1eec3c21f0c624f848b83521caa627e 100644 (file)
@@ -29,7 +29,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 #define PORT 14325
 
@@ -174,15 +173,14 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-/**
- * Main method, starts scheduler with task1,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
   int ok;
 
+  GNUNET_log_setup ("test_client",
+                    "WARNING",
+                    NULL);
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT);
   GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost");
@@ -194,21 +192,4 @@ check ()
   return ok;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  GNUNET_log_setup ("test_client",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret += check ();
-
-  return ret;
-}
-
 /* end of test_client.c */
index b914ae1c6f20f88b648d5b098531f58b83b44c4c..5ad9d986035455aea94056df60a908e0f90cf568 100644 (file)
@@ -351,34 +351,16 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   runone ();
 }
 
-/**
- * Main method, starts scheduler with task1,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
-{
-  ok = 1;
-  GNUNET_SCHEDULER_run (&task, &ok);
-  return ok;
-}
-
 
 int
 main (int argc, char *argv[])
 {
-  int ret;
-
   GNUNET_log_setup ("test-common-logging-runtime-loglevels",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret = check ();
-
-  return ret;
+  ok = 1;
+  GNUNET_SCHEDULER_run (&task, &ok);
+  return ok;
 }
 
 /* end of test_common_logging_runtime_loglevels.c */
index 4568f8ecbf5e8529bece2368bd6b86bbd303d2dc..e129c80ea7dc100323b7cbcfb7b9b08331b85df5 100644 (file)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 
@@ -80,17 +78,13 @@ receive_check (void *cls, const void *buf, size_t available,
 {
   int *ok = cls;
 
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive validates incoming data\n");
-#endif
   GNUNET_assert (buf != NULL);  /* no timeout */
   if (0 == memcmp (&"Hello World"[sofar], buf, available))
     sofar += available;
   if (sofar < 12)
   {
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n");
-#endif
     GNUNET_CONNECTION_receive (asock, 1024,
                                GNUNET_TIME_relative_multiply
                                (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check,
@@ -98,9 +92,7 @@ receive_check (void *cls, const void *buf, size_t available,
   }
   else
   {
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive closes accepted socket\n");
-#endif
     *ok = 0;
     GNUNET_CONNECTION_destroy (asock);
     GNUNET_CONNECTION_destroy (csock);
@@ -111,41 +103,33 @@ receive_check (void *cls, const void *buf, size_t available,
 static void
 run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n");
-#endif
   asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls);
   GNUNET_assert (asock != NULL);
   GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys listen socket\n");
-#endif
   GNUNET_CONNECTION_destroy (lsock);
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test asks to receive on accepted socket\n");
-#endif
   GNUNET_CONNECTION_receive (asock, 1024,
                              GNUNET_TIME_relative_multiply
                              (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check,
                              cls);
 }
 
+
 static size_t
 make_hello (void *cls, size_t size, void *buf)
 {
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test prepares to transmit on connect socket\n");
-#endif
   GNUNET_assert (size >= 12);
   strcpy ((char *) buf, "Hello World");
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys client socket\n");
-#endif
   return 12;
 }
 
+
 static void
 task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -154,30 +138,26 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (lsock != NULL);
   csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT);
   GNUNET_assert (csock != NULL);
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n");
-#endif
   GNUNET_assert (NULL !=
                  GNUNET_CONNECTION_notify_transmit_ready (csock, 12,
                                                           GNUNET_TIME_UNIT_SECONDS,
                                                           &make_hello, NULL));
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n");
-#endif
   GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept,
                                  cls);
 }
 
 
-/**
- * Main method, starts scheduler with task ,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
   int ok;
 
+  GNUNET_log_setup ("test_connection",
+                    "WARNING",
+                    NULL);
+
   ok = 1;
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
@@ -187,22 +167,4 @@ check ()
   return ok;
 }
 
-
-
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  GNUNET_log_setup ("test_connection",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret += check ();
-  return ret;
-}
-
 /* end of test_connection.c */
index ba7acaefcc3bb72d32a854cfbae256e60cab4b4a..e5c8edeeb7828aed994f64b871e863f5ce973452 100644 (file)
@@ -27,7 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 #define PORT 12435
 
@@ -174,36 +173,17 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-/**
- * Main method, starts scheduler with task ,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
-{
-  int ok;
-
-  ok = 1;
-  GNUNET_SCHEDULER_run (&task, &ok);
-  return ok;
-}
-
-
-
 int
 main (int argc, char *argv[])
 {
-  int ret = 0;
+  int ok;
 
   GNUNET_log_setup ("test_connection_addressing",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret += check ();
-  return ret;
+  ok = 1;
+  GNUNET_SCHEDULER_run (&task, &ok);
+  return ok;
 }
 
 /* end of test_connection_addressing.c */
index 93fcd5fdfdca5929b99f9d6b1b716edc138305dd..90490343c15f60e43522fabf16301fe170b844c7 100644 (file)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 
index c0597b24be17fa48e6db6f66098858a57246e03f..8d3f775b54e250d077f0b36cd800c1c47963da3b 100644 (file)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 static struct GNUNET_CONNECTION_Handle *csock;
@@ -78,18 +76,14 @@ send_kilo (void *cls, size_t size, void *buf)
 
   if (size == 0)
   {
-#if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got the desired timeout!\n");
-#endif
     GNUNET_assert (buf == NULL);
     *ok = 0;
     GNUNET_CONNECTION_destroy (lsock);
     GNUNET_CONNECTION_destroy (csock);
     return 0;
   }
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending kilo to fill buffer.\n");
-#endif
   GNUNET_assert (size >= 1024);
   memset (buf, 42, 1024);
 
@@ -117,15 +111,15 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-
-/**
- * Main method, starts scheduler with task_timeout.
- */
-static int
-check_timeout ()
+int
+main (int argc, char *argv[])
 {
   int ok;
 
+  GNUNET_log_setup ("test_connection_timeout",
+                    "WARNING",
+                    NULL);
+
   ok = 1;
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
@@ -135,20 +129,4 @@ check_timeout ()
   return ok;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  GNUNET_log_setup ("test_connection_timeout",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret += check_timeout ();
-  return ret;
-}
-
 /* end of test_connection_timeout.c */
index 2e8f9be2eb415c3f12798d49c024000244b1a011..50eaf709a772f0dff94b33ed01e5b4997990e931 100644 (file)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 13425
 
 static struct GNUNET_CONNECTION_Handle *csock;
@@ -40,10 +38,7 @@ handle_timeout (void *cls, size_t size, void *buf)
 {
   int *ok = cls;
 
-#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received timeout signal.\n");
-#endif
-
   GNUNET_assert (size == 0);
   GNUNET_assert (buf == NULL);
   *ok = 0;
@@ -64,15 +59,14 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-
-/**
- * Main method, starts scheduler with task_timeout.
- */
-static int
-check_timeout ()
+int
+main (int argc, char *argv[])
 {
   int ok;
 
+  GNUNET_log_setup ("test_connection_timeout_no_connect",
+                    "WARNING",
+                    NULL);
   ok = 1;
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
@@ -82,20 +76,4 @@ check_timeout ()
   return ok;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  GNUNET_log_setup ("test_connection_timeout_no_connect",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret += check_timeout ();
-  return ret;
-}
-
 /* end of test_connection_timeout_no_connect.c */
index fec72d273b2ec768e9687e4ed75601e47836cffc..195ac689bb881eec983fbed12bc9895378ad66b7 100644 (file)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 static struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -61,16 +59,14 @@ task_transmit_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-
-
-/**
- * Main method, starts scheduler with task_timeout.
- */
-static int
-check_transmit_cancel ()
+int
+main (int argc, char *argv[])
 {
   int ok;
 
+  GNUNET_log_setup ("test_connection_transmit_cancel",
+                    "WARNING",
+                    NULL);
   ok = 1;
   cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
@@ -80,22 +76,4 @@ check_transmit_cancel ()
   return ok;
 }
 
-
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  GNUNET_log_setup ("test_connection_transmit_cancel",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret += check_transmit_cancel ();
-
-  return ret;
-}
-
 /* end of test_connection_transmit_cancel.c */
index a517887bff54c9e6a1c56c8c688a37a79ddaa9b3..f068a6ab0403fe1cfc5897e381102914aa1c1a6c 100644 (file)
@@ -26,7 +26,6 @@
 #include "gnunet_configuration_lib.h"
 #include "gnunet_getopt_lib.h"
 
-#define VERBOSE 0
 
 static int
 testMinimal ()
@@ -45,6 +44,7 @@ testMinimal ()
   return 0;
 }
 
+
 static int
 testVerbose ()
 {
@@ -75,6 +75,7 @@ testVerbose ()
   return 0;
 }
 
+
 static int
 testVersion ()
 {
@@ -96,6 +97,7 @@ testVersion ()
   return 0;
 }
 
+
 static int
 testAbout ()
 {
@@ -117,6 +119,7 @@ testAbout ()
   return 0;
 }
 
+
 static int
 testLogOpts ()
 {
@@ -153,6 +156,7 @@ testLogOpts ()
   return 0;
 }
 
+
 static int
 testFlagNum ()
 {
@@ -190,6 +194,7 @@ testFlagNum ()
   return 0;
 }
 
+
 int
 main (int argc, char *argv[])
 {
index 4486e6a998fc12ddade158d438a2fafa42459112..2cdd7504051a9d9f95d06bea781573bc3a4d05ea 100644 (file)
@@ -26,7 +26,6 @@
 #include "gnunet_configuration_lib.h"
 #include "gnunet_os_lib.h"
 
-#define VERBOSE 1
 
 /**
  * Check if the address we got is IPv4 or IPv6 loopback (which should
@@ -40,20 +39,20 @@ proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr,
 {
   int *ok = cls;
   char buf[INET6_ADDRSTRLEN];
+  const char * protocol;
 
   if (NULL == addr)
     return GNUNET_OK;
-#if VERBOSE
-  const char * protocol;
   if (addrlen == sizeof (struct sockaddr_in))
     protocol = "IPv4";
   else
     protocol = "IPv6";
-  printf ("%s Address `%s'\n", protocol, GNUNET_a2s ((const struct sockaddr *) addr,addrlen) );
-  printf ("     Netmask `%s'\n", GNUNET_a2s ((const struct sockaddr *) netmask, addrlen) );
-  printf ("     Broadcast `%s'\n", GNUNET_a2s ((const struct sockaddr *) broadcast_addr,addrlen) );
-#endif
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "%s Address `%s'\n", protocol, GNUNET_a2s ((const struct sockaddr *) addr,addrlen) );
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Netmask `%s'\n", GNUNET_a2s ((const struct sockaddr *) netmask, addrlen) );
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "`%s'\n", GNUNET_a2s ((const struct sockaddr *) broadcast_addr,addrlen) );
   inet_ntop (addr->sa_family,
              (addr->sa_family ==
               AF_INET) ? (void *) &((struct sockaddr_in *) addr)->sin_addr
@@ -64,23 +63,16 @@ proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr,
   return GNUNET_OK;
 }
 
-static int
-testifcs ()
+
+int
+main (int argc, char *argv[])
 {
   int ret;
 
+  GNUNET_log_setup ("test-os-network", "WARNING", NULL);
   ret = 1;
   GNUNET_OS_network_interfaces_list (&proc, &ret);
   return ret;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int errCnt = 0;
-
-  GNUNET_log_setup ("test-os-network", "WARNING", NULL);
-  if (0 != testifcs ())
-    errCnt++;
-  return errCnt;
-}
+/* end of test_os_network.c */
index 94e2719a2aa05406a0646c9f2ded8088fb24a437..bb740db5fad8c007511102a20faa2ec4ebf13c3d 100644 (file)
@@ -25,7 +25,6 @@
 #include "gnunet_common.h"
 #include "gnunet_os_lib.h"
 
-#define VERBOSE 0
 
 static int
 testprio ()
index 0d1481857e3e889b1f336129f71d1f0cf02add77..5b9973250ac93eb89b7d0fa33c006aaa8a4cebe4 100644 (file)
 #include "gnunet_scheduler_lib.h"
 #include "disk.h"
 
-#define VERBOSE GNUNET_NO
 
-static char *test_phrase = "HELLO WORLD";
+static const char *test_phrase = "HELLO WORLD";
+
 static int ok;
 
 static struct GNUNET_OS_Process *proc;
 
-/* Pipe to write to started processes stdin (on write end) */
+/**
+ * Pipe to write to started processes stdin (on write end) 
+ */
 static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin;
 
-/* Pipe to read from started processes stdout (on read end) */
+/**
+ * Pipe to read from started processes stdout (on read end) 
+ */
 static struct GNUNET_DISK_PipeHandle *hello_pipe_stdout;
 
 static GNUNET_SCHEDULER_TaskIdentifier die_task;
 
+
 static void
 end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -62,6 +67,7 @@ end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_DISK_pipe_close (hello_pipe_stdin);
 }
 
+
 static void
 read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -73,9 +79,7 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   bytes = GNUNET_DISK_file_read (stdout_read_handle, &buf, sizeof (buf));
 
-#if VERBOSE
-  FPRINTF (stderr, "bytes is %d\n", bytes);
-#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "bytes is %d\n", bytes);
 
   if (bytes < 1)
   {
@@ -87,10 +91,8 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   ok = strncmp (&buf[0], test_phrase, strlen (test_phrase));
-#if VERBOSE
-  FPRINTF (stderr, "read %s\n", &buf[0]);
-#endif
-  if (ok == 0)
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "read %s\n", &buf[0]);
+  if (0 == ok)
   {
     GNUNET_SCHEDULER_cancel (die_task);
     GNUNET_SCHEDULER_add_now (&end_task, NULL);
@@ -190,11 +192,9 @@ check_kill ()
   proc =
     GNUNET_OS_start_process (GNUNET_YES, hello_pipe_stdin, hello_pipe_stdout, "cat",
                             "gnunet-service-resolver", "-", NULL); 
-  sleep (1); /* give process time to start and open pipe */
+  sleep (1); /* give process time to start, so we actually use the pipe-kill mechanism! */
   if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
-  {
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-  }
   GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (proc));
   GNUNET_OS_process_destroy (proc);
   proc = NULL;
@@ -238,16 +238,13 @@ main (int argc, char *argv[])
   int ret;
 
   GNUNET_log_setup ("test-os-start-process",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
   ret = 0;
   ret |= check_run ();
   ret |= check_kill ();
   ret |= check_instant_kill ();
-
   return ret;
 }
+
+/* end of test_os_start_process.c */
index 2a4840102cd795aa27660cc114c4b512fe05d7b8..fa4d31b8db3bd2e319eabd683c2e918b3bdc8a95 100644 (file)
@@ -29,8 +29,6 @@
 
 #define NUMBER_OF_PEERS 10
 
-#define VERBOSE GNUNET_NO
-
 /**
  * A list of Peer ID's to play with
  */
@@ -46,9 +44,8 @@ generatePeerIdList ()
   {
     GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
                                       &pidArr[i].hashPubKey);
-#if VERBOSE
-    printf ("Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i]));
-#endif
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i]));
   }
 }
 
@@ -124,7 +121,7 @@ check ()
 int
 main ()
 {
-  int i;
+  unsigned int i;
 
   GNUNET_log_setup ("test-peer", "ERROR", NULL);
   for (i = 0; i < 1; i++)
index 428cdaffbe211af2d99d34edb2eaf36574fb5805..122d5f480351f92139ba74c78eee02457d5e9ef2 100644 (file)
@@ -24,7 +24,6 @@
 #include "platform.h"
 #include "gnunet_plugin_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 static void
 test_cb (void *cls, const char *libname, void *lib_ret)
@@ -39,11 +38,12 @@ test_cb (void *cls, const char *libname, void *lib_ret)
 }
 
 
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
   void *ret;
 
+  GNUNET_log_setup ("test-plugin", "WARNING", NULL);
   GNUNET_log_skip (1, GNUNET_NO);
   ret = GNUNET_PLUGIN_load ("libgnunet_plugin_missing", NULL);
   GNUNET_log_skip (0, GNUNET_NO);
@@ -52,7 +52,7 @@ check ()
   ret = GNUNET_PLUGIN_load ("libgnunet_plugin_test", "in");
   if (ret == NULL)
     return 1;
-  if (0 != strcmp (ret, "Hello"))
+  if (0 != strcmp (ret, "Hello"))    
     return 2;
   ret = GNUNET_PLUGIN_unload ("libgnunet_plugin_test", "out");
   if (ret == NULL)
@@ -60,20 +60,8 @@ check ()
   if (0 != strcmp (ret, "World"))
     return 4;
   free (ret);
-
   GNUNET_PLUGIN_load_all ("libgnunet_plugin_tes", "in", &test_cb, "test");
   return 0;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret;
-
-  GNUNET_log_setup ("test-plugin", "WARNING", NULL);
-  ret = check ();
-
-  return ret;
-}
-
 /* end of test_plugin.c */
index 9832ade6f7ebdad64e4a02e68c0a026845e8a407..2a9ed2db16588f577572045cd69636009b10a23a 100644 (file)
 #include "gnunet_time_lib.h"
 #include "gnunet_disk_lib.h"
 
-#define VERBOSE GNUNET_NO
+
+struct GNUNET_DISK_PipeHandle *p;
+
+static const struct GNUNET_DISK_FileHandle *fds[2];
+
 
 static void
 task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -51,9 +55,6 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   (*ok) = 4;
 }
 
-struct GNUNET_DISK_PipeHandle *p;
-static const struct GNUNET_DISK_FileHandle *fds[2];
-
 
 static void
 taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -74,6 +75,7 @@ taskNeverRun (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (0);
 }
 
+
 static void
 taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -84,6 +86,7 @@ taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   (*ok) = 0;
 }
 
+
 static void
 taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -132,7 +135,6 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-
 /**
  * Main method, starts scheduler with task1,
  * checks that "ok" is correct at the end.
@@ -229,7 +231,6 @@ checkCancel ()
 }
 
 
-
 int
 main (int argc, char *argv[])
 {
index 8ba35f5b958a8bc5793118ff1729178e054d2eb5..a246e96a69d188c25008127485f21f9b16bb29a8 100644 (file)
@@ -28,8 +28,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 static struct GNUNET_TIME_Absolute target;
 
 static int i;
@@ -71,9 +69,13 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   i += INCR;
 }
 
-static int
-check ()
+
+int
+main (int argc, char *argv[])
 {
+  int ret;
+
+  GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL);
   target = GNUNET_TIME_absolute_get ();
   GNUNET_SCHEDULER_run (&test_task, NULL);
   FPRINTF (stdout, "Sleep precision: %llu ms. ",
@@ -89,15 +91,4 @@ check ()
   return 0;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret;
-
-  GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL);
-  ret = check ();
-
-  return ret;
-}
-
 /* end of test_scheduler_delay.c */
index 0faf61bee665295788c134df8784f4d2258d9637..19f993249263e742e6256c8a19dbcde03d7936ad 100644 (file)
@@ -28,8 +28,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
index c54f9cbc81362c8ad0d1e4dc010e7533739c07f0..b54df48893616e365310f23525c825fc559a63f6 100644 (file)
@@ -28,7 +28,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 #define PORT 12435
 
index ad56071fa43c4860763088da531c8059a35a9dfd..c4945630151da22fe698108c6937f44cfbb21b11 100644 (file)
@@ -30,8 +30,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 22335
 
 #define MY_TYPE 128
@@ -190,35 +188,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-/**
- * Main method, starts scheduler with task1,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
-{
-
-  ok = 1;
-  GNUNET_SCHEDULER_run (&task, NULL);
-  return ok;
-}
-
-
 int
 main (int argc, char *argv[])
 {
-  int ret = 0;
-
   GNUNET_log_setup ("test_server_with_client",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret += check ();
-
-  return ret;
+  ok = 1;
+  GNUNET_SCHEDULER_run (&task, NULL);
+  return ok;
 }
 
 /* end of test_server_with_client.c */
index eae80e4e891bdaa4b2039da5c01aeb76690229cb..57a67d3f4517a0f7bbd2df590b0f263e689a5d4e 100644 (file)
@@ -30,8 +30,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define MY_TYPE 128
 
 
@@ -43,6 +41,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
 
 static int ok;
 
+
 static void
 send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -150,7 +149,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   un.sun_path[0] = '\0';
 #endif
 
-
   sap[0] = (struct sockaddr *) &un;
   slens[0] = sizeof (un);
   sap[1] = NULL;
@@ -178,35 +176,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
-/**
- * Main method, starts scheduler with task1,
- * checks that "ok" is correct at the end.
- */
-static int
-check ()
-{
-
-  ok = 1;
-  GNUNET_SCHEDULER_run (&task, NULL);
-  return ok;
-}
-
-
 int
 main (int argc, char *argv[])
 {
-  int ret = 0;
-
   GNUNET_log_setup ("test_server_with_client_unix",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
-  ret += check ();
-
-  return ret;
+  ok = 1;
+  GNUNET_SCHEDULER_run (&task, NULL);
+  return ok;
 }
 
 /* end of test_server_with_client_unix.c */
index 55472497210227a89b57f4657ed0c16a00ed01b1..be49d18775bdab993c6d063b939b037578858397 100644 (file)
@@ -31,8 +31,6 @@
 #include "gnunet_time_lib.h"
 
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 #define MY_TYPE 256
@@ -148,17 +146,11 @@ check ()
     "test_service",
     "-c",
     "test_service_data.conf",
-    "-L",
-#if VERBOSE
-    "DEBUG",
-#else
-    "WARNING",
-#endif
     NULL
   };
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n");
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_SERVICE_run (5, argv, "test_service",
+                 GNUNET_SERVICE_run (3, argv, "test_service",
                                      GNUNET_SERVICE_OPTION_NONE, &runner, &ok));
   GNUNET_assert (0 == ok);
   return ok;
@@ -201,17 +193,11 @@ check6 ()
     "test_service6",
     "-c",
     "test_service_data.conf",
-    "-L",
-#if VERBOSE
-    "DEBUG",
-#else
-    "WARNING",
-#endif
     NULL
   };
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n");
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_SERVICE_run (5, argv, "test_service6",
+                 GNUNET_SERVICE_run (3, argv, "test_service6",
                                      GNUNET_SERVICE_OPTION_NONE, &runner6,
                                      &ok));
   GNUNET_assert (0 == ok);
@@ -241,12 +227,6 @@ check_start_stop ()
     "test-service-program",
     "-c",
     "test_service_data.conf",
-    "-L",
-#if VERBOSE
-    "DEBUG",
-#else
-    "WARNING",
-#endif
     NULL
   };
   const struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -255,9 +235,9 @@ check_start_stop ()
   int ret = 1;
 
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help",
+                 GNUNET_PROGRAM_run (3, argv, "test-service-program", "no help",
                                      options, &start_stop_main, &ret));
-
+  
   GNUNET_break (0 == ret);
   return ret;
 }
@@ -270,11 +250,7 @@ main (int argc, char *argv[])
   struct GNUNET_NETWORK_Handle *s = NULL;
 
   GNUNET_log_setup ("test-service",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
   ret += check ();
   ret += check ();
index b662623e8c474b9e4720d03884ec52f521e8ef59..45dd904f460731265fe6d005772774ee6bd9b3fe 100644 (file)
 #include "gnunet_common.h"
 #include "gnunet_strings_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 #define WANT(a,b) if (0 != strcmp(a,b)) { fprintf(stderr, "Got `%s', wanted `%s'\n", b, a); GNUNET_free(b); GNUNET_break(0); return 1;} else { GNUNET_free (b); }
 #define WANTB(a,b,l) if (0 != memcmp(a,b,l)) { GNUNET_break(0); return 1;} else { }
 
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
   char buf[128];
   char *r;
@@ -39,6 +38,7 @@ check ()
   struct GNUNET_TIME_Absolute at;
   const char *hdir;
 
+  GNUNET_log_setup ("test_strings", "ERROR", NULL);
   sprintf (buf, "4 %s", _( /* size unit */ "b"));
   b = GNUNET_STRINGS_byte_size_fancy (4);
   WANT (buf, b);
@@ -106,14 +106,5 @@ check ()
   return 0;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret;
-
-  GNUNET_log_setup ("test_strings", "ERROR", NULL);
-  ret = check ();
-  return ret;
-}
 
 /* end of test_strings.c */
index b4c723344d58835bc378210837dbf80eee47c104..cd11754161ae6068d56ab8868fa838294f25a6c1 100644 (file)
 #include "gnunet_common.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
 
-static int
-check ()
+int
+main (int argc, char *argv[])
 {
   struct GNUNET_TIME_Absolute now;
   struct GNUNET_TIME_AbsoluteNBO nown;
@@ -43,6 +42,7 @@ check ()
   struct GNUNET_TIME_RelativeNBO reln;
   unsigned int i;
 
+  GNUNET_log_setup ("test-time", "WARNING", NULL);
   forever = GNUNET_TIME_UNIT_FOREVER_ABS;
   relForever = GNUNET_TIME_UNIT_FOREVER_REL;
   relUnit = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -230,15 +230,5 @@ check ()
   return 0;
 }
 
-int
-main (int argc, char *argv[])
-{
-  int ret;
-
-  GNUNET_log_setup ("test-time", "WARNING", NULL);
-  ret = check ();
-
-  return ret;
-}
 
 /* end of test_time.c */