aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2014-06-04 16:57:26 +0000
committerFlorian Dold <florian.dold@gmail.com>2014-06-04 16:57:26 +0000
commitd00e1d68624dc1576284a0a4fbc15a6140401960 (patch)
tree0363e2943f41c3884b4bbd204763581cb023d2fd /src/set
parent4a24e01d19cdad1e6c1bcd72b1919e18c90e0ba0 (diff)
downloadgnunet-d00e1d68624dc1576284a0a4fbc15a6140401960.tar.gz
gnunet-d00e1d68624dc1576284a0a4fbc15a6140401960.zip
timeout for set tests
Diffstat (limited to 'src/set')
-rw-r--r--src/set/test_set_api.c42
-rw-r--r--src/set/test_set_union_result_full.c31
2 files changed, 67 insertions, 6 deletions
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c
index d2a0262c8..5bbbded5d 100644
--- a/src/set/test_set_api.c
+++ b/src/set/test_set_api.c
@@ -38,6 +38,8 @@ const static struct GNUNET_CONFIGURATION_Handle *config;
38 38
39static int iter_count; 39static int iter_count;
40 40
41static int ret;
42
41 43
42static void 44static void
43result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element, 45result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
@@ -50,10 +52,15 @@ result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
50 break; 52 break;
51 case GNUNET_SET_STATUS_FAILURE: 53 case GNUNET_SET_STATUS_FAILURE:
52 printf ("set 1: failure\n"); 54 printf ("set 1: failure\n");
55 ret = 1;
56 GNUNET_SCHEDULER_shutdown ();
53 break; 57 break;
54 case GNUNET_SET_STATUS_DONE: 58 case GNUNET_SET_STATUS_DONE:
55 printf ("set 1: done\n"); 59 printf ("set 1: done\n");
56 GNUNET_SET_destroy (set1); 60 GNUNET_SET_destroy (set1);
61 set1 = NULL;
62 if (NULL == set2)
63 GNUNET_SCHEDULER_shutdown ();
57 break; 64 break;
58 default: 65 default:
59 GNUNET_assert (0); 66 GNUNET_assert (0);
@@ -72,10 +79,14 @@ result_cb_set2 (void *cls, const struct GNUNET_SET_Element *element,
72 break; 79 break;
73 case GNUNET_SET_STATUS_FAILURE: 80 case GNUNET_SET_STATUS_FAILURE:
74 printf ("set 2: failure\n"); 81 printf ("set 2: failure\n");
82 ret = 1;
75 break; 83 break;
76 case GNUNET_SET_STATUS_DONE: 84 case GNUNET_SET_STATUS_DONE:
77 printf ("set 2: done\n"); 85 printf ("set 2: done\n");
78 GNUNET_SET_destroy (set2); 86 GNUNET_SET_destroy (set2);
87 set2 = NULL;
88 if (NULL == set1)
89 GNUNET_SCHEDULER_shutdown ();
79 break; 90 break;
80 default: 91 default:
81 GNUNET_assert (0); 92 GNUNET_assert (0);
@@ -214,6 +225,23 @@ test_iter ()
214 225
215 226
216/** 227/**
228 * Signature of the main function of a task.
229 *
230 * @param cls closure
231 * @param tc context information (why was this task triggered now)
232 */
233static void
234timeout_fail (void *cls,
235 const struct GNUNET_SCHEDULER_TaskContext *tc)
236{
237 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
238 return;
239 GNUNET_SCHEDULER_shutdown ();
240 ret = 1;
241}
242
243
244/**
217 * Signature of the 'main' function for a (single-peer) testcase that 245 * Signature of the 'main' function for a (single-peer) testcase that
218 * is run using 'GNUNET_TESTING_peer_run'. 246 * is run using 'GNUNET_TESTING_peer_run'.
219 * 247 *
@@ -229,6 +257,9 @@ run (void *cls,
229 257
230 struct GNUNET_SET_OperationHandle *my_oh; 258 struct GNUNET_SET_OperationHandle *my_oh;
231 259
260 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
261 &timeout_fail, NULL);
262
232 config = cfg; 263 config = cfg;
233 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id); 264 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id);
234 printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id)); 265 printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id));
@@ -256,11 +287,12 @@ run (void *cls,
256int 287int
257main (int argc, char **argv) 288main (int argc, char **argv)
258{ 289{
259 int ret; 290 if (0 != GNUNET_TESTING_peer_run ("test_set_api",
260 291 "test_set.conf",
261 ret = GNUNET_TESTING_peer_run ("test_set_api", 292 &run, NULL))
262 "test_set.conf", 293 {
263 &run, NULL); 294 return 1;
295 }
264 return ret; 296 return ret;
265} 297}
266 298
diff --git a/src/set/test_set_union_result_full.c b/src/set/test_set_union_result_full.c
index 2ddd65c7c..b84a21f23 100644
--- a/src/set/test_set_union_result_full.c
+++ b/src/set/test_set_union_result_full.c
@@ -53,10 +53,14 @@ result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
53 case GNUNET_SET_STATUS_FAILURE: 53 case GNUNET_SET_STATUS_FAILURE:
54 printf ("set 1: failure\n"); 54 printf ("set 1: failure\n");
55 ret = 1; 55 ret = 1;
56 GNUNET_SCHEDULER_shutdown ();
56 break; 57 break;
57 case GNUNET_SET_STATUS_DONE: 58 case GNUNET_SET_STATUS_DONE:
58 printf ("set 1: done\n"); 59 printf ("set 1: done\n");
59 GNUNET_SET_destroy (set1); 60 GNUNET_SET_destroy (set1);
61 set1 = NULL;
62 if (NULL == set2)
63 GNUNET_SCHEDULER_shutdown ();
60 break; 64 break;
61 default: 65 default:
62 GNUNET_assert (0); 66 GNUNET_assert (0);
@@ -76,10 +80,14 @@ result_cb_set2 (void *cls, const struct GNUNET_SET_Element *element,
76 case GNUNET_SET_STATUS_FAILURE: 80 case GNUNET_SET_STATUS_FAILURE:
77 printf ("set 2: failure\n"); 81 printf ("set 2: failure\n");
78 ret = 1; 82 ret = 1;
83 GNUNET_SCHEDULER_shutdown ();
79 break; 84 break;
80 case GNUNET_SET_STATUS_DONE: 85 case GNUNET_SET_STATUS_DONE:
81 printf ("set 2: done\n"); 86 printf ("set 2: done\n");
82 GNUNET_SET_destroy (set2); 87 GNUNET_SET_destroy (set2);
88 set2 = NULL;
89 if (NULL == set1)
90 GNUNET_SCHEDULER_shutdown ();
83 break; 91 break;
84 default: 92 default:
85 GNUNET_assert (0); 93 GNUNET_assert (0);
@@ -218,6 +226,23 @@ test_iter ()
218 226
219 227
220/** 228/**
229 * Signature of the main function of a task.
230 *
231 * @param cls closure
232 * @param tc context information (why was this task triggered now)
233 */
234static void
235timeout_fail (void *cls,
236 const struct GNUNET_SCHEDULER_TaskContext *tc)
237{
238 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
239 return;
240 GNUNET_SCHEDULER_shutdown ();
241 ret = 1;
242}
243
244
245/**
221 * Signature of the 'main' function for a (single-peer) testcase that 246 * Signature of the 'main' function for a (single-peer) testcase that
222 * is run using 'GNUNET_TESTING_peer_run'. 247 * is run using 'GNUNET_TESTING_peer_run'.
223 * 248 *
@@ -230,6 +255,10 @@ run (void *cls,
230 const struct GNUNET_CONFIGURATION_Handle *cfg, 255 const struct GNUNET_CONFIGURATION_Handle *cfg,
231 struct GNUNET_TESTING_Peer *peer) 256 struct GNUNET_TESTING_Peer *peer)
232{ 257{
258
259 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
260 &timeout_fail, NULL);
261
233 config = cfg; 262 config = cfg;
234 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id); 263 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id);
235 printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id)); 264 printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id));
@@ -253,7 +282,7 @@ main (int argc, char **argv)
253 "test_set.conf", 282 "test_set.conf",
254 &run, NULL)) 283 &run, NULL))
255 { 284 {
256 return 0; 285 return 1;
257 } 286 }
258 return ret; 287 return ret;
259} 288}