From c871949ce934d896718de59775c8b0b7285720c1 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Sun, 18 Oct 2009 17:19:54 +0000 Subject: [PATCH] bio testcase harness --- src/util/test_bio.c | 62 ++++++++++++++++++++++++++------------------- 1 file 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 @@ /** * @file util/test_bio.c * @brief testcase for the buffered IO module - * @author + * @author JiLu */ @@ -29,34 +29,44 @@ #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 +#include + +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 */ -- 2.25.1