gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33524 - gnunet/src/set


From: gnunet
Subject: [GNUnet-SVN] r33524 - gnunet/src/set
Date: Wed, 4 Jun 2014 18:57:26 +0200

Author: dold
Date: 2014-06-04 18:57:26 +0200 (Wed, 04 Jun 2014)
New Revision: 33524

Modified:
   gnunet/src/set/test_set_api.c
   gnunet/src/set/test_set_union_result_full.c
Log:
timeout for set tests

Modified: gnunet/src/set/test_set_api.c
===================================================================
--- gnunet/src/set/test_set_api.c       2014-06-04 16:51:45 UTC (rev 33523)
+++ gnunet/src/set/test_set_api.c       2014-06-04 16:57:26 UTC (rev 33524)
@@ -38,7 +38,9 @@
 
 static int iter_count;
 
+static int ret;
 
+
 static void
 result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
                 enum GNUNET_SET_Status status)
@@ -50,10 +52,15 @@
       break;
     case GNUNET_SET_STATUS_FAILURE:
       printf ("set 1: failure\n");
+      ret = 1;
+      GNUNET_SCHEDULER_shutdown ();
       break;
     case GNUNET_SET_STATUS_DONE:
       printf ("set 1: done\n");
       GNUNET_SET_destroy (set1);
+      set1 = NULL;
+      if (NULL == set2)
+        GNUNET_SCHEDULER_shutdown ();
       break;
     default:
       GNUNET_assert (0);
@@ -72,10 +79,14 @@
       break;
     case GNUNET_SET_STATUS_FAILURE:
       printf ("set 2: failure\n");
+      ret = 1;
       break;
     case GNUNET_SET_STATUS_DONE:
       printf ("set 2: done\n");
       GNUNET_SET_destroy (set2);
+      set2 = NULL;
+      if (NULL == set1)
+        GNUNET_SCHEDULER_shutdown ();
       break;
     default:
       GNUNET_assert (0);
@@ -214,6 +225,23 @@
 
 
 /**
+ * Signature of the main function of a task.
+ *
+ * @param cls closure
+ * @param tc context information (why was this task triggered now)
+ */
+static void
+timeout_fail (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+  GNUNET_SCHEDULER_shutdown ();
+  ret = 1;
+}
+
+
+/**
  * Signature of the 'main' function for a (single-peer) testcase that
  * is run using 'GNUNET_TESTING_peer_run'.
  *
@@ -229,6 +257,9 @@
 
   struct GNUNET_SET_OperationHandle *my_oh;
 
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5),
+                                &timeout_fail, NULL);
+
   config = cfg;
   GNUNET_CRYPTO_get_peer_identity (cfg, &local_id);
   printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id));
@@ -256,11 +287,12 @@
 int
 main (int argc, char **argv)
 {
-  int ret;
-
-  ret = GNUNET_TESTING_peer_run ("test_set_api",
-                                 "test_set.conf",
-                                 &run, NULL);
+  if (0 != GNUNET_TESTING_peer_run ("test_set_api",
+                                    "test_set.conf",
+                                    &run, NULL))
+  {
+    return 1;
+  }
   return ret;
 }
 

Modified: gnunet/src/set/test_set_union_result_full.c
===================================================================
--- gnunet/src/set/test_set_union_result_full.c 2014-06-04 16:51:45 UTC (rev 
33523)
+++ gnunet/src/set/test_set_union_result_full.c 2014-06-04 16:57:26 UTC (rev 
33524)
@@ -53,10 +53,14 @@
     case GNUNET_SET_STATUS_FAILURE:
       printf ("set 1: failure\n");
       ret = 1;
+      GNUNET_SCHEDULER_shutdown ();
       break;
     case GNUNET_SET_STATUS_DONE:
       printf ("set 1: done\n");
       GNUNET_SET_destroy (set1);
+      set1 = NULL;
+      if (NULL == set2)
+        GNUNET_SCHEDULER_shutdown ();
       break;
     default:
       GNUNET_assert (0);
@@ -76,10 +80,14 @@
     case GNUNET_SET_STATUS_FAILURE:
       printf ("set 2: failure\n");
       ret = 1;
+      GNUNET_SCHEDULER_shutdown ();
       break;
     case GNUNET_SET_STATUS_DONE:
       printf ("set 2: done\n");
       GNUNET_SET_destroy (set2);
+      set2 = NULL;
+      if (NULL == set1)
+        GNUNET_SCHEDULER_shutdown ();
       break;
     default:
       GNUNET_assert (0);
@@ -218,6 +226,23 @@
 
 
 /**
+ * Signature of the main function of a task.
+ *
+ * @param cls closure
+ * @param tc context information (why was this task triggered now)
+ */
+static void
+timeout_fail (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+  GNUNET_SCHEDULER_shutdown ();
+  ret = 1;
+}
+
+
+/**
  * Signature of the 'main' function for a (single-peer) testcase that
  * is run using 'GNUNET_TESTING_peer_run'.
  *
@@ -230,6 +255,10 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
+
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5),
+                                &timeout_fail, NULL);
+
   config = cfg;
   GNUNET_CRYPTO_get_peer_identity (cfg, &local_id);
   printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id));
@@ -253,7 +282,7 @@
                                     "test_set.conf",
                                     &run, NULL))
   {
-    return 0;
+    return 1;
   }
   return ret;
 }




reply via email to

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