diff options
author | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2017-10-26 15:13:33 (GMT) |
---|---|---|
committer | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2017-10-26 15:13:33 (GMT) |
commit | 59e7c7703e62717e7bf482bec2bbad52aada3c80 (patch) | |
tree | 59ebe294f77f57850a017ff9596234066d3acebd /test | |
parent | c3aa3978b2873b158a1917f8961c035f413b5e56 (diff) | |
parent | 084704392fa93d1569861c53504e89236468a3b6 (diff) | |
download | hdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.zip hdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.tar.gz hdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.tar.bz2 |
Merge branch 'develop' into hdf5_1_10
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/CMakeTests.cmake | 27 | ||||
-rw-r--r-- | test/Makefile.am | 12 | ||||
-rw-r--r-- | test/big.c | 6 | ||||
-rw-r--r-- | test/btree2.c | 8 | ||||
-rw-r--r-- | test/cache.c | 115 | ||||
-rw-r--r-- | test/cache_common.c | 2 | ||||
-rw-r--r-- | test/dsets.c | 4 | ||||
-rw-r--r-- | test/enc_dec_plist_cross_platform.c | 4 | ||||
-rw-r--r-- | test/external.c | 8 | ||||
-rw-r--r-- | test/file_image.c | 6 | ||||
-rw-r--r-- | test/filenotclosed.c | 146 | ||||
-rw-r--r-- | test/fillval.c | 2 | ||||
-rw-r--r-- | test/gen_plist.c | 14 | ||||
-rw-r--r-- | test/h5test.c | 4 | ||||
-rw-r--r-- | test/istore.c | 2 | ||||
-rw-r--r-- | test/links.c | 12 | ||||
-rw-r--r-- | test/ohdr.c | 5 | ||||
-rw-r--r-- | test/plugin.c | 486 | ||||
-rw-r--r-- | test/test_filenotclosed.sh.in | 41 | ||||
-rw-r--r-- | test/test_plugin.sh.in | 15 | ||||
-rw-r--r-- | test/tfile.c | 12 | ||||
-rw-r--r-- | test/tmisc.c | 253 | ||||
-rw-r--r-- | test/twriteorder.c | 12 |
24 files changed, 832 insertions, 365 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d7965cb..8522c1d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -373,6 +373,7 @@ set (H5_CHECK_TESTS atomic_reader links_env flushrefresh + filenotclosed ) foreach (test ${H5_CHECK_TESTS}) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 332d466..61ac3d2 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -573,6 +573,7 @@ set (test_CLEANFILES flushrefresh_VERIFICATION_CHECKPOINT1 flushrefresh_VERIFICATION_CHECKPOINT2 flushrefresh_VERIFICATION_DONE + filenotclosed.h5 atomic_data accum_swmr_big.h5 ohdr_swmr.h5 @@ -786,6 +787,22 @@ set_tests_properties (H5TEST-cache_image PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) +#-- Adding test for filenotclosed +add_test ( + NAME H5TEST-clear-filenotclosed-objects + COMMAND ${CMAKE_COMMAND} + -E remove + filenotclosed.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +add_test (NAME H5TEST-filenotclosed COMMAND $<TARGET_FILE:filenotclosed>) +set_tests_properties (H5TEST-filenotclosed PROPERTIES + DEPENDS H5TEST-clear-filenotclosed-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + #-- Adding test for err_compat if (HDF5_ENABLE_DEPRECATED_SYMBOLS) add_test (NAME H5TEST-clear-err_compat-objects @@ -1013,6 +1030,16 @@ set_tests_properties (H5PLUGIN-plugin PROPERTIES ) ############################################################################## +# HDFFV-9655 relative plugin test disabled +# +#add_test (NAME H5PLUGIN-pluginRelative COMMAND $<TARGET_FILE:plugin>) +#set_tests_properties (H5PLUGIN-pluginRelative PROPERTIES +# ENVIRONMENT "HDF5_PLUGIN_PATH=@/${BIN_REL_PATH}testdir1${CMAKE_SEP}@/${BIN_REL_PATH}testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" +# WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} +#) +############################################################################## + +############################################################################## ### S W M R T E S T S ############################################################################## # testflushrefresh.sh: flushrefresh diff --git a/test/Makefile.am b/test/Makefile.am index 8b8f5c5..ba2d79b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -25,14 +25,15 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testerror.sh: err_compat, error_test # testlibinfo.sh: # testcheck_version.sh: tcheck_version -# tetlinks_env.sh: links_env +# testlinks_env.sh: links_env +# test_filenotclosed.sh: filenotclosed.c # testflushrefresh.sh: flushrefresh # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* -TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \ +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filenotclosed.sh\ testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh -SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ +SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_filenotclosed$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) swmr_writer$(EXEEXT) \ swmr_remove_reader$(EXEEXT) swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) \ @@ -65,6 +66,7 @@ TEST_PROG= testhdf5 \ # accum_swmr_reader is used by accum.c. # atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh +# filenotclosed is used by test_filenotclosed.sh # flushrefresh is used by testflushrefresh.sh. # use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # swmr_* files (besides swmr.c) are used by testswmr.sh. @@ -74,7 +76,7 @@ TEST_PROG= testhdf5 \ # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ testmeta accum_swmr_reader atomic_writer atomic_reader \ - links_env flushrefresh use_append_chunk use_append_mchunks use_disable_mdc_flushes \ + links_env filenotclosed flushrefresh use_append_chunk use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer @@ -214,6 +216,6 @@ use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh \ - testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh + testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh include $(top_srcdir)/config/conclude.am @@ -172,7 +172,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; @@ -210,7 +210,7 @@ supports_big(void) int fd = -1; fsizes_t fsize = NO_FILE; - if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) + if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write a few byte at the beginning */ @@ -293,7 +293,7 @@ enough_room(hid_t fapl) /* Create files */ for (i=0; i<NELMTS(fd); i++) { HDsnprintf(name, sizeof(name), filename, i); - if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) { + if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { goto done; } if ((off_t)size != HDlseek(fd[i], (off_t)size, SEEK_SET)) { diff --git a/test/btree2.c b/test/btree2.c index ec3e20e..4c820b3 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -8736,7 +8736,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Make a copy of the file in memory, in order to speed up deletion testing */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) + if((fd = HDopen(filename, O_RDONLY)) < 0) TEST_ERROR /* Retrieve the file's size */ @@ -8833,7 +8833,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ @@ -8920,7 +8920,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ @@ -9005,7 +9005,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ diff --git a/test/cache.c b/test/cache.c index 0896814..97a1b91 100644 --- a/test/cache.c +++ b/test/cache.c @@ -239,10 +239,16 @@ smoke_check_1(int express_test, unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache, paged aggregation") + TESTING("smoke check #1P -- all clean, ins, dest, ren, 4/2 MB cache") else TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -440,10 +446,16 @@ smoke_check_2(int express_test, unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache, paged aggregation") + TESTING("smoke check #2P -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache") else TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -640,10 +652,16 @@ smoke_check_3(int express_test, unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache, paged aggregation") + TESTING("smoke check #3P -- all clean, ins, dest, ren, 2/1 KB cache") else TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -841,10 +859,16 @@ smoke_check_4(int express_test, unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache, paged aggregation") + TESTING("smoke check #4P -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache") else TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -1090,10 +1114,16 @@ smoke_check_5(int express_test, unsigned paged) }; if(paged) - TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1, paged aggregation") + TESTING("smoke check #5P -- all clean, ins, prot, unprot, AR cache 1") else TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -1328,10 +1358,16 @@ smoke_check_6(int express_test, unsigned paged) }; if(paged) - TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1, paged aggregation") + TESTING("smoke check #6P -- ~1/2 dirty, ins, prot, unprot, AR cache 1") else TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + pass = TRUE; switch (express_test) @@ -1567,10 +1603,16 @@ smoke_check_7(int express_test, unsigned paged) }; if(paged) - TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2, paged aggregation") + TESTING("smoke check #7P -- all clean, ins, prot, unprot, AR cache 2") else TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -1806,10 +1848,16 @@ smoke_check_8(int express_test, unsigned paged) }; if(paged) - TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2, paged aggregation") + TESTING("smoke check #8P -- ~1/2 dirty, ins, prot, unprot, AR cache 2") else TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -2006,10 +2054,16 @@ smoke_check_9(int express_test, unsigned paged) H5C_t * cache_ptr = NULL; if(paged) - TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked, paged aggregation") + TESTING("smoke check #9P -- all clean, ins, dest, ren, 4/2 MB, corked") else TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -2328,10 +2382,16 @@ smoke_check_10(int express_test, unsigned paged) H5C_t * cache_ptr = NULL; if(paged) - TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked, paged aggregation") + TESTING("smoke check #10P -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked") else TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked") + if ( paged && ( express_test > 0 ) ) { + + SKIPPED(); + return(0); + } + switch (express_test) { case 0: @@ -2644,7 +2704,7 @@ express_test, unsigned paged) #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ if(paged) - TESTING("write permitted check -- 1/0 MB cache, paged aggregation") + TESTING("write permitted check -- 1/0 MB cache (paged aggregation)") else TESTING("write permitted check -- 1/0 MB cache") @@ -3056,13 +3116,14 @@ check_insert_entry(unsigned paged) (cache_ptr->pel_len != 2) || (cache_ptr->pel_size != 2 * entry_sizes[entry_type]) || (cache_ptr->LRU_list_len != 2) || - (cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type]) || + (cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type]) #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - (cache_ptr->dLRU_list_len != 2) || + || (cache_ptr->dLRU_list_len != 2) || (cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type]) || -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ (cache_ptr->cLRU_list_len != 0) || - (cache_ptr->cLRU_list_size != (size_t)0)) { + (cache_ptr->cLRU_list_size != (size_t)0) +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + ) { pass = FALSE; failure_mssg = "Unexpected insert results 10."; @@ -13327,7 +13388,7 @@ check_multiple_read_protect(unsigned paged) test_entry_t * entry_ptr; if(paged) - TESTING("multiple read only protects on a single entry (paged aggregation)") + TESTING("multiple read only protects on a single entry (paged aggr)") else TESTING("multiple read only protects on a single entry") @@ -15952,7 +16013,7 @@ check_destroy_pinned_err(unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("destroy cache with permanently pinned entry error (paged aggregation)") + TESTING("destroy cache with permanently pinned entry error (pgd aggr)") else TESTING("destroy cache with permanently pinned entry error") @@ -24436,7 +24497,7 @@ check_auto_cache_resize_epoch_markers(unsigned paged) }; if(paged) - TESTING("automatic cache resize epoch marker management (paged aggregation)") + TESTING("automatic cache resize epoch marker management (paged aggr)") else TESTING("automatic cache resize epoch marker management") @@ -28228,13 +28289,13 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) if(fill_via_insertion) { if(paged) - TESTING("to ensure metadata blizzard absence when inserting (paged aggregation)") + TESTING("to ensure metadata blizzard absence when inserting (pgd aggr)") else TESTING("to ensure metadata blizzard absence when inserting") } /* end if */ else { if(paged) - TESTING("to ensure metadata blizzard absence on protect/unprotect (paged aggregation)") + TESTING("to ensure metadata blizzard absence on protect/unprotect (pa)") else TESTING("to ensure metadata blizzard absence on protect/unprotect") } /* end else */ @@ -34381,7 +34442,7 @@ check_entry_deletions_during_scans(unsigned paged) H5F_t * file_ptr = NULL; if(paged) - TESTING("entry deletion during list scan detection and adaption (paged aggregation)") + TESTING("entry deletion during list scan detection and adaption (par)") else TESTING("entry deletion during list scan detection and adaption") @@ -36392,6 +36453,18 @@ main(void) /* Test with paged aggregation enabled or not */ /* Each test will call setup_cache() which set up the file space strategy according to "paged" */ for(paged = FALSE; paged <= TRUE; paged++) { + + if ( paged ) { + + HDfprintf(stdout, + "\n\nRe-running tests with paged aggregation:\n"); + + if ( express_test > 0 ) + HDfprintf(stdout, " Skipping smoke checks.\n"); + + HDfprintf(stdout, "\n"); + } + nerrs += smoke_check_1(express_test, paged); nerrs += smoke_check_2(express_test, paged); nerrs += smoke_check_3(express_test, paged); diff --git a/test/cache_common.c b/test/cache_common.c index 69bc26a..cadccec 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -2436,8 +2436,10 @@ reset_entries(void) base_addr[j].header.ro_ref_count = FALSE; base_addr[j].header.next = NULL; base_addr[j].header.prev = NULL; +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS base_addr[j].header.aux_next = NULL; base_addr[j].header.aux_prev = NULL; +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ base_addr[j].self = &(base_addr[j]); base_addr[j].cache_ptr = NULL; diff --git a/test/dsets.c b/test/dsets.c index 6c6574a..4088304 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -553,7 +553,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) goto error; file = -1; - f = HDopen(filename, O_RDONLY, 0); + f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; @@ -662,7 +662,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) goto error; file = -1; - f = HDopen(filename, O_RDONLY, 0); + f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c index 5511828..1fbb41b 100644 --- a/test/enc_dec_plist_cross_platform.c +++ b/test/enc_dec_plist_cross_platform.c @@ -178,7 +178,7 @@ test_plists(const char *filename_prefix) /* Read file 1 */ testfile = H5_get_srcdir_filename(filename); - if((fd_1 = HDopen(testfile, O_RDONLY, 0666)) < 0) + if((fd_1 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR size_1 = (size_t)HDlseek(fd_1, (HDoff_t)0, SEEK_END); HDlseek(fd_1, (HDoff_t)0, SEEK_SET); @@ -195,7 +195,7 @@ test_plists(const char *filename_prefix) /* Read file 1 */ testfile = H5_get_srcdir_filename(filename); - if((fd_2 = HDopen(testfile, O_RDONLY, 0666)) < 0) + if((fd_2 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR size_2 = (size_t)HDlseek(fd_2, (HDoff_t)0, SEEK_END); HDlseek(fd_2, (HDoff_t)0, SEEK_SET); diff --git a/test/external.c b/test/external.c index 9502586..20a9ed8 100644 --- a/test/external.c +++ b/test/external.c @@ -59,9 +59,9 @@ files_have_same_contents(const char *name1, const char *name2) char buf1[1024], buf2[1024]; hbool_t ret = FALSE; /* not equal until proven otherwise */ - if((fd1 = HDopen(name1, O_RDONLY, 0666)) < 0) + if((fd1 = HDopen(name1, O_RDONLY)) < 0) goto out; - if((fd2 = HDopen(name2, O_RDONLY, 0666)) < 0) + if((fd2 = HDopen(name2, O_RDONLY)) < 0) goto out; /* Loop until files are empty or we encounter a problem */ @@ -137,7 +137,7 @@ reset_raw_data_files(void) /* Open file */ HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the @@ -171,7 +171,7 @@ reset_raw_data_files(void) /* Open file */ HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the diff --git a/test/file_image.c b/test/file_image.c index 90b3233..12f0a18 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -624,7 +624,7 @@ test_core(void) VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); /* Create file image buffer */ - fd = HDopen(copied_filename, O_RDONLY, 0666); + fd = HDopen(copied_filename, O_RDONLY); VERIFY(fd > 0, "open failed"); ret = HDfstat(fd, &sb); VERIFY(ret == 0, "fstat failed"); @@ -814,7 +814,7 @@ test_get_file_image(const char * test_banner, HDsnprintf(member_file_name, 1024, file_name, i); /* open the test file using standard I/O calls */ - fd = HDopen(member_file_name, O_RDONLY, 0666); + fd = HDopen(member_file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(size_remaining >= FAMILY_SIZE ){ @@ -862,7 +862,7 @@ test_get_file_image(const char * test_banner, VERIFY(file_image_ptr != NULL, "HDmalloc(2) failed."); /* open the test file using standard I/O calls */ - fd = HDopen(file_name, O_RDONLY, 0666); + fd = HDopen(file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(user) { diff --git a/test/filenotclosed.c b/test/filenotclosed.c new file mode 100644 index 0000000..d1f468a --- /dev/null +++ b/test/filenotclosed.c @@ -0,0 +1,146 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test to verify that the assertion/abort failure is fixed when the + * application does not close the file. (See HDFFV-10160) + */ + + +#include "h5test.h" + +#define FILENAME "filenotclosed" +#define DATASET "dset" + +/*------------------------------------------------------------------------- + * Function: catch_signal + * + * Purpose: The signal handler to catch the SIGABRT signal. + * + * Return: No return + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ +static void catch_signal(int H5_ATTR_UNUSED signo) +{ + HDexit(1); +} /* catch_signal() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test to verify the following problem described in HDFFV-10160 is fixed: + * "a.out: H5Fint.c:1679: H5F_close: Assertion `f->file_id > 0' failed." + * + * Return: Success: exit(EXIT_SUCCESS) + * Failure: exit(EXIT_FAILURE) + * + * Programmer: Vailin Choi; June 2017 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl = -1; /* File access property lists */ + hid_t fid = -1; /* File ID */ + hid_t did = -1; /* Dataset ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t cur_dim[1] = {5}; /* Current dimension sizes */ + hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim[1] = {10}; /* Chunk dimension sizes */ + int buf[5] = {1, 2, 3, 4, 5}; /* The data to be written to the dataset */ + char filename[100]; /* File name */ + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Contiguous address vfd */ + + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Skip test when using VFDs that has different address spaces for each + * type of metadata allocation. + * Further investigation is needed to resolve the test failure with the + * split/multi driver. Please see HDFFV-10160. + */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + if(!contig_addr_vfd) { + SKIPPED(); + puts(" Temporary skipped for a spilt/multi driver"); + HDexit(EXIT_SUCCESS); + } + + h5_reset(); + + /* To exit from the file for SIGABRT signal */ + if(HDsignal(SIGABRT, catch_signal) == SIG_ERR) + TEST_ERROR + + fapl = h5_fileaccess(); + h5_fixname(FILENAME, fapl, filename, sizeof(filename)); + + /* Set to latest format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR + + /* Create the file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create the dcpl and set the chunk size */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + + if(H5Pset_chunk(dcpl, 1, chunk_dim) < 0) + TEST_ERROR + + /* Create the dataspace */ + if((sid = H5Screate_simple(1, cur_dim, max_dim)) < 0) + TEST_ERROR + + /* Create the dataset */ + if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Write to the dataset */ + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR + + /* Close the dataset */ + if(H5Dclose(did) < 0) + TEST_ERROR + + /* Close the dataspace */ + if(H5Sclose(sid) < 0) + TEST_ERROR + + /* Close the property lists */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + if(H5Pclose(fapl) < 0) + TEST_ERROR + + /* The file is not closed. */ + /* The library will call H5_term_library to shut down the library. */ + + HDexit(EXIT_SUCCESS); + +error: + HDputs("*** TEST FAILED ***"); + HDexit(EXIT_FAILURE); +} diff --git a/test/fillval.c b/test/fillval.c index ea13de0..8c8e902 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1890,7 +1890,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) hsize_t nelmts; nelmts = max_size[0]*max_size[1]*max_size[2]*max_size[3]*max_size[4]; - if((fd=HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0 || + if((fd = HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || HDclose(fd) < 0) goto error; if(H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts*sizeof(int)) < 0) goto error; diff --git a/test/gen_plist.c b/test/gen_plist.c index 41f232d..62693bd 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -463,23 +463,23 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil /* Generate filename */ if((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, little_endian ? "le" : "be")) < 0) - assert(ret > 0); + HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); - assert(temp_buf); + HDassert(temp_buf); if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); - fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, 0666); - assert(fd > 0); + fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + HDassert(fd > 0); write_size = HDwrite(fd, temp_buf, temp_size); - assert(write_size == (ssize_t)temp_size); + HDassert(write_size == (ssize_t)temp_size); HDclose(fd); diff --git a/test/h5test.c b/test/h5test.c index 1e1e290..af45589 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1658,9 +1658,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) goto error; /* Copy old file into temporary file */ - if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) + if((fd_old = HDopen(filename, O_RDONLY)) < 0) goto error; - if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) + if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Copy data */ diff --git a/test/istore.c b/test/istore.c index 8dc5efd..c401e87 100644 --- a/test/istore.c +++ b/test/istore.c @@ -73,7 +73,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; diff --git a/test/links.c b/test/links.c index 2d1ef03..7b3e37d 100644 --- a/test/links.c +++ b/test/links.c @@ -3730,7 +3730,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout") if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) - TEST_ERROR + TEST_ERROR /* * set up name for main file: @@ -3780,7 +3780,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Create external link to target file: ext_link->extlinks17:/A/Dataset */ if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* create fapl to be a "core" file without backing store */ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) @@ -3793,9 +3793,9 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* try to open the external linked target dataset */ did = H5Dopen2(fid, "ext_link", dapl_id); if(did < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening the target dataset"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening the target dataset"); + goto error; } /* Initialize the dataset */ @@ -3805,7 +3805,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Write the data to the dataset */ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) - TEST_ERROR + TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR diff --git a/test/ohdr.c b/test/ohdr.c index faec835..3915b38 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -392,8 +392,9 @@ test_ohdr_swmr(hbool_t new_format) if(H5Oget_info(did, &obj_info) < 0) FAIL_STACK_ERROR - if(obj_info.hdr.version != OBJ_VERSION_LATEST) - FAIL_STACK_ERROR + if(new_format) + if(obj_info.hdr.version != OBJ_VERSION_LATEST) + FAIL_STACK_ERROR /* The size of object header should be greater than the speculative read size of H5O_SPEC_READ_SIZE */ /* This will exercise the coding for the re-read of the object header for SWMR access */ diff --git a/test/plugin.c b/test/plugin.c index 3034c0b..ea199f6 100644 --- a/test/plugin.c +++ b/test/plugin.c @@ -10,9 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu - * 13 February 2013 - * * Purpose: Tests the plugin module (H5PL) */ @@ -660,13 +657,10 @@ error: /*------------------------------------------------------------------------- * Function: test_groups_with_filters * - * Purpose: Tests opening group with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 + * Purpose: Tests opening group with dynamically loaded filters * - * Programmer: Raymond Lu - * 1 April 2013 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -710,264 +704,388 @@ error: /*------------------------------------------------------------------------- - * Function: test_filter_path_apis + * Function: test_path_api_calls * - * Purpose: Tests accessing the path table for dynamically loaded filters + * Purpose: Tests the H5PL API calls that manipulate the plugin search + * paths. * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED/FAIL + * *------------------------------------------------------------------------- */ static herr_t -test_filter_path_apis(void) +test_path_api_calls(void) { - herr_t ret_value = -1; - unsigned int i; - unsigned int ndx; + unsigned int n_starting_paths; + unsigned int u; + unsigned int n_paths; herr_t ret; - ssize_t pathlen = -1; - char pathname[256]; - char tempname[256]; + ssize_t path_len = -1; + char path[256]; + char temp_name[256]; HDputs("Testing access to the filter path table"); - if(H5Zfilter_avail(H5Z_FILTER_DYNLIB1) != TRUE) TEST_ERROR + if(H5Zfilter_avail(H5Z_FILTER_DYNLIB1) != TRUE) + TEST_ERROR + + /* Set the number of paths to create for this test. + * + * This should be set high enough to ensure that at least one array + * expansion will take place. See H5PLpath.c for details. + */ + n_starting_paths = 42; + /* Check that initialization is correct */ TESTING(" initialize"); - H5PLsize(&ndx); - if(ndx!=2) TEST_ERROR + + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != 2) + TEST_ERROR + PASSED(); + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ TESTING(" remove"); - /* Remove all existing paths*/ - for(i=ndx; i > 0; i--) - if(H5PLremove(i-1) < 0) { - HDfprintf(stderr," at %d: %s\n", i, pathname); + + /* Get the current size */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + + /* Remove all existing paths */ + for(u = n_paths; u > 0; u--) + if(H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); TEST_ERROR - } /* end if */ + } + /* Verify the table is empty */ - H5PLsize(&ndx); - if(ndx > 0) TEST_ERROR + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths > 0) + TEST_ERROR + PASSED(); - TESTING(" remove (exceed min)"); - /* Exceed the min path removal */ + + TESTING(" remove (index 0 in empty table)"); + + /* Try to remove index zero in an empty list (SHOULD FAIL) */ H5E_BEGIN_TRY { ret = H5PLremove(0); } H5E_END_TRY - if(ret >= 0) TEST_ERROR + if(ret >= 0) + TEST_ERROR + PASSED(); + + /****************/ + /* H5PLappend() */ + /****************/ + TESTING(" append"); - /* Create multiple paths to fill table */ - for(i=0; i < H5PL_MAX_PATH_NUM; i++) { - HDsprintf(pathname, "a_path_%d", i); - if(H5PLappend(pathname) < 0) { - HDfprintf(stderr," at %d: %s\n", i, pathname); + + /* Add a bunch of paths to the path table */ + for(u = 0; u < n_starting_paths; u++) { + HDsprintf(path, "a_path_%u", u); + if(H5PLappend(path) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); TEST_ERROR } } - /* Verify the table is full */ - H5PLsize(&ndx); - if(ndx != H5PL_MAX_PATH_NUM) TEST_ERROR - PASSED(); - TESTING(" append (exceed)"); - /* Exceed the max path append */ - H5E_BEGIN_TRY { - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM); - ret = H5PLappend(pathname); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR PASSED(); - TESTING(" remove (exceed max)"); - /* Exceed the max path removal */ + + /**********************/ + /* H5PLremove() again */ + /**********************/ + + TESTING(" remove (index too high)"); + + /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ H5E_BEGIN_TRY { - ret = H5PLremove(H5PL_MAX_PATH_NUM); + ret = H5PLremove(n_starting_paths); } H5E_END_TRY - if(ret >= 0) TEST_ERROR + + if(ret >= 0) + TEST_ERROR + PASSED(); + + /*************/ + /* H5PLget() */ + /*************/ + TESTING(" get (path name)"); - if((pathlen = H5PLget(0, NULL, 0)) <= 0) { + + /* Get the path length by passing in NULL */ + if((path_len = H5PLget(0, NULL, 0)) <= 0) { HDfprintf(stderr," get path 0 length failed\n"); TEST_ERROR } - if(pathlen != 8) TEST_ERROR + if(path_len != 8) + TEST_ERROR - if((pathlen = H5PLget(0, pathname, 256)) <= 0) { - HDfprintf(stderr," get 0 len: %d : %s\n", pathlen, pathname); + /* Get the path */ + if((path_len = H5PLget(0, path, 256)) <= 0) { + HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); TEST_ERROR } - if(HDstrcmp(pathname, "a_path_0") != 0) { - HDfprintf(stderr," get 0: %s\n", pathname); + if(HDstrcmp(path, "a_path_0") != 0) { + HDfprintf(stderr," get 0: %s\n", path); TEST_ERROR } + PASSED(); - TESTING(" get (bounds)"); - if((pathlen = H5PLget(1, pathname, 256)) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_1") != 0) { - HDfprintf(stderr," get 1: %s\n", pathname); + + TESTING(" get (high and low indices)"); + + /* Get path at index 1 */ + if((path_len = H5PLget(1, path, 256)) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 1: %s\n", path); TEST_ERROR } - if((pathlen = H5PLget(H5PL_MAX_PATH_NUM - 1, pathname, 256)) <= 0) TEST_ERROR - HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM - 1); - if(HDstrcmp(pathname, tempname) != 0) { - HDfprintf(stderr," get %d: %s\n", H5PL_MAX_PATH_NUM - 1, pathname); + + /* Get path at the last index */ + if((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) + TEST_ERROR + HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); + if(HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); TEST_ERROR } + PASSED(); - TESTING(" get (bounds exceed)"); + + TESTING(" get (index too high)"); + + /* Get path at the last + 1 index (SHOULD FAIL) */ H5E_BEGIN_TRY { - pathlen = H5PLget(H5PL_MAX_PATH_NUM, NULL, 0); + path_len = H5PLget(n_starting_paths, NULL, 0); } H5E_END_TRY - if(pathlen > 0) TEST_ERROR + if(path_len > 0) + TEST_ERROR + PASSED(); - TESTING(" remove (verify for prepend)"); - /* Remove one path*/ - if(H5PLremove(8) < 0) TEST_ERROR + + /*****************/ + /* H5PLprepend() */ + /*****************/ + + /* We'll remove a path at an arbitrary index and then + * prepend a new path. + */ + + TESTING(" remove (arbitrary index 1)"); + + /* Remove one path */ + if(H5PLremove(8) < 0) + TEST_ERROR /* Verify that the entries were moved */ - if((pathlen = H5PLget(8, pathname, 256)) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_9") != 0) { - HDfprintf(stderr," get 8: %s\n", pathname); + if((path_len = H5PLget(8, path, 256)) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_9") != 0) { + HDfprintf(stderr," get 8: %s\n", path); TEST_ERROR } + + /* Verify the table shrank */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != n_starting_paths - 1) + TEST_ERROR + PASSED(); - /* Verify the table is not full */ - H5PLsize(&ndx); - if (ndx != H5PL_MAX_PATH_NUM - 1) TEST_ERROR TESTING(" prepend"); - /* Prepend one path*/ - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 1); - if(H5PLprepend(pathname) < 0) { - HDfprintf(stderr," prepend %d: %s\n", H5PL_MAX_PATH_NUM + 1, pathname); + + /* Prepend one path */ + HDsprintf(path, "a_path_%d", n_starting_paths + 1); + if(H5PLprepend(path) < 0) { + HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); TEST_ERROR } - /* Verify the table is full */ - H5PLsize(&ndx); - if(ndx != H5PL_MAX_PATH_NUM) TEST_ERROR + /* Verify the table increased */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != n_starting_paths) + TEST_ERROR /* Verify that the entries were moved */ - if(H5PLget(8, pathname, 256) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_7") != 0) { - HDfprintf(stderr," get 8: %s\n", pathname); + if(H5PLget(8, path, 256) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_7") != 0) { + HDfprintf(stderr," get 8: %s\n", path); TEST_ERROR } - if(H5PLget(0, pathname, 256) <= 0) TEST_ERROR - HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1); - if(HDstrcmp(pathname, tempname) != 0) { - HDfprintf(stderr," get 0: %s\n", pathname); + + /* Verify that the path was inserted at index zero */ + if(H5PLget(0, path, 256) <= 0) + TEST_ERROR + HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); + if(HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); TEST_ERROR } - PASSED(); - TESTING(" prepend (exceed)"); - /* Exceed the max path prepend */ - H5E_BEGIN_TRY { - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 2); - ret = H5PLprepend(pathname); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR PASSED(); + + /*****************/ + /* H5PLreplace() */ + /*****************/ + TESTING(" replace"); - /* Replace one path*/ - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 4); - if(H5PLreplace(pathname, 1) < 0) { - HDfprintf(stderr," replace 1: %s\n", pathname); + + /* Replace one path at index 1 */ + HDsprintf(path, "a_path_%u", n_starting_paths + 4); + if(H5PLreplace(path, 1) < 0) { + HDfprintf(stderr," replace 1: %s\n", path); TEST_ERROR } - /* Verify the table is full */ - H5PLsize(&ndx); - if(ndx != H5PL_MAX_PATH_NUM) TEST_ERROR + /* Verify the table size remained the same */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != n_starting_paths) + TEST_ERROR + + /* Verify that the entries were not moved by + * inspecting the paths at indices +/- 1. + */ - /* Verify that the entries were not moved */ - if(H5PLget(0, pathname, 256) <= 0) TEST_ERROR - HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1); - if(HDstrcmp(pathname, tempname) != 0) { - HDfprintf(stderr," get 0: %s\n", pathname); + /* Check path at index 0 */ + if(H5PLget(0, path, 256) <= 0) + TEST_ERROR + HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); + if(HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); TEST_ERROR } - if(H5PLget(2, pathname, 256) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_1") != 0) { - HDfprintf(stderr," get 2: %s\n", pathname); + + /* Check path at index 2 */ + if(H5PLget(2, path, 256) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 2: %s\n", path); TEST_ERROR } + PASSED(); - TESTING(" remove (verify for insert)"); - /* Remove one path*/ - if(H5PLremove(4) < 0) TEST_ERROR + + /****************/ + /* H5PLinsert() */ + /****************/ + + /* We'll remove a path at an arbitrary index and then + * insert a new path. + */ + + TESTING(" remove (arbitrary index 2)"); + + /* Remove one path */ + if(H5PLremove(4) < 0) + TEST_ERROR /* Verify that the entries were moved */ - if(H5PLget(4, pathname, 256) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_4") != 0) { - HDfprintf(stderr," get 4: %s\n", pathname); + if(H5PLget(4, path, 256) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_4") != 0) { + HDfprintf(stderr," get 4: %s\n", path); TEST_ERROR } + + /* Verify the table size */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != n_starting_paths - 1) + TEST_ERROR PASSED(); - /* Verify the table is not full */ - H5PLsize(&ndx); - if(ndx != 15) TEST_ERROR TESTING(" insert"); - /* Insert one path*/ - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 5); - if(H5PLinsert(pathname, 3) < 0) { - HDfprintf(stderr," insert 3: %s\n", pathname); + + /* Insert one path at index 3*/ + HDsprintf(path, "a_path_%d", n_starting_paths + 5); + if(H5PLinsert(path, 3) < 0) { + HDfprintf(stderr," insert 3: %s\n", path); TEST_ERROR } /* Verify that the entries were moved */ - if(H5PLget(4, pathname, 256) <= 0) TEST_ERROR - if(HDstrcmp(pathname, "a_path_2") != 0) { - HDfprintf(stderr," get 4: %s\n", pathname); + if(H5PLget(4, path, 256) <= 0) + TEST_ERROR + if(HDstrcmp(path, "a_path_2") != 0) { + HDfprintf(stderr," get 4: %s\n", path); TEST_ERROR } + + /* Verify the table size increased */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths != n_starting_paths) + TEST_ERROR + PASSED(); - /* Verify the table is full */ - H5PLsize(&ndx); - if(ndx != H5PL_MAX_PATH_NUM) TEST_ERROR - TESTING(" insert (exceed)"); - /* Exceed the max path insert */ - H5E_BEGIN_TRY { - HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 6); - ret = H5PLinsert(pathname, 12); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ + TESTING(" remove (all)"); + + /* Get the current size */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + + /* Remove all existing paths */ + for(u = n_paths; u > 0; u--) + if(H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR + } + + /* Verify the table is empty */ + if(H5PLsize(&n_paths) < 0) + TEST_ERROR + if(n_paths > 0) + TEST_ERROR PASSED(); - ret_value = 0; + + return SUCCEED; error: - return ret_value; -} + return FAIL; +} /* end test_path_api_calls() */ /*------------------------------------------------------------------------- * Function: main * - * Purpose: Tests the plugin module (H5PL) + * Purpose: Tests the plugin module (H5PL) * - * Return: Success: exit(EXIT_SUCCESS) - * - * Failure: exit(EXIT_FAILURE) - * - * Programmer: Raymond Lu - * 14 March 2013 + * Return: EXIT_SUCCESS/EXIT_FAILURE * *------------------------------------------------------------------------- */ @@ -987,37 +1105,44 @@ main(void) /* Testing setup */ h5_reset(); - fapl = h5_fileaccess(); + + if ((fapl = h5_fileaccess()) < 0) + TEST_ERROR /* Turn off the chunk cache, so all the chunks are immediately written to disk */ - if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) TEST_ERROR + if (H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + TEST_ERROR rdcc_nbytes = 0; - if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) TEST_ERROR + if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + TEST_ERROR /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { HDputs("\nTesting with new file format:"); my_fapl = fapl2; - } /* end if */ + } else { HDputs("Testing with old file format:"); my_fapl = fapl; - } /* end else */ + } /* Create the file for this test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Test dynamically loaded filters for chunked dataset */ nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0); @@ -1025,12 +1150,15 @@ main(void) /* Test dynamically loaded filters for groups */ nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0); - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR } /* end for */ /* Close FAPL */ - if(H5Pclose(fapl2) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) TEST_ERROR + if (H5Pclose(fapl2) < 0) + TEST_ERROR + if (H5Pclose(fapl) < 0) + TEST_ERROR /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1039,10 +1167,12 @@ main(void) /* Close the library so that all loaded plugin libraries are unloaded */ h5_reset(); - fapl = h5_fileaccess(); + if ((fapl = h5_fileaccess()) < 0) + TEST_ERROR /* Reopen the file for testing data reading */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Read the data with filters */ nerrors += (test_read_with_filters(file) < 0 ? 1 : 0); @@ -1055,29 +1185,33 @@ main(void) /* Close the library so that all loaded plugin libraries are unloaded */ h5_reset(); - fapl = h5_fileaccess(); + if ((fapl = h5_fileaccess()) < 0) + TEST_ERROR /* Reopen the file for testing data reading */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Read the data with disabled filters */ nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0); - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* Test the APIs for access to the filter plugin path table */ - nerrors += (test_filter_path_apis() < 0 ? 1 : 0); + nerrors += (test_path_api_calls() < 0 ? 1 : 0); - if(nerrors) TEST_ERROR + if (nerrors) + TEST_ERROR HDprintf("All plugin tests passed.\n"); h5_cleanup(FILENAME, fapl); - return 0; + HDexit(EXIT_SUCCESS); error: nerrors = MAX(1, nerrors); HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - return 1; -} + HDexit(EXIT_FAILURE); +} /* end main() */ diff --git a/test/test_filenotclosed.sh.in b/test/test_filenotclosed.sh.in new file mode 100644 index 0000000..0b43c5b --- /dev/null +++ b/test/test_filenotclosed.sh.in @@ -0,0 +1,41 @@ +#! /bin/sh +# +# 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://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test to verify that the assertion/abort failure is fixed when the application +# does not close the file. (See HDFFV-10160) + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T ### +############################################################################## +############################################################################## + +echo "Testing file not closed assertion/abort failure" +TEST_NAME=filenotclosed # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +# +# Run the test +#$RUNSERIAL $TEST_BIN >/dev/null 2>&1 +$RUNSERIAL $TEST_BIN 2>&1 +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test PASSED" +else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered***" +fi +exit $nerrors diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in index 2a1ceaf..c90a978 100644 --- a/test/test_plugin.sh.in +++ b/test/test_plugin.sh.in @@ -38,7 +38,7 @@ case $(uname) in esac PLUGIN_LIBDIR1=testdir1 PLUGIN_LIBDIR2=testdir2 -CP="cp -p" # Use -p to preserve mode,ownership,timestamps +CP="cp -p" # Use -p to preserve mode,ownership,timestamps RM="rm -rf" # Print a line-line message left justified in a field of 70 characters @@ -85,6 +85,19 @@ if [ $? != 0 ]; then nerrors=`expr $nerrors + 1` fi +############################################ +# HDFFV-9655 test for relative path disabled +# setup plugin path relative to test +# actual executable is in the .libs folder +#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_LIBDIR1}:@/../${PLUGIN_LIBDIR2}" +# +# Run the test +#$ENVCMD $TEST_BIN +#if [ $? != 0 ]; then +# nerrors=`expr $nerrors + 1` +#fi +############################################# + # print results if test $nerrors -ne 0 ; then echo "$nerrors errors encountered" diff --git a/test/tfile.c b/test/tfile.c index 70508cd..027ad62 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1612,7 +1612,7 @@ test_file_ishdf5(void) /* Create non-HDF5 file and check it */ - fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666); + fd = HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd, FAIL, "HDopen"); /* Initialize information to write */ @@ -2658,7 +2658,7 @@ cal_chksum(const char *file, uint32_t *chksum) herr_t ret; /* Generic return value */ /* Open the file */ - fdes = HDopen(file, O_RDONLY, 0); + fdes = HDopen(file, O_RDONLY); CHECK(fdes, FAIL, "HDopen"); /* Retrieve the file's size */ @@ -2721,7 +2721,7 @@ test_rw_noupdate(void) /* Calculate checksum for the file */ ret = cal_chksum(FILE1, &chksum1); - CHECK(ret, FAIL, "HDopen"); + CHECK(ret, FAIL, "cal_chksum"); /* Open and close File With Read/Write Permission */ fid = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2733,7 +2733,7 @@ test_rw_noupdate(void) /* Calculate checksum for the file */ ret = cal_chksum(FILE1, &chksum2); - CHECK(ret, FAIL, "HDopen"); + CHECK(ret, FAIL, "cal_chksum"); /* The two checksums are the same, i.e. the file is not changed */ VERIFY(chksum1, chksum2, "Checksum"); @@ -4357,9 +4357,9 @@ test_filespace_compatible(void) const char *filename = H5_get_srcdir_filename(OLD_FILENAME[j]); /* Corrected test file name */ /* Open and copy the test file into a temporary file */ - fd_old = HDopen(filename, O_RDONLY, 0666); + fd_old = HDopen(filename, O_RDONLY); CHECK(fd_old, FAIL, "HDopen"); - fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, 0666); + fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd_new, FAIL, "HDopen"); /* Copy data */ diff --git a/test/tmisc.c b/test/tmisc.c index 2c0fa96..102325a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -178,17 +178,12 @@ typedef struct #define MISC13_GROUP1_NAME "Group1" #define MISC13_GROUP2_NAME "Group2" #define MISC13_DTYPE_NAME "Datatype" -#define MISC13_RANK 2 -#define MISC13_DIM1 20 -#define MISC13_DIM2 30 +#define MISC13_RANK 1 +#define MISC13_DIM1 600 #define MISC13_CHUNK_DIM1 10 -#define MISC13_CHUNK_DIM2 15 #define MISC13_USERBLOCK_SIZE 512 #define MISC13_COPY_BUF_SIZE 4096 -unsigned m13_data[MISC13_DIM1][MISC13_DIM2]; /* Data to write to dataset */ -unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset */ - /* Definitions for misc. test #14 */ #define MISC14_FILE "tmisc14.h5" #define MISC14_DSET1_NAME "Dataset1" @@ -2088,38 +2083,36 @@ test_misc12(void) /* Various routines for misc. 13 test */ static void -init_data(void) +misc13_init_data(unsigned *original_data) { - unsigned u,v; /* Local index variables */ + unsigned u; - for(u=0; u<MISC13_DIM1; u++) - for(v=0; v<MISC13_DIM2; v++) - m13_data[u][v]=(u*MISC13_DIM2)+v; + for(u = 0; u < MISC13_DIM1; u++) + original_data[u] = u; } -static int -verify_data(void) +static hbool_t +misc13_verify_data_match(const unsigned *original_data, const unsigned *read_data) { - unsigned u,v; /* Local index variables */ + unsigned u; - for(u=0; u<MISC13_DIM1; u++) - for(v=0; v<MISC13_DIM2; v++) - if(m13_data[u][v]!=m13_rdata[u][v]) - return(-1); - return(0); + for(u = 0; u < MISC13_DIM1; u++) + if(original_data[u] != read_data[u]) + return FALSE; + + return TRUE; } static void -create_dataset(hid_t loc_id, const char *name, hid_t dcpl) +misc13_create_dataset(hid_t loc_id, const char *name, hid_t dcpl, const unsigned *data) { - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hsize_t dims[MISC13_RANK]; /* Dataset dimensions */ - herr_t ret; /* Generic return value */ + hid_t dsid = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[MISC13_RANK]; /* Dataset dimensions */ + herr_t ret; /* Generic return value */ /* Create dataspace for use with dataset */ dims[0] = MISC13_DIM1; - dims[1] = MISC13_DIM2; sid = H5Screate_simple(MISC13_RANK, dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); @@ -2128,7 +2121,7 @@ create_dataset(hid_t loc_id, const char *name, hid_t dcpl) CHECK(dsid, FAIL, "H5Dcreate2"); /* Write some data to dataset */ - ret = H5Dwrite(dsid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, m13_data); + ret = H5Dwrite(dsid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); CHECK(ret, FAIL, "H5Dwrite"); /* Close the contiguous dataset */ @@ -2138,64 +2131,74 @@ create_dataset(hid_t loc_id, const char *name, hid_t dcpl) /* Close the dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} + +} /* end misc13_create_dataset() */ static void -verify_dataset(hid_t loc_id, const char *name) +misc13_verify_dataset(hid_t loc_id, const char *name, const unsigned *data) { - hid_t dsid; /* Dataset ID */ - herr_t ret; /* Generic return value */ + unsigned *read_data = NULL; /* Data to write to dataset */ + hid_t dsid = -1; /* Dataset ID */ + herr_t ret; /* Generic return value */ + + /* Create a data buffer for the dataset read */ + read_data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); + CHECK(read_data, NULL, "HDcalloc"); /* Open the contiguous dataset in the root group */ dsid = H5Dopen2(loc_id, name, H5P_DEFAULT); CHECK(dsid, FAIL, "H5Dopen2"); /* Read the data */ - ret = H5Dread(dsid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, m13_rdata); + ret = H5Dread(dsid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_data); CHECK(ret, FAIL, "H5Dread"); - /* Verify that the data is correct */ - ret=verify_data(); - CHECK(ret, FAIL, "verify_data"); + /* Verify that the data are correct */ + ret = misc13_verify_data_match(data, read_data); + CHECK(ret, FAIL, "misc13_verify_data_match"); /* Close the contiguous dataset */ ret = H5Dclose(dsid); CHECK(ret, FAIL, "H5Dclose"); -} + + /* Free the dataset read buffer */ + HDfree(read_data); + +} /* end misc13_verify_dataset() */ static void -create_hdf_file(const char *name) +misc13_create_hdf_file(const char *name, const unsigned *data) { - hid_t fid; /* File ID */ - hid_t gid,gid2; /* Group IDs */ - hid_t tid; /* Datatype ID */ - hid_t dcpl; /* Dataset creation property list ID */ - hsize_t chunk_dims[MISC13_RANK]; /* Chunk dimensions */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + hid_t gid1 = -1; /* Group ID (level 1) */ + hid_t gid2 = -1; /* Group ID (level 2) */ + hid_t tid = -1; /* Datatype ID */ + hid_t dcplid = -1; /* Dataset creation property list ID */ + hsize_t chunk_dims[MISC13_RANK]; /* Chunk dimensions */ + herr_t ret; /* Generic return value */ /* Create file */ - fid=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create DCPL for use with datasets */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + dcplid = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcplid, FAIL, "H5Pcreate"); /* Set the DCPL to be chunked */ - ret = H5Pset_layout(dcpl, H5D_CHUNKED); + ret = H5Pset_layout(dcplid, H5D_CHUNKED); CHECK(ret, FAIL, "H5Pset_layout"); /* Use chunked storage for this DCPL */ chunk_dims[0] = MISC13_CHUNK_DIM1; - chunk_dims[1] = MISC13_CHUNK_DIM2; - ret = H5Pset_chunk(dcpl, MISC13_RANK, chunk_dims); + ret = H5Pset_chunk(dcplid, MISC13_RANK, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); /* Create contiguous dataset in root group */ - create_dataset(fid, MISC13_DSET1_NAME, H5P_DEFAULT); + misc13_create_dataset(fid, MISC13_DSET1_NAME, H5P_DEFAULT, data); /* Create chunked dataset in root group */ - create_dataset(fid, MISC13_DSET2_NAME, dcpl); + misc13_create_dataset(fid, MISC13_DSET2_NAME, dcplid, data); /* Create a datatype to commit to the file */ tid = H5Tcopy(H5T_NATIVE_INT); @@ -2210,11 +2213,11 @@ create_hdf_file(const char *name) CHECK(ret, FAIL, "H5Tclose"); /* Create a group in the root group */ - gid = H5Gcreate2(fid, MISC13_GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); + gid1 = H5Gcreate2(fid, MISC13_GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid1, FAIL, "H5Gcreate2"); /* Create another group in the new group */ - gid2 = H5Gcreate2(gid, MISC13_GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(gid1, MISC13_GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid2, FAIL, "H5Gcreate2"); /* Close the second group */ @@ -2222,17 +2225,17 @@ create_hdf_file(const char *name) CHECK(ret, FAIL, "H5Gclose"); /* Create contiguous dataset in new group */ - create_dataset(gid, MISC13_DSET1_NAME, H5P_DEFAULT); + misc13_create_dataset(gid1, MISC13_DSET1_NAME, H5P_DEFAULT, data); /* Create chunked dataset in new group */ - create_dataset(gid, MISC13_DSET2_NAME, dcpl); + misc13_create_dataset(gid1, MISC13_DSET2_NAME, dcplid, data); /* Create a datatype to commit to the new group */ tid = H5Tcopy(H5T_NATIVE_INT); CHECK(tid, FAIL, "H5Tcopy"); /* Create a named datatype in the new group */ - ret = H5Tcommit2(gid, MISC13_DTYPE_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Tcommit2(gid1, MISC13_DTYPE_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); /* Close named datatype */ @@ -2240,25 +2243,26 @@ create_hdf_file(const char *name) CHECK(ret, FAIL, "H5Tclose"); /* Close the first group */ - ret = H5Gclose(gid); + ret = H5Gclose(gid1); CHECK(ret, FAIL, "H5Gclose"); /* Close the DCPL */ - ret = H5Pclose(dcpl); + ret = H5Pclose(dcplid); CHECK(ret, FAIL, "H5Pclose"); /* Close the file */ ret = H5Fclose(fid); - HDassert(ret >= 0); CHECK(ret, FAIL, "H5Fclose"); -} + +} /* end misc13_create_hdf_file() */ static void -insert_user_block(const char *old_name, const char *new_name,const char *str,size_t size) +misc13_insert_user_block(const char *old_name, const char *new_name, const char *str, size_t size) { - FILE *new_fp, *old_fp; /* Pointers to new & old files */ - void *user_block; /* Pointer to user block to write to file */ - void *copy_buf; /* Pointer to buffer for copying data */ + FILE *new_fp = NULL; /* Pointers to new & old files */ + FILE *old_fp = NULL; + void *user_block = NULL; /* Pointer to user block to write to file */ + void *copy_buf = NULL; /* Pointer to buffer for copying data */ size_t written; /* Amount of data written to new file */ size_t read_in; /* Amount of data read in from old file */ int ret; /* Generic status value */ @@ -2268,10 +2272,10 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz CHECK(user_block, NULL, "HDcalloc"); /* Copy in the user block data */ - HDmemcpy(user_block,str,strlen(str)); + HDmemcpy(user_block, str, strlen(str)); /* Open the new file */ - new_fp=HDfopen(new_name,"wb"); + new_fp = HDfopen(new_name,"wb"); CHECK(new_fp, NULL, "HDfopen"); /* Write the user block to the new file */ @@ -2279,7 +2283,7 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz VERIFY(written, size, "HDfwrite"); /* Open the old file */ - old_fp=HDfopen(old_name,"rb"); + old_fp = HDfopen(old_name,"rb"); CHECK(old_fp, NULL, "HDfopen"); /* Allocate space for the copy buffer */ @@ -2291,14 +2295,14 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz /* Write the data to the new file */ written = HDfwrite(copy_buf, (size_t)1, read_in, new_fp); VERIFY(written, read_in, "HDfwrite"); - } /* end while */ + } /* Close the old file */ - ret=HDfclose(old_fp); + ret = HDfclose(old_fp); VERIFY(ret, 0, "HDfclose"); /* Close the new file */ - ret=HDfclose(new_fp); + ret = HDfclose(new_fp); VERIFY(ret, 0, "HDfclose"); /* Free the copy buffer */ @@ -2306,81 +2310,84 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz /* Free the user block */ HDfree(user_block); -} + +} /* end misc13_insert_user_block() */ static void -verify_file(const char *name, hsize_t blk_size, unsigned check_new_data) +misc13_verify_file(const char *name, const unsigned *data, hsize_t userblock_size, + hbool_t check_for_new_dataset) { - hid_t fid; /* File ID */ - hid_t gid,gid2; /* Group IDs */ - hid_t tid; /* Datatype ID */ - hid_t fcpl; /* File creation property list ID */ - hsize_t userblock; /* Userblock size retrieved from FCPL */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + hid_t gid1 = -1; /* Group IDs */ + hid_t gid2 = -1; /* Group IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t fcplid = -1; /* File creation property list ID */ + hsize_t ub_size_out; /* Userblock size retrieved from FCPL */ + herr_t ret; /* Generic return value */ /* Open the file */ - fid=H5Fopen(name, H5F_ACC_RDONLY, H5P_DEFAULT); + fid = H5Fopen(name, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Get the file's FCPL */ - fcpl=H5Fget_create_plist(fid); - CHECK(fcpl, FAIL, "H5Fget_create_plist"); + fcplid = H5Fget_create_plist(fid); + CHECK(fcplid, FAIL, "H5Fget_create_plist"); /* Get the user block size for the file */ - ret=H5Pget_userblock(fcpl,&userblock); + ret = H5Pget_userblock(fcplid, &ub_size_out); CHECK(ret, FAIL, "H5Pget_userblock"); /* Check the userblock size */ - VERIFY(userblock, blk_size, "H5Pget_userblock"); + VERIFY(userblock_size, ub_size_out, "H5Pget_userblock"); /* Close the FCPL */ - ret = H5Pclose(fcpl); + ret = H5Pclose(fcplid); CHECK(ret, FAIL, "H5Pclose"); /* Verify the contiguous dataset in the root group */ - verify_dataset(fid,MISC13_DSET1_NAME); + misc13_verify_dataset(fid, MISC13_DSET1_NAME, data); /* Verify the chunked dataset in the root group */ - verify_dataset(fid,MISC13_DSET2_NAME); + misc13_verify_dataset(fid, MISC13_DSET2_NAME, data); /* Verify the "new" contiguous dataset in the root group, if asked */ - if(check_new_data) - verify_dataset(fid,MISC13_DSET3_NAME); + if(check_for_new_dataset) + misc13_verify_dataset(fid, MISC13_DSET3_NAME, data); /* Open the named datatype in the root group */ tid = H5Topen2(fid, MISC13_DTYPE_NAME, H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); /* Verify the type is correct */ - VERIFY(H5Tequal(tid,H5T_NATIVE_INT), TRUE, "H5Tequal"); + VERIFY(H5Tequal(tid, H5T_NATIVE_INT), TRUE, "H5Tequal"); /* Close named datatype */ - ret=H5Tclose(tid); + ret = H5Tclose(tid); CHECK(ret, FAIL, "H5Tclose"); /* Open the first group */ - gid = H5Gopen2(fid, MISC13_GROUP1_NAME, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gopen2"); + gid1 = H5Gopen2(fid, MISC13_GROUP1_NAME, H5P_DEFAULT); + CHECK(gid1, FAIL, "H5Gopen2"); /* Verify the contiguous dataset in the first group */ - verify_dataset(gid,MISC13_DSET1_NAME); + misc13_verify_dataset(gid1, MISC13_DSET1_NAME, data); /* Verify the chunked dataset in the first group */ - verify_dataset(gid,MISC13_DSET2_NAME); + misc13_verify_dataset(gid1, MISC13_DSET2_NAME, data); /* Open the named datatype in the first group */ - tid = H5Topen2(gid,MISC13_DTYPE_NAME, H5P_DEFAULT); + tid = H5Topen2(gid1, MISC13_DTYPE_NAME, H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); /* Verify the type is correct */ - VERIFY(H5Tequal(tid,H5T_NATIVE_INT), TRUE, "H5Tequal"); + VERIFY(H5Tequal(tid, H5T_NATIVE_INT), TRUE, "H5Tequal"); /* Close named datatype */ - ret=H5Tclose(tid); + ret = H5Tclose(tid); CHECK(ret, FAIL, "H5Tclose"); /* Open the second group */ - gid2 = H5Gopen2(gid, MISC13_GROUP2_NAME, H5P_DEFAULT); + gid2 = H5Gopen2(gid1, MISC13_GROUP2_NAME, H5P_DEFAULT); CHECK(gid2, FAIL, "H5Gopen2"); /* Close the second group */ @@ -2388,31 +2395,33 @@ verify_file(const char *name, hsize_t blk_size, unsigned check_new_data) CHECK(ret, FAIL, "H5Gclose"); /* Close the first group */ - ret = H5Gclose(gid); + ret = H5Gclose(gid1); CHECK(ret, FAIL, "H5Gclose"); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} + +} /* end misc13_verify_file() */ static void -add_to_new_file(const char *name) +misc13_add_to_new_file(const char *name, const unsigned *data) { - hid_t fid; /* File ID */ + hid_t fid = -1; /* File ID */ herr_t ret; /* Generic return value */ /* Open the file */ - fid=H5Fopen(name, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(name, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Create new contiguous dataset in root group */ - create_dataset(fid, MISC13_DSET3_NAME, H5P_DEFAULT); + misc13_create_dataset(fid, MISC13_DSET3_NAME, H5P_DEFAULT, data); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} + +} /* end misc13_add_to_new_file() */ /**************************************************************** ** @@ -2423,26 +2432,44 @@ add_to_new_file(const char *name) static void test_misc13(void) { + unsigned *data = NULL; /* Data to write to dataset */ + hsize_t userblock_size; /* Correct size of userblock */ + hbool_t check_for_new_dataset; /* Whether to check for the post-userblock-creation dataset */ + + /* Create a data buffer for the datasets */ + data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); + CHECK(data, NULL, "HDcalloc"); + /* Initialize data to write */ - init_data(); + misc13_init_data(data); /* Create first file, with no user block */ - create_hdf_file(MISC13_FILE_1); + misc13_create_hdf_file(MISC13_FILE_1, data); /* Verify file contents are correct */ - verify_file(MISC13_FILE_1,(hsize_t)0,0); + userblock_size = 0; + check_for_new_dataset = FALSE; + misc13_verify_file(MISC13_FILE_1, data, userblock_size, check_for_new_dataset); /* Create a new file by inserting a user block in front of the first file */ - insert_user_block(MISC13_FILE_1, MISC13_FILE_2, "Test String", (size_t)MISC13_USERBLOCK_SIZE); + misc13_insert_user_block(MISC13_FILE_1, MISC13_FILE_2, "Test String", (size_t)MISC13_USERBLOCK_SIZE); /* Verify file contents are still correct */ - verify_file(MISC13_FILE_2,(hsize_t)MISC13_USERBLOCK_SIZE,0); + userblock_size = MISC13_USERBLOCK_SIZE; + check_for_new_dataset = FALSE; + misc13_verify_file(MISC13_FILE_2, data, userblock_size, check_for_new_dataset); /* Make certain we can modify the new file */ - add_to_new_file(MISC13_FILE_2); + misc13_add_to_new_file(MISC13_FILE_2, data); /* Verify file contents are still correct */ - verify_file(MISC13_FILE_2,(hsize_t)MISC13_USERBLOCK_SIZE,1); + userblock_size = MISC13_USERBLOCK_SIZE; + check_for_new_dataset = TRUE; + misc13_verify_file(MISC13_FILE_2, data, userblock_size, check_for_new_dataset); + + /* Free the dataset buffer */ + HDfree(data); + } /* end test_misc13() */ /**************************************************************** diff --git a/test/twriteorder.c b/test/twriteorder.c index 0e1d0d4..4c86636 100644 --- a/test/twriteorder.c +++ b/test/twriteorder.c @@ -231,9 +231,9 @@ int create_wo_file(void) int ret_code; /* Create the data file */ - if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, 0664)) < 0) { - printf("WRITER: error from open\n"); - return -1; + if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) { + HDprintf("WRITER: error from open\n"); + return -1; } blkaddr=0; /* write it to partition 0 */ @@ -297,9 +297,9 @@ int read_wo_file(void) char buffer[BLOCKSIZE_DFT]; /* Open the data file */ - if ((read_fd = HDopen(DATAFILE, O_RDONLY, 0)) < 0) { - printf("READER: error from open\n"); - return -1; + if ((read_fd = HDopen(DATAFILE, O_RDONLY)) < 0) { + HDprintf("READER: error from open\n"); + return -1; } /* keep reading the initial block address until it is non-zero before proceeding. */ while (blkaddr == 0){ |