/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Neil Fortner * Thursday, August 14, 2008 * * Purpose: Tests closing the library after reference counts have been * manipulated. */ #include "h5test.h" #define DSET_NAME "test_dset" #define ATTR_NAME "test_attr" #define GROUP_NAME "test_grp" #define ERR_WIDTH 40 /* Width of output for the SIGABRT handler */ #define MAX_NINC 16 /* Maximum increments of a reference count */ /* Macro to increment the reference count on id a random number of times (from * 1 to MAX_NINC). Assumes integers i and ninc are in scope. */ #define RAND_INC(id) \ ninc = (HDrand() % MAX_NINC) + 1; \ \ for (i=0; i 1"); /* Create the file */ if ((ids[T_FILE] = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR RAND_INC (T_FILE) /* Create the property list */ if ((ids[T_PLIST] = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR RAND_INC (T_PLIST) /* Create a property class */ if ((ids[T_PCLASS] = H5Pcreate_class (H5P_DATASET_CREATE, "foo", NULL, NULL, NULL, NULL, NULL, NULL)) < 0) TEST_ERROR RAND_INC (T_PCLASS) /* Create a datatype */ if ((ids[T_TYPE] = H5Tcreate (H5T_OPAQUE, (size_t) 16)) < 0) TEST_ERROR RAND_INC (T_TYPE) /* Create a dataspace */ if ((ids[T_SPACE] = H5Screate (H5S_SCALAR)) < 0) TEST_ERROR RAND_INC (T_SPACE) /* Create a dataset */ if ((ids[T_DSET] = H5Dcreate2 (ids[T_FILE], DSET_NAME, H5T_NATIVE_INT, ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR RAND_INC (T_DSET) /* Create an attribute */ if ((ids[T_ATTR] = H5Acreate2 (ids[T_DSET], ATTR_NAME, H5T_NATIVE_INT, ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR RAND_INC (T_ATTR) /* Create a group */ if ((ids[T_GROUP] = H5Gcreate2 (ids[T_FILE], GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR RAND_INC (T_GROUP) /* Create an error class */ if ((ids[T_ECLASS] = H5Eregister_class("foo","bar","baz")) < 0) TEST_ERROR RAND_INC (T_ECLASS) /* Create an error message */ if ((ids[T_EMSG] = H5Ecreate_msg(ids[T_ECLASS],H5E_MAJOR,"mumble")) < 0) TEST_ERROR RAND_INC (T_EMSG) /* Create an error stack */ if ((ids[T_ESTACK] = H5Eget_current_stack()) < 0) TEST_ERROR RAND_INC (T_ESTACK) HDsignal (SIGABRT, &Abrt_Handler); if (H5close() < 0) TEST_ERROR PASSED(); h5_reset(); fapl = H5Pcreate (H5P_FILE_ACCESS); h5_cleanup (FILENAME, fapl); return 0; error: puts("***** APPLICATION REFERENCE COUNT TESTS FAILED *****"); return 1; }