From cfac5f773e8fc360a69d8384674d7a557d5a43f6 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 17 Nov 2000 16:12:23 -0500 Subject: [svn-r2974] Purpose: Code bullet-proofing Description: There were several hard-coded values in various places in this test and it wasn't checking for out-of-memory conditions very robustly. Solution: Changed hard-coded values to be computed values and performed better checking for out-of-memory situations. Platforms tested: SGI O2K (modi4) and Solaris 2.6 (baldric) --- test/tvltypes.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/test/tvltypes.c b/test/tvltypes.c index ca13a91..5c4e3ee 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -164,7 +164,7 @@ test_vltypes_vlen_atomic(void) CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(size,10*sizeof(unsigned int),"H5Dvlen_get_buf_size"); + VERIFY(size,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata); @@ -172,7 +172,7 @@ test_vltypes_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,10*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dread"); /* Compare data read in */ for(i=0; ip=malloc((j+1)*sizeof(unsigned int)); + if(t1->p==NULL) { + printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + num_errs++; + return; + } /* end if */ t1->len=j+1; for(k=0; k<(j+1); k++) ((unsigned int *)t1->p)[k]=i*100+j*10+k; @@ -644,7 +674,7 @@ test_vltypes_vlen_vlen_atomic(void) /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(size,10*sizeof(hvl_t)+20*sizeof(unsigned int),"H5Dvlen_get_buf_size"); + VERIFY(size,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(hvl_t)+vlen_size_func(SPACE1_DIM1)*sizeof(unsigned int),"H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata); @@ -653,7 +683,7 @@ test_vltypes_vlen_vlen_atomic(void) /* 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 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(mem_used,10*sizeof(hvl_t)+20*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(hvl_t)+vlen_size_func(SPACE1_DIM1)*sizeof(unsigned int),"H5Dread"); /* Compare data read in */ for(i=0; i