diff options
author | Safey A.Halim <safey.allah@gmail.com> | 2009-11-10 08:06:11 +0000 |
---|---|---|
committer | Safey A.Halim <safey.allah@gmail.com> | 2009-11-10 08:06:11 +0000 |
commit | 63aea8612441c32317fbe7ffd238f14a03c614fe (patch) | |
tree | cfaa6d673aa09ef4dd0f705c5a244b51c7b95e5b /src/util/test_configuration.c | |
parent | 37edd6776d34c68b4e84bdc705ea451aac2c71b2 (diff) | |
download | gnunet-63aea8612441c32317fbe7ffd238f14a03c614fe.tar.gz gnunet-63aea8612441c32317fbe7ffd238f14a03c614fe.zip |
Diffstat (limited to 'src/util/test_configuration.c')
-rw-r--r-- | src/util/test_configuration.c | 129 |
1 files changed, 74 insertions, 55 deletions
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index 4c7f69a14..150b8d6b4 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -173,62 +173,81 @@ 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 = GNUNET_CONFIGURATION_create (); | ||
235 | struct GNUNET_CONFIGURATION_Handle* cfgNew = GNUNET_CONFIGURATION_create(); | ||
182 | if (GNUNET_OK != | 236 | if (GNUNET_OK != |
183 | GNUNET_CONFIGURATION_parse (cfg, "test_configuration_data.conf")) | 237 | GNUNET_CONFIGURATION_parse (cfgDefault, "src/util/test_configuration_data.conf")) |
184 | { | 238 | { |
185 | fprintf (stderr, "Failed to parse configuration file\n"); | 239 | fprintf (stderr, "Failed to parse configuration file\n"); |
186 | GNUNET_CONFIGURATION_destroy (cfg); | 240 | GNUNET_CONFIGURATION_destroy (cfgDefault); |
187 | return 1; | 241 | return 1; |
188 | } | 242 | } |
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 != | 243 | if (GNUNET_OK != |
203 | GNUNET_CONFIGURATION_load (cfg, "test_configuration_data.conf")) | 244 | GNUNET_CONFIGURATION_parse (cfgNew, "/Users/soufi/Desktop/test_configuration_data.conf")) |
204 | { | 245 | { |
205 | GNUNET_break (0); | 246 | fprintf (stderr, "Failed to parse configuration file\n"); |
206 | GNUNET_CONFIGURATION_destroy (cfg); | 247 | GNUNET_CONFIGURATION_destroy (cfgNew); |
207 | return 1; | 248 | return 1; |
208 | } | 249 | } |
209 | if ((GNUNET_OK != | 250 | |
210 | GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "WEAKRANDOM", | 251 | GNUNET_CONFIGURATION_write_diffs(cfgDefault, cfgNew, "/tmp/safey.conf"); |
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 | return 0; | 252 | return 0; |
234 | } | 253 | } |