gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21972 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r21972 - gnunet/src/util
Date: Wed, 13 Jun 2012 17:18:35 +0200

Author: grothoff
Date: 2012-06-13 17:18:35 +0200 (Wed, 13 Jun 2012)
New Revision: 21972

Modified:
   gnunet/src/util/test_client.c
   gnunet/src/util/test_common_logging_runtime_loglevels.c
   gnunet/src/util/test_connection.c
   gnunet/src/util/test_connection_addressing.c
   gnunet/src/util/test_connection_receive_cancel.c
   gnunet/src/util/test_connection_timeout.c
   gnunet/src/util/test_connection_timeout_no_connect.c
   gnunet/src/util/test_connection_transmit_cancel.c
   gnunet/src/util/test_getopt.c
   gnunet/src/util/test_os_network.c
   gnunet/src/util/test_os_priority.c
   gnunet/src/util/test_os_start_process.c
   gnunet/src/util/test_peer.c
   gnunet/src/util/test_plugin.c
   gnunet/src/util/test_scheduler.c
   gnunet/src/util/test_scheduler_delay.c
   gnunet/src/util/test_server.c
   gnunet/src/util/test_server_disconnect.c
   gnunet/src/util/test_server_with_client.c
   gnunet/src/util/test_server_with_client_unix.c
   gnunet/src/util/test_service.c
   gnunet/src/util/test_strings.c
   gnunet/src/util/test_time.c
Log:
-cleaning up VERBOSE and check nonsense in util tests

Modified: gnunet/src/util/test_client.c
===================================================================
--- gnunet/src/util/test_client.c       2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_client.c       2012-06-13 15:18:35 UTC (rev 21972)
@@ -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 @@
 }
 
 
-/**
- * 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 @@
   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 */

Modified: gnunet/src/util/test_common_logging_runtime_loglevels.c
===================================================================
--- gnunet/src/util/test_common_logging_runtime_loglevels.c     2012-06-13 
14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_common_logging_runtime_loglevels.c     2012-06-13 
15:18:35 UTC (rev 21972)
@@ -351,34 +351,16 @@
   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 */

Modified: gnunet/src/util/test_connection.c
===================================================================
--- gnunet/src/util/test_connection.c   2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_connection.c   2012-06-13 15:18:35 UTC (rev 21972)
@@ -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 @@
 {
   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 @@
   }
   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 @@
 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 @@
   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 @@
   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 */

Modified: gnunet/src/util/test_connection_addressing.c
===================================================================
--- gnunet/src/util/test_connection_addressing.c        2012-06-13 14:37:12 UTC 
(rev 21971)
+++ gnunet/src/util/test_connection_addressing.c        2012-06-13 15:18:35 UTC 
(rev 21972)
@@ -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 @@
 }
 
 
-/**
- * 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 */

Modified: gnunet/src/util/test_connection_receive_cancel.c
===================================================================
--- gnunet/src/util/test_connection_receive_cancel.c    2012-06-13 14:37:12 UTC 
(rev 21971)
+++ gnunet/src/util/test_connection_receive_cancel.c    2012-06-13 15:18:35 UTC 
(rev 21972)
@@ -27,8 +27,6 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 

Modified: gnunet/src/util/test_connection_timeout.c
===================================================================
--- gnunet/src/util/test_connection_timeout.c   2012-06-13 14:37:12 UTC (rev 
21971)
+++ gnunet/src/util/test_connection_timeout.c   2012-06-13 15:18:35 UTC (rev 
21972)
@@ -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 @@
 
   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 @@
 }
 
 
-
-/**
- * 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 @@
   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 */

Modified: gnunet/src/util/test_connection_timeout_no_connect.c
===================================================================
--- gnunet/src/util/test_connection_timeout_no_connect.c        2012-06-13 
14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_connection_timeout_no_connect.c        2012-06-13 
15:18:35 UTC (rev 21972)
@@ -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 @@
 {
   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 @@
 }
 
 
-
-/**
- * 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 @@
   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 */

Modified: gnunet/src/util/test_connection_transmit_cancel.c
===================================================================
--- gnunet/src/util/test_connection_transmit_cancel.c   2012-06-13 14:37:12 UTC 
(rev 21971)
+++ gnunet/src/util/test_connection_transmit_cancel.c   2012-06-13 15:18:35 UTC 
(rev 21972)
@@ -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 @@
 }
 
 
-
-
-/**
- * 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 @@
   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 */

Modified: gnunet/src/util/test_getopt.c
===================================================================
--- gnunet/src/util/test_getopt.c       2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_getopt.c       2012-06-13 15:18:35 UTC (rev 21972)
@@ -26,7 +26,6 @@
 #include "gnunet_configuration_lib.h"
 #include "gnunet_getopt_lib.h"
 
-#define VERBOSE 0
 
 static int
 testMinimal ()
@@ -45,6 +44,7 @@
   return 0;
 }
 
+
 static int
 testVerbose ()
 {
@@ -75,6 +75,7 @@
   return 0;
 }
 
+
 static int
 testVersion ()
 {
@@ -96,6 +97,7 @@
   return 0;
 }
 
+
 static int
 testAbout ()
 {
@@ -117,6 +119,7 @@
   return 0;
 }
 
+
 static int
 testLogOpts ()
 {
@@ -153,6 +156,7 @@
   return 0;
 }
 
+
 static int
 testFlagNum ()
 {
@@ -190,6 +194,7 @@
   return 0;
 }
 
