aboutsummaryrefslogtreecommitdiff
path: root/src/set/test_set_api.c
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/test_set_api.c
parent4a24e01d19cdad1e6c1bcd72b1919e18c90e0ba0 (diff)
downloadgnunet-d00e1d68624dc1576284a0a4fbc15a6140401960.tar.gz
gnunet-d00e1d68624dc1576284a0a4fbc15a6140401960.zip
timeout for set tests
Diffstat (limited to 'src/set/test_set_api.c')
-rw-r--r--src/set/test_set_api.c42
1 files changed, 37 insertions, 5 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