From 3bdafe922acf2cee93b2a5e0f25ffab706226d84 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 3 Jul 1999 05:34:27 -0500 Subject: [svn-r1419] Modified dtypes.c to add new dataset transfer property list ID in H5Tconvert calls. Added tests to tvltypes.c which test arrays of VL compound datatypes, array of compound datatypes with VL fields and arrays of nested VL sequences of VL sequences of atomic types, all of which are working correctly. --- test/dtypes.c | 86 +++++----- test/tvltypes.c | 482 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 519 insertions(+), 49 deletions(-) diff --git a/test/dtypes.c b/test/dtypes.c index 5325260..d3c73ae 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -481,7 +481,7 @@ test_compound_2(void) goto error; /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg)<0) goto error; + if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; /* Compare results */ for (i=0; icommand) num_opaque_conversions_g++; return 0; @@ -1627,7 +1627,7 @@ test_opaque(void) /* Make sure that we can't convert between the types yet */ H5E_BEGIN_TRY { - status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL); + status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT); } H5E_END_TRY; if (status>=0) { FAILED(); @@ -1640,7 +1640,7 @@ test_opaque(void) goto error; /* Try the conversion again, this time it should work */ - if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL)<0) goto error; + if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT)<0) goto error; if (saved+1 != num_opaque_conversions_g) { FAILED(); printf(" unexpected number of opaque conversions\n"); @@ -1690,7 +1690,7 @@ test_conv_int (void) /* (unsigned)0x80000000 -> (unsigned)0xffff */ byte[0] = byte[1] = byte[2] = 0; byte[3] = 0x80; - if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0xff) { @@ -1703,7 +1703,7 @@ test_conv_int (void) /* (unsigned)0xffffffff -> (signed)0x7fff */ byte[0] = byte[1] = byte[2] = byte[3] = 0xff; - if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0x7f) { @@ -1716,7 +1716,7 @@ test_conv_int (void) /* (signed)0xffffffff -> (unsigned)0x0000 */ byte[0] = byte[1] = byte[2] = byte[3] = 0xff; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0x00 || byte[1]!=0x00) { @@ -1730,7 +1730,7 @@ test_conv_int (void) /* (signed)0x7fffffff -> (unsigned)0xffff */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0x7f; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0xff) { @@ -1744,7 +1744,7 @@ test_conv_int (void) /* (signed)0x7fffffff -> (signed)0x7fff */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0x7f; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0x7f) { @@ -1758,7 +1758,7 @@ test_conv_int (void) /* (signed)0xbfffffff -> (signed)0x8000 */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0xbf; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0x00 || byte[1]!=0x80) { @@ -1951,7 +1951,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) for (j=0; jp=malloc((j+1)*sizeof(uint32_t)); + t1->len=j+1; + for(k=0; k<(j+1); k++) + ((uint32_t *)t1->p)[k]=i*100+j*10+k; + } /* end for */ + } /* end for */ + + /* Create file */ + fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Create dataspace for datasets */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + /* Create a VL datatype to refer to */ + tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + CHECK(tid1, FAIL, "H5Tvlen_create"); + + /* Create the base VL type */ + tid2 = H5Tvlen_create (tid1); + CHECK(tid2, FAIL, "H5Tvlen_create"); + + /* Create a dataset */ + dataset=H5Dcreate(fid1,"Dataset1",tid2,sid1,H5P_DEFAULT); + CHECK(dataset, FAIL, "H5Dcreate"); + + /* Write dataset to disk */ + ret=H5Dwrite(dataset,tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Change to the custom memory allocation routines for reading VL data */ + xfer_pid=H5Pcreate(H5P_DATASET_XFER); + CHECK(xfer_pid, FAIL, "H5Pcreate"); + + ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used); + CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); + + /* Read dataset from disk */ + ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Make certain the correct amount of memory has been used */ + /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ + /* 20 uint32_t elements allocated = 1 + 3 + 6 + 10 elements */ + VERIFY(mem_used,10*sizeof(hvl_t)+20*sizeof(uint32_t),"H5Dread"); + + /* Compare data read in */ + for(i=0; ilen!=t2->len) { + num_errs++; + printf("VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",(int)i,(int)j,(int)t1->len,(int)t2->len); + continue; + } /* end if */ + for(k=0; klen; k++) { + if( ((uint32_t *)t1->p)[k] != ((uint32_t *)t2->p)[k] ) { + num_errs++; + printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((uint32_t *)t1->p)[k], (int)k, (int)((uint32_t *)t2->p)[k]); + continue; + } /* end if */ + } /* end for */ + } /* end for */ + } /* end for */ + + /* Reclaim all the (nested) VL data */ + ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); + + /* Make certain the VL memory has been freed */ + VERIFY(mem_used,0,"H5Dvlen_reclaim"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close datatype */ + ret = H5Tclose(tid2); + CHECK(ret, FAIL, "H5Tclose"); + + /* Close datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + /* Close disk dataspace */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -127,7 +594,7 @@ test_vltypes_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* end test_vltypes_atomic() */ +} /* end test_vltypes_vlen_vlen_atomic() */ /**************************************************************** ** @@ -141,7 +608,10 @@ test_vltypes(void) MESSAGE(5, ("Testing Variable-Length Datatypes\n")); /* These next tests use the same file */ - test_vltypes_atomic(); /* Test basic VL datatype code */ + test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */ + test_vltypes_vlen_compound(); /* Test VL compound datatypes */ + test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */ + test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */ } /* test_vltypes() */ -- cgit v0.12