summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-10 14:10:30 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-10 14:10:30 (GMT)
commit5ec5c1dd65c55d4e00545c41a39feaae072e323f (patch)
tree9890a14eec503ffb853da68ae5ce7fdc3f3800c4 /testpar
parent56c9297a5a7214db76dae8efdbbb2495e94f68b2 (diff)
downloadhdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.zip
hdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.tar.gz
hdf5-5ec5c1dd65c55d4e00545c41a39feaae072e323f.tar.bz2
[svn-r27179] Merge 27162 & 27163 from trunk:
fix for HDFFV-9412: - Check for mpi is_initialized and is_finalized before making MPI calls in init/terminate of HDF5. - Add a test to make sure we can make serial HDF5 calls from rank 0 after MPI_Finalize is called. tested with h5committest
Diffstat (limited to 'testpar')
-rw-r--r--testpar/CMakeLists.txt1
-rw-r--r--testpar/Makefile.am5
-rw-r--r--testpar/Makefile.in24
-rw-r--r--testpar/t_init_term.c76
4 files changed, 97 insertions, 9 deletions
diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt
index 37b461b..2fe8f62 100644
--- a/testpar/CMakeLists.txt
+++ b/testpar/CMakeLists.txt
@@ -47,6 +47,7 @@ set (H5P_TESTS
t_pflush2
t_pshutdown
t_prestart
+ t_init_term
t_shapesame
)
diff --git a/testpar/Makefile.am b/testpar/Makefile.am
index c79a609..b190ce8 100644
--- a/testpar/Makefile.am
+++ b/testpar/Makefile.am
@@ -25,7 +25,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test
# Test programs. These are our main targets.
#
-TEST_PROG_PARA=t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_shapesame
+TEST_PROG_PARA=t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_init_term t_shapesame
check_PROGRAMS = $(TEST_PROG_PARA)
@@ -39,7 +39,8 @@ LDADD = $(LIBH5TEST) $(LIBHDF5)
# MPItest.h5 is from t_mpi
# Para*.h5 are from testphdf
# shutdown.h5 is from t_pshutdown
+# after_mpi_fin.h5 is from t_init_term
# go is used for debugging. See testphdf5.c.
-CHECK_CLEANFILES+=MPItest.h5 Para*.h5 CacheTestDummy.h5 shutdown.h5 go
+CHECK_CLEANFILES+=MPItest.h5 Para*.h5 CacheTestDummy.h5 shutdown.h5 after_mpi_fin.h5 go
include $(top_srcdir)/config/conclude.am
diff --git a/testpar/Makefile.in b/testpar/Makefile.in
index 5b43546..8b6c54c 100644
--- a/testpar/Makefile.in
+++ b/testpar/Makefile.in
@@ -113,7 +113,7 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = t_mpi$(EXEEXT) testphdf5$(EXEEXT) t_cache$(EXEEXT) \
t_pflush1$(EXEEXT) t_pflush2$(EXEEXT) t_pshutdown$(EXEEXT) \
- t_prestart$(EXEEXT) t_shapesame$(EXEEXT)
+ t_prestart$(EXEEXT) t_init_term$(EXEEXT) t_shapesame$(EXEEXT)
t_cache_SOURCES = t_cache.c
t_cache_OBJECTS = t_cache.$(OBJEXT)
t_cache_LDADD = $(LDADD)
@@ -122,6 +122,10 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
+t_init_term_SOURCES = t_init_term.c
+t_init_term_OBJECTS = t_init_term.$(OBJEXT)
+t_init_term_LDADD = $(LDADD)
+t_init_term_DEPENDENCIES = $(LIBH5TEST) $(LIBHDF5)
t_mpi_SOURCES = t_mpi.c
t_mpi_OBJECTS = t_mpi.$(OBJEXT)
t_mpi_LDADD = $(LDADD)
@@ -188,10 +192,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_prestart.c \
- t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
-DIST_SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_prestart.c \
- t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
+SOURCES = t_cache.c t_init_term.c t_mpi.c t_pflush1.c t_pflush2.c \
+ t_prestart.c t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
+DIST_SOURCES = t_cache.c t_init_term.c t_mpi.c t_pflush1.c t_pflush2.c \
+ t_prestart.c t_pshutdown.c t_shapesame.c $(testphdf5_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -687,13 +691,14 @@ TRACE = perl $(top_srcdir)/bin/trace
# MPItest.h5 is from t_mpi
# Para*.h5 are from testphdf
# shutdown.h5 is from t_pshutdown
+# after_mpi_fin.h5 is from t_init_term
# go is used for debugging. See testphdf5.c.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 MPItest.h5 \
- Para*.h5 CacheTestDummy.h5 shutdown.h5 go
+ Para*.h5 CacheTestDummy.h5 shutdown.h5 after_mpi_fin.h5 go
# Test programs. These are our main targets.
#
-TEST_PROG_PARA = t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_shapesame
+TEST_PROG_PARA = t_mpi testphdf5 t_cache t_pflush1 t_pflush2 t_pshutdown t_prestart t_init_term t_shapesame
testphdf5_SOURCES = testphdf5.c t_dset.c t_file.c t_file_image.c t_mdset.c \
t_ph5basic.c t_coll_chunk.c t_span_tree.c t_chunk_alloc.c t_filter_read.c
@@ -769,6 +774,10 @@ t_cache$(EXEEXT): $(t_cache_OBJECTS) $(t_cache_DEPENDENCIES) $(EXTRA_t_cache_DEP
@rm -f t_cache$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_cache_OBJECTS) $(t_cache_LDADD) $(LIBS)
+t_init_term$(EXEEXT): $(t_init_term_OBJECTS) $(t_init_term_DEPENDENCIES) $(EXTRA_t_init_term_DEPENDENCIES)
+ @rm -f t_init_term$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(t_init_term_OBJECTS) $(t_init_term_LDADD) $(LIBS)
+
t_mpi$(EXEEXT): $(t_mpi_OBJECTS) $(t_mpi_DEPENDENCIES) $(EXTRA_t_mpi_DEPENDENCIES)
@rm -f t_mpi$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_mpi_OBJECTS) $(t_mpi_LDADD) $(LIBS)
@@ -810,6 +819,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_file_image.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_filter_read.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_init_term.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_mdset.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_mpi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pflush1.Po@am__quote@
diff --git a/testpar/t_init_term.c b/testpar/t_init_term.c
new file mode 100644
index 0000000..824f773
--- /dev/null
+++ b/testpar/t_init_term.c
@@ -0,0 +1,76 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Mohamad Chaarawi
+ * June 2015
+ *
+ * Purpose: This test checks for the correct initialization and
+ * termination of the HDF5 library with MPI init and finalize.
+ */
+
+#include "testphdf5.h"
+
+int nerrors = 0; /* errors count */
+
+const char *FILENAME[] = {
+ "after_mpi_fin",
+ NULL
+};
+
+int
+main (int argc, char **argv)
+{
+ int mpi_size, mpi_rank;
+ MPI_Comm comm = MPI_COMM_WORLD;
+
+ /* Initialize and finalize MPI */
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(comm, &mpi_size);
+ MPI_Comm_rank(comm, &mpi_rank);
+
+ if(MAINPROCESS)
+ TESTING("Usage of Serial HDF5 after MPI_Finalize() is called");
+
+ MPI_Finalize();
+
+ nerrors += GetTestNumErrs();
+
+ /* test if we can initialize the library with MPI being finalized
+ and create a file serially */
+ H5open();
+
+ if(mpi_rank == 0) {
+ char filename[1024];
+ hid_t file_id;
+
+ h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename);
+ file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((file_id >= 0), "H5Fcreate succeeded");
+ H5Fclose(file_id);
+ file_id = -1;
+ }
+
+ H5close();
+
+ if(MAINPROCESS) {
+ if(0 == nerrors)
+ PASSED()
+ else
+ H5_FAILED()
+ }
+
+ return (nerrors!=0);
+}