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