diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2019-01-04 04:45:58 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2019-01-04 04:45:58 (GMT) |
commit | d59aa1d75cb6d0ae4f5964d017e275aa53394eb6 (patch) | |
tree | d38f835c069066dc7423f610fc8a775c1427c132 /testpar | |
parent | 2a28b92e2bb7748e123a9ee5ccad1c8bcb42462d (diff) | |
download | hdf5-d59aa1d75cb6d0ae4f5964d017e275aa53394eb6.zip hdf5-d59aa1d75cb6d0ae4f5964d017e275aa53394eb6.tar.gz hdf5-d59aa1d75cb6d0ae4f5964d017e275aa53394eb6.tar.bz2 |
Cleaned up the parallel flush test and set t_pflush1 to always fail.
Also set CMake to handle this.
Diffstat (limited to 'testpar')
-rw-r--r-- | testpar/CMakeTests.cmake | 6 | ||||
-rw-r--r-- | testpar/t_pflush1.c | 247 | ||||
-rw-r--r-- | testpar/t_pflush2.c | 265 |
3 files changed, 273 insertions, 245 deletions
diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index dffb813..a0d7f59 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -22,9 +22,9 @@ foreach (testp ${H5P_TESTS}) add_test (NAME TEST_PAR_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:${testp}> ${MPIEXEC_POSTFLAGS}) endforeach () -# The following will only be correct on windows shared -#set_tests_properties (TEST_PAR_t_pflush1 PROPERTIES WILL_FAIL "true") -set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") +# The t_pflush1 test is hard-coded to fail. +set_tests_properties (TEST_PAR_t_pflush1 PROPERTIES WILL_FAIL "true") +#set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) ############################################################################## diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 4677bfe..27b561b 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -15,11 +15,11 @@ * Programmer: Leon Arber <larber@uiuc.edu> * Sept. 28, 2006. * - * Purpose: This is the first half of a two-part test that makes sure - * that a file can be read after a parallel application crashes as long - * as the file was flushed first. We simulate a crash by - * calling _exit(0) since this doesn't flush HDF5 caches but - * still exits with success. + * Purpose: This is the first half of a two-part test that makes sure + * that a file can be read after a parallel application crashes + * as long as the file was flushed first. We simulate a crash by + * calling _exit() since this doesn't flush HDF5 caches but + * still exits with success. */ #include "h5test.h" @@ -29,171 +29,190 @@ const char *FILENAME[] = { NULL }; -static double the_data[100][100]; +static int data_g[100][100]; +#define N_GROUPS 100 + + /*------------------------------------------------------------------------- - * Function: create_file - * - * Purpose: Creates file used in part 1 of the test + * Function: create_test_file * - * Return: Success: 0 + * Purpose: Creates the file used in part 1 of the test * - * Failure: 1 + * Return: Success: A valid file ID + * Failure: H5I_INVALID_HID * - * Programmer: Leon Arber + * Programmer: Leon Arber * Sept. 26, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static hid_t -create_file(char* name, hid_t fapl) +create_test_file(char *name, hid_t fapl_id) { - hid_t file, dcpl, space, dset, groups, grp, plist; - hsize_t ds_size[2] = {100, 100}; - hsize_t ch_size[2] = {5, 5}; - hsize_t i, j; - - - - if((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2] = {100, 100}; + hsize_t chunk_dims[2] = {5, 5}; + hsize_t i, j; + + if((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + goto error; /* Create a chunked dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error; - if((space = H5Screate_simple(2, ds_size, NULL)) < 0) goto error; - if((dset = H5Dcreate2(file, "dset", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - - plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); - + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + goto error; + if((sid = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto error; /* Write some data */ - for(i = 0; i < ds_size[0]; i++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - for(j = 0; j < ds_size[1]; j++) - the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1); - } - if(H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, plist, the_data) < 0) goto error; + for(i = 0; i < dims[0]; i++) + for(j = 0; j < dims[1]; j++) + data_g[i][j] = (int)(i + (i * j) + j); + + if(H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + goto error; /* Create some groups */ - if((groups = H5Gcreate2(file, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < 100; i++) { - sprintf(name, "grp%02u", (unsigned)i); - if((grp = H5Gcreate2(groups, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + if((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for(i = 0; i < N_GROUPS; i++) { + HDsprintf(name, "grp%02u", (unsigned)i); + if((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Gclose(gid) < 0) + goto error; } - return file; + return fid; error: - HD_exit(1); -} + return H5I_INVALID_HID; +} /* end create_test_file() */ + /*------------------------------------------------------------------------- * Function: main * - * Purpose: Part 1 of a two-part H5Fflush() test. - * - * Return: Success: 0 + * Purpose: Part 1 of a two-part parallel H5Fflush() test. * - * Failure: 1 + * Return: EXIT_FAILURE (always) * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Modifications: - * Leon Arber - * Sept. 26, 2006, expand test to check for failure if H5Fflush is not called. - * - * *------------------------------------------------------------------------- */ int main(int argc, char* argv[]) { - hid_t file1, file2, fapl; - MPI_File *mpifh_p = NULL; - char name[1024]; - const char *envval = NULL; - int mpi_size, mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + MPI_File *mpifh_p = NULL; + char name[1024]; + const char *envval = NULL; + int mpi_size; + int mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl, comm, info); - if(mpi_rank == 0) - TESTING("H5Fflush (part1)"); + TESTING("H5Fflush (part1)"); + + /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); if(envval == NULL) envval = "nomatch"; - if(HDstrcmp(envval, "split")) { + + if(!HDstrcmp(envval, "split")) { + if(mpi_rank == 0) { + SKIPPED(); + HDputs(" Test not compatible with current Virtual File Driver"); + } + MPI_Finalize(); + HDexit(EXIT_FAILURE); + } + + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id, comm, info) < 0) + goto error; + /* Create the file */ - h5_fixname(FILENAME[0], fapl, name, sizeof name); - file1 = create_file(name, fapl); + h5_fixname(FILENAME[0], fapl_id, name, sizeof(name)); + if((fid1 = create_test_file(name, fapl_id)) < 0) + goto error; /* Flush and exit without closing the library */ - if(H5Fflush(file1, H5F_SCOPE_GLOBAL) < 0) goto error; + if(H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) + goto error; /* Create the other file which will not be flushed */ - h5_fixname(FILENAME[1], fapl, name, sizeof name); - file2 = create_file(name, fapl); - + h5_fixname(FILENAME[1], fapl_id, name, sizeof(name)); + if((fid2 = create_test_file(name, fapl_id)) < 0) + goto error; if(mpi_rank == 0) PASSED(); - fflush(stdout); - fflush(stderr); - } /* end if */ - else { - SKIPPED(); - puts(" Test not compatible with current Virtual File Driver"); - } /* end else */ - - /* - * Some systems like AIX do not like files not closed when MPI_Finalize + + HDfflush(stdout); + HDfflush(stderr); + + /* Some systems like AIX do not like files not being closed when MPI_Finalize * is called. So, we need to get the MPI file handles, close them by hand. * Then the _exit is still needed to stop at_exit from happening in some systems. * Note that MPIO VFD returns the address of the file-handle in the VFD struct * because MPI_File_close wants to modify the file-handle variable. */ - /* close file1 */ - if(H5Fget_vfd_handle(file1, fapl, (void **)&mpifh_p) < 0) { - printf("H5Fget_vfd_handle for file1 failed\n"); - goto error; - } /* end if */ - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) { - printf("MPI_File_close for file1 failed\n"); - goto error; - } /* end if */ - /* close file2 */ - if(H5Fget_vfd_handle(file2, fapl, (void **)&mpifh_p) < 0) { - printf("H5Fget_vfd_handle for file2 failed\n"); - goto error; - } /* end if */ - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) { - printf("MPI_File_close for file2 failed\n"); - goto error; - } /* end if */ - - fflush(stdout); - fflush(stderr); - HD_exit(0); + /* Close file 1 */ + if(H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) + goto error; + if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + goto error; + + /* Close file 2 */ + if(H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) + goto error; + if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + goto error; + + HDfflush(stdout); + HDfflush(stderr); + + /* Always exit with a failure code! + * + * In accordance with the standard, not having all processes + * call MPI_Finalize() can be considered an error, so mpiexec + * et al. may indicate failure on return. It's much easier to + * always ignore the failure condition than to handle some + * platforms returning success and others failure. + */ + HD_exit(EXIT_FAILURE); error: - fflush(stdout); - fflush(stderr); - HD_exit(1); -} + HDfflush(stdout); + HDfflush(stderr); + HDprintf("*** ERROR ***\n"); + HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); + HD_exit(EXIT_FAILURE); +} /* end main() */ diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index 2051f4e..f58e5a5 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -30,116 +30,124 @@ const char *FILENAME[] = { NULL }; -static double the_data[100][100]; +static int data_g[100][100]; +#define N_GROUPS 100 /*------------------------------------------------------------------------- - * Function: check_file + * Function: check_test_file * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: SUCCEED/FAIL * - * Failure: 1 - * - * Programmer: Leon Arber + * Programmer: Leon Arber * Sept. 26, 2006. * *------------------------------------------------------------------------- */ -static int -check_file(char* name, hid_t fapl) +static herr_t +check_test_file(char* name, hid_t fapl_id) { - hid_t file, space, dset, groups, grp, plist; - hsize_t ds_size[2]; - double error; - hsize_t i, j; - - plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); - if((file = H5Fopen(name, H5F_ACC_RDONLY, fapl)) < 0) goto error; + hid_t fid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2]; + int val; + hsize_t i, j; + + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + if((fid = H5Fopen(name, H5F_ACC_RDONLY, fapl_id)) < 0) + goto error; /* Open the dataset */ - if((dset = H5Dopen2(file, "dset", H5P_DEFAULT)) < 0) goto error; - if((space = H5Dget_space(dset)) < 0) goto error; - if(H5Sget_simple_extent_dims(space, ds_size, NULL) < 0) goto error; - assert(100==ds_size[0] && 100==ds_size[1]); + if((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + goto error; + if((sid = H5Dget_space(did)) < 0) + goto error; + if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + goto error; + HDassert(100 == dims[0] && 100 == dims[1]); /* Read some data */ - if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, plist, - the_data) < 0) goto error; - for (i=0; i<ds_size[0]; i++) { - for (j=0; j<ds_size[1]; j++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - error = fabs(the_data[i][j]-(double)(hssize_t)i/((hssize_t)j+1)); - if (error>0.0001) { - H5_FAILED(); - printf(" dset[%lu][%lu] = %g\n", - (unsigned long)i, (unsigned long)j, the_data[i][j]); - printf(" should be %g\n", - (double)(hssize_t)i/(hssize_t)(j+1)); - goto error; - } - } + if(H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + goto error; + for(i = 0; i < dims[0]; i++) { + for(j = 0; j < dims[1]; j++) { + val = (int)(i + (i * j) + j); + if(data_g[i][j] != val) { + H5_FAILED(); + HDprintf(" data_g[%lu][%lu] = %d\n", (unsigned long)i, (unsigned long)j, data_g[i][j]); + HDprintf(" should be %d\n", val); + } + } } /* Open some groups */ - if((groups = H5Gopen2(file, "some_groups", H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < 100; i++) { - sprintf(name, "grp%02u", (unsigned)i); - if((grp = H5Gopen2(groups, name, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + if((top_level_gid = H5Gopen2(fid, "some_groups", H5P_DEFAULT)) < 0) + goto error; + for(i = 0; i < N_GROUPS; i++) { + HDsprintf(name, "grp%02u", (unsigned)i); + if((gid = H5Gopen2(top_level_gid, name, H5P_DEFAULT)) < 0) + goto error; + if(H5Gclose(gid) < 0) + goto error; } - if(H5Gclose(groups) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Fclose(file) < 0) goto error; - if(H5Pclose(plist) < 0) goto error; - if(H5Sclose(space) < 0) goto error; + if(H5Gclose(top_level_gid) < 0) + goto error; + if(H5Dclose(did) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + if(H5Pclose(dxpl_id) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { - H5Pclose(plist); - H5Gclose(groups); - H5Dclose(dset); - H5Fclose(file); - H5Sclose(space); + H5Pclose(dxpl_id); + H5Gclose(top_level_gid); + H5Dclose(did); + H5Fclose(fid); + H5Sclose(sid); + H5Gclose(gid); } H5E_END_TRY; - return 1; -} + return FAIL; +} /* end check_test_file() */ /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: EXIT_SUCCESS/EXIT_FAIL * - * Failure: 1 - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Modifications: - * Leon Arber - * Sept. 26, 2006, expand to check for case where the was file not flushed. - * *------------------------------------------------------------------------- */ int -main(int argc, char* argv[]) +main(int argc, char *argv[]) { + hid_t fapl_id1 = H5I_INVALID_HID; + hid_t fapl_id2 = H5I_INVALID_HID; H5E_auto2_t func; - char name[1024]; + char name[1024]; const char *envval = NULL; - int mpi_size, mpi_rank; + int mpi_size; + int mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; @@ -148,69 +156,70 @@ main(int argc, char* argv[]) MPI_Comm_rank(comm, &mpi_rank); if(mpi_rank == 0) - TESTING("H5Fflush (part2 with flush)"); + TESTING("H5Fflush (part2 with flush)"); - /* Don't run this test using the core or split file drivers */ + /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); - if (envval == NULL) + if(envval == NULL) envval = "nomatch"; - if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split")) { - hid_t fapl1, fapl2; - - fapl1 = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl1, comm, info); - - fapl2 = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl2, comm, info); - - /* Check the case where the file was flushed */ - h5_fixname(FILENAME[0], fapl1, name, sizeof name); - if(check_file(name, fapl1)) - { - H5_FAILED() - goto error; - } - else if(mpi_rank == 0) - { - PASSED() - } - - /* Check the case where the file was not flushed. This should give an error - * so we turn off the error stack temporarily */ - if(mpi_rank == 0) - TESTING("H5Fflush (part2 without flush)"); - H5Eget_auto2(H5E_DEFAULT,&func,NULL); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - h5_fixname(FILENAME[1], fapl2, name, sizeof name); - if(check_file(name, fapl2)) - { - if(mpi_rank == 0) - { - PASSED() - } - } - else - { - H5_FAILED() - goto error; - } - H5Eset_auto2(H5E_DEFAULT, func, NULL); - - - h5_clean_files(&FILENAME[0], fapl1); - h5_clean_files(&FILENAME[1], fapl2); + + if(!HDstrcmp(envval, "split")) { + if(mpi_rank == 0) { + SKIPPED(); + HDputs(" Test not compatible with current Virtual File Driver"); + } + MPI_Finalize(); + HDexit(EXIT_FAILURE); + } + + if((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id1, comm, info) < 0) + goto error; + + if((fapl_id2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id2, comm, info) < 0) + goto error; + + /* Check the case where the file was flushed */ + h5_fixname(FILENAME[0], fapl_id1, name, sizeof(name)); + if(check_test_file(name, fapl_id1)) { + H5_FAILED() + goto error; } - else - { - SKIPPED(); - puts(" Test not compatible with current Virtual File Driver"); + else if(mpi_rank == 0) { + PASSED() } + /* Check the case where the file was not flushed. This should give an error + * so we turn off the error stack temporarily. + */ + if(mpi_rank == 0) + TESTING("H5Fflush (part2 without flush)"); + H5Eget_auto2(H5E_DEFAULT,&func, NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + h5_fixname(FILENAME[1], fapl_id2, name, sizeof(name)); + if(check_test_file(name, fapl_id2)) { + if(mpi_rank == 0) + PASSED() + } + else { + H5_FAILED() + goto error; + } + + H5Eset_auto2(H5E_DEFAULT, func, NULL); + + h5_clean_files(&FILENAME[0], fapl_id1); + h5_clean_files(&FILENAME[1], fapl_id2); + MPI_Finalize(); - return 0; - error: - return 1; -} + HDexit(EXIT_SUCCESS); + +error: + HDexit(EXIT_FAILURE); +} /* end main() */ |