summaryrefslogtreecommitdiffstats
path: root/tools/h5diff/h5diffgentest.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-02-28 14:49:48 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-02-28 14:49:48 (GMT)
commit66fa79b4234287d1b51ef62b394aa92fcafe7dd2 (patch)
treef9df07d9e98ee2a7dcaee08691b757e43550169a /tools/h5diff/h5diffgentest.c
parenta884d556b7401444be47828145786adf56edf311 (diff)
downloadhdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.zip
hdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.tar.gz
hdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.tar.bz2
[svn-r14690] Description:
Handle comparing datasets & attributes w/variable-length strings properly. Tested on: Linux/64 2.6.9 (chicago)
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r--tools/h5diff/h5diffgentest.c142
1 files changed, 101 insertions, 41 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 735dc0f..2a95ce0 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -444,7 +444,7 @@ int test_types(const char *fname)
*/
H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
H5Lregister(UD_link_class);
- H5Lcreate_ud(fid1, "ud_link", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_ud(fid1, "ud_link", MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* Close
@@ -814,12 +814,13 @@ void write_attr_in(hid_t loc_id,
hid_t sid;
hid_t tid;
herr_t status;
- int val, i, j, k, n;
+ int val, i, j, k, l, n;
float f;
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
- char buf1[2][2]= {"ab","de"}; /* string */
+ char buf1[2][STR_SIZE]= {"ab","de"}; /* string */
+ char *buf1a[2]; /* VL string */
char buf2[2]= {1,2}; /* bitfield, opaque */
s_t buf3[2]= {{1,2},{3,4}}; /* compound */
hobj_ref_t buf4[2]; /* reference */
@@ -832,7 +833,8 @@ void write_attr_in(hid_t loc_id,
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
- char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */
+ char buf12[3][2][STR_SIZE]= {{"ab","cd"},{"ef","gh"},{"ij","kl"}}; /* string */
+ char *buf12a[3][2]; /* VL string */
char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
hobj_ref_t buf42[3][2]; /* reference */
@@ -844,9 +846,11 @@ void write_attr_in(hid_t loc_id,
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
- char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq",
- "rs","tu","vw","xz","AB","CD","EF","GH",
- "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
+ char buf13[4][3][2][STR_SIZE]= {{{"ab","cd"},{"ef","gh"},{"ij","kl"}},
+ {{"mn","pq"},{"rs","tu"},{"vw","xz"}},
+ {{"AB","CD"},{"EF","GH"},{"IJ","KL"}},
+ {{"MN","PQ"},{"RS","TU"},{"VW","XZ"}}}; /* string */
+ char *buf13a[4][3][2]; /* VL string */
char buf23[4][3][2]; /* bitfield, opaque */
s_t buf33[4][3][2]; /* compound */
hobj_ref_t buf43[4][3][2]; /* reference */
@@ -871,9 +875,7 @@ void write_attr_in(hid_t loc_id,
{
for (i=0; i<2; i++)
for (j=0; j<2; j++)
- {
buf1[i][j]='z';
- }
}
/*
buf1[2][2]= {"ab","de"};
@@ -888,10 +890,17 @@ void write_attr_in(hid_t loc_id,
[ 1 ] e z
*/
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid, 2);
+ status = H5Tset_size(tid, (size_t)STR_SIZE);
write_attr(loc_id,1,dims,"string",tid,buf1);
status = H5Tclose(tid);
+ for (i=0; i<2; i++)
+ buf1a[i]=buf1[i];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_attr(loc_id,1,dims,"VLstring",tid,buf1a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -935,7 +944,7 @@ void write_attr_in(hid_t loc_id,
[ 1 ] 2 0 2
*/
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_attr(loc_id,1,dims,"opaque",tid,buf2);
status = H5Tclose(tid);
@@ -1126,7 +1135,10 @@ position array of </g1> array of </g1> difference
*/
if (make_diffs)
{
- memset(buf12, 'z', sizeof buf12);
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ for (k=0; k<2; k++)
+ buf12[i][j][k]='z';
}
/*
@@ -1150,10 +1162,18 @@ position array of </g1> array of </g1> difference
*/
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid, 2);
+ status = H5Tset_size(tid, (size_t)STR_SIZE);
write_attr(loc_id,2,dims2,"string2D",tid,buf12);
status = H5Tclose(tid);
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ buf12a[i][j]=buf12[i][j];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_attr(loc_id,2,dims2,"VLstring2D",tid,buf12a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -1201,7 +1221,7 @@ position array of </g1> array of </g1> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
*/
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_attr(loc_id,2,dims2,"opaque2D",tid,buf22);
status = H5Tclose(tid);
@@ -1288,7 +1308,6 @@ position enum2D of </g1> enum2D of </g1> difference
n=0;
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
- int l;
buf52[i][j].p = malloc((i + 1) * sizeof(int));
buf52[i][j].len = i + 1;
for (l = 0; l < i + 1; l++)
@@ -1411,7 +1430,11 @@ position float2D of </g1> float2D of </g1> difference
if (make_diffs)
{
- memset(buf13,'z',sizeof buf13);
+ for (i=0; i<4; i++)
+ for (j=0; j<3; j++)
+ for (k=0; k<2; k++)
+ for (l=0; l<2; l++)
+ buf13[i][j][k][l]='z';
}
/*
@@ -1472,10 +1495,19 @@ position string3D of </g1> string3D of </g1> difference
*/
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid, 2);
+ status = H5Tset_size(tid, (size_t)STR_SIZE);
write_attr(loc_id,3,dims3,"string3D",tid,buf13);
status = H5Tclose(tid);
+ for (i=0; i<4; i++)
+ for (j=0; j<3; j++)
+ for (k=0; k<2; k++)
+ buf13a[i][j][k]=buf13[i][j][k];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_attr(loc_id,3,dims3,"VLstring3D",tid,buf13a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -1528,7 +1560,7 @@ position bitfield3D of </g1> bitfield3D of </g1> difference
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_attr(loc_id,3,dims3,"opaque3D",tid,buf23);
status = H5Tclose(tid);
@@ -1686,7 +1718,6 @@ position enum3D of </g1> enum3D of </g1> difference
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
for (k = 0; k < 2; k++) {
- int l;
buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
buf53[i][j][k].len = i + 1;
for (l = 0; l < i + 1; l++)
@@ -1821,13 +1852,14 @@ void write_dset_in(hid_t loc_id,
hid_t tid;
hid_t dcpl;
herr_t status;
- int val, i, j, k, n;
+ int val, i, j, k, l, n;
float f;
int fillvalue=2;
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
char buf1[2][STR_SIZE]= {"ab","de"}; /* string */
+ char *buf1a[2]; /* VL string */
char buf2[2]= {1,2}; /* bitfield, opaque */
s_t buf3[2]= {{1,2},{3,4}}; /* compound */
hobj_ref_t buf4[2]; /* reference */
@@ -1840,7 +1872,8 @@ void write_dset_in(hid_t loc_id,
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
- char buf12[6][STR_SIZE]= {"ab","cd","ef","gh","ij","kl"}; /* string */
+ char buf12[3][2][STR_SIZE]= {{"ab","cd"},{"ef","gh"},{"ij","kl"}}; /* string */
+ char *buf12a[3][2]; /* VL string */
char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
hobj_ref_t buf42[3][2]; /* reference */
@@ -1851,9 +1884,11 @@ void write_dset_in(hid_t loc_id,
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
- char buf13[24][STR_SIZE]= {"ab","cd","ef","gh","ij","kl","mn","pq",
- "rs","tu","vw","xz","AB","CD","EF","GH",
- "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
+ char buf13[4][3][2][STR_SIZE]= {{{"ab","cd"},{"ef","gh"},{"ij","kl"}},
+ {{"mn","pq"},{"rs","tu"},{"vw","xz"}},
+ {{"AB","CD"},{"EF","GH"},{"IJ","KL"}},
+ {{"MN","PQ"},{"RS","TU"},{"VW","XZ"}}}; /* string */
+ char *buf13a[4][3][2]; /* VL string */
char buf23[4][3][2]; /* bitfield, opaque */
s_t buf33[4][3][2]; /* compound */
hobj_ref_t buf43[4][3][2]; /* reference */
@@ -1878,17 +1913,22 @@ void write_dset_in(hid_t loc_id,
{
for (i=0; i<2; i++)
for (j=0; j<2; j++)
- {
buf1[i][j]='z';
- }
}
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid,STR_SIZE);
+ status = H5Tset_size(tid,(size_t)STR_SIZE);
write_dset(loc_id,1,dims,"string",tid,buf1);
status = H5Tclose(tid);
+ for (i=0; i<2; i++)
+ buf1a[i]=buf1[i];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_dset(loc_id,1,dims,"VLstring",tid,buf1a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -1917,7 +1957,7 @@ void write_dset_in(hid_t loc_id,
}
}
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_dset(loc_id,1,dims,"opaque",tid,buf2);
status = H5Tclose(tid);
@@ -2051,15 +2091,26 @@ void write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf12, 'z', sizeof buf12);
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ for (k=0; k<2; k++)
+ buf12[i][j][k]='z';
}
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid,STR_SIZE);
+ status = H5Tset_size(tid,(size_t)STR_SIZE);
write_dset(loc_id,2,dims2,"string2D",tid,buf12);
status = H5Tclose(tid);
+ for (i=0; i<3; i++)
+ for (j=0; j<2; j++)
+ buf12a[i][j]=buf12[i][j];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_dset(loc_id,2,dims2,"VLstring2D",tid,buf12a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -2079,7 +2130,7 @@ void write_dset_in(hid_t loc_id,
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_dset(loc_id,2,dims2,"opaque2D",tid,buf22);
status = H5Tclose(tid);
@@ -2135,8 +2186,6 @@ void write_dset_in(hid_t loc_id,
n = 0;
for(i = 0; i < 3; i++)
for(j = 0; j < 2; j++) {
- int l;
-
buf52[i][j].p = malloc((i + 1) * sizeof(int));
buf52[i][j].len = i + 1;
for(l = 0; l < i + 1; l++)
@@ -2213,14 +2262,27 @@ void write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf13,'z',sizeof buf13);
+ for (i=0; i<4; i++)
+ for (j=0; j<3; j++)
+ for (k=0; k<2; k++)
+ for (l=0; l<2; l++)
+ buf13[i][j][k][l]='z';
}
tid = H5Tcopy(H5T_C_S1);
- status = H5Tset_size(tid,STR_SIZE);
+ status = H5Tset_size(tid,(size_t)STR_SIZE);
write_dset(loc_id,3,dims3,"string3D",tid,buf13);
status = H5Tclose(tid);
+ for (i=0; i<4; i++)
+ for (j=0; j<3; j++)
+ for (k=0; k<2; k++)
+ buf13a[i][j][k]=buf13[i][j][k];
+ tid = H5Tcopy(H5T_C_S1);
+ status = H5Tset_size(tid, H5T_VARIABLE);
+ write_dset(loc_id,3,dims3,"VLstring3D",tid,buf13a);
+ status = H5Tclose(tid);
+
/*-------------------------------------------------------------------------
* H5T_BITFIELD
*-------------------------------------------------------------------------
@@ -2246,7 +2308,7 @@ void write_dset_in(hid_t loc_id,
* H5T_OPAQUE
*-------------------------------------------------------------------------
*/
- tid = H5Tcreate(H5T_OPAQUE, 1);
+ tid = H5Tcreate(H5T_OPAQUE, (size_t)1);
status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */
write_dset(loc_id,3,dims3,"opaque3D",tid,buf23);
status = H5Tclose(tid);
@@ -2316,8 +2378,6 @@ void write_dset_in(hid_t loc_id,
for(i = 0; i < 4; i++)
for(j = 0; j < 3; j++)
for(k = 0; k < 2; k++) {
- int l;
-
buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
buf53[i][j][k].len = i + 1;
for(l = 0; l < i + 1; l++)
@@ -2410,7 +2470,7 @@ void gen_datareg(hid_t fid,
int i;
/* allocate the buffer for write the references */
- rbuf = calloc(2, sizeof(hdset_reg_ref_t));
+ rbuf = calloc((size_t)2, sizeof(hdset_reg_ref_t));
/* allocate the buffer for write the data dataset */
buf = malloc(10 * 10 * sizeof(int));
@@ -2455,7 +2515,7 @@ void gen_datareg(hid_t fid,
coord[3][0]=2; coord[3][1]=5;
coord[4][0]=1; coord[4][1]=7;
}
- H5Sselect_elements(sid1,H5S_SELECT_SET,5,coord);
+ H5Sselect_elements(sid1,H5S_SELECT_SET,(size_t)5,(const hsize_t *)coord);
H5Sget_select_npoints(sid1);
/* store second dataset region */
@@ -2524,7 +2584,7 @@ int test_hyperslab(const char *fname,
goto out;
/* create a evenly divided buffer from 0 to 127 */
- buf = (char *)HDmalloc((unsigned)(nelmts * size));
+ buf = (char *)HDmalloc((size_t)(nelmts * size));
s = 1024 * 1024 / 127;
for(i = 0, j = 0, c = 0; i < 1024 * 1024; j++, i++) {
if(j == s) {