Skip to content

Commit 9d2134e

Browse files
authored
Add missing test files to h5gentest --h5repack (#5791)
* Add missing test files to h5gentest --h5repack and update generator routines for type handling.
1 parent b0fb7eb commit 9d2134e

File tree

5 files changed

+150
-19
lines changed

5 files changed

+150
-19
lines changed

tools/test/h5dump/h5dumpgentest.c

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,12 @@ gent_softlink(void)
686686
#define NX 4
687687
#define NY 2
688688
int
689-
gent_softlink2(void)
689+
gent_softlink2(bool big_endian_committed)
690690
{
691691
hid_t fileid1 = H5I_INVALID_HID;
692692
hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID;
693-
hid_t datatype = H5I_INVALID_HID;
693+
hid_t target_type = H5I_INVALID_HID;
694+
hid_t datatype = H5I_INVALID_HID;
694695
hid_t dset1 = H5I_INVALID_HID, dset2 = H5I_INVALID_HID;
695696
hid_t dataspace = H5I_INVALID_HID;
696697
hsize_t dimsf[2]; /* dataset dimensions */
@@ -729,8 +730,22 @@ gent_softlink2(void)
729730
/*-----------------------------------------------------------------------
730731
* Named datatype
731732
*------------------------------------------------------------------------*/
732-
datatype = H5Tcopy(H5T_NATIVE_INT);
733-
status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
733+
if ((target_type = H5Tcopy(H5T_NATIVE_INT)) < 0) {
734+
fprintf(stderr, "Error: %s> H5Tcopy failed.\n", FILE4_1);
735+
status = FAIL;
736+
goto out;
737+
}
738+
739+
if (big_endian_committed) {
740+
if (H5Tset_order(target_type, H5T_ORDER_BE) < 0) {
741+
status = FAIL;
742+
goto out;
743+
}
744+
}
745+
746+
datatype = H5Tcopy(target_type);
747+
748+
status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
734749
if (status < 0) {
735750
fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", FILE4_1);
736751
status = FAIL;
@@ -748,13 +763,10 @@ gent_softlink2(void)
748763
dimsf[1] = NY;
749764
dataspace = H5Screate_simple(2, dimsf, NULL);
750765

751-
/*
752-
* We will store little endian INT numbers.
753-
*/
754-
755766
/*---------------
756767
* dset1
757768
*/
769+
758770
/* Create a new dataset as sample object */
759771
dset1 = H5Dcreate2(fileid1, "/dset1", H5T_STD_I32BE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
760772
if (dset1 < 0) {
@@ -774,14 +786,14 @@ gent_softlink2(void)
774786
* dset2
775787
*/
776788
/* Create a new dataset as sample object */
777-
dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
789+
dset2 = H5Dcreate2(fileid1, "/dset2", target_type, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
778790
if (dset2 < 0) {
779791
fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1);
780792
status = FAIL;
781793
goto out;
782794
}
783795

784-
status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2);
796+
status = H5Dwrite(dset2, target_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2);
785797
if (status < 0) {
786798
fprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1);
787799
status = FAIL;
@@ -2238,7 +2250,7 @@ gent_objref(void)
22382250
}
22392251

22402252
void
2241-
gent_datareg(void)
2253+
gent_datareg(bool undefined_fill_value)
22422254
{
22432255
/*some code is taken from enum.c in the test dir */
22442256

@@ -2247,6 +2259,7 @@ gent_datareg(void)
22472259
dset2; /* Dereferenced dataset ID */
22482260
hid_t sid1, /* Dataspace ID #1 */
22492261
sid2; /* Dataspace ID #2 */
2262+
hid_t dcpl_id = H5I_INVALID_HID;
22502263
hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
22512264
hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
22522265
hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
@@ -2272,8 +2285,16 @@ gent_datareg(void)
22722285
/* Create dataspace for datasets */
22732286
sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
22742287

2288+
dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
2289+
2290+
if (undefined_fill_value) {
2291+
/* Set the fill value to be undefined */
2292+
H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_IFSET);
2293+
H5Pset_fill_value(dcpl_id, H5I_INVALID_HID, NULL);
2294+
}
2295+
22752296
/* Create a dataset */
2276-
dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
2297+
dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
22772298

22782299
for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
22792300
*tu8++ = (uint8_t)(i * 3);
@@ -2288,7 +2309,7 @@ gent_datareg(void)
22882309
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
22892310

22902311
/* Create a dataset */
2291-
dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
2312+
dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
22922313

22932314
/* Create references */
22942315

@@ -2351,6 +2372,8 @@ gent_datareg(void)
23512372
/* Close file */
23522373
H5Fclose(fid1);
23532374

2375+
H5Pclose(dcpl_id);
2376+
23542377
/* Free memory buffers */
23552378
free(wbuf);
23562379
free(rbuf);

tools/test/h5dump/h5dumpgentest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void gent_dataset(void);
2222
void gent_dataset2(void);
2323
void gent_attribute(void);
2424
void gent_softlink(void);
25-
int gent_softlink2(void);
25+
int gent_softlink2(bool big_endian_committed);
2626
void gent_hardlink(void);
2727
void gent_extlink(void);
2828
void gent_udlink(void);
@@ -37,7 +37,7 @@ void gent_str(void);
3737
void gent_str2(void);
3838
void gent_enum(void);
3939
void gent_objref(void);
40-
void gent_datareg(void);
40+
void gent_datareg(bool undefined_fill_value);
4141
void gent_attrreg(void);
4242
void gent_nestcomp(void);
4343
void gent_opaque(void);

tools/test/h5gentest.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ gen_h5dump_files(void)
155155
gent_group();
156156
gent_attribute();
157157
gent_softlink();
158-
nerrors += (gent_softlink2() < 0 ? 1 : 0);
158+
nerrors += (gent_softlink2(false) < 0 ? 1 : 0);
159159
gent_dataset();
160160
gent_hardlink();
161161
gent_extlink();
@@ -171,7 +171,7 @@ gen_h5dump_files(void)
171171
gent_str2();
172172
gent_enum();
173173
gent_objref();
174-
gent_datareg();
174+
gent_datareg(false);
175175
gent_attrreg();
176176
gent_nestcomp();
177177
gent_opaque();
@@ -342,7 +342,25 @@ gen_h5repack_files(void)
342342
nerrors += (generate_f32le(external) < 0 ? 1 : 0);
343343
} /* end for external data storage or not */
344344

345+
Test_Extlink_Copy();
346+
347+
gent_group_creation_order();
348+
349+
gent_extlink();
350+
gent_extlinks();
351+
gent_softlink2(true);
352+
gent_attrreg();
353+
gent_datareg(true);
354+
gent_family();
355+
356+
nerrors += (gent_onion_1d_dset() < 0 ? 1 : 0);
357+
nerrors += (gent_onion_create_delete_objects() < 0 ? 1 : 0);
358+
nerrors += (gent_onion_dset_extension() < 0 ? 1 : 0);
359+
345360
nerrors += (make_h5repack_testfiles() < 0 ? 1 : 0);
361+
nerrors += (gen_filespaces() < 0 ? 1 : 0);
362+
363+
nerrors += (test_attributes(H5DIFF_FILE5, 0) < 0 ? 1 : 0);
346364
return nerrors;
347365
}
348366

@@ -405,12 +423,12 @@ gen_h5ls_files(void)
405423
gent_group();
406424
gent_dataset();
407425
gent_softlink();
408-
gent_softlink2();
426+
gent_softlink2(false);
409427
gent_str();
410428

411429
gent_vldatatypes();
412430
gent_compound_dt();
413-
gent_datareg();
431+
gent_datareg(false);
414432
gent_empty();
415433
gent_hardlink();
416434
gent_loop();

tools/test/h5repack/h5repackgentest.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626
#define FILE_UINT8BE "h5repack_uint8be"
2727
#define FILE_F32LE "h5repack_f32le"
2828

29+
#define NELMTS(X) (sizeof(X) / sizeof(X[0])) /* # of elements */
30+
31+
const char *FILENAMES[] = {
32+
"h5repack_fsm_aggr_nopersist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + not persisting free-space */
33+
"h5repack_fsm_aggr_persist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + persisting free-space */
34+
"h5repack_paged_nopersist.h5", /* H5F_FSPACE_STRATEGY_PAGE + not persisting free-space */
35+
"h5repack_paged_persist.h5", /* H5F_FSPACE_STRATEGY_PAGE + persisting free-space */
36+
"h5repack_aggr.h5", /* H5F_FSPACE_STRATEGY_AGGR */
37+
"h5repack_none.h5" /* H5F_FSPACE_STRATEGY_NONE */
38+
};
39+
40+
#define NUM_ELMTS 100
41+
2942
#define H5REPACKGENTEST_OOPS \
3043
{ \
3144
ret_value = -1; \
@@ -5760,4 +5773,80 @@ make_complex_attr_references(hid_t loc_id)
57605773
H5Tclose(vlen_regref_attr_tid);
57615774

57625775
return ret;
5776+
}
5777+
5778+
/* TODO: This is duplicated from gen_filespace.c. Eventually, this should be centralized somewhere. */
5779+
int
5780+
gen_filespaces(void)
5781+
{
5782+
hid_t fid = H5I_INVALID_HID; /* File ID */
5783+
hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
5784+
hid_t did = H5I_INVALID_HID; /* Dataset ID */
5785+
hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
5786+
hsize_t dim[1]; /* Dimension sizes */
5787+
int data[NUM_ELMTS]; /* Buffer for data */
5788+
int i, j; /* Local index variables */
5789+
H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
5790+
unsigned fs_persist; /* Persisting free-space or not */
5791+
5792+
j = 0;
5793+
for (fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES;
5794+
fs_strategy++) {
5795+
for (fs_persist = false; fs_persist <= true; fs_persist++) {
5796+
5797+
if (fs_persist && fs_strategy >= H5F_FSPACE_STRATEGY_AGGR)
5798+
continue;
5799+
5800+
/* Get a copy of the default file creation property */
5801+
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
5802+
goto error;
5803+
5804+
if (H5Pset_file_space_strategy(fcpl, fs_strategy, fs_persist, (hsize_t)1) < 0)
5805+
goto error;
5806+
5807+
/* Create the file with the file space info */
5808+
if ((fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
5809+
goto error;
5810+
5811+
/* Create the dataset */
5812+
dim[0] = NUM_ELMTS;
5813+
if ((sid = H5Screate_simple(1, dim, NULL)) < 0)
5814+
goto error;
5815+
if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) <
5816+
0)
5817+
goto error;
5818+
5819+
for (i = 0; i < NUM_ELMTS; i++)
5820+
data[i] = i;
5821+
5822+
/* Write the dataset */
5823+
if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
5824+
goto error;
5825+
5826+
/* Closing */
5827+
if (H5Dclose(did) < 0)
5828+
goto error;
5829+
if (H5Sclose(sid) < 0)
5830+
goto error;
5831+
if (H5Fclose(fid) < 0)
5832+
goto error;
5833+
if (H5Pclose(fcpl) < 0)
5834+
goto error;
5835+
++j;
5836+
}
5837+
}
5838+
assert(j == NELMTS(FILENAMES));
5839+
5840+
return 0;
5841+
5842+
error:
5843+
H5E_BEGIN_TRY
5844+
{
5845+
H5Sclose(sid);
5846+
H5Sclose(did);
5847+
H5Pclose(fcpl);
5848+
H5Fclose(fid);
5849+
}
5850+
H5E_END_TRY
5851+
return -1;
57635852
}

tools/test/h5repack/h5repackgentest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int generate_uint8be(bool external);
2222
int generate_f32le(bool external);
2323
int make_h5repack_testfiles(void);
2424
int verify_userblock(const char *filename);
25+
int gen_filespaces(void);
2526

2627
/* fill value test */
2728
#define H5REPACK_FNAME0 "h5repack_fill.h5"

0 commit comments

Comments
 (0)