diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
commit | 7e79a8d71e6a579710e0fc2c677dfc32336d058f (patch) | |
tree | d9b4f93046b8c2930fd35b3ec75953eccf1c1a47 /test | |
parent | 52f3545bde417a7eaeb996bfc97b58ab32075c73 (diff) | |
download | hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.zip hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.gz hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.bz2 |
[svn-r7507] *** empty log message ***
Diffstat (limited to 'test')
-rw-r--r-- | test/Dependencies | 4 | ||||
-rw-r--r-- | test/Makefile.in | 26 | ||||
-rw-r--r-- | test/dtypes.c | 2 | ||||
-rw-r--r-- | test/enum.c | 5 | ||||
-rw-r--r-- | test/err_compat.c | 295 | ||||
-rw-r--r-- | test/error_test.c (renamed from test/errors.c) | 14 | ||||
-rw-r--r-- | test/gheap.c | 42 | ||||
-rw-r--r-- | test/h5test.c | 9 | ||||
-rw-r--r-- | test/lheap.c | 32 | ||||
-rw-r--r-- | test/ohdr.c | 90 | ||||
-rw-r--r-- | test/testfiles/err_compat_1 | 20 | ||||
-rw-r--r-- | test/testfiles/err_compat_2 | 4 | ||||
-rw-r--r-- | test/testfiles/error_test_1 | 31 | ||||
-rw-r--r-- | test/testfiles/error_test_2 | 4 | ||||
-rw-r--r-- | test/testhdf5.c | 4 | ||||
-rw-r--r-- | test/testhdf5.h | 77 |
16 files changed, 635 insertions, 24 deletions
diff --git a/test/Dependencies b/test/Dependencies index 7de8ea9..262fac7 100644 --- a/test/Dependencies +++ b/test/Dependencies @@ -2724,8 +2724,8 @@ dangle.lo: \ $(top_srcdir)/src/H5Oprivate.h \ $(top_srcdir)/src/H5HGprivate.h \ $(top_srcdir)/src/H5Zprivate.h -errors.lo: \ - $(top_srcdir)/test/errors.c \ +error_test.lo: \ + $(top_srcdir)/test/error_test.c \ $(top_srcdir)/test/h5test.h \ $(top_srcdir)/src/hdf5.h \ $(top_srcdir)/src/H5public.h \ diff --git a/test/Makefile.in b/test/Makefile.in index 4a89e03..d46d90e 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -22,14 +22,21 @@ srcdir=@srcdir@ ## libraries to the library list. CPPFLAGS=-I. -I$(srcdir) -I../src -I$(top_srcdir)/src @CPPFLAGS@ +## Test script for error_test and err_compat +TEST_SCRIPTS=$(srcdir)/testerror.sh + ## These are our main targets. They should be listed in the order to be ## executed, generally most specific tests to least specific tests. TEST_PROGS=testhdf5 lheap ohdr stab gheap hyperslab istore bittests dtypes \ dsets cmpd_dset extend external links unlink big mtime fillval mount \ flush1 flush2 enum gass_write gass_read gass_append set_extent \ srb_write srb_append srb_read ttsafe stream_test getname file_handle \ - ntypes dangle errors + ntypes dangle + +## Test programs for Error API +ERR_PROGS=error_test err_compat +PROGS=$(ERR_PROGS) $(TEST_PROGS) TIMINGS=testmeta ## The libh5test.a library provides common support code for the tests. We link @@ -57,7 +64,7 @@ MOSTLYCLEAN=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \ set_extent_read.h5 set_extent_create.h5 getname.h5 \ getname[1-3].h5 sec2_file.h5 family_file000[0-3][0-9].h5 \ multi_file-[rs].h5 core_file new_move_[ab].h5 ntypes.h5 \ - dangle.h5 errors.h5 + dangle.h5 error_test.h5 err_compat.h5 CLEAN=$(TIMINGS) @@ -75,7 +82,7 @@ TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \ ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c ttsafe_acreate.c \ gass_write.c gass_read.c gass_append.c srb_read.c srb_write.c \ srb_append.c stream_test.c set_extent.c getname.c file_handle.c \ - ntypes.c dangle.c errors.c + ntypes.c dangle.c error_test.c err_compat.c TEST_OBJ=$(TEST_SRC:.c=.lo) @@ -94,8 +101,12 @@ timings _timings: $(TIMINGS) fi; \ done; +## Programs have to be built before they can be tested! +## +check test _test: $(PROGS) + ## How to build the tests... They all depend on the test and hdf5 libraries. -$(TEST_PROGS): $(LIB) $(LIBHDF5) +$(PROGS): $(LIB) $(LIBHDF5) TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo tgenprop.lo \ th5s.lo theap.lo titerate.lo tmeta.lo ttime.lo trefer.lo trefstr.lo \ @@ -212,7 +223,10 @@ ntypes: ntypes.lo dangle: dangle.lo @$(LT_LINK_EXE) $(CFLAGS) -o $@ dangle.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) -errors: errors.lo - @$(LT_LINK_EXE) $(CFLAGS) -o $@ errors.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) +error_test: error_test.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ error_test.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) + +err_compat: err_compat.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ err_compat.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) @CONCLUDE@ diff --git a/test/dtypes.c b/test/dtypes.c index d8a6229..2c13b3d 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1239,7 +1239,7 @@ test_compound_7(void) /* Increase compound type size and try inserting field again */ if(H5Tset_size(tid2, sizeof(struct s2))<0) { H5_FAILED(); - printf("Incorrect size for struct 2\n"); + printf("Can't increase size for compound type\n"); goto error; } /* end if */ diff --git a/test/enum.c b/test/enum.c index 9e454c2..bd8397b 100644 --- a/test/enum.c +++ b/test/enum.c @@ -376,7 +376,12 @@ test_value_dsnt_exist(void) TESTING("for non-existing name and value"); /* Turn off error reporting since we expect failure in this test */ +#ifdef H5_WANT_H5_V1_6_COMPAT + if (H5Eset_auto(NULL, NULL) < 0) goto error; +#else if (H5Eset_auto(H5E_DEFAULT, NULL, NULL) < 0) goto error; +#endif /* H5_WANT_H5_V1_6_COMPAT */ + if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error; /* These calls should fail, since no memebrs exist yet */ diff --git a/test/err_compat.c b/test/err_compat.c new file mode 100644 index 0000000..fd84824 --- /dev/null +++ b/test/err_compat.c @@ -0,0 +1,295 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * October 14, 2001 + * + * Purpose: Tests Error API + */ +#include "h5test.h" + +#ifndef H5_WANT_H5_V1_6_COMPAT +int main(void) +{ + printf("Test skipped because backward compatbility with v1.6 is NOT configured in\n"); + return 0; +} +#else + +const char *FILENAME[] = { + "errors_compat", + NULL +}; + +#define DIM0 100 +#define DIM1 200 + +int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; + +#define DSET_NAME "a_dataset" +#define FAKE_ID -1 + +herr_t custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data); + + +/*------------------------------------------------------------------------- + * Function: test_error + * + * Purpose: Test error API functions + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +#ifndef TMP +static herr_t +test_error(hid_t file) +{ + hid_t dataset, space; + hid_t estack_id; + hsize_t dims[2]; + const char *FUNC_test_error="test_error"; + H5E_auto_t old_func; + void *old_data; + + TESTING("error API based on data I/O"); + fprintf(stderr, "\n"); + + /* Create the data space */ + dims[0] = DIM0; + dims[1] = DIM1; + if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + + /* Test H5E_BEGIN_TRY */ + H5E_BEGIN_TRY { + dataset = H5Dcreate(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT); + } H5E_END_TRY; + + /* Create the dataset */ + if ((dataset = H5Dcreate(file, DSET_NAME, H5T_STD_I32BE, space, + H5P_DEFAULT))<0) { + H5Epush(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_CANTCREATE, + "H5Dcreate failed"); + goto error; + } + + /* Test enabling and disabling default printing */ +#ifndef TMP + if (H5Eget_auto(&old_func, &old_data)<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func) + TEST_ERROR; + if (old_func != (H5E_auto_t)H5Eprint) + TEST_ERROR; + + if(H5Eset_auto(NULL, NULL)<0) + TEST_ERROR; +#endif + + /* Make H5Dwrite fail, verify default print is disabled */ + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { + H5Epush(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, + "H5Dwrite shouldn't succeed"); + goto error; + } + + if(H5Eset_auto(old_func, old_data)<0) + TEST_ERROR; + + /* In case program comes to this point, close dataset */ + if(H5Dclose(dataset)<0) TEST_ERROR; + + TEST_ERROR; + + error: + return -1; +} +#endif + + +/*------------------------------------------------------------------------- + * Function: error_stack + * + * Purpose: Dummy function. Simply make it fail. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 14, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +error_stack(void) +{ + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: dump_error + * + * Purpose: Prints error stack in default and customized ways. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 17, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +dump_error(void) +{ + /* Print errors in library default way */ + fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); + if(H5Eprint(stderr)<0) + TEST_ERROR; + + /* Customized way to print errors */ + fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + if(H5Ewalk(H5E_WALK_UPWARD, custom_print_cb, stderr)<0) + TEST_ERROR; + + return 0; + + error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: custom_print_cb + * + * Purpose: Callback function to print error stack in customized way. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 17, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data) +{ + FILE *stream = (FILE *)client_data; + char *maj; + char *min; + const int indent = 4; + + if((min = H5Eget_minor(err_desc->min_num))==NULL) + TEST_ERROR; + + if((maj = H5Eget_major(err_desc->maj_num))==NULL) + TEST_ERROR; + + fprintf (stream, "%*serror #%03d: %s in %s(): line %u\n", + indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); + fprintf (stream, "%*smajor: %s\n", indent*2, "", maj); + fprintf (stream, "%*sminor: %s\n", indent*2, "", min); + + return 0; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test error API. + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t file, fapl; + char filename[1024]; + const char *FUNC_main="main"; + H5E_auto_t old_func; + void *old_data; + + fprintf(stderr, " This program tests the Error API compatible with HDF5 v1.6. There're supposed to be some error messages\n"); + /*h5_reset();*/ + fapl = h5_fileaccess(); + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR ; + + /* Test error stack */ + if(error_stack()<0) { + /* Push an error onto error stack */ + H5Epush(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, + "Error test failed"); + + /* Print out the errors on stack */ + dump_error(); + + /* Empty error stack */ + H5Eclear(); + } + + /* Test error API */ + if(test_error(file)<0) { + H5Epush(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, + "Error test failed"); + H5Eprint(stderr); + } + + if (H5Fclose(file)<0) TEST_ERROR ; + h5_cleanup(FILENAME, fapl); + + printf("All error API tests passed.\n"); + return 0; + + error: + printf("***** ERROR TEST FAILED! *****\n"); + return 1; +} +#endif /* H5_WANT_H5_V1_6_COMPAT */ diff --git a/test/errors.c b/test/error_test.c index 3c40026..7e45f3d 100644 --- a/test/errors.c +++ b/test/error_test.c @@ -18,9 +18,16 @@ * * Purpose: Tests the H5Tget_native_type function. */ - #include "h5test.h" +#ifdef H5_WANT_H5_V1_6_COMPAT +int main(void) +{ + printf("Test skipped because backward compatbility with v1.6 is configured in\n"); + return 0; +} +#else + const char *FILENAME[] = { "errors", NULL @@ -344,10 +351,10 @@ custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data) if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE)<0) TEST_ERROR; - if(H5Eget_msg(err_desc->maj_id, NULL, maj, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE)<0) TEST_ERROR; - if(H5Eget_msg(err_desc->min_id, NULL, min, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE)<0) TEST_ERROR; fprintf (stream, "%*serror #%03d: %s in %s(): line %u\n", @@ -479,3 +486,4 @@ main(void) printf("***** ERROR TEST FAILED! *****\n"); return 1; } +#endif /* H5_WANT_H5_V1_6_COMPAT */ diff --git a/test/gheap.c b/test/gheap.c index b6b0b4c..d7098ea 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -89,7 +89,11 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -108,7 +112,11 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in)) { H5_FAILED(); puts(" Unable to read object"); @@ -181,7 +189,11 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i)<0) { H5_FAILED(); puts(" Unable to insert object into global heap"); @@ -195,7 +207,11 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in)) { H5_FAILED(); puts(" Unable to read object"); @@ -266,7 +282,11 @@ test_3 (hid_t fapl) for (i=0; i<1024; i++) { size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -345,7 +365,11 @@ test_4 (hid_t fapl) /* Insert */ size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -359,7 +383,11 @@ test_4 (hid_t fapl) * remove B, insert D, E, F; remove E; etc. */ if (1==i%3) { - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_remove (f, H5P_DATASET_XFER_DEFAULT, obj+i-1); if (status<0) { H5_FAILED(); diff --git a/test/h5test.c b/test/h5test.c index f583e4e..a3d4abf 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -112,7 +112,12 @@ static herr_t h5_errors(hid_t err_stack, void UNUSED *client_data) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint (stdout); +#else H5Eprint (err_stack, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + return 0; } @@ -214,7 +219,11 @@ h5_reset(void) HDfflush(stdout); HDfflush(stderr); H5close(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto (h5_errors, NULL); +#else H5Eset_auto (H5E_DEFAULT, h5_errors, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Cause the library to emit some diagnostics early so they don't diff --git a/test/lheap.c b/test/lheap.c index 6389a33..9e70848 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -74,12 +74,20 @@ main(void) goto error; if (NULL==(f=H5I_object(file))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5HL_create(f, H5P_DATASET_XFER_DEFAULT, 0, &heap_addr/*out*/)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } for (i = 0; i < NOBJS; i++) { @@ -90,7 +98,11 @@ main(void) if ((size_t)(-1)==(obj[i]=H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap_addr, strlen(buf)+1, buf))) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } @@ -106,7 +118,11 @@ main(void) if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } for (i=0; i<NOBJS; i++) { @@ -118,13 +134,21 @@ main(void) if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL == (s = H5HL_offset_into(f, heap, obj[i]))) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } @@ -138,7 +162,11 @@ main(void) if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } diff --git a/test/ohdr.c b/test/ohdr.c index 3d679f0..1e60e2d 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -74,7 +74,11 @@ main(void) if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } @@ -85,7 +89,11 @@ main(void) HDmemset(&oh_ent,0,sizeof(H5G_entry_t)); if (H5O_create(f, H5P_DATASET_XFER_DEFAULT, 64, &oh_ent/*out*/)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -96,17 +104,29 @@ main(void) stab.heap_addr = 22222222; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -128,17 +148,29 @@ main(void) stab.heap_addr = 44444444; if (H5O_modify(&oh_ent, H5O_STAB_ID, 0, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -161,17 +193,29 @@ main(void) stab.heap_addr = 66666666; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -193,17 +237,29 @@ main(void) stab.heap_addr = 88888888; if (H5O_modify(&oh_ent, H5O_STAB_ID, 1, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -227,13 +283,21 @@ main(void) stab.heap_addr = (i+1)*1000+2; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -248,12 +312,20 @@ main(void) stab.heap_addr = (i + 1) * 1000 + 20; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } @@ -265,13 +337,21 @@ main(void) TESTING("message deletion"); if (H5O_remove(&oh_ent, H5O_STAB_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); puts(" H5O_read() should have failed but didn't"); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -281,7 +361,11 @@ main(void) TESTING("object header closing"); if (H5O_close(&oh_ent)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5Fclose(file)<0) goto error; diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 new file mode 100644 index 0000000..2fd82e2 --- /dev/null +++ b/test/testfiles/err_compat_1 @@ -0,0 +1,20 @@ +############################# +Expected output for err_compat +############################# +Testing error API based on data I/O All error API tests passed. + This program tests the Error API compatible with HDF5 v1.6. There're supposed to be some error messages +********* Print error stack in HDF5 default way ********* +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/test/err_compat.c line 268 in main(): Error test failed + major: Error API + minor: Bad value + +********* Print error stack in customized way ********* + error #000: ../../hdf5/test/err_compat.c in main(): line 268 + major: Error API + minor: Bad value + +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/test/err_compat.c line 280 in main(): Error test failed + major: Error API + minor: Unrecognized message diff --git a/test/testfiles/err_compat_2 b/test/testfiles/err_compat_2 new file mode 100644 index 0000000..be6c40d --- /dev/null +++ b/test/testfiles/err_compat_2 @@ -0,0 +1,4 @@ +############################# +Expected output for err_compat +############################# +Test skipped because backward compatbility with v1.6 is NOT configured in diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 new file mode 100644 index 0000000..9a23e53 --- /dev/null +++ b/test/testfiles/error_test_1 @@ -0,0 +1,31 @@ +############################# +Expected output for error_test +############################# +Testing error API based on data I/O All error API tests passed. + This program tests the Error API. There're supposed to be some error messages +********* Print error stack in HDF5 default way ********* +Error Test-DIAG: Error detected in Error Program (1.0) thread 0: + #000: ../../hdf5/test/error_test.c line 272 in error_stack(): Get number test failed, returned 0 + major: Error in API + minor: Error in H5Eget_num + +********* Print error stack in customized way ********* + error #000: ../../hdf5/test/error_test.c in error_stack(): line 272 + class: Error Test + major: Error in API + minor: Error in H5Eget_num +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/src/H5Dio.c line 420 in H5Dwrite(): not a dataset + major: Invalid arguments to routine + minor: Inappropriate type +Error Test-DIAG: Error detected in Error Program (1.0) thread 0: + #000: ../../hdf5/test/error_test.c line 468 in main(): Error test failed, it's wrong + major: Error in test + minor: Error in subroutine + #001: ../../hdf5/test/error_test.c line 150 in test_error(): H5Dwrite failed as supposed to + major: Error in IO + minor: Error in H5Dwrite +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #002: ../../hdf5/src/H5Dio.c line 420 in H5Dwrite(): not a dataset + major: Invalid arguments to routine + minor: Inappropriate type diff --git a/test/testfiles/error_test_2 b/test/testfiles/error_test_2 new file mode 100644 index 0000000..f9d7317 --- /dev/null +++ b/test/testfiles/error_test_2 @@ -0,0 +1,4 @@ +############################# +Expected output for error_test +############################# +Test skipped because backward compatbility with v1.6 is configured in diff --git a/test/testhdf5.c b/test/testhdf5.c index 72c513d..175f711 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -153,7 +153,11 @@ main(int argc, char *argv[]) * half the functions this test calls are private, so automatic error * reporting wouldn't do much good since it's triggered at the API layer. */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto (NULL, NULL); +#else H5Eset_auto (H5E_DEFAULT, NULL, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Tests are generally arranged from least to most complexity... */ InitTest("configure", test_configure, cleanup_configure, "Configure definitions"); diff --git a/test/testhdf5.h b/test/testhdf5.h index 32cbaaa..f5e51e3 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -33,6 +33,81 @@ extern int Verbosity; /* Use %ld to print the value because long should cover most cases. */ /* Used to make certain a return value _is_not_ a value */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define CHECK(ret, val, where) do { \ + if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \ + "in %s returned %ld \n", \ + where, (int)__LINE__, __FILE__, \ + (long)(ret)); \ + if ((ret) == (val)) { \ + print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ + num_errs++; \ + H5Eprint (stdout); \ + } \ + H5Eclear(); \ +} while(0) + +#define CHECK_I(ret,where) { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ + (where), (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if ((ret)<0) { \ + print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ + (where), (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear (); \ +} + +#define CHECK_PTR(ret,where) { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ + (where), (int)__LINE__, __FILE__, (ret)); \ + } \ + if (!(ret)) { \ + print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ + (where), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear (); \ +} + +/* Used to make certain a return value _is_ a value */ +#define VERIFY(x, val, where) do { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ + } \ + if ((x) != (val)) { \ + print_func("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear(); \ +} while(0) + +/* Used to document process through a test and to check for errors */ +#define RESULT(ret,func) do { \ + if (Verbosity>8) { \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if (Verbosity>9) HEprint(stdout, 0); \ + if ((ret) == FAIL) { \ + print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear(); \ +} while(0) + +#else #define CHECK(ret, val, where) do { \ if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \ "in %s returned %ld \n", \ @@ -106,6 +181,8 @@ extern int Verbosity; H5Eclear(H5E_DEFAULT); \ } while(0) +#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Used to document process through a test */ #define MESSAGE(V,A) {if (Verbosity>(V)) print_func A;} |