summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c171
-rw-r--r--test/objcopy.c64
-rw-r--r--test/vol.c26
3 files changed, 176 insertions, 85 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 37fc8c7..bd55491 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -5965,34 +5965,37 @@ error:
*
* Purpose: Tests functions of encoding and decoding datatype.
*
- * Return: Success: 0
- *
- * Failure: number of errors
- *
- * Programmer: Raymond Lu
- * July 14, 2004
- *
+ * Return: Success: 0
+ * Failure: number of errors
*-------------------------------------------------------------------------
*/
static int
test_encode(void)
{
- struct s1 {
+ struct cmpd {
int a;
float b;
long c;
double d;
};
- hid_t file = -1, tid1 = -1, tid2 = -1, tid3 = -1;
- hid_t decoded_tid1 = -1, decoded_tid2 = -1, decoded_tid3 = -1;
+ hid_t file = H5I_INVALID_HID;
+ hid_t tid1 = H5I_INVALID_HID;
+ hid_t tid2 = H5I_INVALID_HID;
+ hid_t tid3 = H5I_INVALID_HID;
+ hid_t decoded_tid1 = H5I_INVALID_HID;
+ hid_t decoded_tid2 = H5I_INVALID_HID;
+ hid_t decoded_tid3 = H5I_INVALID_HID;
char filename[1024];
- char compnd_type[] = "Compound_type", enum_type[] = "Enum_type";
- char vlstr_type[] = "VLstring_type";
+ char compnd_type[] = "Compound_type";
+ char enum_type[] = "Enum_type";
+ char vlstr_type[] = "VLstring_type";
short enum_val;
size_t cmpd_buf_size = 0;
size_t enum_buf_size = 0;
size_t vlstr_buf_size = 0;
- unsigned char *cmpd_buf = NULL, *enum_buf = NULL, *vlstr_buf = NULL;
+ unsigned char *cmpd_buf = NULL;
+ unsigned char *enum_buf = NULL;
+ unsigned char *vlstr_buf = NULL;
hid_t ret_id;
herr_t ret;
@@ -6008,75 +6011,75 @@ test_encode(void)
*-----------------------------------------------------------------------
*/
/* Create a compound datatype */
- if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) {
+ if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd))) < 0) {
H5_FAILED();
HDprintf("Can't create datatype!\n");
goto error;
- } /* end if */
- if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) {
+ }
+ if (H5Tinsert(tid1, "a", HOFFSET(struct cmpd, a), H5T_NATIVE_INT) < 0) {
H5_FAILED();
HDprintf("Can't insert field 'a'\n");
goto error;
- } /* end if */
- if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) {
+ }
+ if (H5Tinsert(tid1, "b", HOFFSET(struct cmpd, b), H5T_NATIVE_FLOAT) < 0) {
H5_FAILED();
HDprintf("Can't insert field 'b'\n");
goto error;
- } /* end if */
- if (H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) {
+ }
+ if (H5Tinsert(tid1, "c", HOFFSET(struct cmpd, c), H5T_NATIVE_LONG) < 0) {
H5_FAILED();
HDprintf("Can't insert field 'c'\n");
goto error;
- } /* end if */
- if (H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) {
+ }
+ if (H5Tinsert(tid1, "d", HOFFSET(struct cmpd, d), H5T_NATIVE_DOUBLE) < 0) {
H5_FAILED();
HDprintf("Can't insert field 'd'\n");
goto error;
- } /* end if */
+ }
/* Create a enumerate datatype */
if ((tid2 = H5Tcreate(H5T_ENUM, sizeof(short))) < 0) {
H5_FAILED();
HDprintf("Can't create enumerate type\n");
goto error;
- } /* end if */
+ }
if (H5Tenum_insert(tid2, "RED", (enum_val = 0, &enum_val)) < 0) {
H5_FAILED();
HDprintf("Can't insert field into enumeration type\n");
goto error;
- } /* end if */
+ }
if (H5Tenum_insert(tid2, "GREEN", (enum_val = 1, &enum_val)) < 0) {
H5_FAILED();
HDprintf("Can't insert field into enumeration type\n");
goto error;
- } /* end if */
+ }
if (H5Tenum_insert(tid2, "BLUE", (enum_val = 2, &enum_val)) < 0) {
H5_FAILED();
HDprintf("Can't insert field into enumeration type\n");
goto error;
- } /* end if */
+ }
if (H5Tenum_insert(tid2, "ORANGE", (enum_val = 3, &enum_val)) < 0) {
H5_FAILED();
HDprintf("Can't insert field into enumeration type\n");
goto error;
- } /* end if */
+ }
if (H5Tenum_insert(tid2, "YELLOW", (enum_val = 4, &enum_val)) < 0) {
H5_FAILED();
HDprintf("Can't insert field into enumeration type\n");
goto error;
- } /* end if */
+ }
/* Create a variable-length string type */
if ((tid3 = H5Tcopy(H5T_C_S1)) < 0) {
H5_FAILED();
HDprintf("Can't copy a string type\n");
goto error;
- } /* end if */
+ }
if (H5Tset_size(tid3, H5T_VARIABLE) < 0) {
H5_FAILED();
HDprintf("Can't the string type to be variable-length\n");
goto error;
- } /* end if */
+ }
/*-----------------------------------------------------------------------
* Test encoding and decoding compound, enumerate, and VL string datatypes
@@ -6087,12 +6090,12 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode compound type\n");
goto error;
- } /* end if */
+ }
if (cmpd_buf_size > 0)
cmpd_buf = (unsigned char *)HDcalloc((size_t)1, cmpd_buf_size);
- /* Try decoding bogus buffer */
+ /* Try decoding an incorrect (empty) buffer (should fail) */
H5E_BEGIN_TRY
{
ret_id = H5Tdecode(cmpd_buf);
@@ -6100,7 +6103,7 @@ test_encode(void)
H5E_END_TRY;
if (ret_id != FAIL) {
H5_FAILED();
- HDprintf("Decoded bogus buffer!\n");
+ HDprintf("Decoded an empty buffer!\n");
goto error;
}
@@ -6108,7 +6111,7 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode compound type\n");
goto error;
- } /* end if */
+ }
/* Decode from the compound buffer and return an object handle */
if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0)
@@ -6119,26 +6122,26 @@ test_encode(void)
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/* Query member number and member index by name, for compound type. */
if (H5Tget_nmembers(decoded_tid1) != 4) {
H5_FAILED();
HDprintf("Can't get member number\n");
goto error;
- } /* end if */
+ }
if (H5Tget_member_index(decoded_tid1, "c") != 2) {
H5_FAILED();
HDprintf("Can't get correct index number\n");
goto error;
- } /* end if */
+ }
/* Encode enumerate type in a buffer */
if (H5Tencode(tid2, NULL, &enum_buf_size) < 0) {
H5_FAILED();
HDprintf("Can't encode enumerate type\n");
goto error;
- } /* end if */
+ }
if (enum_buf_size > 0)
enum_buf = (unsigned char *)HDcalloc((size_t)1, enum_buf_size);
@@ -6147,40 +6150,40 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode enumerate type\n");
goto error;
- } /* end if */
+ }
/* Decode from the enumerate buffer and return an object handle */
if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) {
H5_FAILED();
HDprintf("Can't decode enumerate type\n");
goto error;
- } /* end if */
+ }
/* Verify that the datatype was copied exactly */
if (H5Tequal(decoded_tid2, tid2) <= 0) {
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/* Query member number and member index by name, for enumeration type. */
if (H5Tget_nmembers(decoded_tid2) != 5) {
H5_FAILED();
HDprintf("Can't get member number\n");
goto error;
- } /* end if */
+ }
if (H5Tget_member_index(decoded_tid2, "ORANGE") != 3) {
H5_FAILED();
HDprintf("Can't get correct index number\n");
goto error;
- } /* end if */
+ }
/* Encode VL string type in a buffer */
if (H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
H5_FAILED();
HDprintf("Can't encode VL string type\n");
goto error;
- } /* end if */
+ }
if (vlstr_buf_size > 0)
vlstr_buf = (unsigned char *)HDcalloc((size_t)1, vlstr_buf_size);
@@ -6189,26 +6192,26 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode VL string type\n");
goto error;
- } /* end if */
+ }
/* Decode from the VL string buffer and return an object handle */
if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) {
H5_FAILED();
HDprintf("Can't decode VL string type\n");
goto error;
- } /* end if */
+ }
/* Verify that the datatype was copied exactly */
if (H5Tequal(decoded_tid3, tid3) <= 0) {
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
if (!H5Tis_variable_str(decoded_tid3)) {
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/*-----------------------------------------------------------------------
* Commit and reopen the compound, enumerate, VL string datatypes
@@ -6219,17 +6222,17 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't commit compound datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(tid1) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(decoded_tid1) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
HDfree(cmpd_buf);
cmpd_buf_size = 0;
@@ -6238,17 +6241,17 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't commit compound datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(tid2) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(decoded_tid2) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
HDfree(enum_buf);
enum_buf_size = 0;
@@ -6257,17 +6260,17 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't commit vl string datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(tid3) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(decoded_tid3) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
HDfree(vlstr_buf);
vlstr_buf_size = 0;
@@ -6288,7 +6291,7 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode compound type\n");
goto error;
- } /* end if */
+ }
if (cmpd_buf_size > 0)
cmpd_buf = (unsigned char *)HDcalloc((size_t)1, cmpd_buf_size);
@@ -6297,7 +6300,7 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode compound type\n");
goto error;
- } /* end if */
+ }
/* Decode from the compound buffer and return an object handle */
if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0)
@@ -6308,26 +6311,26 @@ test_encode(void)
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/* Query member number and member index by name, for compound type. */
if (H5Tget_nmembers(decoded_tid1) != 4) {
H5_FAILED();
HDprintf("Can't get member number\n");
goto error;
- } /* end if */
+ }
if (H5Tget_member_index(decoded_tid1, "c") != 2) {
H5_FAILED();
HDprintf("Can't get correct index number\n");
goto error;
- } /* end if */
+ }
/* Encode enumerate type in a buffer */
if (H5Tencode(tid2, NULL, &enum_buf_size) < 0) {
H5_FAILED();
HDprintf("Can't encode enumerate type\n");
goto error;
- } /* end if */
+ }
if (enum_buf_size > 0)
enum_buf = (unsigned char *)HDcalloc((size_t)1, enum_buf_size);
@@ -6336,40 +6339,40 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode enumerate type\n");
goto error;
- } /* end if */
+ }
/* Decode from the enumerate buffer and return an object handle */
if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) {
H5_FAILED();
HDprintf("Can't decode enumerate type\n");
goto error;
- } /* end if */
+ }
/* Verify that the datatype was copied exactly */
if (H5Tequal(decoded_tid2, tid2) <= 0) {
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/* Query member number and member index by name, for enumeration type. */
if (H5Tget_nmembers(decoded_tid2) != 5) {
H5_FAILED();
HDprintf("Can't get member number\n");
goto error;
- } /* end if */
+ }
if (H5Tget_member_index(decoded_tid2, "ORANGE") != 3) {
H5_FAILED();
HDprintf("Can't get correct index number\n");
goto error;
- } /* end if */
+ }
/* Encode VL string type in a buffer */
if (H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) {
H5_FAILED();
HDprintf("Can't encode VL string type\n");
goto error;
- } /* end if */
+ }
if (vlstr_buf_size > 0)
vlstr_buf = (unsigned char *)HDcalloc((size_t)1, vlstr_buf_size);
@@ -6378,14 +6381,14 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't encode VL string type\n");
goto error;
- } /* end if */
+ }
/* Decode from the VL string buffer and return an object handle */
if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) {
H5_FAILED();
HDprintf("Can't decode VL string type\n");
goto error;
- } /* end if */
+ }
HDfree(vlstr_buf);
/* Verify that the datatype was copied exactly */
@@ -6393,12 +6396,12 @@ test_encode(void)
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
if (!H5Tis_variable_str(decoded_tid3)) {
H5_FAILED();
HDprintf("Datatype wasn't encoded & decoded identically\n");
goto error;
- } /* end if */
+ }
/*-----------------------------------------------------------------------
* Test the reference count of the decoded datatypes
@@ -6410,19 +6413,19 @@ test_encode(void)
H5_FAILED();
HDprintf("Decoded datatype has incorrect reference count\n");
goto error;
- } /* end if */
+ }
if (H5Iget_ref(decoded_tid2) != 1) {
H5_FAILED();
HDprintf("Decoded datatype has incorrect reference count\n");
goto error;
- } /* end if */
+ }
if (H5Iget_ref(decoded_tid3) != 1) {
H5_FAILED();
HDprintf("Decoded datatype has incorrect reference count\n");
goto error;
- } /* end if */
+ }
/* Make sure the reference counts for the decoded datatypes can be
* decremented and the datatypes are closed. */
@@ -6430,19 +6433,19 @@ test_encode(void)
H5_FAILED();
HDprintf("Decoded datatype can't close\n");
goto error;
- } /* end if */
+ }
if (H5Idec_ref(decoded_tid2) != 0) {
H5_FAILED();
HDprintf("Decoded datatype can't close\n");
goto error;
- } /* end if */
+ }
if (H5Idec_ref(decoded_tid3) != 0) {
H5_FAILED();
HDprintf("Decoded datatype can't close\n");
goto error;
- } /* end if */
+ }
/* Make sure the decoded datatypes are already closed. */
H5E_BEGIN_TRY
@@ -6487,23 +6490,23 @@ test_encode(void)
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(tid2) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Tclose(tid3) < 0) {
H5_FAILED();
HDprintf("Can't close datatype\n");
goto error;
- } /* end if */
+ }
if (H5Fclose(file) < 0) {
H5_FAILED();
HDprintf("Can't close file\n");
goto error;
- } /* end if */
+ }
HDfree(cmpd_buf);
HDfree(enum_buf);
diff --git a/test/objcopy.c b/test/objcopy.c
index 012c81d..eac99e0 100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -16397,6 +16397,68 @@ error:
return (H5_ITER_ERROR);
} /* end test_copy_iterate_cb */
+/*
+ * Test for a bug with copying of v1 object headers where the
+ * new object header would end up with a gap in the header data,
+ * which v1 object header shouldn't have.
+ */
+static int
+test_copy_cdt_v1_header_bug(hid_t fcpl_src, hid_t src_fapl)
+{
+ hid_t file_id = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hid_t ocpypl_id = H5I_INVALID_HID;
+ char src_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): bug with copying v1 object headers");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
+
+ if ((file_id = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0)
+ TEST_ERROR;
+
+ if ((type_id = H5Tcreate(H5T_STRING, 385)) < 0)
+ TEST_ERROR;
+ if (H5Tset_strpad(type_id, H5T_STR_NULLPAD) < 0)
+ TEST_ERROR;
+ if (H5Tset_cset(type_id, H5T_CSET_ASCII) < 0)
+ TEST_ERROR;
+
+ if (H5Tcommit2(file_id, "committed_str_type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ TEST_ERROR;
+ if (H5Pset_copy_object(ocpypl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ TEST_ERROR;
+
+ if (H5Ocopy(file_id, "committed_str_type", file_id, "committed_str_type2", ocpypl_id, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ if (H5Tclose(type_id) < 0)
+ TEST_ERROR;
+ if (H5Pclose(ocpypl_id) < 0)
+ TEST_ERROR;
+ if (H5Fclose(file_id) < 0)
+ TEST_ERROR;
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(type_id);
+ H5Pclose(ocpypl_id);
+ H5Fclose(file_id);
+ }
+ H5E_END_TRY;
+
+ return 1;
+}
+
static int
test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
{
@@ -17577,6 +17639,8 @@ main(void)
nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_null_ref_open(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
+ nerrors += test_copy_cdt_v1_header_bug(fcpl_src, src_fapl);
+
nerrors += test_copy_iterate(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
} /* end if */
diff --git a/test/vol.c b/test/vol.c
index 27ffdcd..29bbb06 100644
--- a/test/vol.c
+++ b/test/vol.c
@@ -2227,9 +2227,10 @@ test_vol_cap_flags(void)
hid_t fapl_id = H5I_INVALID_HID;
hid_t vol_id = H5I_INVALID_HID;
uint64_t vol_cap_flags = H5VL_CAP_FLAG_NONE;
+ char *vol_env = NULL;
H5VL_pass_through_info_t passthru_info;
- TESTING("VOL capacity flags");
+ TESTING("VOL capability flags");
/* Register a fake VOL */
if ((vol_id = H5VLregister_connector(&fake_vol_g, H5P_DEFAULT)) < 0)
@@ -2251,6 +2252,29 @@ test_vol_cap_flags(void)
if (vol_cap_flags & H5VL_CAP_FLAG_ATTR_BASIC)
TEST_ERROR;
+ /* If using the native VOL by default, check flags again with H5P_DEFAULT */
+ vol_env = HDgetenv(HDF5_VOL_CONNECTOR);
+ if (!vol_env || (0 == HDstrcmp(vol_env, "native"))) {
+ H5VL_class_t *cls;
+ hid_t connector_id;
+
+ if (H5Pget_vol_id(H5P_DEFAULT, &connector_id) < 0)
+ TEST_ERROR;
+ if (NULL == (cls = H5I_object(connector_id)))
+ TEST_ERROR;
+
+ vol_cap_flags = H5VL_CAP_FLAG_NONE;
+
+ if (H5Pget_vol_cap_flags(H5P_DEFAULT, &vol_cap_flags) < 0)
+ TEST_ERROR;
+
+ if (vol_cap_flags != cls->cap_flags)
+ TEST_ERROR;
+
+ if (H5VLclose(connector_id) < 0)
+ TEST_ERROR;
+ }
+
/* Stack the [internal] passthrough VOL connector on top of the fake connector */
passthru_info.under_vol_id = vol_id;
passthru_info.under_vol_info = NULL;