From 7d7b28e602317db136135017e7ff52e8a22ca35a Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Fri, 9 Mar 2001 18:50:44 -0500 Subject: [svn-r3598] Purpose: adding a test source code for generating h4toh5 test files Description: Solution: Platforms tested: linux and solaris 2.7 --- tools/h4toh5test.c | 3954 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3954 insertions(+) create mode 100644 tools/h4toh5test.c diff --git a/tools/h4toh5test.c b/tools/h4toh5test.c new file mode 100644 index 0000000..ea971a7 --- /dev/null +++ b/tools/h4toh5test.c @@ -0,0 +1,3954 @@ +/*** this code is to generate various hdf files to test h4toh5 converter and h4toh5 lib API. The code itself is NOT optimizied but try to consider various cases that examine how converter works. */ + +#include "hdf.h" +#include "mfhdf.h" +#include + + +#define FILESDS1 "sds_typ_test.hdf" +#define FILESDS2 "sds_dim_test.hdf" +#define FILESDS3 "sds_attr_test.hdf" +#define FILEGR "gr_typ_test.hdf" +#define FILERAS8 "ras_8_test.hdf" +#define FILERAS24 "ras_24_test.hdf" +#define FILEGRPAL "image_attr_test.hdf" +#define FILEVD "vdata_test.hdf" +#define FILECLASHVG "vgnameclash_test.hdf" +#define FILECLASHSDS "sdsnameclash_test.hdf" +#define FILECLASHVD "vdnameclash_test.hdf" +#define FILECLASHGR "grnameclash_test.hdf" +#define FILELOOP "vg_loop_test.hdf" +#define FILEHL "vg_hl_test.hdf" +#define FILEVG "vg_all_test.hdf" +#define FILEANNO "anno_test.hdf" + +/* for testing sds*/ +#define TYP_RANK 3 +#define TYP_DIMSIZE 4 +#define INT8_UPLIMIT 0x7E +#define UINT8_UPLIMIT 0xFC +#define INT16_UPLIMIT 0x7FFE +#define UINT16_UPLIMIT 0xFFFC +#define INT32_UPLIMIT 0x7FFFFFFE +#define UINT32_UPLIMIT 0xFFFFFFFC +#define ATT_SIZE 10 + +/* for testing image*/ +#define X_LENGTH 10 +#define Y_LENGTH 5 +#define NUM_COLORS 256 +#define F_ATT1_NAME "File Attribute" +#define RI_ATT1_NAME "Image Attribute" +#define F_ATT1_VAL "Contents of First FILE Attribute" +#define F_ATT1_N_VALUES 32 +#define RI_ATT1_VAL "Contents of IMAGE's First Attribute" +#define RI_ATT1_N_VALUES 35 + +/* for testing vdata*/ +#define NRECORDS 10 +#define FIELD_1 "Temp" +#define FIELD_2 "Height" +#define FIELD_3 "Speed" +#define FIELD_4 "Ident" +#define FIELD_5 "Position" +#define FIELD_NAMES "Temp,Height,Speed,Ident,Position" +#define FIELD_VDNAMES "Temp,Height" + +/*for testing vgroup*/ +#define VGATTR_NAME "Vgroup attribute 1" +int test_sdstyp(void); +int test_sdsdim(void); +int test_sdsattr(void); +int test_grtyp(void); +int test_ras8(void); +int test_ras24(void); +int test_imageattr(void); +int test_vdata(void); +int test_vgnameclash(void); +int test_sdsnameclash(void); +int test_grnameclash(void); +int test_vdnameclash(void); +int test_vgloop(void); +int test_vghl(void); +int test_vgall(void); +int test_anno(void); + +int main(void) { + if(test_sdstyp()== FAIL) { + printf("failed to create sds_typ_test.hdf file.\n"); + return FAIL; + } + if(test_sdsdim()== FAIL) { + printf("failed to create sds_dim_test.hdf file. \n"); + return FAIL; + } + if(test_sdsattr()== FAIL) { + printf("failed to create sds_attr_test.hdf file. \n"); + return FAIL; + } + if(test_grtyp()==FAIL) { + printf("failed to create gr_typ_test.hdf file. \n"); + return FAIL; + } + + if(test_ras8()==FAIL) { + printf("failed to create ras8_test.hdf file.\n"); + return FAIL; + } + + if(test_ras24()==FAIL) { + printf("failed to create ras24_test.hdf file.\n"); + return FAIL; + } + + if(test_imageattr()== FAIL) { + printf("failed to create image_attr_test.hdf file.\n"); + return FAIL; + } + + if(test_vdata()== FAIL) { + printf("failed to create vdata_test.hdf file.\n"); + return FAIL; + } + + if(test_vgnameclash()==FAIL) { + printf("failed to create vg_nameclash.hdf file.\n"); + return FAIL; + } + + if(test_sdsnameclash()==FAIL) { + printf("failed to create sds_nameclash.hdf file.\n"); + return FAIL; + } + + if(test_grnameclash()==FAIL) { + printf("failed to create gr_nameclash.hdf file. \n"); + return FAIL; + } + + if(test_vdnameclash()==FAIL) { + printf("failed to create vd_nameclash.hdf file.\n"); + return FAIL; + } + if(test_vgloop()==FAIL) { + printf("failed to create vg_loop.hdf file. \n"); + return FAIL; + } + if(test_vghl()==FAIL) { + printf("failed to create vg_hl.hdf file. \n"); + return FAIL; + } + if(test_vgall()==FAIL) { + printf("failed to create vg_all.hdf file. \n"); + return FAIL; + } + if(test_anno()==FAIL) { + printf("failed to create vg_anno.hdf file. \n"); + return FAIL; + } + return 0; +} + +/* this subroutine will hdf file with typical sds objects, + + The rank is TYP_RANK, each dimensional size is TYP_DIMSIZE. + Datatype we are testing is: + char, + int8, + int16, + int32, + uint16, + uint32, + lint16, + lint32, + luint32, + float32, + float64, + +*/ +int test_sdstyp(){ + + int32 file_id,sds_id; + int32 i,j,k; + int32 typ_start[TYP_RANK],typ_edges[TYP_RANK],typ_stride[TYP_RANK]; + char8 typchar_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int8 typint8_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int16 typint16_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int32 typint32_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + uint16 typuint16_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int32 typlint32_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + uint32 typluint32_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + float32 typfloat32_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + float64 typfloat64_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + float64 typlfloat64_array[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int32 typ_dims[TYP_RANK]; + int32 CUB_SIZE; + int istat; + /* TYPICAL sds array, we limit the dimensional size for testing purpose. */ + + CUB_SIZE = (TYP_DIMSIZE-1)*(TYP_DIMSIZE-1)*(TYP_DIMSIZE-1); + + /* 1. data type is char */ + for (i=0;ivb and vb->va */ + +int test_vgloop() { + + int32 file_id, vgroupa_ref, vgroupa_id, vgroupb_ref,vgroupb_id; + int32 istat,dims[TYP_RANK]; + int i,j,k; + + /*2. for sds */ + int32 sd_id,sds_id; + int32 sds_ref; + int32 array_data[TYP_DIMSIZE][TYP_DIMSIZE][TYP_DIMSIZE]; + int32 start[TYP_RANK],edges[TYP_RANK],stride[TYP_RANK]; + + + for (i=0;i