aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/fs/test_fs_uri.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
indentation
Diffstat (limited to 'src/fs/test_fs_uri.c')
-rw-r--r--src/fs/test_fs_uri.c308
1 files changed, 162 insertions, 146 deletions
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index 0894b8b938..e8f6ed70f7 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -39,37 +39,37 @@ testKeyword ()
char *emsg;
if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/++", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
ret = GNUNET_FS_uri_parse ("gnunet://fs/ksk/foo+bar", &emsg);
if (ret == NULL)
- {
- GNUNET_free (emsg);
- ABORT ();
- }
+ {
+ GNUNET_free (emsg);
+ ABORT ();
+ }
if (!GNUNET_FS_uri_test_ksk (ret))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
if ((2 != ret->data.ksk.keywordCount) ||
(0 != strcmp (" foo", ret->data.ksk.keywords[0])) ||
(0 != strcmp (" bar", ret->data.ksk.keywords[1])))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
uri = GNUNET_FS_uri_to_string (ret);
if (0 != strcmp (uri, "gnunet://fs/ksk/foo+bar"))
- {
- GNUNET_free (uri);
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_free (uri);
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (uri);
GNUNET_FS_uri_destroy (ret);
return 0;
@@ -86,46 +86,45 @@ testLocation ()
struct GNUNET_CONFIGURATION_Handle *cfg;
baseURI =
- GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", &emsg);
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
+ &emsg);
GNUNET_assert (baseURI != NULL);
GNUNET_assert (emsg == NULL);
cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_parse (cfg, "test_fs_uri_data.conf"))
- {
- fprintf (stderr, "Failed to parse configuration file\n");
- GNUNET_FS_uri_destroy (baseURI);
- GNUNET_CONFIGURATION_destroy (cfg);
- return 1;
- }
- uri = GNUNET_FS_uri_loc_create (baseURI,
- cfg,
- GNUNET_TIME_absolute_get ());
+ if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, "test_fs_uri_data.conf"))
+ {
+ fprintf (stderr, "Failed to parse configuration file\n");
+ GNUNET_FS_uri_destroy (baseURI);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return 1;
+ }
+ uri = GNUNET_FS_uri_loc_create (baseURI, cfg, GNUNET_TIME_absolute_get ());
if (uri == NULL)
- {
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (baseURI);
- GNUNET_CONFIGURATION_destroy (cfg);
- return 1;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (baseURI);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return 1;
+ }
if (!GNUNET_FS_uri_test_loc (uri))
- {
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (uri);
- GNUNET_FS_uri_destroy (baseURI);
- GNUNET_CONFIGURATION_destroy (cfg);
- return 1;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (uri);
+ GNUNET_FS_uri_destroy (baseURI);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return 1;
+ }
uri2 = GNUNET_FS_uri_loc_get_uri (uri);
if (!GNUNET_FS_uri_test_equal (baseURI, uri2))
- {
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (uri);
- GNUNET_FS_uri_destroy (uri2);
- GNUNET_FS_uri_destroy (baseURI);
- GNUNET_CONFIGURATION_destroy (cfg);
- return 1;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (uri);
+ GNUNET_FS_uri_destroy (uri2);
+ GNUNET_FS_uri_destroy (baseURI);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return 1;
+ }
GNUNET_FS_uri_destroy (uri2);
GNUNET_FS_uri_destroy (baseURI);
uric = GNUNET_FS_uri_to_string (uri);
@@ -136,22 +135,22 @@ testLocation ()
uri2 = GNUNET_FS_uri_parse (uric, &emsg);
GNUNET_free (uric);
if (uri2 == NULL)
- {
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (uri);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (emsg);
- return 1;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (uri);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (emsg);
+ return 1;
+ }
GNUNET_assert (NULL == emsg);
if (GNUNET_YES != GNUNET_FS_uri_test_equal (uri, uri2))
- {
- GNUNET_break (0);
- GNUNET_FS_uri_destroy (uri);
- GNUNET_FS_uri_destroy (uri2);
- GNUNET_CONFIGURATION_destroy (cfg);
- return 1;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_FS_uri_destroy (uri);
+ GNUNET_FS_uri_destroy (uri2);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return 1;
+ }
GNUNET_FS_uri_destroy (uri2);
GNUNET_FS_uri_destroy (uri);
GNUNET_CONFIGURATION_destroy (cfg);
@@ -166,51 +165,57 @@ testNamespace (int i)
char *emsg;
if (NULL !=
- (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ (ret =
+ GNUNET_FS_uri_parse ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK",
+ &emsg)))
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
if (NULL !=
- (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ (ret =
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg)))
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
if (NULL != (ret = GNUNET_FS_uri_parse ("gnunet://fs/sks/test", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
ret =
- GNUNET_FS_uri_parse ("gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test", &emsg);
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test",
+ &emsg);
if (ret == NULL)
- {
- GNUNET_free (emsg);
- ABORT ();
- }
+ {
+ GNUNET_free (emsg);
+ ABORT ();
+ }
if (GNUNET_FS_uri_test_ksk (ret))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
if (!GNUNET_FS_uri_test_sks (ret))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
uri = GNUNET_FS_uri_to_string (ret);
if (0 != strcmp (uri,
"gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test"))
- {
- GNUNET_FS_uri_destroy (ret);
- GNUNET_free (uri);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ GNUNET_free (uri);
+ ABORT ();
+ }
GNUNET_free (uri);
GNUNET_FS_uri_destroy (ret);
return 0;
@@ -224,57 +229,68 @@ testFile (int i)
char *emsg;
if (NULL !=
- (ret = GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ (ret =
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42",
+ &emsg)))
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
if (NULL !=
- (ret = GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ (ret =
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000",
+ &emsg)))
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
if (NULL !=
- (ret = GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH", &emsg)))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ (ret =
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH",
+ &emsg)))
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (emsg);
ret =
- GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", &emsg);
+ GNUNET_FS_uri_parse
+ ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
+ &emsg);
if (ret == NULL)
- {
- GNUNET_free (emsg);
- ABORT ();
- }
+ {
+ GNUNET_free (emsg);
+ ABORT ();
+ }
if (GNUNET_FS_uri_test_ksk (ret))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
if (GNUNET_FS_uri_test_sks (ret))
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
if (GNUNET_ntohll (ret->data.chk.file_length) != 42)
- {
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
uri = GNUNET_FS_uri_to_string (ret);
if (0 != strcmp (uri,
"gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
- {
- GNUNET_free (uri);
- GNUNET_FS_uri_destroy (ret);
- ABORT ();
- }
+ {
+ GNUNET_free (uri);
+ GNUNET_FS_uri_destroy (ret);
+ ABORT ();
+ }
GNUNET_free (uri);
GNUNET_FS_uri_destroy (ret);
return 0;
@@ -286,22 +302,22 @@ main (int argc, char *argv[])
int failureCount = 0;
int i;
- GNUNET_log_setup ("test_fs_uri",
+ GNUNET_log_setup ("test_fs_uri",
#if VERBOSE
- "DEBUG",
+ "DEBUG",
#else
- "WARNING",
+ "WARNING",
#endif
- NULL);
+ NULL);
GNUNET_CRYPTO_random_disable_entropy_gathering ();
failureCount += testKeyword ();
failureCount += testLocation ();
for (i = 0; i < 255; i++)
- {
- /* fprintf (stderr, "."); */
- failureCount += testNamespace (i);
- failureCount += testFile (i);
- }
+ {
+ /* fprintf (stderr, "."); */
+ failureCount += testNamespace (i);
+ failureCount += testFile (i);
+ }
/* fprintf (stderr, "\n"); */
GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-uri");
if (failureCount != 0)