summaryrefslogtreecommitdiffstats
path: root/testpar/t_oflush.c
diff options
context:
space:
mode:
authorraylu-hdf <60487644+raylu-hdf@users.noreply.github.com>2022-07-12 15:55:34 (GMT)
committerGitHub <noreply@github.com>2022-07-12 15:55:34 (GMT)
commitb2363a8195408331797cd32820fbb0dfc288f646 (patch)
tree6234565e810281f9f3be2f68963db16480d01b1c /testpar/t_oflush.c
parentc62b02660933852d0d5528aee02d8509be13423a (diff)
downloadhdf5-b2363a8195408331797cd32820fbb0dfc288f646.zip
hdf5-b2363a8195408331797cd32820fbb0dfc288f646.tar.gz
hdf5-b2363a8195408331797cd32820fbb0dfc288f646.tar.bz2
H5Oflush fails for parallel (#1876)
* H5Oflush causes H5Fclose to trigger an assertion failure in metadata cache for parallel. This commit makes sure H5Oflush fails for parallel until this problem is solved in the future. * Committing clang-format changes * Changed the use of H5F_get_driver_id to H5F_HAS_FEATURE. Co-authored-by: songyulu <songyulu@jelly.ad.hdfgroup.org> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'testpar/t_oflush.c')
-rw-r--r--testpar/t_oflush.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/testpar/t_oflush.c b/testpar/t_oflush.c
new file mode 100644
index 0000000..1a4ee69
--- /dev/null
+++ b/testpar/t_oflush.c
@@ -0,0 +1,118 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Test for H5Oflush. For the current design, H5Oflush doesn't work correctly
+ * with parallel. It causes an assertion failure in metadata cache during
+ * H5Fclose. This test makes sure H5Oflush fails for dataset, group, and named
+ * datatype properly until the problem is solved. */
+
+#include "testphdf5.h"
+#include "H5Dprivate.h"
+#include "H5private.h"
+
+#define DATASETNAME "IntArray"
+#define NX 5
+#define NY 6
+#define RANK 2
+
+void
+test_oflush(void)
+{
+ int mpi_size, mpi_rank;
+ hid_t file, dataset;
+ hid_t dataspace;
+ hid_t fapl_id;
+ const char *filename;
+ hid_t gid, dtype_flush;
+ hsize_t dimsf[2];
+ herr_t ret;
+ int data[NX][NY];
+ int i, j;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+
+ /* Make sure MPIO driver is used */
+ fapl_id = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, FACC_MPIO);
+ VRFY((fapl_id >= 0), "fapl creation succeeded");
+
+ /* Data buffer initialization */
+ for (j = 0; j < NX; j++)
+ for (i = 0; i < NY; i++)
+ data[j][i] = i + j;
+
+ filename = GetTestParameters();
+
+ file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
+ VRFY((file >= 0), "file creation succeeded");
+
+ /* Describe the size of the array and create the data space for fixed
+ * size dataset */
+ dimsf[0] = NX;
+ dimsf[1] = NY;
+
+ dataspace = H5Screate_simple(RANK, dimsf, NULL);
+ VRFY((dataspace >= 0), "data space creation succeeded");
+
+ /* Create a new dataset within the file using defined dataspace and
+ * datatype and default dataset creation properties */
+ dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((dataset >= 0), "dataset creation succeeded");
+
+ /* Write the data to the dataset using default transfer properties */
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ VRFY((ret >= 0), "dataset creation succeeded");
+
+ /* Make sure H5Oflush fails with dataset */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Oflush(dataset);
+ }
+ H5E_END_TRY
+ VRFY((ret < 0), "H5Oflush should fail as expected");
+
+ H5Sclose(dataspace);
+ H5Dclose(dataset);
+
+ /* Create a group */
+ gid = H5Gcreate(file, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((gid >= 0), "group creation succeeded");
+
+ /* Make sure H5Oflush fails with group */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Oflush(gid);
+ }
+ H5E_END_TRY
+ VRFY((ret < 0), "H5Oflush should fail as expected");
+
+ H5Gclose(gid);
+
+ /* Create a named datatype */
+ dtype_flush = H5Tcopy(H5T_NATIVE_INT);
+ H5Tcommit(file, "dtype", dtype_flush, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make sure H5Oflush fails with named datatype */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Oflush(dtype_flush);
+ }
+ H5E_END_TRY
+ VRFY((ret < 0), "H5Oflush should fail as expected");
+
+ H5Tclose(dtype_flush);
+
+ /* Close and release resources */
+ H5Fclose(file);
+ H5Pclose(fapl_id);
+}