+
 int
 main (int argc, char *argv[])
 {

Modified: gnunet/src/util/test_os_network.c
===================================================================
--- gnunet/src/util/test_os_network.c   2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_os_network.c   2012-06-13 15:18:35 UTC (rev 21972)
@@ -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 @@
 {
   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 @@
   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 */

Modified: gnunet/src/util/test_os_priority.c
===================================================================
--- gnunet/src/util/test_os_priority.c  2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_os_priority.c  2012-06-13 15:18:35 UTC (rev 21972)
@@ -25,7 +25,6 @@
 #include "gnunet_common.h"
 #include "gnunet_os_lib.h"
 
-#define VERBOSE 0
 
 static int
 testprio ()

Modified: gnunet/src/util/test_os_start_process.c
===================================================================
--- gnunet/src/util/test_os_start_process.c     2012-06-13 14:37:12 UTC (rev 
21971)
+++ gnunet/src/util/test_os_start_process.c     2012-06-13 15:18:35 UTC (rev 
21972)
@@ -33,21 +33,26 @@
 #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 @@
   GNUNET_DISK_pipe_close (hello_pipe_stdin);
 }
 
+
 static void
 read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -73,9 +79,7 @@
 
   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 @@
   }
 
   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 @@
   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 @@
   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 */

Modified: gnunet/src/util/test_peer.c
===================================================================
--- gnunet/src/util/test_peer.c 2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_peer.c 2012-06-13 15:18:35 UTC (rev 21972)
@@ -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 @@
   {
     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 @@
 int
 main ()
 {
-  int i;
+  unsigned int i;
 
   GNUNET_log_setup ("test-peer", "ERROR", NULL);
   for (i = 0; i < 1; i++)

Modified: gnunet/src/util/test_plugin.c
===================================================================
--- gnunet/src/util/test_plugin.c       2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_plugin.c       2012-06-13 15:18:35 UTC (rev 21972)
@@ -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 @@
 }
 
 
-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 @@
   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 @@
   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 */

Modified: gnunet/src/util/test_scheduler.c
===================================================================
--- gnunet/src/util/test_scheduler.c    2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_scheduler.c    2012-06-13 15:18:35 UTC (rev 21972)
@@ -27,8 +27,12 @@
 #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,10 +55,7 @@
   (*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 @@
   GNUNET_assert (0);
 }
 
+
 static void
 taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -84,6 +86,7 @@
   (*ok) = 0;
 }
 
+
 static void
 taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -132,7 +135,6 @@
 }
 
 
-
 /**
  * Main method, starts scheduler with task1,
  * checks that "ok" is correct at the end.
@@ -229,7 +231,6 @@
 }
 
 
-
 int
 main (int argc, char *argv[])
 {

Modified: gnunet/src/util/test_scheduler_delay.c
===================================================================
--- gnunet/src/util/test_scheduler_delay.c      2012-06-13 14:37:12 UTC (rev 
21971)
+++ gnunet/src/util/test_scheduler_delay.c      2012-06-13 15:18:35 UTC (rev 
21972)
@@ -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 @@
   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 @@
   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 */

Modified: gnunet/src/util/test_server.c
===================================================================
--- gnunet/src/util/test_server.c       2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_server.c       2012-06-13 15:18:35 UTC (rev 21972)
@@ -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)

Modified: gnunet/src/util/test_server_disconnect.c
===================================================================
--- gnunet/src/util/test_server_disconnect.c    2012-06-13 14:37:12 UTC (rev 
21971)
+++ gnunet/src/util/test_server_disconnect.c    2012-06-13 15:18:35 UTC (rev 
21972)
@@ -28,7 +28,6 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
 
 #define PORT 12435
 

Modified: gnunet/src/util/test_server_with_client.c
===================================================================
--- gnunet/src/util/test_server_with_client.c   2012-06-13 14:37:12 UTC (rev 
21971)
+++ gnunet/src/util/test_server_with_client.c   2012-06-13 15:18:35 UTC (rev 
21972)
@@ -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 @@
 }
 
 
-/**
- * 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 */

Modified: gnunet/src/util/test_server_with_client_unix.c
===================================================================
--- gnunet/src/util/test_server_with_client_unix.c      2012-06-13 14:37:12 UTC 
(rev 21971)
+++ gnunet/src/util/test_server_with_client_unix.c      2012-06-13 15:18:35 UTC 
(rev 21972)
@@ -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 int ok;
 
+
 static void
 send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -150,7 +149,6 @@
   un.sun_path[0] = '\0';
 #endif
 
-
   sap[0] = (struct sockaddr *) &un;
   slens[0] = sizeof (un);
   sap[1] = NULL;
@@ -178,35 +176,15 @@
 }
 
 
-/**
- * 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 */

Modified: gnunet/src/util/test_service.c
===================================================================
--- gnunet/src/util/test_service.c      2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_service.c      2012-06-13 15:18:35 UTC (rev 21972)
@@ -31,8 +31,6 @@
 #include "gnunet_time_lib.h"
 
 
-#define VERBOSE GNUNET_NO
-
 #define PORT 12435
 
 #define MY_TYPE 256
@@ -148,17 +146,11 @@
     "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 @@
     "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 @@
     "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 @@
   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 @@
   struct GNUNET_NETWORK_Handle *s = NULL;
 
   GNUNET_log_setup ("test-service",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
   ret += check ();
   ret += check ();

Modified: gnunet/src/util/test_strings.c
===================================================================
--- gnunet/src/util/test_strings.c      2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_strings.c      2012-06-13 15:18:35 UTC (rev 21972)
@@ -25,13 +25,12 @@
 #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 @@
   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 @@
   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 */

Modified: gnunet/src/util/test_time.c
===================================================================
--- gnunet/src/util/test_time.c 2012-06-13 14:37:12 UTC (rev 21971)
+++ gnunet/src/util/test_time.c 2012-06-13 15:18:35 UTC (rev 21972)
@@ -25,10 +25,9 @@
 #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 @@
   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 @@
   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 */




reply via email to

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