aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-08-21 08:41:21 +0000
committerChristian Grothoff <christian@grothoff.org>2009-08-21 08:41:21 +0000
commit9a10e9c06a3b08c8ab73edb7d2093a6d452ecc05 (patch)
treed9ee186c9f61fdc90f128cf39ed113112b21e8ec /src/fs/test_fs_uri.c
parentab1934147f74c835b525864b770795f858e37b89 (diff)
downloadgnunet-9a10e9c06a3b08c8ab73edb7d2093a6d452ecc05.tar.gz
gnunet-9a10e9c06a3b08c8ab73edb7d2093a6d452ecc05.zip
fixes
Diffstat (limited to 'src/fs/test_fs_uri.c')
-rw-r--r--src/fs/test_fs_uri.c170
1 files changed, 87 insertions, 83 deletions
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index f07ba4179..6da56a742 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2003, 2004, 2006, 2007 Christian Grothoff (and other contributing authors) 3 (C) 2003, 2004, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -35,104 +35,110 @@ static int
35testKeyword () 35testKeyword ()
36{ 36{
37 char *uri; 37 char *uri;
38 struct GNUNET_ECRS_URI *ret; 38 struct GNUNET_FS_Uri *ret;
39 char *emsg;
39 40
40 if (NULL != GNUNET_ECRS_string_to_uri (NULL, "gnunet://ecrs/ksk/++")) 41 if (NULL != GNUNET_FS_uri_parse ("gnunet://ecrs/ksk/++", &emsg))
41 ABORT (); 42 ABORT ();
42 ret = GNUNET_ECRS_string_to_uri (NULL, "gnunet://ecrs/ksk/foo+bar"); 43 GNUNET_free (emsg);
44 ret = GNUNET_FS_uri_parse ("gnunet://ecrs/ksk/foo+bar", &emsg);
43 if (ret == NULL) 45 if (ret == NULL)
44 ABORT (); 46 ABORT ();
45 if (!GNUNET_ECRS_uri_test_ksk (ret)) 47 if (!GNUNET_FS_uri_test_ksk (ret))
46 { 48 {
47 GNUNET_ECRS_uri_destroy (ret); 49 GNUNET_FS_uri_destroy (ret);
48 ABORT (); 50 ABORT ();
49 } 51 }
50 if ((2 != ret->data.ksk.keywordCount) || 52 if ((2 != ret->data.ksk.keywordCount) ||
51 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) || 53 (0 != strcmp (" foo", ret->data.ksk.keywords[0])) ||
52 (0 != strcmp (" bar", ret->data.ksk.keywords[1]))) 54 (0 != strcmp (" bar", ret->data.ksk.keywords[1])))
53 { 55 {
54 GNUNET_ECRS_uri_destroy (ret); 56 GNUNET_FS_uri_destroy (ret);
55 ABORT (); 57 ABORT ();
56 } 58 }
57 59
58 uri = GNUNET_ECRS_uri_to_string (ret); 60 uri = GNUNET_FS_uri_to_string (ret);
59 if (0 != strcmp (uri, "gnunet://ecrs/ksk/foo+bar")) 61 if (0 != strcmp (uri, "gnunet://ecrs/ksk/foo+bar"))
60 { 62 {
61 GNUNET_free (uri); 63 GNUNET_free (uri);
62 GNUNET_ECRS_uri_destroy (ret); 64 GNUNET_FS_uri_destroy (ret);
63 ABORT (); 65 ABORT ();
64 } 66 }
65 GNUNET_free (uri); 67 GNUNET_free (uri);
66 GNUNET_ECRS_uri_destroy (ret); 68 GNUNET_FS_uri_destroy (ret);
67 return 0; 69 return 0;
68} 70}
69 71
70static int 72static int
71testLocation () 73testLocation ()
72{ 74{
73 struct GNUNET_ECRS_URI *uri; 75 struct GNUNET_FS_Uri *uri;
74 char *uric; 76 char *uric;
75 struct GNUNET_ECRS_URI *uri2; 77 struct GNUNET_FS_Uri *uri2;
76 GNUNET_RSA_PublicKey pk; 78 struct GNUNET_FS_Uri *baseURI;
77 struct GNUNET_RSA_PrivateKey *hk; 79 char *emsg;
78 struct GNUNET_ECRS_URI *baseURI; 80 struct GNUNET_CONFIGURATION_Handle *cfg;
79 81
80 baseURI = 82 baseURI =
81 GNUNET_ECRS_string_to_uri (NULL, 83 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", &emsg);
82 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"); 84 GNUNET_assert (baseURI != NULL);
83 hk = GNUNET_RSA_create_key (); 85 cfg = GNUNET_CONFIGURATION_create ();
84 GNUNET_RSA_get_public_key (hk, &pk); 86 if (GNUNET_OK !=
85 uri = GNUNET_ECRS_location_to_uri (baseURI, 87 GNUNET_CONFIGURATION_parse (cfg, "test_fs_uri_data.conf"))
86 &pk, 43, 88 {
87 (GNUNET_ECRS_SignFunction) & 89 fprintf (stderr, "Failed to parse configuration file\n");
88 GNUNET_RSA_sign, hk); 90 GNUNET_CONFIGURATION_destroy (cfg);
89 GNUNET_RSA_free_key (hk); 91 return 1;
92 }
93 uri = GNUNET_FS_uri_loc_create (baseURI,
94 cfg,
95 GNUNET_TIME_absolute_get ());
90 if (uri == NULL) 96 if (uri == NULL)
91 { 97 {
92 GNUNET_GE_BREAK (NULL, 0); 98 GNUNET_break (0);
93 GNUNET_ECRS_uri_destroy (baseURI); 99 GNUNET_FS_uri_destroy (baseURI);
94 return 1; 100 return 1;
95 } 101 }
96 if (!GNUNET_ECRS_uri_test_loc (uri)) 102 if (!GNUNET_FS_uri_test_loc (uri))
97 { 103 {
98 GNUNET_GE_BREAK (NULL, 0); 104 GNUNET_break (0);
99 GNUNET_ECRS_uri_destroy (uri); 105 GNUNET_FS_uri_destroy (uri);
100 GNUNET_ECRS_uri_destroy (baseURI); 106 GNUNET_FS_uri_destroy (baseURI);
101 return 1; 107 return 1;
102 } 108 }
103 uri2 = GNUNET_ECRS_uri_get_content_uri_from_loc (uri); 109 uri2 = GNUNET_FS_uri_loc_get_uri (uri);
104 if (!GNUNET_ECRS_uri_test_equal (baseURI, uri2)) 110 if (!GNUNET_FS_uri_test_equal (baseURI, uri2))
105 { 111 {
106 GNUNET_GE_BREAK (NULL, 0); 112 GNUNET_break (0);
107 GNUNET_ECRS_uri_destroy (uri); 113 GNUNET_FS_uri_destroy (uri);
108 GNUNET_ECRS_uri_destroy (uri2); 114 GNUNET_FS_uri_destroy (uri2);
109 GNUNET_ECRS_uri_destroy (baseURI); 115 GNUNET_FS_uri_destroy (baseURI);
110 return 1; 116 return 1;
111 } 117 }
112 GNUNET_ECRS_uri_destroy (uri2); 118 GNUNET_FS_uri_destroy (uri2);
113 GNUNET_ECRS_uri_destroy (baseURI); 119 GNUNET_FS_uri_destroy (baseURI);
114 uric = GNUNET_ECRS_uri_to_string (uri); 120 uric = GNUNET_FS_uri_to_string (uri);
115#if 0 121#if 0
116 /* not for the faint of heart: */ 122 /* not for the faint of heart: */
117 printf ("URI: `%s'\n", uric); 123 printf ("URI: `%s'\n", uric);
118#endif 124#endif
119 uri2 = GNUNET_ECRS_string_to_uri (NULL, uric); 125 uri2 = GNUNET_FS_uri_parse (uric, &emsg);
120 GNUNET_free (uric); 126 GNUNET_free (uric);
121 if (uri2 == NULL) 127 if (uri2 == NULL)
122 { 128 {
123 GNUNET_GE_BREAK (NULL, 0); 129 GNUNET_break (0);
124 GNUNET_ECRS_uri_destroy (uri); 130 GNUNET_FS_uri_destroy (uri);
125 return 1; 131 return 1;
126 } 132 }
127 if (GNUNET_YES != GNUNET_ECRS_uri_test_equal (uri, uri2)) 133 if (GNUNET_YES != GNUNET_FS_uri_test_equal (uri, uri2))
128 { 134 {
129 GNUNET_GE_BREAK (NULL, 0); 135 GNUNET_break (0);
130 GNUNET_ECRS_uri_destroy (uri); 136 GNUNET_FS_uri_destroy (uri);
131 GNUNET_ECRS_uri_destroy (uri2); 137 GNUNET_FS_uri_destroy (uri2);
132 return 1; 138 return 1;
133 } 139 }
134 GNUNET_ECRS_uri_destroy (uri2); 140 GNUNET_FS_uri_destroy (uri2);
135 GNUNET_ECRS_uri_destroy (uri); 141 GNUNET_FS_uri_destroy (uri);
136 return 0; 142 return 0;
137} 143}
138 144
@@ -140,44 +146,42 @@ static int
140testNamespace (int i) 146testNamespace (int i)
141{ 147{
142 char *uri; 148 char *uri;
143 struct GNUNET_ECRS_URI *ret; 149 struct GNUNET_FS_Uri *ret;
150 char *emsg;
144 151
145 if (NULL != 152 if (NULL !=
146 GNUNET_ECRS_string_to_uri (NULL, 153 GNUNET_FS_uri_parse ("gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK", &emsg))
147 "gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3VUK"))
148 ABORT (); 154 ABORT ();
149 if (NULL != 155 if (NULL !=
150 GNUNET_ECRS_string_to_uri (NULL, 156 GNUNET_FS_uri_parse ("gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg))
151 "gnunet://ecrs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test"))
152 ABORT (); 157 ABORT ();
153 if (NULL != GNUNET_ECRS_string_to_uri (NULL, "gnunet://ecrs/sks/test")) 158 if (NULL != GNUNET_FS_uri_parse ("gnunet://ecrs/sks/test", &emsg))
154 ABORT (); 159 ABORT ();
155 ret = 160 ret =
156 GNUNET_ECRS_string_to_uri (NULL, 161 GNUNET_FS_uri_parse ("gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test", &emsg);
157 "gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
158 if (ret == NULL) 162 if (ret == NULL)
159 ABORT (); 163 ABORT ();
160 if (GNUNET_ECRS_uri_test_ksk (ret)) 164 if (GNUNET_FS_uri_test_ksk (ret))
161 { 165 {
162 GNUNET_ECRS_uri_destroy (ret); 166 GNUNET_FS_uri_destroy (ret);
163 ABORT (); 167 ABORT ();
164 } 168 }
165 if (!GNUNET_ECRS_uri_test_sks (ret)) 169 if (!GNUNET_FS_uri_test_sks (ret))
166 { 170 {
167 GNUNET_ECRS_uri_destroy (ret); 171 GNUNET_FS_uri_destroy (ret);
168 ABORT (); 172 ABORT ();
169 } 173 }
170 174
171 uri = GNUNET_ECRS_uri_to_string (ret); 175 uri = GNUNET_FS_uri_to_string (ret);
172 if (0 != strcmp (uri, 176 if (0 != strcmp (uri,
173 "gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test")) 177 "gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test"))
174 { 178 {
175 GNUNET_ECRS_uri_destroy (ret); 179 GNUNET_FS_uri_destroy (ret);
176 GNUNET_free (uri); 180 GNUNET_free (uri);
177 ABORT (); 181 ABORT ();
178 } 182 }
179 GNUNET_free (uri); 183 GNUNET_free (uri);
180 GNUNET_ECRS_uri_destroy (ret); 184 GNUNET_FS_uri_destroy (ret);
181 return 0; 185 return 0;
182} 186}
183 187
@@ -185,51 +189,51 @@ static int
185testFile (int i) 189testFile (int i)
186{ 190{
187 char *uri; 191 char *uri;
188 struct GNUNET_ECRS_URI *ret; 192 struct GNUNET_FS_Uri *ret;
193 char *emsg;
189 194
190 if (NULL != 195 if (NULL !=
191 GNUNET_ECRS_string_to_uri (NULL, 196 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42", &emsg))
192 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H00000440000.42"))
193 ABORT (); 197 ABORT ();
198 GNUNET_free (emsg);
194 if (NULL != 199 if (NULL !=
195 GNUNET_ECRS_string_to_uri (NULL, 200 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000", &emsg))
196 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000"))
197 ABORT (); 201 ABORT ();
202 GNUNET_free (emsg);
198 if (NULL != 203 if (NULL !=
199 GNUNET_ECRS_string_to_uri (NULL, 204 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH", &emsg))
200 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.FGH"))
201 ABORT (); 205 ABORT ();
206 GNUNET_free (emsg);
202 ret = 207 ret =
203 GNUNET_ECRS_string_to_uri (NULL, 208 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", &emsg);
204 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
205 if (ret == NULL) 209 if (ret == NULL)
206 ABORT (); 210 ABORT ();
207 if (GNUNET_ECRS_uri_test_ksk (ret)) 211 if (GNUNET_FS_uri_test_ksk (ret))
208 { 212 {
209 GNUNET_ECRS_uri_destroy (ret); 213 GNUNET_FS_uri_destroy (ret);
210 ABORT (); 214 ABORT ();
211 } 215 }
212 if (GNUNET_ECRS_uri_test_sks (ret)) 216 if (GNUNET_FS_uri_test_sks (ret))
213 { 217 {
214 GNUNET_ECRS_uri_destroy (ret); 218 GNUNET_FS_uri_destroy (ret);
215 ABORT (); 219 ABORT ();
216 } 220 }
217 if (GNUNET_ntohll (ret->data.fi.file_length) != 42) 221 if (GNUNET_ntohll (ret->data.chk.file_length) != 42)
218 { 222 {
219 GNUNET_ECRS_uri_destroy (ret); 223 GNUNET_FS_uri_destroy (ret);
220 ABORT (); 224 ABORT ();
221 } 225 }
222 226
223 uri = GNUNET_ECRS_uri_to_string (ret); 227 uri = GNUNET_FS_uri_to_string (ret);
224 if (0 != strcmp (uri, 228 if (0 != strcmp (uri,
225 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42")) 229 "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
226 { 230 {
227 GNUNET_free (uri); 231 GNUNET_free (uri);
228 GNUNET_ECRS_uri_destroy (ret); 232 GNUNET_FS_uri_destroy (ret);
229 ABORT (); 233 ABORT ();
230 } 234 }
231 GNUNET_free (uri); 235 GNUNET_free (uri);
232 GNUNET_ECRS_uri_destroy (ret); 236 GNUNET_FS_uri_destroy (ret);
233 return 0; 237 return 0;
234} 238}
235 239
@@ -239,7 +243,7 @@ main (int argc, char *argv[])
239 int failureCount = 0; 243 int failureCount = 0;
240 int i; 244 int i;
241 245
242 GNUNET_disable_entropy_gathering (); 246 GNUNET_CRYPTO_random_disable_entropy_gathering ();
243 failureCount += testKeyword (); 247 failureCount += testKeyword ();
244 failureCount += testLocation (); 248 failureCount += testLocation ();
245 for (i = 0; i < 255; i++) 249 for (i = 0; i < 255; i++)
@@ -252,4 +256,4 @@ main (int argc, char *argv[])
252 return 0; 256 return 0;
253} 257}
254 258
255/* end of uritest.c */ 259/* end of test_fs_uri.c */