diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-11-10 08:34:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-11-10 08:34:13 +0000 |
commit | c81ee0c9dd540678c332608443ade794437d926f (patch) | |
tree | 84ca67363c5653936dc042f6715f04ab904faf0e /src/util/test_configuration.c | |
parent | 660c6da4fcbca6bd2cb15599dfe3c6d53b890c7f (diff) | |
download | gnunet-c81ee0c9dd540678c332608443ade794437d926f.tar.gz gnunet-c81ee0c9dd540678c332608443ade794437d926f.zip |
code clean up, rolling back mods to test_configuration
Diffstat (limited to 'src/util/test_configuration.c')
-rw-r--r-- | src/util/test_configuration.c | 116 |
1 files changed, 47 insertions, 69 deletions
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index 3cd076f0f..4c7f69a14 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -173,84 +173,62 @@ testConfigFilenames () | |||
173 | int | 173 | int |
174 | main (int argc, char *argv[]) | 174 | main (int argc, char *argv[]) |
175 | { | 175 | { |
176 | // int failureCount = 0; | 176 | int failureCount = 0; |
177 | // char *c; | 177 | char *c; |
178 | 178 | ||
179 | // GNUNET_log_setup ("test_configuration", "WARNING", NULL); | 179 | GNUNET_log_setup ("test_configuration", "WARNING", NULL); |
180 | // cfg = GNUNET_CONFIGURATION_create (); | 180 | cfg = GNUNET_CONFIGURATION_create (); |
181 | // GNUNET_assert (cfg != NULL); | 181 | GNUNET_assert (cfg != NULL); |
182 | // if (GNUNET_OK != | ||
183 | // GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf")) | ||
184 | // { | ||
185 | // fprintf (stderr, "Failed to parse configuration file\n"); | ||
186 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
187 | // return 1; | ||
188 | // } | ||
189 | // failureCount += testConfig (); | ||
190 | // failureCount += 2 * testConfigFilenames (); | ||
191 | // | ||
192 | // if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf")) | ||
193 | // { | ||
194 | // fprintf (stderr, "Failed to write configuration file\n"); | ||
195 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
196 | // return 1; | ||
197 | // } | ||
198 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
199 | // GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf")); | ||
200 | // | ||
201 | // cfg = GNUNET_CONFIGURATION_create (); | ||
202 | // if (GNUNET_OK != | ||
203 | // GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf")) | ||
204 | // { | ||
205 | // GNUNET_break (0); | ||
206 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
207 | // return 1; | ||
208 | // } | ||
209 | // if ((GNUNET_OK != | ||
210 | // GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", | ||
211 | // &c)) | ||
212 | // || (0 != strcmp (c, "YES"))) | ||
213 | // { | ||
214 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
215 | // return 1; | ||
216 | // } | ||
217 | // GNUNET_free (c); | ||
218 | // if ((GNUNET_OK != | ||
219 | // GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", | ||
220 | // &c)) | ||
221 | // || (0 != strcmp (c, "/var/lib/gnunet/"))) | ||
222 | // { | ||
223 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
224 | // return 1; | ||
225 | // } | ||
226 | // GNUNET_free (c); | ||
227 | // GNUNET_CONFIGURATION_destroy (cfg); | ||
228 | // if (failureCount != 0) | ||
229 | // { | ||
230 | // fprintf (stderr, "Test failed: %u\n", failureCount); | ||
231 | // return 1; | ||
232 | // } | ||
233 | // | ||
234 | struct GNUNET_CONFIGURATION_Handle *cfgDefault = | ||
235 | GNUNET_CONFIGURATION_create (); | ||
236 | struct GNUNET_CONFIGURATION_Handle *cfgNew = GNUNET_CONFIGURATION_create (); | ||
237 | if (GNUNET_OK != | 182 | if (GNUNET_OK != |
238 | GNUNET_CONFIGURATION_parse (cfgDefault, | 183 | GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf")) |
239 | "src/util/test_configuration_data.conf")) | ||
240 | { | 184 | { |
241 | fprintf (stderr, "Failed to parse configuration file\n"); | 185 | fprintf (stderr, "Failed to parse configuration file\n"); |
242 | GNUNET_CONFIGURATION_destroy (cfgDefault); | 186 | GNUNET_CONFIGURATION_destroy (cfg); |
243 | return 1; | 187 | return 1; |
244 | } | 188 | } |
245 | if (GNUNET_OK != | 189 | failureCount += testConfig (); |
246 | GNUNET_CONFIGURATION_parse (cfgNew, | 190 | failureCount += 2 * testConfigFilenames (); |
247 | "/Users/soufi/Desktop/test_configuration_data.conf")) | 191 | |
192 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, "/tmp/gnunet-test.conf")) | ||
248 | { | 193 | { |
249 | fprintf (stderr, "Failed to parse configuration file\n"); | 194 | fprintf (stderr, "Failed to write configuration file\n"); |
250 | GNUNET_CONFIGURATION_destroy (cfgNew); | 195 | GNUNET_CONFIGURATION_destroy (cfg); |
251 | return 1; | 196 | return 1; |
252 | } | 197 | } |
198 | GNUNET_CONFIGURATION_destroy (cfg); | ||
199 | GNUNET_assert (0 == UNLINK ("/tmp/gnunet-test.conf")); | ||
253 | 200 | ||
254 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfgNew, "/tmp/safey.conf"); | 201 | cfg = GNUNET_CONFIGURATION_create (); |
202 | if (GNUNET_OK != | ||
203 | GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf")) | ||
204 | { | ||
205 | GNUNET_break (0); | ||
206 | GNUNET_CONFIGURATION_destroy (cfg); | ||
207 | return 1; | ||
208 | } | ||
209 | if ((GNUNET_OK != | ||
210 | GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", | ||
211 | &c)) | ||
212 | || (0 != strcmp (c, "YES"))) | ||
213 | { | ||
214 | GNUNET_CONFIGURATION_destroy (cfg); | ||
215 | return 1; | ||
216 | } | ||
217 | GNUNET_free (c); | ||
218 | if ((GNUNET_OK != | ||
219 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", | ||
220 | &c)) | ||
221 | || (0 != strcmp (c, "/var/lib/gnunet/"))) | ||
222 | { | ||
223 | GNUNET_CONFIGURATION_destroy (cfg); | ||
224 | return 1; | ||
225 | } | ||
226 | GNUNET_free (c); | ||
227 | GNUNET_CONFIGURATION_destroy (cfg); | ||
228 | if (failureCount != 0) | ||
229 | { | ||
230 | fprintf (stderr, "Test failed: %u\n", failureCount); | ||
231 | return 1; | ||
232 | } | ||
255 | return 0; | 233 | return 0; |
256 | } | 234 | } |