diff options
Diffstat (limited to 'test/tmisc.c')
-rw-r--r-- | test/tmisc.c | 482 |
1 files changed, 319 insertions, 163 deletions
diff --git a/test/tmisc.c b/test/tmisc.c index c43f54f..a8103af 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -451,6 +451,9 @@ test_misc2_write_attribute(void) char *string_att1 = strdup("string attribute in file one"); char *string_att2 = strdup("string attribute in file two"); + memset(&data, 0, sizeof(data)); + memset(&data_check, 0, sizeof(data_check)); + type = misc2_create_type(); dataspace = H5Screate(H5S_SCALAR); @@ -1148,6 +1151,7 @@ test_misc7(void) { hid_t fid, did, tid, sid; int enum_value = 1; + bool vol_is_native; herr_t ret; /* Output message about test being performed */ @@ -1159,6 +1163,14 @@ test_misc7(void) fid = H5Fcreate(MISC7_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, fid, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + CHECK(H5Fclose(fid), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + /* Create the dataspace */ sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); @@ -1255,10 +1267,10 @@ test_misc8(void) hsize_t storage_size; /* Number of bytes of raw data storage used */ int *wdata; /* Data to write */ int *tdata; /* Temporary pointer to data write */ -#ifdef VERIFY_DATA - int *rdata; /* Data to read */ - int *tdata2; /* Temporary pointer to data to read */ -#endif /* VERIFY_DATA */ +#ifndef H5_HAVE_PARALLEL + int *rdata; /* Data to read */ + int *tdata2; /* Temporary pointer to data to read */ +#endif unsigned u, v; /* Local index variables */ int mdc_nelmts; /* Metadata number of elements */ size_t rdcc_nelmts; /* Raw data number of elements */ @@ -1266,25 +1278,12 @@ test_misc8(void) double rdcc_w0; /* Raw data write percentage */ hsize_t start[MISC8_RANK]; /* Hyperslab start */ hsize_t count[MISC8_RANK]; /* Hyperslab block count */ + bool vol_is_native; herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing dataset storage sizes\n")); - /* Allocate space for the data to write & read */ - wdata = (int *)malloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); - CHECK_PTR(wdata, "malloc"); -#ifdef VERIFY_DATA - rdata = (int *)malloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); - CHECK_PTR(rdata, "malloc"); -#endif /* VERIFY_DATA */ - - /* Initialize values */ - tdata = wdata; - for (u = 0; u < MISC8_DIM0; u++) - for (v = 0; v < MISC8_DIM1; v++) - *tdata++ = (int)(((u * MISC8_DIM1) + v) % 13); - /* Create a file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(fapl, FAIL, "H5Pcreate"); @@ -1308,6 +1307,28 @@ test_misc8(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5I_INVALID_HID, fid, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + CHECK(H5Fclose(fid), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + + /* Allocate space for the data to write & read */ + wdata = (int *)malloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); + CHECK_PTR(wdata, "malloc"); +#ifndef H5_HAVE_PARALLEL + rdata = (int *)malloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); + CHECK_PTR(rdata, "malloc"); +#endif + + /* Initialize values */ + tdata = wdata; + for (u = 0; u < MISC8_DIM0; u++) + for (v = 0; v < MISC8_DIM1; v++) + *tdata++ = (int)(((u * MISC8_DIM1) + v) % 13); + /* Create a simple dataspace */ sid = H5Screate_simple(rank, dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); @@ -1537,7 +1558,6 @@ test_misc8(void) ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Dwrite"); -#ifdef VERIFY_DATA /* Read data */ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); @@ -1550,7 +1570,6 @@ test_misc8(void) if (*tdata != *tdata2) TestErrPrintf("Error on line %d: u=%u, v=%d, *tdata=%d, *tdata2=%d\n", __LINE__, (unsigned)u, (unsigned)v, (int)*tdata, (int)*tdata2); -#endif /* VERIFY_DATA */ /* Check the storage size after data is written */ storage_size = H5Dget_storage_size(did); @@ -1632,7 +1651,6 @@ test_misc8(void) ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Dwrite"); -#ifdef VERIFY_DATA /* Read data */ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); @@ -1645,7 +1663,6 @@ test_misc8(void) if (*tdata != *tdata2) TestErrPrintf("Error on line %d: u=%u, v=%d, *tdata=%d, *tdata2=%d\n", __LINE__, (unsigned)u, (unsigned)v, (int)*tdata, (int)*tdata2); -#endif /* VERIFY_DATA */ /* Check the storage size after data is written */ storage_size = H5Dget_storage_size(did); @@ -1697,7 +1714,6 @@ test_misc8(void) ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Dwrite"); -#ifdef VERIFY_DATA /* Read data */ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); @@ -1710,7 +1726,6 @@ test_misc8(void) if (*tdata != *tdata2) TestErrPrintf("Error on line %d: u=%u, v=%d, *tdata=%d, *tdata2=%d\n", __LINE__, (unsigned)u, (unsigned)v, (int)*tdata, (int)*tdata2); -#endif /* VERIFY_DATA */ /* Check the storage size after data is written */ storage_size = H5Dget_storage_size(did); @@ -1744,9 +1759,9 @@ test_misc8(void) /* Free the read & write buffers */ free(wdata); -#ifdef VERIFY_DATA +#ifndef H5_HAVE_PARALLEL free(rdata); -#endif /* VERIFY_DATA */ +#endif } /* end test_misc8() */ /**************************************************************** @@ -1800,25 +1815,35 @@ test_misc10(void) hid_t dcpl; /* Dataset creation property list */ hid_t space, type; /* Old dataset's dataspace & datatype */ const char *testfile = H5_get_srcdir_filename(MISC10_FILE_OLD); /* Corrected test file name */ + bool vol_is_native; bool driver_is_default_compatible; herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing using old dataset creation property list\n")); - ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); - CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); - - if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); - return; - } - /* * Open the old file and the dataset and get old settings. */ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fopen"); + + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, file, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + CHECK(H5Fclose(file), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + /* Check if VFD used is native file format compatible */ + CHECK(h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible), FAIL, + "h5_driver_is_default_vfd_compatible"); + if (!driver_is_default_compatible) { + CHECK(H5Fclose(file), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); @@ -1884,7 +1909,8 @@ test_misc11(void) H5F_fspace_strategy_t strategy; /* File space strategy */ hsize_t threshold; /* Free-space section threshold */ bool persist; /* To persist free-space or not */ - herr_t ret; /* Generic return value */ + bool vol_is_native; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing file creation properties retrieved correctly\n")); @@ -1897,12 +1923,17 @@ test_misc11(void) file = H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); - /* Get the file's version information */ - ret = H5Fget_info2(file, &finfo); - CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 0, "H5Fget_info2"); - VERIFY(finfo.free.version, 0, "H5Fget_info2"); - VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, file, &vol_is_native), FAIL, "h5_using_native_vol"); + + if (vol_is_native) { + /* Get the file's version information */ + ret = H5Fget_info2(file, &finfo); + CHECK(ret, FAIL, "H5Fget_info2"); + VERIFY(finfo.super.version, 0, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + } /* Close file */ ret = H5Fclose(file); @@ -1955,16 +1986,21 @@ test_misc11(void) file = H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, file, &vol_is_native), FAIL, "h5_using_native_vol"); + /* Close FCPL */ ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Get the file's version information */ - ret = H5Fget_info2(file, &finfo); - CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 2, "H5Fget_info2"); - VERIFY(finfo.free.version, 0, "H5Fget_info2"); - VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + if (vol_is_native) { + /* Get the file's version information */ + ret = H5Fget_info2(file, &finfo); + CHECK(ret, FAIL, "H5Fget_info2"); + VERIFY(finfo.super.version, 2, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + } /* Close file */ ret = H5Fclose(file); @@ -1974,16 +2010,21 @@ test_misc11(void) file = H5Fopen(MISC11_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, file, &vol_is_native), FAIL, "h5_using_native_vol"); + /* Get the file's creation property list */ fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); - /* Get the file's version information */ - ret = H5Fget_info2(file, &finfo); - CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 2, "H5Fget_info2"); - VERIFY(finfo.free.version, 0, "H5Fget_info2"); - VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + if (vol_is_native) { + /* Get the file's version information */ + ret = H5Fget_info2(file, &finfo); + CHECK(ret, FAIL, "H5Fget_info2"); + VERIFY(finfo.super.version, 2, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); + } /* Retrieve all the property values & check them */ ret = H5Pget_userblock(fcpl, &userblock); @@ -2500,6 +2541,12 @@ test_misc13(void) unsigned *data = NULL; /* Data to write to dataset */ hsize_t userblock_size; /* Correct size of userblock */ bool check_for_new_dataset; /* Whether to check for the post-userblock-creation dataset */ + bool vol_is_native; + + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) + return; /* Create a data buffer for the datasets */ data = (unsigned *)calloc(MISC13_DIM1, sizeof(unsigned)); @@ -2830,6 +2877,9 @@ test_misc16(void) hsize_t dims[] = {MISC16_SPACE_DIM}; int i; + memset(wdata, 0, sizeof(wdata)); + memset(rdata, 0, sizeof(rdata)); + /* Initialize the data */ /* (Note that these are supposed to stress the code, so are a little weird) */ memcpy(wdata[0], "1234567", MISC16_STR_SIZE); @@ -2918,6 +2968,9 @@ test_misc17(void) hsize_t dims[] = {MISC17_SPACE_DIM1, MISC17_SPACE_DIM2}; int i; + memset(wdata, 0, sizeof(wdata)); + memset(rdata, 0, sizeof(rdata)); + /* Initialize the data */ /* (Note that these are supposed to stress the code, so are a little weird) */ memcpy(wdata[0], "1234567", MISC17_SPACE_DIM2); @@ -3003,12 +3056,16 @@ test_misc18(void) H5O_native_info_t ninfo; /* Native file format information about object */ char attr_name[32]; /* Attribute name buffer */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + bool vol_is_native; + herr_t ret; /* Generic return value */ /* Create the file */ fid = H5Fcreate(MISC18_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, fid, &vol_is_native), FAIL, "h5_using_native_vol"); + /* Create dataspace for attributes */ sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); @@ -3021,22 +3078,25 @@ test_misc18(void) ret = H5Oget_info_by_name3(fid, MISC18_DSET1_NAME, &oinfo, H5O_INFO_NUM_ATTRS, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 0, "H5Oget_info_by_name"); + + if (vol_is_native) { #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, - H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.total, 272, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.free, 152, "H5Oget_info_by_name"); - VERIFY(old_oinfo.num_attrs, 0, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.total, 272, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.free, 152, "H5Oget_info_by_name"); + VERIFY(old_oinfo.num_attrs, 0, "H5Oget_info_by_name"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - ret = H5Oget_native_info_by_name(fid, MISC18_DSET1_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nmesgs, 6, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nchunks, 1, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.total, 272, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.free, 152, "H5Oget_native_info_by_name"); + ret = H5Oget_native_info_by_name(fid, MISC18_DSET1_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nmesgs, 6, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nchunks, 1, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.total, 272, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.free, 152, "H5Oget_native_info_by_name"); + } /* Create second dataset */ did2 = H5Dcreate2(fid, MISC18_DSET2_NAME, H5T_STD_U32LE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3046,22 +3106,25 @@ test_misc18(void) ret = H5Oget_info_by_name3(fid, MISC18_DSET2_NAME, &oinfo, H5O_INFO_NUM_ATTRS, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 0, "H5Oget_info_by_name"); + + if (vol_is_native) { #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, - H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.total, 272, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.free, 152, "H5Oget_info_by_name"); - VERIFY(old_oinfo.num_attrs, 0, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.total, 272, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.free, 152, "H5Oget_info_by_name"); + VERIFY(old_oinfo.num_attrs, 0, "H5Oget_info_by_name"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - ret = H5Oget_native_info_by_name(fid, MISC18_DSET2_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nmesgs, 6, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nchunks, 1, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.total, 272, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.free, 152, "H5Oget_native_info_by_name"); + ret = H5Oget_native_info_by_name(fid, MISC18_DSET2_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nmesgs, 6, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nchunks, 1, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.total, 272, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.free, 152, "H5Oget_native_info_by_name"); + } /* Loop creating attributes on each dataset, flushing them to the file each time */ for (u = 0; u < 10; u++) { @@ -3091,43 +3154,49 @@ test_misc18(void) ret = H5Oget_info_by_name3(fid, MISC18_DSET1_NAME, &oinfo, H5O_INFO_NUM_ATTRS, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 10, "H5Oget_info_by_name"); + + if (vol_is_native) { #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, - H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.total, 888, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.free, 16, "H5Oget_info_by_name"); - VERIFY(old_oinfo.num_attrs, 10, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.total, 888, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.free, 16, "H5Oget_info_by_name"); + VERIFY(old_oinfo.num_attrs, 10, "H5Oget_info_by_name"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - ret = H5Oget_native_info_by_name(fid, MISC18_DSET1_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nmesgs, 24, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nchunks, 9, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.total, 888, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.free, 16, "H5Oget_native_info_by_name"); + ret = H5Oget_native_info_by_name(fid, MISC18_DSET1_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nmesgs, 24, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nchunks, 9, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.total, 888, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.free, 16, "H5Oget_native_info_by_name"); + } /* Get object information for dataset #2 now */ ret = H5Oget_info_by_name3(fid, MISC18_DSET2_NAME, &oinfo, H5O_INFO_NUM_ATTRS, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 10, "H5Oget_info_by_name"); + + if (vol_is_native) { #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, - H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.total, 888, "H5Oget_info_by_name"); - VERIFY(old_oinfo.hdr.space.free, 16, "H5Oget_info_by_name"); - VERIFY(old_oinfo.num_attrs, 10, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.total, 888, "H5Oget_info_by_name"); + VERIFY(old_oinfo.hdr.space.free, 16, "H5Oget_info_by_name"); + VERIFY(old_oinfo.num_attrs, 10, "H5Oget_info_by_name"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - ret = H5Oget_native_info_by_name(fid, MISC18_DSET2_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_mative_info_by_name"); - VERIFY(ninfo.hdr.nmesgs, 24, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.nchunks, 9, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.total, 888, "H5Oget_native_info_by_name"); - VERIFY(ninfo.hdr.space.free, 16, "H5Oget_native_info_by_name"); + ret = H5Oget_native_info_by_name(fid, MISC18_DSET2_NAME, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_mative_info_by_name"); + VERIFY(ninfo.hdr.nmesgs, 24, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.nchunks, 9, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.total, 888, "H5Oget_native_info_by_name"); + VERIFY(ninfo.hdr.space.free, 16, "H5Oget_native_info_by_name"); + } /* Close second dataset */ ret = H5Dclose(did2); @@ -3702,17 +3771,30 @@ test_misc20(void) unsigned version; /* Version of storage layout info */ hsize_t contig_size; /* Size of contiguous storage size from layout into */ const char *testfile = H5_get_srcdir_filename(MISC20_FILE_OLD); /* Corrected test file name */ + bool vol_is_native; bool driver_is_default_compatible; herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing large dimension truncation fix\n")); - ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); - CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); + /* Create the file */ + fid = H5Fcreate(MISC20_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, fid, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + CHECK(H5Fclose(fid), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + /* Check if VFD used is native file format compatible */ + CHECK(h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible), FAIL, + "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + CHECK(H5Fclose(fid), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } @@ -3730,10 +3812,6 @@ test_misc20(void) * been truncated. */ - /* Create the file */ - fid = H5Fcreate(MISC20_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fcreate"); - /* Create dataspace with _really_ big dimensions */ sid = H5Screate_simple(rank, big_dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); @@ -4400,22 +4478,27 @@ test_misc23(void) * test H5Lcreate_external() **********************************************************************/ - status = H5Lcreate_external("fake_filename", "fake_path", file_id, "/A/B20/grp", create_id, access_id); - CHECK(status, FAIL, "H5Lcreate_external"); + if (vol_cap_flags_g & H5VL_CAP_FLAG_EXTERNAL_LINKS) { + status = + H5Lcreate_external("fake_filename", "fake_path", file_id, "/A/B20/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lcreate_external"); - tri_status = H5Lexists(file_id, "/A/B20/grp", access_id); - VERIFY(tri_status, true, "H5Lexists"); + tri_status = H5Lexists(file_id, "/A/B20/grp", access_id); + VERIFY(tri_status, true, "H5Lexists"); + } /********************************************************************** * test H5Lcreate_ud() **********************************************************************/ - status = - H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t)9, create_id, access_id); - CHECK(status, FAIL, "H5Lcreate_ud"); + if (vol_cap_flags_g & H5VL_CAP_FLAG_UD_LINKS) { + status = H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t)9, create_id, + access_id); + CHECK(status, FAIL, "H5Lcreate_ud"); - tri_status = H5Lexists(file_id, "/A/B21/grp", access_id); - VERIFY(tri_status, true, "H5Lexists"); + tri_status = H5Lexists(file_id, "/A/B21/grp", access_id); + VERIFY(tri_status, true, "H5Lexists"); + } /********************************************************************** * close @@ -4998,17 +5081,25 @@ test_misc25b(void) hid_t fid; /* File ID */ hid_t gid; /* Group ID */ const char *testfile = H5_get_srcdir_filename(MISC25B_FILE); /* Corrected test file name */ + bool vol_is_native; bool driver_is_default_compatible; herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Exercise null object header message bug\n")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } @@ -5259,17 +5350,25 @@ test_misc27(void) hid_t fid; /* File ID */ hid_t gid; /* Group ID */ const char *testfile = H5_get_srcdir_filename(MISC27_FILE); /* Corrected test file name */ + bool vol_is_native; bool driver_is_default_compatible; herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Corrupt object header handling\n")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } @@ -5324,6 +5423,7 @@ test_misc28(void) int nused; char buf[MISC28_SIZE]; int i; + bool vol_is_native; herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -5350,17 +5450,22 @@ test_misc28(void) fid = H5Fcreate(MISC28_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(fid, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(fapl, fid, &vol_is_native), FAIL, "h5_using_native_vol"); + sidf = H5Screate_simple(2, dims, NULL); CHECK(sidf, FAIL, "H5Screate_simple"); did = H5Dcreate2(fid, "dataset", H5T_NATIVE_CHAR, sidf, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); - /* Verify that the chunk cache is empty */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)0, "H5D__current_cache_size_test"); - VERIFY(nused, 0, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that the chunk cache is empty */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)0, "H5D__current_cache_size_test"); + VERIFY(nused, 0, "H5D__current_cache_size_test"); + } /* Initialize write buffer */ for (i = 0; i < MISC28_SIZE; i++) @@ -5377,11 +5482,13 @@ test_misc28(void) ret = H5Dwrite(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf); CHECK(ret, FAIL, "H5Dwrite"); - /* Verify that all 10 chunks written have been cached */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that all 10 chunks written have been cached */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + } /* Initialize write buffer */ for (i = 0; i < MISC28_SIZE; i++) @@ -5396,11 +5503,13 @@ test_misc28(void) ret = H5Dwrite(did, H5T_NATIVE_CHAR, sidm, sidf, H5P_DEFAULT, buf); CHECK(ret, FAIL, "H5Dwrite"); - /* Verify that the size of the cache remains at 10 */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that the size of the cache remains at 10 */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + } /* Close dataset */ ret = H5Dclose(did); @@ -5410,11 +5519,13 @@ test_misc28(void) did = H5Dopen2(fid, "dataset", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen2"); - /* Verify that the chunk cache is empty */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)0, "H5D__current_cache_size_test"); - VERIFY(nused, 0, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that the chunk cache is empty */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)0, "H5D__current_cache_size_test"); + VERIFY(nused, 0, "H5D__current_cache_size_test"); + } /* Select hyperslabe for reading */ start[1] = 0; @@ -5429,11 +5540,13 @@ test_misc28(void) for (i = 0; i < MISC28_SIZE; i++) VERIFY(buf[i], i, "H5Dread"); - /* Verify that all 10 chunks read have been cached */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that all 10 chunks read have been cached */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + } /* Select new hyperslab */ start[1] = 1; @@ -5448,11 +5561,13 @@ test_misc28(void) for (i = 0; i < MISC28_SIZE; i++) VERIFY(buf[i], MISC28_SIZE - 1 - i, "H5Dread"); - /* Verify that the size of the cache remains at 10 */ - ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); - CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); - VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + if (vol_is_native) { + /* Verify that the size of the cache remains at 10 */ + ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); + CHECK(ret, FAIL, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)MISC28_SIZE, "H5D__current_cache_size_test"); + VERIFY(nused, MISC28_SIZE, "H5D__current_cache_size_test"); + } /* Close dataset */ ret = H5Dclose(did); @@ -5482,6 +5597,7 @@ test_misc28(void) static void test_misc29(void) { + bool vol_is_native; bool driver_is_default_compatible; hid_t fid; /* File ID */ herr_t ret; /* Generic return value */ @@ -5489,11 +5605,18 @@ test_misc29(void) /* Output message about test being performed */ MESSAGE(5, ("Speculative metadata reads\n")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } @@ -5541,10 +5664,18 @@ test_misc30(void) { hsize_t file_size[] = {0, 0}; /* Sizes of file created */ unsigned get_info; /* Whether to perform the get info call */ + bool vol_is_native; /* Output message about test being performed */ MESSAGE(5, ("Local heap dropping free block info\n")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + for (get_info = false; get_info <= true; get_info++) { hid_t fid; /* File ID */ hid_t gid; /* Group ID */ @@ -5610,8 +5741,9 @@ test_misc31(void) hid_t attr_id; /* Attribute id */ hid_t group_id; /* Group id */ hid_t dtype_id; /* Datatype id */ - herr_t ret; /* Generic return value */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + bool vol_is_native; + herr_t ret; /* Generic return value */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Output message about test being performed */ MESSAGE(5, ("Deprecated routines initialize after H5close()\n")); @@ -5620,6 +5752,14 @@ test_misc31(void) file_id = H5Fcreate(MISC31_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fcreate"); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, file_id, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + CHECK(H5Fclose(file_id), FAIL, "H5Fclose"); + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + /* Test dataset package */ space_id = H5Screate(H5S_SCALAR); CHECK(space_id, FAIL, "H5Screate"); @@ -5774,17 +5914,25 @@ test_misc33(void) hid_t fid = H5I_INVALID_HID; /* File ID */ const char *testfile = H5_get_srcdir_filename(MISC33_FILE); /* Corrected test file name */ H5O_info2_t oinfo; /* Structure for object metadata information */ + bool vol_is_native; bool driver_is_default_compatible; herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing that bad offset into the heap returns error")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } @@ -6072,6 +6220,7 @@ static void test_misc37(void) { const char *testfile = H5_get_srcdir_filename(CVE_2020_10812_FILENAME); + bool vol_is_native; bool driver_is_default_compatible; hid_t fid; herr_t ret; @@ -6079,11 +6228,18 @@ test_misc37(void) /* Output message about test being performed */ MESSAGE(5, ("Fix for HDFFV-11052/CVE-2020-10812")); + /* Check if native VOL is being used */ + CHECK(h5_using_native_vol(H5P_DEFAULT, H5I_INVALID_HID, &vol_is_native), FAIL, "h5_using_native_vol"); + if (!vol_is_native) { + MESSAGE(5, (" -- SKIPPED --\n")); + return; + } + ret = h5_driver_is_default_vfd_compatible(H5P_DEFAULT, &driver_is_default_compatible); CHECK(ret, FAIL, "h5_driver_is_default_vfd_compatible"); if (!driver_is_default_compatible) { - printf("-- SKIPPED --\n"); + MESSAGE(5, (" -- SKIPPED --\n")); return; } |