Skip to content

Commit bbdebee

Browse files
authored
These two generators create strings without NUL for testing (HDFGroup#4608)
1 parent cefadcf commit bbdebee

File tree

2 files changed

+55
-51
lines changed

2 files changed

+55
-51
lines changed

tools/test/h5dump/h5dumpgentest.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,7 +4064,7 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
40644064

40654065
/* create 1D attributes with dimension [2], 2 elements */
40664066
hsize_t dims[1] = {2};
4067-
char buf1[2][3] = {"ab", "de"}; /* string */
4067+
char buf1[2][2] = {"ab", "de"}; /* string, NO NUL fixed length */
40684068
char buf2[2] = {1, 2}; /* bitfield, opaque */
40694069
s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */
40704070
hobj_ref_t buf4[2]; /* reference */
@@ -4076,8 +4076,8 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
40764076

40774077
/* create 2D attributes with dimension [3][2], 6 elements */
40784078
hsize_t dims2[2] = {3, 2};
4079-
char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */
4080-
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
4079+
char buf12[6][2] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string, NO NUL fixed length */
4080+
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
40814081
s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */
40824082
hobj_ref_t buf42[3][2]; /* reference */
40834083
hvl_t buf52[3][2]; /* vlen */
@@ -4086,16 +4086,17 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
40864086
float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */
40874087

40884088
/* create 3D attributes with dimension [4][3][2], 24 elements */
4089-
hsize_t dims3[3] = {4, 3, 2};
4090-
char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz",
4091-
"AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */
4092-
char buf23[4][3][2]; /* bitfield, opaque */
4093-
s_t buf33[4][3][2]; /* compound */
4094-
hobj_ref_t buf43[4][3][2]; /* reference */
4095-
hvl_t buf53[4][3][2]; /* vlen */
4096-
int buf63[24][3]; /* array */
4097-
int buf73[4][3][2]; /* integer */
4098-
float buf83[4][3][2]; /* float */
4089+
hsize_t dims3[3] = {4, 3, 2};
4090+
char buf13[24][2] = {
4091+
"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", "AB",
4092+
"CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string, NO NUL fixed length */
4093+
char buf23[4][3][2]; /* bitfield, opaque */
4094+
s_t buf33[4][3][2]; /* compound */
4095+
hobj_ref_t buf43[4][3][2]; /* reference */
4096+
hvl_t buf53[4][3][2]; /* vlen */
4097+
int buf63[24][3]; /* array */
4098+
int buf73[4][3][2]; /* integer */
4099+
float buf83[4][3][2]; /* float */
40994100

41004101
/*-------------------------------------------------------------------------
41014102
* 1D attributes
@@ -4489,7 +4490,7 @@ write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
44894490

44904491
/* create 1D attributes with dimension [2], 2 elements */
44914492
hsize_t dims[1] = {2};
4492-
char buf1[2][3] = {"ab", "de"}; /* string */
4493+
char buf1[2][2] = {"ab", "de"}; /* string, NO NUL fixed length */
44934494
char buf2[2] = {1, 2}; /* bitfield, opaque */
44944495
s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */
44954496
hobj_ref_t buf4[2]; /* reference */
@@ -4501,8 +4502,8 @@ write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
45014502

45024503
/* create 2D attributes with dimension [3][2], 6 elements */
45034504
hsize_t dims2[2] = {3, 2};
4504-
char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */
4505-
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
4505+
char buf12[6][2] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string, NO NUL fixed length */
4506+
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
45064507
s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */
45074508
hobj_ref_t buf42[3][2]; /* reference */
45084509
hvl_t buf52[3][2]; /* vlen */
@@ -4511,16 +4512,17 @@ write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
45114512
float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */
45124513

45134514
/* create 3D attributes with dimension [4][3][2], 24 elements */
4514-
hsize_t dims3[3] = {4, 3, 2};
4515-
char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz",
4516-
"AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */
4517-
char buf23[4][3][2]; /* bitfield, opaque */
4518-
s_t buf33[4][3][2]; /* compound */
4519-
hobj_ref_t buf43[4][3][2]; /* reference */
4520-
hvl_t buf53[4][3][2]; /* vlen */
4521-
int buf63[24][3]; /* array */
4522-
int buf73[4][3][2]; /* integer */
4523-
float buf83[4][3][2]; /* float */
4515+
hsize_t dims3[3] = {4, 3, 2};
4516+
char buf13[24][2] = {
4517+
"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", "AB",
4518+
"CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string, NO NUL fixed length */
4519+
char buf23[4][3][2]; /* bitfield, opaque */
4520+
s_t buf33[4][3][2]; /* compound */
4521+
hobj_ref_t buf43[4][3][2]; /* reference */
4522+
hvl_t buf53[4][3][2]; /* vlen */
4523+
int buf63[24][3]; /* array */
4524+
int buf73[4][3][2]; /* integer */
4525+
float buf83[4][3][2]; /* float */
45244526

45254527
/*-------------------------------------------------------------------------
45264528
* 1D

tools/test/h5repack/h5repacktst.c

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,17 +3974,18 @@ write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
39743974
float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */
39753975

39763976
/* create 3D attributes with dimension [4][3][2], 24 elements */
3977-
hsize_t dims3[3] = {4, 3, 2};
3978-
hsize_t dims3r[3] = {1, 1, 1};
3979-
char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz",
3980-
"AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */
3981-
char buf23[4][3][2]; /* bitfield, opaque */
3982-
s_t buf33[4][3][2]; /* compound */
3983-
hobj_ref_t buf43[1][1][1]; /* reference */
3984-
hvl_t buf53[4][3][2]; /* vlen */
3985-
int buf63[24][3]; /* array */
3986-
int buf73[4][3][2]; /* integer */
3987-
float buf83[4][3][2]; /* float */
3977+
hsize_t dims3[3] = {4, 3, 2};
3978+
hsize_t dims3r[3] = {1, 1, 1};
3979+
char buf13[24][2] = {
3980+
"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", "AB",
3981+
"CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string, NO NUL fixed length */
3982+
char buf23[4][3][2]; /* bitfield, opaque */
3983+
s_t buf33[4][3][2]; /* compound */
3984+
hobj_ref_t buf43[1][1][1]; /* reference */
3985+
hvl_t buf53[4][3][2]; /* vlen */
3986+
int buf63[24][3]; /* array */
3987+
int buf73[4][3][2]; /* integer */
3988+
float buf83[4][3][2]; /* float */
39883989

39893990
/*-------------------------------------------------------------------------
39903991
* 1D
@@ -4789,7 +4790,7 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
47894790

47904791
/* create 1D attributes with dimension [2], 2 elements */
47914792
hsize_t dims[1] = {2};
4792-
char buf1[2][3] = {"ab", "de"}; /* string */
4793+
char buf1[2][2] = {"ab", "de"}; /* string, NO NUL fixed length */
47934794
char buf2[2] = {1, 2}; /* bitfield, opaque */
47944795
s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */
47954796
hobj_ref_t buf4[2]; /* reference */
@@ -4802,8 +4803,8 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
48024803

48034804
/* create 2D attributes with dimension [3][2], 6 elements */
48044805
hsize_t dims2[2] = {3, 2};
4805-
char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */
4806-
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
4806+
char buf12[6][2] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string, NO NUL fixed length */
4807+
char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */
48074808
s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */
48084809
hobj_ref_t buf42[3][2]; /* reference */
48094810
e_t buf452[3][2]; /* enum */
@@ -4813,17 +4814,18 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da
48134814
float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */
48144815

48154816
/* create 3D attributes with dimension [4][3][2], 24 elements */
4816-
hsize_t dims3[3] = {4, 3, 2};
4817-
char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz",
4818-
"AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */
4819-
char buf23[4][3][2]; /* bitfield, opaque */
4820-
s_t buf33[4][3][2]; /* compound */
4821-
hobj_ref_t buf43[4][3][2]; /* reference */
4822-
e_t buf453[4][3][2]; /* enum */
4823-
hvl_t buf53[4][3][2]; /* vlen */
4824-
int buf63[24][3]; /* array */
4825-
int buf73[4][3][2]; /* integer */
4826-
float buf83[4][3][2]; /* float */
4817+
hsize_t dims3[3] = {4, 3, 2};
4818+
char buf13[24][2] = {
4819+
"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", "AB",
4820+
"CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string, NO NUL fixed length */
4821+
char buf23[4][3][2]; /* bitfield, opaque */
4822+
s_t buf33[4][3][2]; /* compound */
4823+
hobj_ref_t buf43[4][3][2]; /* reference */
4824+
e_t buf453[4][3][2]; /* enum */
4825+
hvl_t buf53[4][3][2]; /* vlen */
4826+
int buf63[24][3]; /* array */
4827+
int buf73[4][3][2]; /* integer */
4828+
float buf83[4][3][2]; /* float */
48274829

48284830
/*-------------------------------------------------------------------------
48294831
* 1D attributes

0 commit comments

Comments
 (0)