bio testcase harness
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Sun, 18 Oct 2009 17:19:54 +0000 (17:19 +0000)
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Sun, 18 Oct 2009 17:19:54 +0000 (17:19 +0000)
src/util/test_bio.c

index ed51cb84987b917fb0e5ad1216327eb6b8e780ef..0a2f1f595dc5c1721011dc255ea5901f51fb7ae4 100644 (file)
@@ -21,7 +21,7 @@
 /**
  * @file util/test_bio.c
  * @brief testcase for the buffered IO module
- * @author
+ * @author JiLu
  */
 
 
 #include "gnunet_common.h"
 #include "gnunet_disk_lib.h"
 #include "gnunet_bio_lib.h"
-
-int check(){
-
-       int suc;
-    char* fileName = GNUNET_DISK_mktemp ("gnunet_bio");
-       struct GNUNET_BIO_ReadHandle *fileR;
-       struct GNUNET_BIO_WriteHandle *fileW;
-       char *msg;
-       fileR = GNUNET_BIO_read_open (fileName);
-       GNUNET_BIO_read_close(fileR,&msg);
-       fileW = GNUNET_BIO_write_open(fileName);
-       if (GNUNET_OK == GNUNET_BIO_write_close(fileW))
-               suc = 0;
-       else
-               suc = 1;
-
-       return suc;
-
-
-}
-
-
+#include "gnunet_container_lib.h"
+#include "gnunet_strings_lib.h"
+#include "gnunet_time_lib.h"
+#include <extractor.h>
+#include <zlib.h>
+
+const char readWhatMeta[200],readWhatString[200],readWhatInt64[200];
+char readResultString[200];
+size_t readMaxLen;
+int64_t numberOne = 100000L;
+char *msg;
 
 int
 main (int argc, char *argv[])
 {
-
-       int ch = check();
-       return ch;
+           char* fileName = GNUNET_DISK_mktemp ("gnunet_bio");
+               struct GNUNET_BIO_ReadHandle *fileR;
+               struct GNUNET_BIO_WriteHandle *fileW;
+               struct GNUNET_CONTAINER_MetaData *metaDataW;
+               struct GNUNET_CONTAINER_MetaData *metaDataR;
+               metaDataR = GNUNET_CONTAINER_meta_data_create();
+               metaDataW = GNUNET_CONTAINER_meta_data_create();
+               GNUNET_CONTAINER_meta_data_add_publication_date(metaDataW);
+               fileW = GNUNET_BIO_write_open(fileName);
+               const char writeString[]="helloJilu";
+               GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_string(fileW,writeString));
+               GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_meta_data(fileW,metaDataW));
+               GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_int64(fileW,numberOne));
+               GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_close(fileW));
+               fileR = GNUNET_BIO_read_open (fileName);
+               GNUNET_BIO_read_meta_data(fileR,readWhatMeta,&metaDataR);
+               readMaxLen = sizeof(readResultString);
+        //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_string(fileR,readWhatString,&readResultString,readMaxLen));
+               //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_int64__(fileR,readWhatInt64,&numberOne));
+        GNUNET_BIO_read_close(fileR,&msg);
+               GNUNET_CONTAINER_meta_data_destroy(metaDataW);
+               GNUNET_CONTAINER_meta_data_destroy(metaDataR);
+
+               return 0;
 
 }                               /* end of main */