From 2d586abc2773635199351a80897fbcd7381c223b Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Tue, 17 Oct 2006 15:59:10 -0500 Subject: [PATCH] [svn-r12772] added more tests for h5copy (compressed datasets, vl named datatypes ) --- tools/h5copy/h5copygentest.c | 185 +++++++++++++++++++++++++++++++---- tools/h5copy/testh5copy.sh | 12 ++- tools/testfiles/h5copytst.h5 | Bin 6464 -> 13696 bytes 3 files changed, 173 insertions(+), 24 deletions(-) diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c index 3fdc57dd44..68a6027cbf 100644 --- a/tools/h5copy/h5copygentest.c +++ b/tools/h5copy/h5copygentest.c @@ -15,24 +15,29 @@ /* * Generate the binary hdf5 file for the h5copy tests */ - +#include #include "hdf5.h" -#define FILENAME "h5copytst.h5" -#define DATASET_SIMPLE "simple" -#define DATASET_CHUNK "chunk" -#define DATASET_COMPACT "compact" -#define DATASET_COMPOUND "compound" + +#define FILENAME "h5copytst.h5" +#define DATASET_SIMPLE "simple" +#define DATASET_CHUNK "chunk" +#define DATASET_COMPACT "compact" +#define DATASET_COMPOUND "compound" +#define DATASET_COMPRESSED "compressed" +#define DATASET_NAMED_VL "named_vl" +#define DATASET_NESTED_VL "nested_vl" + /*------------------------------------------------------------------------- - * Function: gent_simple_dataset + * Function: gent_simple * * Purpose: Generate a simple dataset in FID * *------------------------------------------------------------------------- */ -static void gent_simple_dataset(hid_t fid) +static void gent_simple(hid_t fid) { hid_t sid, did; hsize_t dims[1] = {6}; @@ -53,13 +58,13 @@ static void gent_simple_dataset(hid_t fid) } /*------------------------------------------------------------------------- - * Function: gent_chunked_dataset + * Function: gent_chunked * * Purpose: Generate a chunked dataset in FID * *------------------------------------------------------------------------- */ -static void gent_chunked_dataset(hid_t fid) +static void gent_chunked(hid_t fid) { hid_t sid, did, pid; hsize_t dims[1] = {6}; @@ -69,7 +74,7 @@ static void gent_chunked_dataset(hid_t fid) /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); - /* create property plist for chunk*/ + /* create property plist */ pid = H5Pcreate(H5P_DATASET_CREATE); H5Pset_chunk(pid, 1, chunk_dims); @@ -87,13 +92,13 @@ static void gent_chunked_dataset(hid_t fid) /*------------------------------------------------------------------------- - * Function: gent_compact_dataset + * Function: gent_compact * * Purpose: Generate a compact dataset in FID * *------------------------------------------------------------------------- */ -static void gent_compact_dataset(hid_t fid) +static void gent_compact(hid_t fid) { hid_t sid, did, pid; hsize_t dims[1] = {6}; @@ -102,7 +107,7 @@ static void gent_compact_dataset(hid_t fid) /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); - /* create property plist for chunk*/ + /* create property plist */ pid = H5Pcreate(H5P_DATASET_CREATE); H5Pset_layout (pid,H5D_COMPACT); @@ -120,13 +125,13 @@ static void gent_compact_dataset(hid_t fid) /*------------------------------------------------------------------------- - * Function: gent_compound_dataset + * Function: gent_compound * * Purpose: Generate a compound dataset in FID * *------------------------------------------------------------------------- */ -static void gent_compound_dataset(hid_t fid) +static void gent_compound(hid_t fid) { typedef struct s_t { @@ -161,7 +166,144 @@ static void gent_compound_dataset(hid_t fid) H5Tclose(tid_s); } +/*------------------------------------------------------------------------- + * Function: gent_compressed + * + * Purpose: Generate a compressed dataset in FID + * + *------------------------------------------------------------------------- + */ +static void gent_compressed(hid_t fid) +{ + hid_t sid, did, pid; + hsize_t dims[1] = {6}; + hsize_t chunk_dims[1] = {2}; + int buf[6] = {1,2,3,4,5,6}; + /* create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + + /* create property plist for chunk*/ + pid = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_chunk(pid, 1, chunk_dims); + + /* set the deflate filter */ +#if defined (H5_HAVE_FILTER_DEFLATE) + H5Pset_deflate(pid, 1); +#endif + + /* create dataset */ + did = H5Dcreate(fid, DATASET_COMPRESSED, H5T_NATIVE_INT, sid, pid); + + /* write */ + H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + + /* close */ + H5Sclose(sid); + H5Dclose(did); + H5Pclose(pid); +} + + +/*------------------------------------------------------------------------- + * Function: gent_named_vl + * + * Purpose: Generate a variable lenght named datatype for a dataset in FID + * + *------------------------------------------------------------------------- + */ +static void gent_named_vl(hid_t fid) +{ + hid_t sid, did, tid; + hsize_t dims[1] = {2}; + hvl_t buf[2]; + + /* allocate and initialize VL dataset to write */ + buf[0].len = 1; + buf[0].p = malloc( 1 * sizeof(int)); + ((int *)buf[0].p)[0]=1; + buf[1].len = 2; + buf[1].p = malloc( 2 * sizeof(int)); + ((int *)buf[1].p)[0]=2; + ((int *)buf[1].p)[1]=3; + + /* create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + + /* create datatype */ + tid = H5Tvlen_create(H5T_NATIVE_INT); + + /* create named datatype */ + H5Tcommit(fid, "vl", tid); + + /* create dataset */ + did = H5Dcreate(fid, DATASET_NAMED_VL, tid, sid, H5P_DEFAULT); + + /* write */ + H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + + /* close */ + H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf); + H5Sclose(sid); + H5Dclose(did); + H5Tclose(tid); + +} + + +/*------------------------------------------------------------------------- + * Function: gent_nested_vl + * + * Purpose: Generate a nested variable lenght dataset in FID + * + *------------------------------------------------------------------------- + */ +static void gent_nested_vl(hid_t fid) +{ + hid_t sid, did, tid1, tid2; + hsize_t dims[1] = {2}; + hvl_t buf[2]; + hvl_t *tvl; + + /* allocate and initialize VL dataset to write */ + buf[0].len = 1; + buf[0].p = malloc( 1 * sizeof(hvl_t)); + tvl = buf[0].p; + tvl->p = malloc( 1 * sizeof(int) ); + tvl->len = 1; + ((int *)tvl->p)[0]=1; + + buf[1].len = 1; + buf[1].p = malloc( 1 * sizeof(hvl_t)); + tvl = buf[1].p; + tvl->p = malloc( 2 * sizeof(int) ); + tvl->len = 2; + ((int *)tvl->p)[0]=2; + ((int *)tvl->p)[1]=3; + + /* create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + + /* create datatype */ + tid1 = H5Tvlen_create(H5T_NATIVE_INT); + + /* create nested VL datatype */ + tid2 = H5Tvlen_create(tid1); + + /* create dataset */ + did = H5Dcreate(fid, DATASET_NESTED_VL, tid2, sid, H5P_DEFAULT); + + /* write */ + H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + + /* close */ + H5Dvlen_reclaim(tid2,sid,H5P_DEFAULT,buf); + H5Sclose(sid); + H5Dclose(did); + H5Tclose(tid1); + H5Tclose(tid2); + +} /*------------------------------------------------------------------------- @@ -177,10 +319,13 @@ int main(void) fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - gent_simple_dataset(fid); - gent_chunked_dataset(fid); - gent_compact_dataset(fid); - gent_compound_dataset(fid); + gent_simple(fid); + gent_chunked(fid); + gent_compact(fid); + gent_compound(fid); + gent_compressed(fid); + gent_named_vl(fid); + gent_nested_vl(fid); H5Fclose(fid); return 0; diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index d3764619d8..ffacd39f33 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -120,10 +120,14 @@ H5DIFFTEST() ### T H E T E S T S ### ############################################################################## -TOOLTEST -i $TESTFILE -o $FILEOUT -v -s simple -d simple -TOOLTEST -i $TESTFILE -o $FILEOUT -v -s chunk -d chunk -TOOLTEST -i $TESTFILE -o $FILEOUT -v -s compact -d compact -TOOLTEST -i $TESTFILE -o $FILEOUT -v -s compound -d compound +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s simple -d simple +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s chunk -d chunk +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s compact -d compact +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s compound -d compound +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s compressed -d compressed +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s named_vl -d named_vl +TOOLTEST -i $TESTFILE -o $FILEOUT -v -s nested_vl -d nested_vl + diff --git a/tools/testfiles/h5copytst.h5 b/tools/testfiles/h5copytst.h5 index 9d44bd77cc9ece5dece43da163c687d3e762ea00..b0a04df21803c581cddb3318693a19c14a1374b4 100644 GIT binary patch literal 13696 zcmeHNJ8u&~5S~2;@bOG|DNvnxNGVWa9!7}D2m%%$67i7I*~WK~1CAZp4oZbwLYI<~ z61qS|g;F6(3VsX~Fta;zIiGzF36BJ2C%WC8$3Et}y}R*jUKVcLJh1oVULZ=RVF-pH zr5RKFVCv+$c`+$TBcWE{fI^+e`VkzTXqovHhZ|fyygxY!*hA)(TCA=NnO0r|w%$<) z6eh1tlfx_Qb(QNcmrR59+UjZ3-i=k1=dELu8!Q#<)?=9hU>Bry({UV{0-u>-%@3ym zpCKYomx}kh(pG?@7)ryawofS>NYf~5Om&#W)Gc>ChtI@|F8x+B5AIFfprxCq8KARk z@QTE{WdR_;++%rGIwaU-S)MQ8ZC_ea z6~9y}IgbGy8A5IrIfYyn(#QqKrI0JY{=q&F%>6J(lDFE;^YIZ;cA<}~=Sf04eoL=e z(>(INrghLIJn1Z11S|p;0gHe|z#{PH5uo4O3L_x-oh`M*x$zlCSs{A*UPsA`>BGR2 zjmD%S^Ac~x?V@Aawne}qU=gqgSOhErTZ@3?XLRxsmlEb@!aQhItBzw}Foybm`GS5P z96{kxW3O`w)E-1)AJ4B!JhGNw&2q${)5hVD@w^ZvPBudd_82HQSrOu~$^6|u@bq|+ zFQy!;!aqNlt(Dt>nF|*h`sX;)C(Xji^)QU;^{-^C{&JZVPaaH|_ro5e5WU<#G5-|P zhYqsASJsPtJf57W`m?!-REeR1q!jdPl#^WrZxW4`M;X~yQ9e6Y_ltA& zVx#IeDbMWT)j|3A#Q1o0eN*EV)BwnM-|`u^*bK@wlr7`s;k7cL-w5if*D@~kTgA4A z7g5qY=Wi=xU`vaDMZh9p5wHmSV+1I+p>Mv&^UA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