From db9525c2a3ee70379032bae71f26866451df7e58 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Mon, 26 Oct 1998 09:49:52 -0500 Subject: [svn-r789] Changes since 19981023 ---------------------- ./MANIFEST ./test/Makefile.in ./test/flush1.c [NEW] ./test/flush2.c [NEW] Test to see if calling H5Fflush() results in a consistent file. ./src/H5.c ./src/H5A.c ./src/H5D.c ./src/H5Fistore.c ./src/H5I.c ./src/H5S.c ./src/H5Shyper.c ./src/H5Sselect.c ./src/H5TB.c Changed comparisons against SUCCEED and FAIL to >=0 and <0 in about 15 places. ./src/H5.c ./src/H5V.c ./src/H5detect.c ./src/H5private.h ./src/H5public.h ./test/big.c ./test/chunk.c ./test/cmpd_dset.c ./test/dsets.c ./test/dtypes.c ./test/external.c ./test/fillval.c ./test/iopipe.c ./test/links.c ./test/mount.c ./test/mtime.c ./test/ragged.c ./test/shtype.c ./test/unlink.c Removed ^M from the end of lines inserted on broken OS's ;-) ./src/H5private.h Changed c++ comments to c comments. ./src/H5R.c Added tracing macros. --- MANIFEST | 2 + src/H5.c | 2 +- src/H5A.c | 2 +- src/H5D.c | 16 +++--- src/H5Distore.c | 10 ++-- src/H5Fistore.c | 10 ++-- src/H5I.c | 7 +-- src/H5R.c | 6 +-- src/H5S.c | 4 -- src/H5Shyper.c | 6 +-- src/H5Sselect.c | 4 +- src/H5TB.c | 15 ------ src/H5private.h | 3 +- test/Makefile.in | 19 ++++--- test/chunk.c | 8 +-- test/flush1.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++ test/flush2.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/mount.c | 1 + test/ragged.c | 2 +- 19 files changed, 331 insertions(+), 66 deletions(-) create mode 100644 test/flush1.c create mode 100644 test/flush2.c diff --git a/MANIFEST b/MANIFEST index 129bd01..2accca6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -295,6 +295,8 @@ ./test/extend.c ./test/external.c ./test/fillval.c +./test/flush1.c +./test/flush2.c ./test/gheap.c ./test/hyperslab.c ./test/iopipe.c diff --git a/src/H5.c b/src/H5.c index 20d7da4..e2ecb89 100644 --- a/src/H5.c +++ b/src/H5.c @@ -235,7 +235,7 @@ H5_init_thread(void) FUNC_ENTER_INIT(H5_init_thread, NULL, FAIL); /* Add the "thread termination" routine to the exit chain */ - if (H5_add_exit(&H5_term_thread) == FAIL) + if (H5_add_exit(&H5_term_thread)<0) HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to set thread atexit function"); diff --git a/src/H5A.c b/src/H5A.c index 8b3241c..da5c3ed 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -72,7 +72,7 @@ H5A_init_interface(void) */ if ((ret_value = H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, - (herr_t (*)(void *)) H5A_close)) == FAIL) { + (herr_t (*)(void *)) H5A_close))<0) { HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to initialize attribute group"); } diff --git a/src/H5D.c b/src/H5D.c index f7bc440..d37b3eb 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -1297,7 +1297,7 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) done: if (space) H5S_close (space); - if (ret_value==FAIL && dataset) { + if (ret_value<0 && dataset) { if (H5F_addr_defined(&(dataset->ent.header))) { H5O_close(&(dataset->ent)); } @@ -1586,16 +1586,15 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, } if (NULL==(tconv_buf=xfer_parms->tconv_buf)) { /* Allocate temporary buffer */ - if (FAIL==(tconv_id = H5TB_get_buf(target_size, 1, - (void **)&tconv_buf))) { + if ((tconv_id = H5TB_get_buf(target_size, 1, (void **)&tconv_buf))<0) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } } if (need_bkg && NULL==(bkg_buf=xfer_parms->bkg_buf)) { /* Allocate temporary buffer */ - if (FAIL==(bkg_id = H5TB_get_buf(request_nelmts*dst_type_size, 1, - (void **)&bkg_buf))) { + if ((bkg_id=H5TB_get_buf(request_nelmts*dst_type_size, 1, + (void **)&bkg_buf))<0) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } @@ -1960,16 +1959,15 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, } if (NULL==(tconv_buf=xfer_parms->tconv_buf)) { /* Allocate temporary buffer */ - if (FAIL==(tconv_id = H5TB_get_buf(target_size, 1, - (void **)&tconv_buf))) { + if ((tconv_id=H5TB_get_buf(target_size, 1, (void **)&tconv_buf))<0) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } } if (need_bkg && NULL==(bkg_buf=xfer_parms->bkg_buf)) { /* Allocate temporary buffer */ - if (FAIL==(bkg_id = H5TB_get_buf(request_nelmts*dst_type_size, 1, - (void **)&bkg_buf))) { + if ((bkg_id=H5TB_get_buf(request_nelmts*dst_type_size, 1, + (void **)&bkg_buf))<0) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } diff --git a/src/H5Distore.c b/src/H5Distore.c index 49311f5..4eeb05f 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -1625,7 +1625,7 @@ H5F_istore_read(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, H5F_istore_ud1_t udata; H5O_layout_t l; /* temporary layout */ H5D_xfer_t tmp_xfer = *xfer; - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); }; @@ -1643,7 +1643,7 @@ H5F_istore_read(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, tmp_xfer.xfer_mode = H5D_XFER_DFLT; if (H5F_arr_read(f, &tmp_xfer, &l, pline, fill, NULL/*no efl*/, sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)==FAIL){ + buf)<0){ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data from file"); } @@ -1802,7 +1802,7 @@ H5F_istore_write(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, H5F_istore_ud1_t udata; H5O_layout_t l; /* temporary layout */ H5D_xfer_t tmp_xfer = *xfer; - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); }; @@ -1820,7 +1820,7 @@ H5F_istore_write(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, tmp_xfer.xfer_mode = H5D_XFER_DFLT; if (H5F_arr_write(f, &tmp_xfer, &l, pline, fill, NULL/*no efl*/, sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)==FAIL){ + buf)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); } @@ -2140,7 +2140,7 @@ H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, printf(")\n"); #endif #ifdef NO - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ #endif /* No file space assigned yet. Allocate it. */ /* The following needs improvement like calling the */ diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 49311f5..4eeb05f 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -1625,7 +1625,7 @@ H5F_istore_read(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, H5F_istore_ud1_t udata; H5O_layout_t l; /* temporary layout */ H5D_xfer_t tmp_xfer = *xfer; - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); }; @@ -1643,7 +1643,7 @@ H5F_istore_read(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, tmp_xfer.xfer_mode = H5D_XFER_DFLT; if (H5F_arr_read(f, &tmp_xfer, &l, pline, fill, NULL/*no efl*/, sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)==FAIL){ + buf)<0){ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data from file"); } @@ -1802,7 +1802,7 @@ H5F_istore_write(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, H5F_istore_ud1_t udata; H5O_layout_t l; /* temporary layout */ H5D_xfer_t tmp_xfer = *xfer; - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); }; @@ -1820,7 +1820,7 @@ H5F_istore_write(H5F_t *f, const H5D_xfer_t *xfer, const H5O_layout_t *layout, tmp_xfer.xfer_mode = H5D_XFER_DFLT; if (H5F_arr_write(f, &tmp_xfer, &l, pline, fill, NULL/*no efl*/, sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)==FAIL){ + buf)<0){ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); } @@ -2140,7 +2140,7 @@ H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, printf(")\n"); #endif #ifdef NO - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)==FAIL){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ #endif /* No file space assigned yet. Allocate it. */ /* The following needs improvement like calling the */ diff --git a/src/H5I.c b/src/H5I.c index b387fc2..3a23010 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -251,7 +251,7 @@ H5I_init_group(H5I_type_t grp, /* IN: Group to initialize */ grp_ptr->count++; done: - if (ret_value == FAIL) { + if (ret_value<0) { /* Error condition cleanup */ if (grp_ptr != NULL) { H5MM_xfree (grp_ptr->id_list); @@ -463,11 +463,6 @@ H5I_register(H5I_type_t grp, void *object) ret_value = new_id; done: - if (ret_value == FAIL) { - /* Error condition cleanup */ - } - - /* Normal function cleanup */ FUNC_LEAVE(ret_value); } diff --git a/src/H5R.c b/src/H5R.c index a7d79c7..15ad790 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -202,7 +202,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t herr_t ret_value = FAIL; FUNC_ENTER(H5Rcreate, FAIL); - H5TRACE5("e","*risRti",ref,loc_id,name,ref_type,space_id); + H5TRACE5("e","xisRti",ref,loc_id,name,ref_type,space_id); /* Check args */ if(ref==NULL) @@ -325,7 +325,7 @@ H5Rdereference(hid_t dataset, H5R_type_t ref_type, void *_ref) hid_t ret_value = FAIL; FUNC_ENTER(H5Rdereference, FAIL); - H5TRACE2("i","i*r",dataset,_ref); + H5TRACE3("i","iRtx",dataset,ref_type,_ref); /* Check args */ if (H5I_DATASET != H5I_get_type(dataset) || NULL == (dset = H5I_object(dataset))) @@ -407,7 +407,7 @@ H5Rget_space(void *ref) hid_t ret_value = FAIL; FUNC_ENTER(H5Rget_space, FAIL); - H5TRACE1("i","*r",ref); + H5TRACE1("i","x",ref); /* Check args */ if(ref==NULL) diff --git a/src/H5S.c b/src/H5S.c index 3c689ba..09bde19 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1247,10 +1247,6 @@ H5Sis_simple(hid_t space_id) ret_value = H5S_is_simple(space); done: - if (ret_value == FAIL) { /* Error condition cleanup */ - - } /* end if */ - /* Normal function cleanup */ FUNC_LEAVE(ret_value); } diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 40a157f..c19a76b 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -441,7 +441,7 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node, assert(fhyper_info); /* Allocate temporary buffer of proper size */ - if((node->cinfo.block_id=H5TB_get_buf(node->cinfo.size*fhyper_info->elmt_size,1,(void **)&(node->cinfo.block)))==FAIL) + if((node->cinfo.block_id=H5TB_get_buf(node->cinfo.size*fhyper_info->elmt_size,1,(void **)&(node->cinfo.block)))<0) HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab cache block"); @@ -683,7 +683,7 @@ H5S_hyper_fread (intn dim, H5S_hyper_fhyper_info_t *fhyper_info) /* Read information from the cached block */ if(regions[i].node->cinfo.cached) { - if(H5S_hyper_block_read(regions[i].node,fhyper_info,region_size)==FAIL) + if(H5S_hyper_block_read(regions[i].node,fhyper_info,region_size)<0) HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error"); } else { @@ -955,7 +955,7 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_fhyper_info_t *fhyper_info) /* Read information from the cached block */ if(regions[i].node->cinfo.cached) { - if(H5S_hyper_block_write(regions[i].node,fhyper_info,region_size)==FAIL) + if(H5S_hyper_block_write(regions[i].node,fhyper_info,region_size)<0) HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, 0, "write error"); } else { diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 8e7383f..e770d3a 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -321,7 +321,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, hssize_t fill=1; /* Allocate temporary buffer */ - if((stride_id = H5TB_get_buf(sizeof(hssize_t)*space->extent.u.simple.rank,0,(void **)&_stride)) ==FAIL) + if((stride_id = H5TB_get_buf(sizeof(hssize_t)*space->extent.u.simple.rank,0,(void **)&_stride))<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate stride vector"); H5V_array_fill(_stride,&fill,sizeof(hssize_t),space->extent.u.simple.rank); @@ -332,7 +332,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, if(block==NULL) { hssize_t fill=1; - if((block_id = H5TB_get_buf(sizeof(hssize_t)*space->extent.u.simple.rank,0,(void **)&_block))==FAIL) + if((block_id = H5TB_get_buf(sizeof(hssize_t)*space->extent.u.simple.rank,0,(void **)&_block))<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate block vector"); H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); diff --git a/src/H5TB.c b/src/H5TB.c index f07b353..9e39324 100644 --- a/src/H5TB.c +++ b/src/H5TB.c @@ -426,11 +426,6 @@ H5TB_resize_buf(hid_t tbuf_id, hsize_t size) } /* end else */ } /* end if */ -#ifdef LATER -done: -#endif - if (ret_value == FAIL) { - } FUNC_LEAVE(ret_value); } /* H5TB_resize_buf() */ @@ -489,11 +484,6 @@ H5TB_garbage_coll(void) ret_value=SUCCEED; -#ifdef LATER -done: -#endif - if (ret_value == FAIL) { - } FUNC_LEAVE(ret_value); } /* H5TB_garbage_coll() */ @@ -532,11 +522,6 @@ H5TB_release_buf(hid_t tbuf_id) ret_value=SUCCEED; -#ifdef LATER -done: -#endif - if (ret_value == FAIL) { - } FUNC_LEAVE(ret_value); } /* H5TB_release_buf() */ diff --git a/src/H5private.h b/src/H5private.h index 058dedf..25e93f6 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -63,7 +63,8 @@ # include # include # include -#endif//if defined(WIN32) +#endif /*if defined(WIN32)*/ + #endif /* diff --git a/test/Makefile.in b/test/Makefile.in index 3b43e76..98f4af0 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -12,7 +12,7 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@ # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. TESTS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \ - external shtype links unlink big mtime fillval mount + external shtype links unlink big mtime fillval mount flush1 flush2 TIMINGS=iopipe chunk ragged overhead # Temporary files @@ -25,17 +25,18 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ shtype2a.h5 shtype2b.h5 shtype3.h5 links.h5 chunk.h5 big.data \ big[0-9][0-9][0-9][0-9][0-9].h5 dtypes1.h5 dtypes2.h5 tattr.h5 \ tselect.h5 mtime.h5 ragged.h5 grptime.h5 unlink.h5 overhead.h5 \ - fillval_[0-9].h5 mount_[0-9].h5 trefer.h5 + fillval_[0-9].h5 mount_[0-9].h5 trefer.h5 flush.h5 CLEAN=$(TIMINGS) # Source and object files for programs... The TEST_SRC list contains all the # source files and is used for things like dependencies, archiving, etc. The # other source lists are for the individual tests, the files of which may # overlap with other tests. -TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c trefer.c tselect.c \ - tstab.c th5s.c dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c \ - external.c iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c \ - mtime.c ragged.c unlink.c overhead.c fillval.c mount.c +TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c trefer.c \ + tselect.c tstab.c th5s.c dtypes.c hyperslab.c istore.c dsets.c \ + cmpd_dset.c extend.c external.c iopipe.c gheap.c shtype.c big.c links.c \ + chunk.c bittests.c mtime.c ragged.c unlink.c overhead.c fillval.c \ + mount.c flush1.c flush2.c TEST_OBJ=$(TEST_SRC:.c=.o) # Private header files (not to be installed)... @@ -119,4 +120,10 @@ fillval: fillval.o ../src/libhdf5.a mount: mount.o ../src/libhdf5.a $(CC) $(CFLAGS) -o $@ mount.o ../src/libhdf5.a $(LIBS) +flush1: flush1.o ../src/libhdf5.a + $(CC) $(CFLAGS) -o $@ flush1.o ../src/libhdf5.a $(LIBS) + +flush2: flush2.o ../src/libhdf5.a + $(CC) $(CFLAGS) -o $@ flush2.o ../src/libhdf5.a $(LIBS) + @CONCLUDE@ diff --git a/test/chunk.c b/test/chunk.c index c0cbb9f..5af7d46 100644 --- a/test/chunk.c +++ b/test/chunk.c @@ -47,9 +47,9 @@ #define RM_CACHE_DELT 5 #define RM_START 0.50 #define RM_END 5.00 -#define RM_DELTA 0.5 -#define RM_W0 1.0 -#define RM_NRDCC 5210 +#define RM_DELTA 0.50 +#define RM_W0 0.0 +#define RM_NRDCC 521 /* Diagonal test */ #define DIAG_CACHE_STRT 25 @@ -57,7 +57,7 @@ #define DIAG_CACHE_DELT 5 #define DIAG_START 0.50 #define DIAG_END 5.00 -#define DIAG_DELTA 0.5 +#define DIAG_DELTA 0.50 /* #define DIAG_W0 0.65 */ /* #define DIAG_NRDCC 521 */ diff --git a/test/flush1.c b/test/flush1.c new file mode 100644 index 0000000..02ddbca --- /dev/null +++ b/test/flush1.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke + * Friday, October 23, 1998 + * + * Purpose: This is the first half of a two-part test that makes sure + * that a file can be read after an 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. + */ +#include +#include +#include + +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +# define __unused__ /*void*/ +#else +# define __unused__ __attribute__((unused)) +#endif + + +#define FILE_NAME_1 "flush.h5" /*do not clean up*/ + + + +/*------------------------------------------------------------------------- + * Function: display_error_cb + * + * Purpose: Displays the error stack after printing "*FAILED*". + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +display_error_cb (void __unused__ *client_data) +{ + puts ("*FAILED*"); + H5Eprint (stdout); + return 0; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Part 1 of a two-part H5Fflush() test. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Robb Matzke + * Friday, October 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t file, dcpl, space, dset, groups, grp; + hsize_t ds_size[2] = {100, 100}; + hsize_t ch_size[2] = {5, 5}; + double the_data[100][100]; + hsize_t i, j; + char name[256]; + + printf("%-70s", "Testing H5Fflush (part1)"); + fflush(stdout); + H5Eset_auto(display_error_cb, NULL); + + /* Create the file */ + if ((file=H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, + H5P_DEFAULT, H5P_DEFAULT))<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=H5Dcreate(file, "dset", H5T_NATIVE_FLOAT, space, H5P_DEFAULT))<0) + goto error; + + /* Write some data */ + for (i=0; i + * Friday, October 23, 1998 + * + * Purpose: This is the second half of a two-part test that makes sure + * that a file can be read after an application crashes as long + * as the file was flushed first. This half tries to read the + * file created by the first half. + */ +#undef NDEBUG +#include +#include +#include +#include + +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +# define __unused__ /*void*/ +#else +# define __unused__ __attribute__((unused)) +#endif + + +#define FILE_NAME_1 "flush.h5" + + + +/*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Removes test files + * + * Return: void + * + * Programmer: Robb Matzke + * Thursday, June 4, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup (void) +{ + if (!getenv ("HDF5_NOCLEANUP")) { + remove (FILE_NAME_1); + } +} + + +/*------------------------------------------------------------------------- + * Function: display_error_cb + * + * Purpose: Displays the error stack after printing "*FAILED*". + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +display_error_cb (void __unused__ *client_data) +{ + puts ("*FAILED*"); + H5Eprint (stdout); + return 0; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Part 1 of a two-part H5Fflush() test. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Robb Matzke + * Friday, October 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t file, space, dset, groups, grp; + hsize_t ds_size[2]; + double the_data[100][100], error; + hsize_t i, j; + char name[256]; + + printf("%-70s", "Testing H5Fflush (part2)"); + fflush(stdout); + H5Eset_auto(display_error_cb, NULL); + + /* Open the file */ + if ((file=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0) goto error; + + /* Open the dataset */ + if ((dset=H5Dopen(file, "dset"))<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]); + + /* Read some data */ + if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, + the_data)<0) goto error; + for (i=0; i