aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-12-06 13:52:01 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-12-06 13:52:01 +0900
commit69e6c0b893b0b642f969ac8a134d043a51e393a3 (patch)
tree80c00ce5b69f9eb8728fb8dda39abac953412574 /src/util
parent5abbc294229cca582d0b104b86be534de2be66ea (diff)
downloadgnunet-69e6c0b893b0b642f969ac8a134d043a51e393a3.tar.gz
gnunet-69e6c0b893b0b642f969ac8a134d043a51e393a3.zip
-fix more test issues
Diffstat (limited to 'src/util')
-rw-r--r--src/util/test_bio.c110
1 files changed, 2 insertions, 108 deletions
diff --git a/src/util/test_bio.c b/src/util/test_bio.c
index 0b76bbb43..90f0121d4 100644
--- a/src/util/test_bio.c
+++ b/src/util/test_bio.c
@@ -40,8 +40,6 @@ test_normal_rw (void)
40 void *buffer; 40 void *buffer;
41 size_t buffer_size = 0; 41 size_t buffer_size = 0;
42 char *filename = GNUNET_DISK_mktemp ("gnunet-bio"); 42 char *filename = GNUNET_DISK_mktemp ("gnunet-bio");
43 struct GNUNET_CONTAINER_MetaData *mdW;
44 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
45 char *rString = NULL; 43 char *rString = NULL;
46 int64_t wNum = TESTNUMBER64; 44 int64_t wNum = TESTNUMBER64;
47 int64_t rNum = 0; 45 int64_t rNum = 0;
@@ -189,41 +187,6 @@ test_bigstring_rw (void)
189 187
190 188
191static int 189static int
192test_bigmeta_rw (void)
193{
194 static char meta[1024 * 1024 * 10];
195 struct GNUNET_BIO_WriteHandle *wh;
196 struct GNUNET_BIO_ReadHandle *rh;
197 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
198 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
199
200 memset (meta, 'b', sizeof (meta));
201 meta[sizeof (meta) - 1] = '\0';
202
203 wh = GNUNET_BIO_write_open_file (filename);
204 GNUNET_assert (NULL != wh);
205 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
206 "test-bigmeta-rw-int32",
207 sizeof (meta)));
208 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write (wh,
209 "test-bigmeta-rw-bytes",
210 meta,
211 sizeof (meta)));
212 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
213
214 rh = GNUNET_BIO_read_open_file (filename);
215 GNUNET_assert (NULL != rh);
216 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
217
218 GNUNET_assert (NULL == mdR);
219
220 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
221 GNUNET_free (filename);
222 return 0;
223}
224
225
226static int
227test_directory_r (void) 190test_directory_r (void)
228{ 191{
229#ifdef LINUX 192#ifdef LINUX
@@ -252,12 +215,12 @@ test_nullfile_rw (void)
252 memset (filename, 'a', sizeof (filename)); 215 memset (filename, 'a', sizeof (filename));
253 filename[sizeof (filename) - 1] = '\0'; 216 filename[sizeof (filename) - 1] = '\0';
254 217
255 GNUNET_log_skip (2, GNUNET_NO); 218 GNUNET_log_skip (1, GNUNET_NO);
256 wh = GNUNET_BIO_write_open_file (filename); 219 wh = GNUNET_BIO_write_open_file (filename);
257 GNUNET_log_skip (0, GNUNET_YES); 220 GNUNET_log_skip (0, GNUNET_YES);
258 GNUNET_assert (NULL == wh); 221 GNUNET_assert (NULL == wh);
259 222
260 GNUNET_log_skip (2, GNUNET_NO); 223 GNUNET_log_skip (1, GNUNET_NO);
261 rh = GNUNET_BIO_read_open_file (filename); 224 rh = GNUNET_BIO_read_open_file (filename);
262 GNUNET_log_skip (0, GNUNET_YES); 225 GNUNET_log_skip (0, GNUNET_YES);
263 GNUNET_assert (NULL == rh); 226 GNUNET_assert (NULL == rh);
@@ -275,8 +238,6 @@ test_fullfile_rw (void)
275 struct GNUNET_BIO_ReadHandle *rh; 238 struct GNUNET_BIO_ReadHandle *rh;
276 char *rString = NULL; 239 char *rString = NULL;
277 char rResult[200]; 240 char rResult[200];
278 struct GNUNET_CONTAINER_MetaData *mdW;
279 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
280 241
281 struct GNUNET_BIO_WriteSpec ws[] = { 242 struct GNUNET_BIO_WriteSpec ws[] = {
282 GNUNET_BIO_write_spec_object ("test-fullfile-rw-bytes", 243 GNUNET_BIO_write_spec_object ("test-fullfile-rw-bytes",
@@ -308,7 +269,6 @@ test_fullfile_rw (void)
308 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL)); 269 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
309 270
310 GNUNET_assert (NULL == rString); 271 GNUNET_assert (NULL == rString);
311 GNUNET_assert (NULL == mdR);
312#endif 272#endif
313 return 0; 273 return 0;
314} 274}
@@ -346,61 +306,6 @@ test_fakestring_rw (void)
346 306
347 307
348static int 308static int
349test_fakemeta_rw (void)
350{
351 struct GNUNET_BIO_WriteHandle *wh;
352 struct GNUNET_BIO_ReadHandle *rh;
353 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
354 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
355
356 wh = GNUNET_BIO_write_open_file (filename);
357 GNUNET_assert (NULL != wh);
358 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
359 "test-fakestring-rw-int32",
360 2));
361 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
362
363 rh = GNUNET_BIO_read_open_file (filename);
364 GNUNET_assert (NULL != rh);
365 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
366
367 GNUNET_assert (NULL == mdR);
368
369 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
370 GNUNET_free (filename);
371 return 0;
372}
373
374
375static int
376test_fakebigmeta_rw (void)
377{
378 struct GNUNET_BIO_WriteHandle *wh;
379 struct GNUNET_BIO_ReadHandle *rh;
380 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
381 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
382 int32_t wNum = 1024 * 1024 * 10;
383
384 wh = GNUNET_BIO_write_open_file (filename);
385 GNUNET_assert (NULL != wh);
386 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
387 "test-fakebigmeta-rw-int32",
388 wNum));
389 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
390
391 rh = GNUNET_BIO_read_open_file (filename);
392 GNUNET_assert (NULL != rh);
393 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
394
395 GNUNET_assert (NULL == mdR);
396
397 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
398 GNUNET_free (filename);
399 return 0;
400}
401
402
403static int
404check_string_rw (void) 309check_string_rw (void)
405{ 310{
406 GNUNET_assert (0 == test_nullstring_rw ()); 311 GNUNET_assert (0 == test_nullstring_rw ());
@@ -412,16 +317,6 @@ check_string_rw (void)
412 317
413 318
414static int 319static int
415check_metadata_rw (void)
416{
417 GNUNET_assert (0 == test_fakebigmeta_rw ());
418 GNUNET_assert (0 == test_fakemeta_rw ());
419 GNUNET_assert (0 == test_bigmeta_rw ());
420 return 0;
421}
422
423
424static int
425check_file_rw (void) 320check_file_rw (void)
426{ 321{
427 GNUNET_assert (0 == test_normal_rw ()); 322 GNUNET_assert (0 == test_normal_rw ());
@@ -437,7 +332,6 @@ main (int argc, char *argv[])
437{ 332{
438 GNUNET_log_setup ("test-bio", "WARNING", NULL); 333 GNUNET_log_setup ("test-bio", "WARNING", NULL);
439 GNUNET_assert (0 == check_file_rw ()); 334 GNUNET_assert (0 == check_file_rw ());
440 GNUNET_assert (0 == check_metadata_rw ());
441 GNUNET_assert (0 == check_string_rw ()); 335 GNUNET_assert (0 == check_string_rw ());
442 return 0; 336 return 0;
443} 337}