aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_scheduler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_scheduler.c')
-rw-r--r--src/util/test_scheduler.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index a246d75c5..55d4c7137 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -25,7 +25,7 @@
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26 26
27 27
28struct GNUNET_DISK_PipeHandle *p; 28static struct GNUNET_DISK_PipeHandle *p;
29 29
30static const struct GNUNET_DISK_FileHandle *fds[2]; 30static const struct GNUNET_DISK_FileHandle *fds[2];
31 31
@@ -80,7 +80,6 @@ taskLast (void *cls)
80{ 80{
81 int *ok = cls; 81 int *ok = cls;
82 82
83 /* t4 should be ready (albeit with lower priority) */
84 GNUNET_assert (8 == *ok); 83 GNUNET_assert (8 == *ok);
85 (*ok) = 0; 84 (*ok) = 0;
86} 85}
@@ -98,8 +97,8 @@ taskRd (void *cls)
98 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); 97 GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0]));
99 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); 98 GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1));
100 (*ok) = 8; 99 (*ok) = 8;
101 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &taskLast, 100 GNUNET_SCHEDULER_add_shutdown (&taskLast,
102 cls); 101 cls);
103 GNUNET_SCHEDULER_shutdown (); 102 GNUNET_SCHEDULER_shutdown ();
104} 103}
105 104
@@ -115,10 +114,14 @@ task4 (void *cls)
115 GNUNET_assert (NULL != p); 114 GNUNET_assert (NULL != p);
116 fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); 115 fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ);
117 fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); 116 fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE);
118 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, 117 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
118 fds[0],
119 &taskRd,
119 cls); 120 cls);
120 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[1], 121 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
121 &taskWrt, cls); 122 fds[1],
123 &taskWrt,
124 cls);
122} 125}
123 126
124 127
@@ -130,9 +133,12 @@ task1 (void *cls)
130 GNUNET_assert (1 == *ok); 133 GNUNET_assert (1 == *ok);
131 (*ok) = 2; 134 (*ok) = 2;
132 GNUNET_SCHEDULER_add_now (&task3, cls); 135 GNUNET_SCHEDULER_add_now (&task3, cls);
133 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task2, 136 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI,
137 &task2,
134 cls); 138 cls);
135 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &task4, cls); 139 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
140 &task4,
141 cls);
136} 142}
137 143
138 144
@@ -158,7 +164,7 @@ taskShutdown (void *cls)
158 164
159 GNUNET_assert (1 == *ok); 165 GNUNET_assert (1 == *ok);
160 *ok = 8; 166 *ok = 8;
161 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); 167 GNUNET_SCHEDULER_add_shutdown (&taskLast, cls);
162 GNUNET_SCHEDULER_shutdown (); 168 GNUNET_SCHEDULER_shutdown ();
163} 169}
164 170
@@ -186,8 +192,9 @@ taskSig (void *cls)
186 192
187 GNUNET_assert (1 == *ok); 193 GNUNET_assert (1 == *ok);
188 *ok = 8; 194 *ok = 8;
189 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); 195 GNUNET_SCHEDULER_add_shutdown (&taskLast, cls);
190 GNUNET_break (0 == PLIBC_KILL (getpid (), GNUNET_TERM_SIG)); 196 GNUNET_break (0 == PLIBC_KILL (getpid (),
197 GNUNET_TERM_SIG));
191} 198}
192 199
193 200
@@ -214,8 +221,7 @@ taskCancel (void *cls)
214 221
215 GNUNET_assert (1 == *ok); 222 GNUNET_assert (1 == *ok);
216 *ok = 0; 223 *ok = 0;
217 GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now 224 GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now (&taskNeverRun, NULL));
218 (&taskNeverRun, NULL));
219} 225}
220 226
221 227