diff options
Diffstat (limited to 'src/fs/test_fs_namespace_list_updateable.c')
-rw-r--r-- | src/fs/test_fs_namespace_list_updateable.c | 142 |
1 files changed, 60 insertions, 82 deletions
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index 291ab6d9d..dc8673e21 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c | |||
@@ -59,8 +59,7 @@ struct PeerContext | |||
59 | 59 | ||
60 | 60 | ||
61 | static void * | 61 | static void * |
62 | progress_cb (void *cls, | 62 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) |
63 | const struct GNUNET_FS_ProgressInfo *event) | ||
64 | { | 63 | { |
65 | return NULL; | 64 | return NULL; |
66 | } | 65 | } |
@@ -72,11 +71,11 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
72 | p->cfg = GNUNET_CONFIGURATION_create (); | 71 | p->cfg = GNUNET_CONFIGURATION_create (); |
73 | #if START_ARM | 72 | #if START_ARM |
74 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 73 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
75 | "gnunet-service-arm", | 74 | "gnunet-service-arm", |
76 | #if VERBOSE | 75 | #if VERBOSE |
77 | "-L", "DEBUG", | 76 | "-L", "DEBUG", |
78 | #endif | 77 | #endif |
79 | "-c", cfgname, NULL); | 78 | "-c", cfgname, NULL); |
80 | #endif | 79 | #endif |
81 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 80 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
82 | } | 81 | } |
@@ -87,16 +86,17 @@ stop_arm (struct PeerContext *p) | |||
87 | { | 86 | { |
88 | #if START_ARM | 87 | #if START_ARM |
89 | if (NULL != p->arm_proc) | 88 | if (NULL != p->arm_proc) |
90 | { | 89 | { |
91 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | 90 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) |
92 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 91 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
93 | if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK) | 92 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
94 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 93 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); |
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
96 | "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); | 95 | "ARM process %u stopped\n", |
97 | GNUNET_OS_process_close (p->arm_proc); | 96 | GNUNET_OS_process_get_pid (p->arm_proc)); |
98 | p->arm_proc = NULL; | 97 | GNUNET_OS_process_close (p->arm_proc); |
99 | } | 98 | p->arm_proc = NULL; |
99 | } | ||
100 | #endif | 100 | #endif |
101 | if (uri_this != NULL) | 101 | if (uri_this != NULL) |
102 | GNUNET_FS_uri_destroy (uri_this); | 102 | GNUNET_FS_uri_destroy (uri_this); |
@@ -113,10 +113,10 @@ stop_arm (struct PeerContext *p) | |||
113 | 113 | ||
114 | static void | 114 | static void |
115 | check_next (void *cls, | 115 | check_next (void *cls, |
116 | const char *last_id, | 116 | const char *last_id, |
117 | const struct GNUNET_FS_Uri *last_uri, | 117 | const struct GNUNET_FS_Uri *last_uri, |
118 | const struct GNUNET_CONTAINER_MetaData *last_meta, | 118 | const struct GNUNET_CONTAINER_MetaData *last_meta, |
119 | const char *next_id) | 119 | const char *next_id) |
120 | { | 120 | { |
121 | GNUNET_break (0 == strcmp (last_id, "next")); | 121 | GNUNET_break (0 == strcmp (last_id, "next")); |
122 | GNUNET_break (0 == strcmp (next_id, "future")); | 122 | GNUNET_break (0 == strcmp (next_id, "future")); |
@@ -126,43 +126,35 @@ check_next (void *cls, | |||
126 | 126 | ||
127 | static void | 127 | static void |
128 | check_this_next (void *cls, | 128 | check_this_next (void *cls, |
129 | const char *last_id, | 129 | const char *last_id, |
130 | const struct GNUNET_FS_Uri *last_uri, | 130 | const struct GNUNET_FS_Uri *last_uri, |
131 | const struct GNUNET_CONTAINER_MetaData *last_meta, | 131 | const struct GNUNET_CONTAINER_MetaData *last_meta, |
132 | const char *next_id) | 132 | const char *next_id) |
133 | { | 133 | { |
134 | GNUNET_break (0 == strcmp (last_id, "this")); | 134 | GNUNET_break (0 == strcmp (last_id, "this")); |
135 | GNUNET_break (0 == strcmp (next_id, "next")); | 135 | GNUNET_break (0 == strcmp (next_id, "next")); |
136 | err -= 2; | 136 | err -= 2; |
137 | err += 4; | 137 | err += 4; |
138 | GNUNET_FS_namespace_list_updateable (ns, | 138 | GNUNET_FS_namespace_list_updateable (ns, next_id, &check_next, NULL); |
139 | next_id, | ||
140 | &check_next, | ||
141 | NULL); | ||
142 | } | 139 | } |
143 | 140 | ||
144 | 141 | ||
145 | static void | 142 | static void |
146 | sks_cont_next (void *cls, | 143 | sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) |
147 | const struct GNUNET_FS_Uri *uri, | ||
148 | const char *emsg) | ||
149 | { | 144 | { |
150 | GNUNET_assert (NULL == emsg); | 145 | GNUNET_assert (NULL == emsg); |
151 | err += 2; | 146 | err += 2; |
152 | GNUNET_FS_namespace_list_updateable (ns, | 147 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this_next, NULL); |
153 | NULL, | ||
154 | &check_this_next, | ||
155 | NULL); | ||
156 | 148 | ||
157 | } | 149 | } |
158 | 150 | ||
159 | 151 | ||
160 | static void | 152 | static void |
161 | check_this (void *cls, | 153 | check_this (void *cls, |
162 | const char *last_id, | 154 | const char *last_id, |
163 | const struct GNUNET_FS_Uri *last_uri, | 155 | const struct GNUNET_FS_Uri *last_uri, |
164 | const struct GNUNET_CONTAINER_MetaData *last_meta, | 156 | const struct GNUNET_CONTAINER_MetaData *last_meta, |
165 | const char *next_id) | 157 | const char *next_id) |
166 | { | 158 | { |
167 | GNUNET_break (0 == strcmp (last_id, "this")); | 159 | GNUNET_break (0 == strcmp (last_id, "this")); |
168 | GNUNET_break (0 == strcmp (next_id, "next")); | 160 | GNUNET_break (0 == strcmp (next_id, "next")); |
@@ -171,27 +163,20 @@ check_this (void *cls, | |||
171 | 163 | ||
172 | 164 | ||
173 | static void | 165 | static void |
174 | sks_cont_this (void *cls, | 166 | sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) |
175 | const struct GNUNET_FS_Uri *uri, | ||
176 | const char *emsg) | ||
177 | { | 167 | { |
178 | 168 | ||
179 | GNUNET_assert (NULL == emsg); | 169 | GNUNET_assert (NULL == emsg); |
180 | err = 1; | 170 | err = 1; |
181 | GNUNET_FS_namespace_list_updateable (ns, | 171 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL); |
182 | NULL, | ||
183 | &check_this, | ||
184 | NULL); | ||
185 | GNUNET_FS_publish_sks (fs, | 172 | GNUNET_FS_publish_sks (fs, |
186 | ns, | 173 | ns, |
187 | "next", | 174 | "next", |
188 | "future", | 175 | "future", |
189 | meta, | 176 | meta, |
190 | uri_next, | 177 | uri_next, |
191 | &bo, | 178 | &bo, |
192 | GNUNET_FS_PUBLISH_OPTION_NONE, | 179 | GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL); |
193 | &sks_cont_next, | ||
194 | NULL); | ||
195 | 180 | ||
196 | } | 181 | } |
197 | 182 | ||
@@ -201,45 +186,38 @@ static void | |||
201 | testNamespace () | 186 | testNamespace () |
202 | { | 187 | { |
203 | 188 | ||
204 | ns = GNUNET_FS_namespace_create (fs, | 189 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); |
205 | "testNamespace"); | ||
206 | GNUNET_assert (NULL != ns); | 190 | GNUNET_assert (NULL != ns); |
207 | bo.content_priority = 1; | 191 | bo.content_priority = 1; |
208 | bo.anonymity_level = 1; | 192 | bo.anonymity_level = 1; |
209 | bo.replication_level = 0; | 193 | bo.replication_level = 0; |
210 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | 194 | bo.expiration_time = |
195 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | ||
211 | meta = GNUNET_CONTAINER_meta_data_create (); | 196 | meta = GNUNET_CONTAINER_meta_data_create (); |
212 | 197 | ||
213 | uri_this = | 198 | uri_this = |
214 | GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", NULL); | 199 | GNUNET_FS_uri_parse |
200 | ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", | ||
201 | NULL); | ||
215 | uri_next = | 202 | uri_next = |
216 | GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43", NULL); | 203 | GNUNET_FS_uri_parse |
217 | GNUNET_FS_publish_sks (fs, | 204 | ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43", |
218 | ns, | 205 | NULL); |
219 | "this", | 206 | GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri_this, &bo, |
220 | "next", | 207 | GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL); |
221 | meta, | ||
222 | uri_this, | ||
223 | &bo, | ||
224 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
225 | &sks_cont_this, | ||
226 | NULL); | ||
227 | } | 208 | } |
228 | 209 | ||
229 | 210 | ||
230 | static void | 211 | static void |
231 | run (void *cls, | 212 | run (void *cls, |
232 | char *const *args, | 213 | char *const *args, |
233 | const char *cfgfile, | 214 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
234 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
235 | { | 215 | { |
236 | setup_peer (&p1, "test_fs_namespace_data.conf"); | 216 | setup_peer (&p1, "test_fs_namespace_data.conf"); |
237 | fs = GNUNET_FS_start (cfg, | 217 | fs = GNUNET_FS_start (cfg, |
238 | "test-fs-namespace", | 218 | "test-fs-namespace", |
239 | &progress_cb, | 219 | &progress_cb, |
240 | NULL, | 220 | NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
241 | GNUNET_FS_FLAGS_NONE, | ||
242 | GNUNET_FS_OPTIONS_END); | ||
243 | testNamespace (); | 221 | testNamespace (); |
244 | } | 222 | } |
245 | 223 | ||
@@ -247,7 +225,7 @@ run (void *cls, | |||
247 | int | 225 | int |
248 | main (int argc, char *argv[]) | 226 | main (int argc, char *argv[]) |
249 | { | 227 | { |
250 | char *const argvx[] = { | 228 | char *const argvx[] = { |
251 | "test-fs-namespace", | 229 | "test-fs-namespace", |
252 | "-c", | 230 | "-c", |
253 | "test_fs_namespace_data.conf", | 231 | "test_fs_namespace_data.conf", |
@@ -260,16 +238,16 @@ main (int argc, char *argv[]) | |||
260 | GNUNET_GETOPT_OPTION_END | 238 | GNUNET_GETOPT_OPTION_END |
261 | }; | 239 | }; |
262 | 240 | ||
263 | GNUNET_log_setup ("test_fs_namespace_list_updateable", | 241 | GNUNET_log_setup ("test_fs_namespace_list_updateable", |
264 | #if VERBOSE | 242 | #if VERBOSE |
265 | "DEBUG", | 243 | "DEBUG", |
266 | #else | 244 | #else |
267 | "WARNING", | 245 | "WARNING", |
268 | #endif | 246 | #endif |
269 | NULL); | 247 | NULL); |
270 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 248 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, |
271 | argvx, "test-fs-namespace", | 249 | argvx, "test-fs-namespace", |
272 | "nohelp", options, &run, NULL); | 250 | "nohelp", options, &run, NULL); |
273 | stop_arm (&p1); | 251 | stop_arm (&p1); |
274 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); | 252 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); |
275 | return err; | 253 | return err; |