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