aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_bio.c
diff options
context:
space:
mode:
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2009-10-18 17:19:54 +0000
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>2009-10-18 17:19:54 +0000
commitc871949ce934d896718de59775c8b0b7285720c1 (patch)
tree53522cc1f739fa8c98ea5fde9948d1155f16d07e /src/util/test_bio.c
parent352db2950121cf81e236a0ac240f53e4e51f9ff8 (diff)
downloadgnunet-c871949ce934d896718de59775c8b0b7285720c1.tar.gz
gnunet-c871949ce934d896718de59775c8b0b7285720c1.zip
bio testcase harness
Diffstat (limited to 'src/util/test_bio.c')
-rw-r--r--src/util/test_bio.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/src/util/test_bio.c b/src/util/test_bio.c
index ed51cb849..0a2f1f595 100644
--- a/src/util/test_bio.c
+++ b/src/util/test_bio.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file util/test_bio.c 22 * @file util/test_bio.c
23 * @brief testcase for the buffered IO module 23 * @brief testcase for the buffered IO module
24 * @author 24 * @author JiLu
25 */ 25 */
26 26
27 27
@@ -29,34 +29,44 @@
29#include "gnunet_common.h" 29#include "gnunet_common.h"
30#include "gnunet_disk_lib.h" 30#include "gnunet_disk_lib.h"
31#include "gnunet_bio_lib.h" 31#include "gnunet_bio_lib.h"
32 32#include "gnunet_container_lib.h"
33int check(){ 33#include "gnunet_strings_lib.h"
34 34#include "gnunet_time_lib.h"
35 int suc; 35#include <extractor.h>
36 char* fileName = GNUNET_DISK_mktemp ("gnunet_bio"); 36#include <zlib.h>
37 struct GNUNET_BIO_ReadHandle *fileR; 37
38 struct GNUNET_BIO_WriteHandle *fileW; 38const char readWhatMeta[200],readWhatString[200],readWhatInt64[200];
39 char *msg; 39char readResultString[200];
40 fileR = GNUNET_BIO_read_open (fileName); 40size_t readMaxLen;
41 GNUNET_BIO_read_close(fileR,&msg); 41int64_t numberOne = 100000L;
42 fileW = GNUNET_BIO_write_open(fileName); 42char *msg;
43 if (GNUNET_OK == GNUNET_BIO_write_close(fileW))
44 suc = 0;
45 else
46 suc = 1;
47
48 return suc;
49
50
51}
52
53
54 43
55int 44int
56main (int argc, char *argv[]) 45main (int argc, char *argv[])
57{ 46{
58 47 char* fileName = GNUNET_DISK_mktemp ("gnunet_bio");
59 int ch = check(); 48 struct GNUNET_BIO_ReadHandle *fileR;
60 return ch; 49 struct GNUNET_BIO_WriteHandle *fileW;
50 struct GNUNET_CONTAINER_MetaData *metaDataW;
51 struct GNUNET_CONTAINER_MetaData *metaDataR;
52 metaDataR = GNUNET_CONTAINER_meta_data_create();
53 metaDataW = GNUNET_CONTAINER_meta_data_create();
54 GNUNET_CONTAINER_meta_data_add_publication_date(metaDataW);
55 fileW = GNUNET_BIO_write_open(fileName);
56 const char writeString[]="helloJilu";
57 GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_string(fileW,writeString));
58 GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_meta_data(fileW,metaDataW));
59 GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_int64(fileW,numberOne));
60 GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_close(fileW));
61 fileR = GNUNET_BIO_read_open (fileName);
62 GNUNET_BIO_read_meta_data(fileR,readWhatMeta,&metaDataR);
63 readMaxLen = sizeof(readResultString);
64 //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_string(fileR,readWhatString,&readResultString,readMaxLen));
65 //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_int64__(fileR,readWhatInt64,&numberOne));
66 GNUNET_BIO_read_close(fileR,&msg);
67 GNUNET_CONTAINER_meta_data_destroy(metaDataW);
68 GNUNET_CONTAINER_meta_data_destroy(metaDataR);
69
70 return 0;
61 71
62} /* end of main */ 72} /* end of main */