mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-21 07:51:46 +08:00
4b7f34acc1
* Update API tracing for new H5VL_request_status_t typedef
* Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure
* Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation
* Remove 'canceled' event status from Java constants
* Be safer about releasing resources when inserting a newly opened/created object or file into an event set
* Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate".
* Remove H5ES_STATUS_CANCELED from Java wrappers also
* Apply patch for dynamically registering optional VOL operations
* (a) Add async APIs for H5O module as listed in jira issue ID-283.
(b) Remove verification of name parameter in async related routines for H55A and H5L modules
because it is checked in H5VL_setup* routine.
(c) Modify h5dump expected output due to the async changes.
* Corrections based on PR feedback.
* Further changes to make based on PR feedback.
* Remove H5Dwait & H5Fwait (moved to the async connector). Added H5atclose
routine. Updated 'optional op' operations.
* Fix missed merge marker, and reformatted line
* Update API tracing infrastructure for H5atclose callback
* Clean up some warnings
* Normalize against develop branch
* Correct level of indirection
* Add doxygen info for H5is_library_terminating and regression tests for it and H5atclose
* Relocate prototype (and doxygen info) for H5Aclose
* Align w/changes on develop
* Move group package initialization code to H5Gint.c, and update tracing macros
* Change non-static function declarations to be static
* Correct GCC diagnostic macro
* Ensure that H5TSpublic.h header gets installed (#129)
* Finish moving API routines that invoke VOL framework to main source files.
* Fix position of H5Fmount and H5Funmount
* Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information.
* Add wrappers for dynamically registered optional operations
* Fix typo
* Update doxygen comment for H5atclose with additional detail.
* Add H5VL\*_vararg versions of H5VL routines that use va_list parameters
* Implement and test H5S_BLOCK
* Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c.
* Add H5Iregister_future routine and tests.
* Correct return value for H5Lexists_async
* Add H5_DLL macro to public H5ES API routines
* Update supported -> flags parameter for introspect_query callback
* Remove my email address. Update passthrough VOL connector ID.
* Fix comment for post_open_api_common
* Remove unused non-blocking VOL connector
* Minor cleanup in async branch in preparation for merge to develop
* Update CMake and the Autotools to use the new pass-through VOL ID
* Finish another iteration on public H5ES routines, along with running the code reformatter
* Another round of reformatting
* Fix for SWMR daily test failures (#160)
The H5I_register_using_existing_id() call did not initialize the future
ID callbacks, causing the library to segfault when it tried to
resolve those function pointers.
* Added selective async APIs (#150)
* Added selective async APIs
Description:
Added the following APIs:
H5Ropen_attr_async
H5Ropen_object_async
H5Ropen_region_async
H5Mcreate_async
H5Mopen_async
H5Mput_async
H5Mget_async
H5Mclose_async
H5Tcommit_async
H5Topen_async
H5Tcopy_async
H5Tclose_async
- Updated an expected output file to include a new internal function
in the error stack for the failure case.
* Updated async APIs per reviews, including removing async version of
H5Tcopy.
* Removed statements that were added by mistake in the previous commit.
* Fix compile issues in H5M and warnings elsewhere
* Reformat code
* Brings VOL_LIST changes from develop. (#163)
* Remove H5Dwait and H5Fwait calls, which were incorrectly brought back in
* Tiny cleanup of H5Lcreate_hard_async
* Run source formatter
* Allow for canceled operation in wait_cb
* Attempt to fix switch on string value
* Re-run source formatter
* Add H5S_BLOCK testfile to CMake clean target
* Add H5Pset_vol_async API routine and 'get_cap_flags' VOL introspection callback
* Clean up warnings
* Add H5P(set\|get)_vol_implicit_async API routines to allow \/ disallow implicit asynchronous operations (default is disallowed)
* Run formatting script
* Remove H5VL_REQUEST_WAIT\*
* Warning cleanup
* Eliminate strdup()s on statically allocated strings
* Warning cleanup
* Split H5VLrestore_lib_state into H5VLstart_lib_state and H5VLrestore_lib_state, and rename H5VLreset_lib_state to H5VLfinish_lib_state.
* Duplicate strings when building err_info to return to applicatin
* Move connector author routines into seperate header files, all included in the new hdf5dev.h header
* Run bin/trace to add TRACE macros
* Allow H5ES_NONE as a valid, but no-op, parameter to all H5ES API routines that accept an event set ID
* Clean up formatting
* Remove H5Pset/get_vol_implicit_async
* Clean up warning
* Remove H5Pget_vol_async and replace with more generic H5Pget_vol_cap_flags
* Clean up warnings
* Add H5ESfree_err_info convenience routine
* Fix typo
* Correct matching for cached VOL plugins
* Add developer header file
* Update for C99 compatibility
* Add missing trace macro
* Stop clang-format from messing with the trace macros. Don't set up VOL wrappers for 'infrastructure' objects like requests and blobs
* Fix warning about formatting a directory
* Clean up formatting for H5E_BEGIN_TRY / H5E_END_TRY
* Reduce scope of H5ES__close
* Enable CMake checks for various types on MacOS
* Clean up properly when H5CX_retrieve_state() fails. Also clean up many compiler warnings.
* Committing clang-format changes
* Merge from develop
* Fix mis-placed assert
* Remove commented-out code
* Re-add macro for unsetenv on Windows (I think it accidentally was merged out)
* Strengthen sanity check from error report to assertion
* Committing clang-format changes
* Add units to the comments for a few fields
* Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it.
* Committing clang-format changes
* Remove H5ESget_time_estimate
* Committing clang-format changes
* Create developer header for datatype routines and move type conversion register/unregister routines there.
* Simplify internal H5VL_setup_name_args and H5VL_setup_idx_args routines
* Add H5VLlink_optional_op, allowing dynamicly registered optional operations for the link VOL subclass, also added H5VL_loc_params argument to the link 'optional' callback to allow them to work correctly.
* Run bin/format_source on current code
* Add H5VLobject_optional_op, allowing dynamicly registered optional operations for the object VOL subclass, also added H5VL_loc_params argument to the object 'optional' callback to allow them to work correctly.
* Run bin/format_source on current code
* Committing clang-format changes
* Revert "Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it."
This reverts commit 5ac92014da
.
* Committing clang-format changes
* Convert attribute 'get' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Update tracing macros
* Convert attribute 'specific' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert dataset 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to attribute 'get' and 'specific' operation parameters.
* Convert datatype 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to H5O_refresh_metadata arguments.
* Reduce warnings
* Reduce warnings
* Track change to datatype 'get' callback
* Fix bug with file pointer getting invalidated when object closed
* Reformat source
* Convert file and group VOL classes 'get' and 'specific' operations to use
struct-of-tagged-union pattern for VOL callback arguments, instead of using
varargs. Also small cleanup to the attribute get name operation. Also moved
'mount' and 'unmount' operations to be group specific operations, instead of
file specific, to better align with their behavior (mounted files are on
groups, so a group is what is operated on).
* Remove remainder of merge conflict marking
* Convert link VOL class 'create' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Remove some unused local variables
* Convert link VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor 'get name by idx' routines to return actual length of name with a parameter instead of the return value, and move some callback context structs for the link interface from the private header file into the source code module, to reduce their visibility scope.
* Update tracing macros
* Convert link VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert object VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert object VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor H5G_loc_exists, et al, to return 'exists' flag in a parameter and errors with the function return value, instead of overloading both into the return value. And, corrected logic error in test/links.c around non-existant objects in a file.
* Convert request VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert blob VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also removes the H5VL_BLOB_GETSIZE operation, as it's unused in the library and the blob ID size for a container is now returned with H5VL_FILE_GET_CONT_INFO.
* Add 'const' to several parameters that are only queried.
* Convert all VOL classes' 'optional' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Convert several 'get' routines to return the length of an array in a parameter instead of combining it into the return value. Move several routines to be in less public namespace. Correct direct_chunk test to verify that parameters aren't modified on error.
* Switch get/specific/optional VOL callback argument structures to be 'async-friendly'. Also other minor cleanups and bug-fixes.
* Add H5Pset_dataset_io_hyperslab_selection / H5S_PLIST feature, to allow skipping H5Dget_space + H5Sselect_hyperslab for async operation
* Add dynamic optional operations for request objects
* Update dynamic operation test for optional request operations
* Update a comment for an operation argument
* Run trace and format_source scripts
* Committing clang-format changes
* Committing clang-format changes
Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org>
Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com>
Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org>
Co-authored-by: Dana Robinson <derobins@hdfgroup.org>
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
544 lines
18 KiB
C
544 lines
18 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* 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://www.hdfgroup.org/licenses. *
|
|
* If you do not have access to either file, you may request a copy from *
|
|
* help@hdfgroup.org. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
/*
|
|
FILE
|
|
refstr.c
|
|
Test HDF reference counted string routines.
|
|
|
|
REMARKS
|
|
|
|
DESIGN
|
|
|
|
BUGS/LIMITATIONS
|
|
|
|
EXPORTED ROUTINES
|
|
|
|
AUTHOR
|
|
Quincey Koziol
|
|
|
|
MODIFICATION HISTORY
|
|
12/17/02 - Started coding
|
|
*/
|
|
|
|
#include "testhdf5.h"
|
|
#include "H5FLprivate.h"
|
|
#include "H5RSprivate.h"
|
|
|
|
/* Declare extern the PQ free list for the wrapped strings */
|
|
H5FL_BLK_EXTERN(str_buf);
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_init(): Test basic H5RS (ref-counted strings) code.
|
|
** Initialize data for RS testing
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_init(void)
|
|
{
|
|
} /* end test_refstr_init() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_create(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests creating and closing ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_create(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
unsigned count; /* Reference count on string */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Creating & Closing Ref-Counted Strings\n"));
|
|
|
|
/* Try creating a ref-counted string */
|
|
rs = H5RS_create("foo");
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs);
|
|
VERIFY(count, 1, "H5RS_get_count");
|
|
|
|
/* Try closing a real ref-counted string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_create() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_count(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests reference counting on ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_count(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
unsigned count; /* Reference count on string */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Incrementing & Decrementing Ref-Counted Strings\n"));
|
|
|
|
/* Try creating a ref-counted string */
|
|
rs = H5RS_create("foo");
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs);
|
|
VERIFY(count, 1, "H5RS_get_count");
|
|
|
|
/* Increment reference count */
|
|
ret = H5RS_incr(rs);
|
|
CHECK(ret, FAIL, "H5RS_incr");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs);
|
|
VERIFY(count, 2, "H5RS_get_count");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs);
|
|
VERIFY(count, 1, "H5RS_get_count");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_count() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_dup(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests duplicating ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_dup(void)
|
|
{
|
|
H5RS_str_t *rs1; /* Ref-counted string created */
|
|
H5RS_str_t *rs2; /* Ref-counted string created */
|
|
unsigned count; /* Reference count on string */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Duplicating Ref-Counted Strings\n"));
|
|
|
|
/* Try creating a ref-counted string */
|
|
rs1 = H5RS_create("foo");
|
|
CHECK_PTR(rs1, "H5RS_create");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs1);
|
|
VERIFY(count, 1, "H5RS_get_count");
|
|
|
|
/* Duplicate r-string */
|
|
rs2 = H5RS_dup(rs1);
|
|
CHECK_PTR(rs2, "H5RS_dup");
|
|
|
|
/* Get the reference count on the strings */
|
|
count = H5RS_get_count(rs1);
|
|
VERIFY(count, 2, "H5RS_get_count");
|
|
count = H5RS_get_count(rs2);
|
|
VERIFY(count, 2, "H5RS_get_count");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs2);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
/* Get the reference count on the string */
|
|
count = H5RS_get_count(rs1);
|
|
VERIFY(count, 1, "H5RS_get_count");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs1);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_dup() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_cmp(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests comparing ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_cmp(void)
|
|
{
|
|
H5RS_str_t *rs1; /* Ref-counted string created */
|
|
H5RS_str_t *rs2; /* Ref-counted string created */
|
|
int cmp; /* Comparison value */
|
|
size_t len; /* Length of string */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Comparing Ref-Counted Strings\n"));
|
|
|
|
/* Create first reference counted string */
|
|
rs1 = H5RS_create("foo");
|
|
CHECK_PTR(rs1, "H5RS_create");
|
|
|
|
/* Create second reference counted string */
|
|
rs2 = H5RS_create("foo2");
|
|
CHECK_PTR(rs2, "H5RS_create");
|
|
|
|
/* Compare the strings in various ways */
|
|
cmp = H5RS_cmp(rs1, rs1);
|
|
VERIFY(cmp, 0, "H5RS_cmp");
|
|
cmp = H5RS_cmp(rs2, rs2);
|
|
VERIFY(cmp, 0, "H5RS_cmp");
|
|
cmp = H5RS_cmp(rs1, rs2);
|
|
if (cmp >= 0)
|
|
TestErrPrintf("%d: string comparison incorrect!\n", __LINE__);
|
|
|
|
/* Check the lengths of the strings also */
|
|
len = H5RS_len(rs1);
|
|
VERIFY(len, 3, "H5RS_len");
|
|
len = H5RS_len(rs2);
|
|
VERIFY(len, 4, "H5RS_len");
|
|
|
|
/* Decrement reference count for strings */
|
|
ret = H5RS_decr(rs2);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
ret = H5RS_decr(rs1);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_cmp() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_wrap(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests wrapping ref-counted strings around existing strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_wrap(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
const char *s; /* Pointer to raw string in ref-counted string */
|
|
char buf[16]; /* Buffer to wrap */
|
|
int cmp; /* Comparison value */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Wrapping Ref-Counted Strings\n"));
|
|
|
|
/* Initialize buffer */
|
|
HDstrcpy(buf, "foo");
|
|
|
|
/* Wrap ref-counted string around existing buffer */
|
|
rs = H5RS_wrap(buf);
|
|
CHECK_PTR(rs, "H5RS_wrap");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
CHECK_PTR_EQ(s, buf, "wrapping");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Increment reference count (should duplicate string) */
|
|
ret = H5RS_incr(rs);
|
|
CHECK(ret, FAIL, "H5RS_incr");
|
|
|
|
/* Change the buffer initially wrapped */
|
|
buf[0] = 'F';
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
if (s == buf)
|
|
TestErrPrintf("%d: Should not have gotten the same pointer from reference-counted string!\n",
|
|
__LINE__);
|
|
cmp = HDstrcmp(s, buf);
|
|
if (cmp <= 0)
|
|
TestErrPrintf("%d: string comparison incorrect!\n", __LINE__);
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_wrap() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_asprintf_cat(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests appending printf-formatted output to ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_asprintf_cat(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
const char *s; /* Pointer to raw string in ref-counted string */
|
|
char buf[256]; /* Buffer to compare against */
|
|
int cmp; /* Comparison value */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Printf-formatted Output to Ref-Counted Strings\n"));
|
|
|
|
/* Wrap ref-counted string around existing buffer */
|
|
rs = H5RS_create(NULL);
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Print initial output to ref-counted string */
|
|
ret = H5RS_asprintf_cat(rs, "%d-%s", (int)10, "foo");
|
|
CHECK(ret, FAIL, "H5RS_asprintf_cat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDsprintf(buf, "%d-%s", (int)10, "foo");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Append more output to ref-counted string */
|
|
ret = H5RS_asprintf_cat(rs, "-%f", (double)20.0);
|
|
CHECK(ret, FAIL, "H5RS_asprintf_cat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDsprintf(buf, "%d-%s-%f", (int)10, "foo", (double)20.0);
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
} /* end test_refstr_asprintf_cat() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_acat(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests appending strings to ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_acat(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
const char *s; /* Pointer to raw string in ref-counted string */
|
|
char buf[256]; /* Buffer to compare against */
|
|
char * large_str, *large_str2; /* Large strings to append */
|
|
int cmp; /* Comparison value */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Appending Strings to Ref-Counted Strings\n"));
|
|
|
|
/* Wrap ref-counted string around existing buffer */
|
|
rs = H5RS_create(NULL);
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Append first string to ref-counted string */
|
|
ret = H5RS_acat(rs, "foo");
|
|
CHECK(ret, FAIL, "H5RS_acat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDsprintf(buf, "%s", "foo");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Append another string to ref-counted string */
|
|
ret = H5RS_acat(rs, "bar");
|
|
CHECK(ret, FAIL, "H5RS_acat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDsprintf(buf, "%s", "foobar");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Append a large string to ref-counted string */
|
|
large_str = HDmalloc(1024);
|
|
CHECK_PTR(large_str, "HDmalloc");
|
|
HDmemset(large_str, 'a', 1024);
|
|
large_str[1023] = '\0';
|
|
ret = H5RS_acat(rs, large_str);
|
|
CHECK(ret, FAIL, "H5RS_acat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDsprintf(buf, "%s", "foobar");
|
|
large_str2 = HDmalloc(1024 + 6);
|
|
CHECK_PTR(large_str2, "HDmalloc");
|
|
HDstrcpy(large_str2, "foobar");
|
|
HDmemset(&large_str2[6], 'a', 1024);
|
|
large_str2[1029] = '\0';
|
|
cmp = HDstrcmp(s, large_str2);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
|
|
/* Free large strings */
|
|
HDfree(large_str);
|
|
HDfree(large_str2);
|
|
} /* end test_refstr_acat() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_ancat(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests appending length-limited strings to ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_ancat(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
const char *s; /* Pointer to raw string in ref-counted string */
|
|
char buf[256]; /* Buffer to compare against */
|
|
int cmp; /* Comparison value */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Appending Strings to Ref-Counted Strings\n"));
|
|
|
|
/* Wrap ref-counted string around existing buffer */
|
|
rs = H5RS_create(NULL);
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Append first string to ref-counted string */
|
|
ret = H5RS_ancat(rs, "foo", 2);
|
|
CHECK(ret, FAIL, "H5RS_ancat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDstrcpy(buf, "fo");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Append another string to ref-counted string */
|
|
ret = H5RS_ancat(rs, "bar", 2);
|
|
CHECK(ret, FAIL, "H5RS_ancat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDstrcpy(buf, "foba");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
} /* end test_refstr_ancat() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_aputc(): Test basic H5RS (ref-counted strings) code.
|
|
** Tests appending characters to ref-counted strings.
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_aputc(void)
|
|
{
|
|
H5RS_str_t *rs; /* Ref-counted string created */
|
|
const char *s; /* Pointer to raw string in ref-counted string */
|
|
char buf[256]; /* Buffer to compare against */
|
|
int cmp; /* Comparison value */
|
|
herr_t ret; /* Generic return value */
|
|
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Appending Strings to Ref-Counted Strings\n"));
|
|
|
|
/* Wrap ref-counted string around existing buffer */
|
|
rs = H5RS_create(NULL);
|
|
CHECK_PTR(rs, "H5RS_create");
|
|
|
|
/* Append first character to ref-counted string */
|
|
ret = H5RS_aputc(rs, 'f');
|
|
CHECK(ret, FAIL, "H5RS_ancat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDstrcpy(buf, "f");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Append another character to ref-counted string */
|
|
ret = H5RS_aputc(rs, 'o');
|
|
CHECK(ret, FAIL, "H5RS_ancat");
|
|
|
|
/* Get pointer to raw string in ref-counted string */
|
|
s = H5RS_get_str(rs);
|
|
CHECK_PTR(s, "H5RS_get_str");
|
|
HDstrcpy(buf, "fo");
|
|
cmp = HDstrcmp(s, buf);
|
|
VERIFY(cmp, 0, "HDstrcmp");
|
|
|
|
/* Decrement reference count for string */
|
|
ret = H5RS_decr(rs);
|
|
CHECK(ret, FAIL, "H5RS_decr");
|
|
} /* end test_refstr_aputc() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr_finalize(): Test basic H5RS (ref-counted strings) code.
|
|
** Wrap up data for ref-counted string testing
|
|
**
|
|
****************************************************************/
|
|
static void
|
|
test_refstr_finalize(void)
|
|
{
|
|
} /* end test_refstr_finalize() */
|
|
|
|
/****************************************************************
|
|
**
|
|
** test_refstr(): Main H5RS testing routine.
|
|
**
|
|
****************************************************************/
|
|
void
|
|
test_refstr(void)
|
|
{
|
|
/* Output message about test being performed */
|
|
MESSAGE(5, ("Testing Reference Counted Strings\n"));
|
|
|
|
/* Initialize ref-counted strings testing data */
|
|
test_refstr_init();
|
|
|
|
/* Actual ref-counted strings tests */
|
|
test_refstr_create(); /* Test ref-counted string creation */
|
|
test_refstr_count(); /* Test ref-counted string counting */
|
|
test_refstr_dup(); /* Test ref-counted string duplication */
|
|
test_refstr_cmp(); /* Test ref-counted string comparison */
|
|
test_refstr_wrap(); /* Test ref-counted string wrapping */
|
|
test_refstr_asprintf_cat(); /* Test ref-counted string printf-formatted output */
|
|
test_refstr_acat(); /* Test ref-counted string appends */
|
|
test_refstr_ancat(); /* Test ref-counted length-limited string appends */
|
|
test_refstr_aputc(); /* Test ref-counted character appends */
|
|
|
|
/* Finalize ref-counted strings testing data */
|
|
test_refstr_finalize();
|
|
} /* end test_refstr() */
|