diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
commit | d9d94d0e53d26af75ec8241383d166544ebd79f3 (patch) | |
tree | 9080b73624389403a198257fe0547bb4634e64d2 /src/util/test_configuration.c | |
parent | 2d792ee2e9cc0c993b8907e2c8edb0c2b8465343 (diff) | |
download | gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.tar.gz gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.zip |
converting to GNUNET_LOG_from*
Diffstat (limited to 'src/util/test_configuration.c')
-rw-r--r-- | src/util/test_configuration.c | 477 |
1 files changed, 241 insertions, 236 deletions
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index f02705f86..1c40f06f6 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -42,7 +42,7 @@ enum | |||
42 | REMOVE_ENTRY, | 42 | REMOVE_ENTRY, |
43 | COMPARE | 43 | COMPARE |
44 | #if DEBUG | 44 | #if DEBUG |
45 | 45 | ||
46 | #endif | 46 | #endif |
47 | }; | 47 | }; |
48 | 48 | ||
@@ -76,80 +76,80 @@ initDiffsCBData (struct DiffsCBData *cbData) | |||
76 | */ | 76 | */ |
77 | static void | 77 | static void |
78 | diffsCallBack (void *cls, const char *section, const char *option, | 78 | diffsCallBack (void *cls, const char *section, const char *option, |
79 | const char *value) | 79 | const char *value) |
80 | { | 80 | { |
81 | struct DiffsCBData *cbData = cls; | 81 | struct DiffsCBData *cbData = cls; |
82 | int cbOption = cbData->callBackOption; | 82 | int cbOption = cbData->callBackOption; |
83 | 83 | ||
84 | switch (cbOption) | 84 | switch (cbOption) |
85 | { | ||
86 | case EDIT_SECTION: | ||
87 | if (NULL == cbData->section) | ||
88 | cbData->section = section; | ||
89 | if (strcmp (cbData->section, section) == 0) | ||
90 | { | 85 | { |
86 | case EDIT_SECTION: | ||
87 | if (NULL == cbData->section) | ||
88 | cbData->section = section; | ||
89 | if (strcmp (cbData->section, section) == 0) | ||
90 | { | ||
91 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | ||
92 | "new-value"); | ||
93 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, | ||
94 | option, "new-value"); | ||
95 | } | ||
96 | break; | ||
97 | case EDIT_ALL: | ||
91 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | 98 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, |
92 | "new-value"); | 99 | "new-value"); |
93 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, | ||
94 | "new-value"); | ||
95 | } | ||
96 | break; | ||
97 | case EDIT_ALL: | ||
98 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, | ||
99 | "new-value"); | ||
100 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, | ||
101 | "new-value"); | ||
102 | break; | ||
103 | case ADD_NEW_ENTRY: | ||
104 | { | ||
105 | static int hit = 0; | ||
106 | |||
107 | if (hit == 0) | ||
108 | { | ||
109 | hit = 1; | ||
110 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, "new-key", | ||
111 | "new-value"); | ||
112 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, | 100 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, |
113 | "new-key", "new-value"); | 101 | option, "new-value"); |
114 | } | 102 | break; |
115 | break; | 103 | case ADD_NEW_ENTRY: |
116 | } | 104 | { |
117 | case COMPARE: | 105 | static int hit = 0; |
118 | { | 106 | |
119 | int ret; | 107 | if (hit == 0) |
120 | char *diffValue; | 108 | { |
121 | 109 | hit = 1; | |
122 | diffValue = NULL; | 110 | GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, |
123 | ret = | 111 | "new-key", "new-value"); |
124 | GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section, | 112 | GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, |
125 | option, &diffValue); | 113 | "new-key", "new-value"); |
126 | if (NULL != diffValue) | 114 | } |
127 | { | 115 | break; |
128 | if (ret == GNUNET_SYSERR || strcmp (diffValue, value) != 0) | 116 | } |
129 | cbData->status = 1; | 117 | case COMPARE: |
130 | } | 118 | { |
131 | else | 119 | int ret; |
132 | cbData->status = 1; | 120 | char *diffValue; |
133 | GNUNET_free_non_null (diffValue); | 121 | |
134 | break; | 122 | diffValue = NULL; |
135 | } | 123 | ret = |
124 | GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section, | ||
125 | option, &diffValue); | ||
126 | if (NULL != diffValue) | ||
127 | { | ||
128 | if (ret == GNUNET_SYSERR || strcmp (diffValue, value) != 0) | ||
129 | cbData->status = 1; | ||
130 | } | ||
131 | else | ||
132 | cbData->status = 1; | ||
133 | GNUNET_free_non_null (diffValue); | ||
134 | break; | ||
135 | } | ||
136 | #if DEBUG | 136 | #if DEBUG |
137 | case PRINT: | 137 | case PRINT: |
138 | if (NULL == cbData->section) | 138 | if (NULL == cbData->section) |
139 | { | 139 | { |
140 | cbData->section = section; | 140 | cbData->section = section; |
141 | printf ("\nSection: %s\n", section); | 141 | printf ("\nSection: %s\n", section); |
142 | } | 142 | } |
143 | else if (strcmp (cbData->section, section) != 0) | 143 | else if (strcmp (cbData->section, section) != 0) |
144 | { | 144 | { |
145 | cbData->section = section; | 145 | cbData->section = section; |
146 | printf ("\nSection: %s\n", section); | 146 | printf ("\nSection: %s\n", section); |
147 | } | 147 | } |
148 | printf ("%s = %s\n", option, value); | 148 | printf ("%s = %s\n", option, value); |
149 | #endif | 149 | #endif |
150 | default: | 150 | default: |
151 | break; | 151 | break; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
@@ -162,40 +162,41 @@ editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option) | |||
162 | diffsCB.cfgDiffs = GNUNET_CONFIGURATION_create (); | 162 | diffsCB.cfgDiffs = GNUNET_CONFIGURATION_create (); |
163 | 163 | ||
164 | switch (option) | 164 | switch (option) |
165 | { | ||
166 | case EDIT_SECTION: | ||
167 | case EDIT_ALL: | ||
168 | case ADD_NEW_ENTRY: | ||
169 | diffsCB.callBackOption = option; | ||
170 | diffsCB.cfg = cfg; | ||
171 | GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &diffsCB); | ||
172 | break; | ||
173 | case EDIT_NOTHING: | ||
174 | /* Do nothing */ | ||
175 | break; | ||
176 | case ADD_NEW_SECTION: | ||
177 | { | ||
178 | int i; | ||
179 | char *key; | ||
180 | |||
181 | for (i = 0; i < 5; i++) | ||
182 | { | 165 | { |
183 | GNUNET_asprintf (&key, "key%d", i); | 166 | case EDIT_SECTION: |
184 | GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key, | 167 | case EDIT_ALL: |
185 | "new-value"); | 168 | case ADD_NEW_ENTRY: |
186 | GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, "new-section", | 169 | diffsCB.callBackOption = option; |
187 | key, "new-value"); | 170 | diffsCB.cfg = cfg; |
188 | GNUNET_free (key); | 171 | GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &diffsCB); |
172 | break; | ||
173 | case EDIT_NOTHING: | ||
174 | /* Do nothing */ | ||
175 | break; | ||
176 | case ADD_NEW_SECTION: | ||
177 | { | ||
178 | int i; | ||
179 | char *key; | ||
180 | |||
181 | for (i = 0; i < 5; i++) | ||
182 | { | ||
183 | GNUNET_asprintf (&key, "key%d", i); | ||
184 | GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key, | ||
185 | "new-value"); | ||
186 | GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, | ||
187 | "new-section", key, | ||
188 | "new-value"); | ||
189 | GNUNET_free (key); | ||
190 | } | ||
191 | break; | ||
192 | } | ||
193 | case REMOVE_SECTION: | ||
194 | break; | ||
195 | case REMOVE_ENTRY: | ||
196 | break; | ||
197 | default: | ||
198 | break; | ||
189 | } | 199 | } |
190 | break; | ||
191 | } | ||
192 | case REMOVE_SECTION: | ||
193 | break; | ||
194 | case REMOVE_ENTRY: | ||
195 | break; | ||
196 | default: | ||
197 | break; | ||
198 | } | ||
199 | 200 | ||
200 | return diffsCB.cfgDiffs; | 201 | return diffsCB.cfgDiffs; |
201 | } | 202 | } |
@@ -220,35 +221,37 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfgDefault, int option) | |||
220 | 221 | ||
221 | /* Modify configuration and save it */ | 222 | /* Modify configuration and save it */ |
222 | cfgDiffs = editConfiguration (cfg, option); | 223 | cfgDiffs = editConfiguration (cfg, option); |
223 | diffsFileName = GNUNET_DISK_mktemp ("gnunet-test-configurations-diffs.conf"); | 224 | diffsFileName = |
225 | GNUNET_DISK_mktemp ("gnunet-test-configurations-diffs.conf"); | ||
224 | if (diffsFileName == NULL) | 226 | if (diffsFileName == NULL) |
225 | { | 227 | { |
226 | GNUNET_break (0); | 228 | GNUNET_break (0); |
227 | GNUNET_CONFIGURATION_destroy (cfg); | 229 | GNUNET_CONFIGURATION_destroy (cfg); |
228 | GNUNET_CONFIGURATION_destroy (cfgDiffs); | 230 | GNUNET_CONFIGURATION_destroy (cfgDiffs); |
229 | return 1; | 231 | return 1; |
230 | } | 232 | } |
231 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, diffsFileName); | 233 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, diffsFileName); |
232 | GNUNET_CONFIGURATION_destroy (cfg); | 234 | GNUNET_CONFIGURATION_destroy (cfg); |
233 | 235 | ||
234 | /* Compare the dumped configuration with modifications done */ | 236 | /* Compare the dumped configuration with modifications done */ |
235 | cfg = GNUNET_CONFIGURATION_create (); | 237 | cfg = GNUNET_CONFIGURATION_create (); |
236 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, diffsFileName)); | 238 | GNUNET_assert (GNUNET_OK == |
239 | GNUNET_CONFIGURATION_parse (cfg, diffsFileName)); | ||
237 | remove (diffsFileName); | 240 | remove (diffsFileName); |
238 | cbData.callBackOption = COMPARE; | 241 | cbData.callBackOption = COMPARE; |
239 | cbData.cfgDiffs = cfgDiffs; | 242 | cbData.cfgDiffs = cfgDiffs; |
240 | GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData); | 243 | GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData); |
241 | if (1 == (ret = cbData.status)) | 244 | if (1 == (ret = cbData.status)) |
242 | { | 245 | { |
243 | fprintf (stderr, | 246 | fprintf (stderr, |
244 | "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n"); | 247 | "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n"); |
245 | goto housekeeping; | 248 | goto housekeeping; |
246 | } | 249 | } |
247 | cbData.cfgDiffs = cfg; | 250 | cbData.cfgDiffs = cfg; |
248 | GNUNET_CONFIGURATION_iterate (cfgDiffs, diffsCallBack, &cbData); | 251 | GNUNET_CONFIGURATION_iterate (cfgDiffs, diffsCallBack, &cbData); |
249 | if ((ret = cbData.status) == 1) | 252 | if ((ret = cbData.status) == 1) |
250 | fprintf (stderr, | 253 | fprintf (stderr, |
251 | "Incorrect Configuration Diffs: Data may be missing in diffs\n"); | 254 | "Incorrect Configuration Diffs: Data may be missing in diffs\n"); |
252 | 255 | ||
253 | housekeeping: | 256 | housekeeping: |
254 | #if DEBUG | 257 | #if DEBUG |
@@ -273,64 +276,65 @@ testConfig () | |||
273 | char *c; | 276 | char *c; |
274 | unsigned long long l; | 277 | unsigned long long l; |
275 | 278 | ||
276 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "test", "b", &c)) | 279 | if (GNUNET_OK != |
280 | GNUNET_CONFIGURATION_get_value_string (cfg, "test", "b", &c)) | ||
277 | return 1; | 281 | return 1; |
278 | if (0 != strcmp ("b", c)) | 282 | if (0 != strcmp ("b", c)) |
279 | { | 283 | { |
280 | fprintf (stderr, "Got `%s'\n", c); | 284 | fprintf (stderr, "Got `%s'\n", c); |
281 | GNUNET_free (c); | 285 | GNUNET_free (c); |
282 | return 2; | 286 | return 2; |
283 | } | 287 | } |
284 | GNUNET_free (c); | 288 | GNUNET_free (c); |
285 | if (GNUNET_OK != | 289 | if (GNUNET_OK != |
286 | GNUNET_CONFIGURATION_get_value_number (cfg, "test", "five", &l)) | 290 | GNUNET_CONFIGURATION_get_value_number (cfg, "test", "five", &l)) |
287 | { | 291 | { |
288 | GNUNET_break (0); | 292 | GNUNET_break (0); |
289 | return 3; | 293 | return 3; |
290 | } | 294 | } |
291 | if (5 != l) | 295 | if (5 != l) |
292 | { | 296 | { |
293 | GNUNET_break (0); | 297 | GNUNET_break (0); |
294 | return 4; | 298 | return 4; |
295 | } | 299 | } |
296 | GNUNET_CONFIGURATION_set_value_string (cfg, "more", "c", "YES"); | 300 | GNUNET_CONFIGURATION_set_value_string (cfg, "more", "c", "YES"); |
297 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "more", "c")) | 301 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "more", "c")) |
298 | { | 302 | { |
299 | GNUNET_break (0); | 303 | GNUNET_break (0); |
300 | return 5; | 304 | return 5; |
301 | } | 305 | } |
302 | GNUNET_CONFIGURATION_set_value_number (cfg, "NUMBERS", "TEN", 10); | 306 | GNUNET_CONFIGURATION_set_value_number (cfg, "NUMBERS", "TEN", 10); |
303 | if (GNUNET_OK != | 307 | if (GNUNET_OK != |
304 | GNUNET_CONFIGURATION_get_value_string (cfg, "NUMBERS", "TEN", &c)) | 308 | GNUNET_CONFIGURATION_get_value_string (cfg, "NUMBERS", "TEN", &c)) |
305 | { | 309 | { |
306 | GNUNET_break (0); | 310 | GNUNET_break (0); |
307 | return 6; | 311 | return 6; |
308 | } | 312 | } |
309 | if (0 != strcmp (c, "10")) | 313 | if (0 != strcmp (c, "10")) |
310 | { | 314 | { |
311 | GNUNET_free (c); | 315 | GNUNET_free (c); |
312 | GNUNET_break (0); | 316 | GNUNET_break (0); |
313 | return 7; | 317 | return 7; |
314 | } | 318 | } |
315 | GNUNET_free (c); | 319 | GNUNET_free (c); |
316 | 320 | ||
317 | if (GNUNET_OK != | 321 | if (GNUNET_OK != |
318 | GNUNET_CONFIGURATION_get_value_filename (cfg, "last", "test", &c)) | 322 | GNUNET_CONFIGURATION_get_value_filename (cfg, "last", "test", &c)) |
319 | { | 323 | { |
320 | GNUNET_break (0); | 324 | GNUNET_break (0); |
321 | return 8; | 325 | return 8; |
322 | } | 326 | } |
323 | #ifndef MINGW | 327 | #ifndef MINGW |
324 | if (0 != strcmp (c, "/hello/world")) | 328 | if (0 != strcmp (c, "/hello/world")) |
325 | #else | 329 | #else |
326 | #define HI "\\hello\\world" | 330 | #define HI "\\hello\\world" |
327 | if (strstr (c, HI) != c + strlen (c) - strlen (HI)) | 331 | if (strstr (c, HI) != c + strlen (c) - strlen (HI)) |
328 | #endif | 332 | #endif |
329 | { | 333 | { |
330 | GNUNET_break (0); | 334 | GNUNET_break (0); |
331 | GNUNET_free (c); | 335 | GNUNET_free (c); |
332 | return 9; | 336 | return 9; |
333 | } | 337 | } |
334 | GNUNET_free (c); | 338 | GNUNET_free (c); |
335 | 339 | ||
336 | return 0; | 340 | return 0; |
@@ -350,10 +354,10 @@ check (void *data, const char *fn) | |||
350 | int *idx = data; | 354 | int *idx = data; |
351 | 355 | ||
352 | if (0 == strcmp (want[*idx], fn)) | 356 | if (0 == strcmp (want[*idx], fn)) |
353 | { | 357 | { |
354 | (*idx)++; | 358 | (*idx)++; |
355 | return GNUNET_OK; | 359 | return GNUNET_OK; |
356 | } | 360 | } |
357 | GNUNET_break (0); | 361 | GNUNET_break (0); |
358 | return GNUNET_SYSERR; | 362 | return GNUNET_SYSERR; |
359 | } | 363 | } |
@@ -366,66 +370,66 @@ testConfigFilenames () | |||
366 | idx = 0; | 370 | idx = 0; |
367 | if (3 != | 371 | if (3 != |
368 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", | 372 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", |
369 | &check, &idx)) | 373 | &check, &idx)) |
370 | { | 374 | { |
371 | GNUNET_break (0); | 375 | GNUNET_break (0); |
372 | return 8; | 376 | return 8; |
373 | } | 377 | } |
374 | if (idx != 3) | 378 | if (idx != 3) |
375 | return 16; | 379 | return 16; |
376 | if (GNUNET_OK != | 380 | if (GNUNET_OK != |
377 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", | 381 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
378 | "/File Name")) | 382 | "/File Name")) |
379 | { | 383 | { |
380 | GNUNET_break (0); | 384 | GNUNET_break (0); |
381 | return 24; | 385 | return 24; |
382 | } | 386 | } |
383 | 387 | ||
384 | if (GNUNET_NO != | 388 | if (GNUNET_NO != |
385 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", | 389 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
386 | "/File Name")) | 390 | "/File Name")) |
387 | { | 391 | { |
388 | GNUNET_break (0); | 392 | GNUNET_break (0); |
389 | return 32; | 393 | return 32; |
390 | } | 394 | } |
391 | if (GNUNET_NO != | 395 | if (GNUNET_NO != |
392 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", | 396 | GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", |
393 | "Stuff")) | 397 | "Stuff")) |
394 | { | 398 | { |
395 | GNUNET_break (0); | 399 | GNUNET_break (0); |
396 | return 40; | 400 | return 40; |
397 | } | 401 | } |
398 | 402 | ||
399 | if (GNUNET_NO != | 403 | if (GNUNET_NO != |
400 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", | 404 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
401 | "/Hello")) | 405 | "/Hello")) |
402 | { | 406 | { |
403 | GNUNET_break (0); | 407 | GNUNET_break (0); |
404 | return 48; | 408 | return 48; |
405 | } | 409 | } |
406 | if (GNUNET_NO != | 410 | if (GNUNET_NO != |
407 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", | 411 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
408 | "/World")) | 412 | "/World")) |
409 | { | 413 | { |
410 | GNUNET_break (0); | 414 | GNUNET_break (0); |
411 | return 56; | 415 | return 56; |
412 | } | 416 | } |
413 | 417 | ||
414 | if (GNUNET_YES != | 418 | if (GNUNET_YES != |
415 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", | 419 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
416 | "/File 1")) | 420 | "/File 1")) |
417 | { | 421 | { |
418 | GNUNET_break (0); | 422 | GNUNET_break (0); |
419 | return 64; | 423 | return 64; |
420 | } | 424 | } |
421 | 425 | ||
422 | if (GNUNET_YES != | 426 | if (GNUNET_YES != |
423 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", | 427 | GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", |
424 | "/File 2")) | 428 | "/File 2")) |
425 | { | 429 | { |
426 | GNUNET_break (0); | 430 | GNUNET_break (0); |
427 | return 72; | 431 | return 72; |
428 | } | 432 | } |
429 | 433 | ||
430 | idx = 0; | 434 | idx = 0; |
431 | want[1] = "/World"; | 435 | want[1] = "/World"; |
@@ -433,16 +437,16 @@ testConfigFilenames () | |||
433 | want[3] = "/File 2"; | 437 | want[3] = "/File 2"; |
434 | if (4 != | 438 | if (4 != |
435 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", | 439 | GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", |
436 | &check, &idx)) | 440 | &check, &idx)) |
437 | { | 441 | { |
438 | GNUNET_break (0); | 442 | GNUNET_break (0); |
439 | return 80; | 443 | return 80; |
440 | } | 444 | } |
441 | if (idx != 4) | 445 | if (idx != 4) |
442 | { | 446 | { |
443 | GNUNET_break (0); | 447 | GNUNET_break (0); |
444 | return 88; | 448 | return 88; |
445 | } | 449 | } |
446 | return 0; | 450 | return 0; |
447 | } | 451 | } |
448 | 452 | ||
@@ -458,11 +462,11 @@ main (int argc, char *argv[]) | |||
458 | GNUNET_assert (cfg != NULL); | 462 | GNUNET_assert (cfg != NULL); |
459 | if (GNUNET_OK != | 463 | if (GNUNET_OK != |
460 | GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf")) | 464 | GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf")) |
461 | { | 465 | { |
462 | fprintf (stderr, "Failed to parse configuration file\n"); | 466 | fprintf (stderr, "Failed to parse configuration file\n"); |
463 | GNUNET_CONFIGURATION_destroy (cfg); | 467 | GNUNET_CONFIGURATION_destroy (cfg); |
464 | return 1; | 468 | return 1; |
465 | } | 469 | } |
466 | failureCount += testConfig (); | 470 | failureCount += testConfig (); |
467 | if (failureCount > 0) | 471 | if (failureCount > 0) |
468 | goto error; | 472 | goto error; |
@@ -472,36 +476,37 @@ main (int argc, char *argv[]) | |||
472 | goto error; | 476 | goto error; |
473 | 477 | ||
474 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf")) | 478 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf")) |
475 | { | 479 | { |
476 | fprintf (stderr, "Failed to write configuration file\n"); | 480 | fprintf (stderr, "Failed to write configuration file\n"); |
477 | GNUNET_CONFIGURATION_destroy (cfg); | 481 | GNUNET_CONFIGURATION_destroy (cfg); |
478 | return 1; | 482 | return 1; |
479 | } | 483 | } |
480 | GNUNET_CONFIGURATION_destroy (cfg); | 484 | GNUNET_CONFIGURATION_destroy (cfg); |
481 | GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf")); | 485 | GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf")); |
482 | 486 | ||
483 | cfg = GNUNET_CONFIGURATION_create (); | 487 | cfg = GNUNET_CONFIGURATION_create (); |
484 | if (GNUNET_OK != | 488 | if (GNUNET_OK != |
485 | GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf")) | 489 | GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf")) |
486 | { | 490 | { |
487 | GNUNET_break (0); | 491 | GNUNET_break (0); |
488 | GNUNET_CONFIGURATION_destroy (cfg); | 492 | GNUNET_CONFIGURATION_destroy (cfg); |
489 | return 1; | 493 | return 1; |
490 | } | 494 | } |
491 | if (GNUNET_OK != | 495 | if (GNUNET_OK != |
492 | GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", &c)) | 496 | GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", |
493 | { | 497 | &c)) |
494 | GNUNET_break (0); | 498 | { |
495 | GNUNET_CONFIGURATION_destroy (cfg); | 499 | GNUNET_break (0); |
496 | return 1; | 500 | GNUNET_CONFIGURATION_destroy (cfg); |
497 | } | 501 | return 1; |
502 | } | ||
498 | if (0 != strcmp (c, "YES")) | 503 | if (0 != strcmp (c, "YES")) |
499 | { | 504 | { |
500 | GNUNET_break (0); | 505 | GNUNET_break (0); |
501 | GNUNET_free (c); | 506 | GNUNET_free (c); |
502 | GNUNET_CONFIGURATION_destroy (cfg); | 507 | GNUNET_CONFIGURATION_destroy (cfg); |
503 | return 1; | 508 | return 1; |
504 | } | 509 | } |
505 | 510 | ||
506 | GNUNET_free (c); | 511 | GNUNET_free (c); |
507 | GNUNET_CONFIGURATION_destroy (cfg); | 512 | GNUNET_CONFIGURATION_destroy (cfg); |
@@ -509,11 +514,11 @@ main (int argc, char *argv[]) | |||
509 | /* Testing configuration diffs */ | 514 | /* Testing configuration diffs */ |
510 | cfgDefault = GNUNET_CONFIGURATION_create (); | 515 | cfgDefault = GNUNET_CONFIGURATION_create (); |
511 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfgDefault, NULL)) | 516 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfgDefault, NULL)) |
512 | { | 517 | { |
513 | GNUNET_break (0); | 518 | GNUNET_break (0); |
514 | GNUNET_CONFIGURATION_destroy (cfgDefault); | 519 | GNUNET_CONFIGURATION_destroy (cfgDefault); |
515 | return 1; | 520 | return 1; |
516 | } | 521 | } |
517 | 522 | ||
518 | /* Nothing changed in the new configuration */ | 523 | /* Nothing changed in the new configuration */ |
519 | failureCount += checkDiffs (cfgDefault, EDIT_NOTHING); | 524 | failureCount += checkDiffs (cfgDefault, EDIT_NOTHING); |
@@ -534,9 +539,9 @@ main (int argc, char *argv[]) | |||
534 | 539 | ||
535 | error: | 540 | error: |
536 | if (failureCount != 0) | 541 | if (failureCount != 0) |
537 | { | 542 | { |
538 | fprintf (stderr, "Test failed: %u\n", failureCount); | 543 | fprintf (stderr, "Test failed: %u\n", failureCount); |
539 | return 1; | 544 | return 1; |
540 | } | 545 | } |
541 | return 0; | 546 | return 0; |
542 | } | 547 | } |