2004-11-28 00:07:11 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2004-11-28 00:07:11 +08:00
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:04 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2004-11-28 00:07:11 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
|
|
|
Test HDF Skip List routines.
|
|
|
|
|
|
|
|
REMARKS
|
|
|
|
|
|
|
|
DESIGN
|
|
|
|
|
|
|
|
BUGS/LIMITATIONS
|
|
|
|
|
|
|
|
EXPORTED ROUTINES
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "testhdf5.h"
|
|
|
|
#include "H5SLprivate.h"
|
|
|
|
|
|
|
|
/* The number of elements in testing arrays */
|
2020-09-30 22:27:10 +08:00
|
|
|
#define NUM_ELEMS 1000
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Random numbers */
|
2016-09-28 01:29:16 +08:00
|
|
|
static int *rand_num;
|
|
|
|
static int *sort_rand_num;
|
|
|
|
static int *rev_sort_rand_num;
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
static int
|
|
|
|
tst_sort(const void *i1, const void *i2)
|
2004-11-28 00:07:11 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (*(const int *)i1 - *(const int *)i2);
|
2004-11-28 00:07:11 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
static int
|
|
|
|
tst_rev_sort(const void *i1, const void *i2)
|
2004-11-28 00:07:11 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (*(const int *)i2 - *(const int *)i1);
|
2004-11-28 00:07:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_init(): Test H5SL (skiplist) code.
|
|
|
|
** Initialize data for skip list testing
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_init(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
time_t curr_time; /* Current time, for seeding random number generator */
|
|
|
|
int new_val; /* New value to insert */
|
2004-11-28 00:07:11 +08:00
|
|
|
unsigned found; /* Flag to indicate value was inserted already */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u, v; /* Local index variables */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2016-09-28 01:29:16 +08:00
|
|
|
/* Allocate arrays */
|
2023-06-29 06:48:12 +08:00
|
|
|
rand_num = (int *)malloc(sizeof(int) * NUM_ELEMS);
|
|
|
|
CHECK_PTR(rand_num, "malloc");
|
|
|
|
sort_rand_num = (int *)malloc(sizeof(int) * NUM_ELEMS);
|
|
|
|
CHECK_PTR(sort_rand_num, "malloc");
|
|
|
|
rev_sort_rand_num = (int *)malloc(sizeof(int) * NUM_ELEMS);
|
|
|
|
CHECK_PTR(rev_sort_rand_num, "malloc");
|
2016-09-28 01:29:16 +08:00
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/* Initialize random number seed */
|
2006-10-31 04:00:57 +08:00
|
|
|
curr_time = HDtime(NULL);
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
HDsrandom((unsigned)curr_time);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Create randomized set of numbers */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
2004-11-28 00:07:11 +08:00
|
|
|
do {
|
|
|
|
/* Reset flag */
|
2016-09-28 01:29:16 +08:00
|
|
|
found = 0;
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Generate random numbers from -5000 to 5000 */
|
2016-09-28 01:29:16 +08:00
|
|
|
new_val = (int)(HDrandom() % 10001) - 5001;
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check if the value is already in the array */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (v = 0; v < u; v++)
|
|
|
|
if (rand_num[v] == new_val)
|
2016-09-28 01:29:16 +08:00
|
|
|
found = 1;
|
2020-09-30 22:27:10 +08:00
|
|
|
} while (found);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Set unique value in array */
|
2020-09-30 22:27:10 +08:00
|
|
|
rand_num[u] = new_val;
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Copy random values to sorted array */
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(sort_rand_num, rand_num, sizeof(int) * NUM_ELEMS);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Sort random numbers */
|
2023-06-28 22:30:54 +08:00
|
|
|
qsort(sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_sort);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Copy random values to reverse sorted array */
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(rev_sort_rand_num, rand_num, sizeof(int) * NUM_ELEMS);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Sort random numbers */
|
2023-06-28 22:30:54 +08:00
|
|
|
qsort(rev_sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_rev_sort);
|
2016-09-28 01:29:16 +08:00
|
|
|
} /* end test_skiplist_init() */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_create(): Test basic H5SL (skiplist) code.
|
|
|
|
** Tests creating and closing skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_create(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(6, ("Testing Creating & Closing Skip Lists\n"));
|
|
|
|
|
|
|
|
/* Try creating a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Try closing the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_create() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_insert(): Test H5SL (skip list) code.
|
|
|
|
** Tests inserting single object into skip list.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_insert(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
|
|
|
int key, /* Key of item to insert */
|
|
|
|
item; /* Item to insert */
|
|
|
|
int search_key; /* Key of item to search for in skip list */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Insertion Into Skip List\n"));
|
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Try searching for item in empty skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
key = 37;
|
|
|
|
found_item = (int *)H5SL_search(slist, &key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_search");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Insert an object into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
key = 2;
|
|
|
|
item = 10;
|
|
|
|
ret = H5SL_insert(slist, &item, &key);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
|
|
|
|
/* Check that the skip list has one element */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 1, "H5SL_count");
|
|
|
|
|
|
|
|
/* Search for the item just inserted */
|
2020-09-30 22:27:10 +08:00
|
|
|
found_item = (int *)H5SL_search(slist, &key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_search");
|
|
|
|
VERIFY(*found_item, item, "H5SL_search");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Search for an item not in list */
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = 37;
|
|
|
|
found_item = (int *)H5SL_search(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_search");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2004-11-30 03:55:18 +08:00
|
|
|
/* Attempt to insert duplicate key (should fail) */
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = 2;
|
|
|
|
ret = H5SL_insert(slist, &search_key, &search_key);
|
2004-11-30 03:55:18 +08:00
|
|
|
VERIFY(ret, FAIL, "H5SL_insert");
|
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_insert() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_insert_many(): Test H5SL (skip list) code.
|
|
|
|
** Tests inserting many objects into skip list.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_insert_many(void)
|
|
|
|
{
|
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Insertion of Many Items Into Skip List\n"));
|
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Search for all objects in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
found_item = (int *)H5SL_search(slist, &rand_num[u]);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_search");
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*found_item, rand_num[u], "H5SL_search");
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end for */
|
|
|
|
|
2004-11-30 05:01:20 +08:00
|
|
|
/* Release all the items from the list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_release(slist);
|
2004-11-30 05:01:20 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_release");
|
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-30 05:01:20 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-30 05:01:20 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-30 05:01:20 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Release all the items from the list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_release(slist);
|
2004-11-30 05:01:20 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_release");
|
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_insert_many() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_remove(): Test H5SL (skip list) code.
|
|
|
|
** Tests basic object removal from skip list.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_remove(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
|
|
|
int key1, /* Key of 1st item to insert */
|
|
|
|
key2, /* Key of 2nd item to insert */
|
|
|
|
key3; /* Key of 3rd item to insert */
|
|
|
|
int search_key; /* Key of item to search for in skip list */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Removal From Skip List\n"));
|
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Try removing an item in empty skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = 37;
|
|
|
|
found_item = (int *)H5SL_remove(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Insert three objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
key1 = 15;
|
|
|
|
ret = H5SL_insert(slist, &key1, &key1);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
key2 = 10;
|
|
|
|
ret = H5SL_insert(slist, &key2, &key2);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
key3 = 20;
|
|
|
|
ret = H5SL_insert(slist, &key3, &key3);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
|
|
|
|
/* Check that the skip list has three elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 3, "H5SL_count");
|
|
|
|
|
|
|
|
/* Try removing items from skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = key1;
|
|
|
|
found_item = (int *)H5SL_remove(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2017-11-28 00:57:26 +08:00
|
|
|
CHECK_PTR_EQ(found_item, &key1, "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = key2;
|
|
|
|
found_item = (int *)H5SL_remove(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2017-11-28 00:57:26 +08:00
|
|
|
CHECK_PTR_EQ(found_item, &key2, "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = key3;
|
|
|
|
found_item = (int *)H5SL_remove(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2017-11-28 00:57:26 +08:00
|
|
|
CHECK_PTR_EQ(found_item, &key3, "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Try removing items from empty skip list (after its been worked on) */
|
2020-09-30 22:27:10 +08:00
|
|
|
search_key = key1;
|
|
|
|
found_item = (int *)H5SL_remove(slist, &search_key);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_remove() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_remove_many(): Test H5SL (skip list) code.
|
|
|
|
** Tests removing many objects from skip list.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-28 00:07:11 +08:00
|
|
|
test_skiplist_remove_many(void)
|
|
|
|
{
|
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Removal of Many Items From Skip List\n"));
|
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Remove all objects from the skip list (in random order) */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
found_item = (int *)H5SL_remove(slist, &rand_num[u]);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*found_item, rand_num[u], "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Insert & remove again (in sorted order), to check that completely empty skip lists can be added again
|
|
|
|
*/
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Remove all objects from the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
found_item = (int *)H5SL_remove(slist, &sort_rand_num[u]);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*found_item, sort_rand_num[u], "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Insert & remove again (in reverse sorted order), to check that completely empty skip lists can be added
|
|
|
|
* again */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Remove all objects from the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
found_item = (int *)H5SL_remove(slist, &rev_sort_rand_num[u]);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(found_item, "H5SL_remove");
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*found_item, rev_sort_rand_num[u], "H5SL_remove");
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_remove_many() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
2004-12-04 11:36:08 +08:00
|
|
|
** test_skiplist_firstnext(): Test H5SL (skip list) code.
|
|
|
|
** Tests iterating over nodes in skip list with first/next calls.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-12-04 11:36:08 +08:00
|
|
|
test_skiplist_firstnext(void)
|
2004-11-28 00:07:11 +08:00
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
2005-01-07 06:30:10 +08:00
|
|
|
MESSAGE(7, ("Testing Iterating Over Skip List With First/Next\n"));
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-28 00:07:11 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2011-10-19 05:27:58 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
2005-01-07 06:30:10 +08:00
|
|
|
/* Check that the list appears empty */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_first");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_first");
|
2020-09-30 22:27:10 +08:00
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (int *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sort_rand_num[u], "H5SL_next");
|
2004-11-28 00:07:11 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2004-11-28 00:07:11 +08:00
|
|
|
} /* end while */
|
|
|
|
|
2005-01-07 06:30:10 +08:00
|
|
|
/* Release all the items from the list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_release(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_release");
|
|
|
|
|
|
|
|
/* Check that the list appears empty again */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_first");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-28 00:07:11 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
2004-12-04 11:36:08 +08:00
|
|
|
} /* end test_skiplist_firstnext() */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2004-11-30 12:42:40 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_string(): Test H5SL (skip list) code.
|
|
|
|
** Tests using strings for keys in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-30 12:42:40 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-11-30 12:42:40 +08:00
|
|
|
test_skiplist_string(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2004-11-30 12:42:40 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2004-11-30 12:42:40 +08:00
|
|
|
typedef struct string_node {
|
2020-09-30 22:27:10 +08:00
|
|
|
int i;
|
2004-11-30 12:42:40 +08:00
|
|
|
const char *s;
|
|
|
|
} string_node;
|
2020-09-30 22:27:10 +08:00
|
|
|
string_node data[10] = {{10, "10"}, {20, "20"}, {15, "15"}, {5, "05"}, {50, "50"},
|
|
|
|
{30, "30"}, {31, "31"}, {32, "32"}, {80, "80"}, {90, "90"}};
|
|
|
|
string_node hashed_data[10] = {{5, "05"}, {10, "10"}, {15, "15"}, {20, "20"}, {30, "30"},
|
|
|
|
{31, "31"}, {32, "32"}, {50, "50"}, {80, "80"}, {90, "90"}};
|
|
|
|
string_node *found_item; /* Item found in skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2004-11-30 12:42:40 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List With String Keys\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_STR, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-11-30 12:42:40 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-30 12:42:40 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], data[u].s);
|
2004-11-30 12:42:40 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-11-30 12:42:40 +08:00
|
|
|
VERIFY(num, 10, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (string_node *)H5SL_item(node);
|
[svn-r14353] Description:
- Add hash value for skip list string types, to reduce # of string
comparisons.
- Fixed bug with metadata/small data block aggregator adding size == 0
block into file free space list.
- Refactored metadata/small data block aggregator code into single set of
common routines.
- Changed block aggregator code to be smarter about releasing space in the
'other' block when the 'other' block has aggregated enough data.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-12-21 04:36:08 +08:00
|
|
|
VERIFY(found_item->i, hashed_data[u].i, "H5SL_next");
|
2004-11-30 12:42:40 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2004-11-30 12:42:40 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-11-30 12:42:40 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_string() */
|
|
|
|
|
2004-12-04 11:36:08 +08:00
|
|
|
static herr_t
|
2015-06-02 03:38:09 +08:00
|
|
|
test_skiplist_iter(void *item, void H5_ATTR_UNUSED *key, void *op_data)
|
2004-12-04 11:36:08 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t *up = (size_t *)op_data;
|
2004-12-04 11:36:08 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*(int *)item, sort_rand_num[*up], "H5SL_iterate");
|
2004-12-04 11:36:08 +08:00
|
|
|
(*up)++;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
return (0);
|
2004-12-04 11:36:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_iterate(): Test H5SL (skip list) code.
|
|
|
|
** Tests iterating over nodes in skip list with callbacks.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-12-04 11:36:08 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-12-04 11:36:08 +08:00
|
|
|
test_skiplist_iterate(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
herr_t ret; /* Generic return value */
|
2004-12-04 11:36:08 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Iterating Over Skip List\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-12-04 11:36:08 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-12-04 11:36:08 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2004-12-04 11:36:08 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-12-04 11:36:08 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
u = 0;
|
|
|
|
ret = H5SL_iterate(slist, test_skiplist_iter, &u);
|
2004-12-04 11:36:08 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_iterate");
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-12-04 11:36:08 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
2004-12-31 00:26:45 +08:00
|
|
|
} /* end test_skiplist_iterate() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_hsize(): Test H5SL (skip list) code.
|
|
|
|
** Tests using hsize_t for keys in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-12-31 00:26:45 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2004-12-31 00:26:45 +08:00
|
|
|
test_skiplist_hsize(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2004-12-31 00:26:45 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
hsize_t data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
|
|
|
hsize_t sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90};
|
2022-07-27 05:45:46 +08:00
|
|
|
hsize_t *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2004-12-31 00:26:45 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List With hsize_t Keys\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_HSIZE, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2004-12-31 00:26:45 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-12-31 00:26:45 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2004-12-31 00:26:45 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2004-12-31 00:26:45 +08:00
|
|
|
VERIFY(num, 10, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (hsize_t *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sorted_data[u], "H5SL_next");
|
2004-12-31 00:26:45 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2004-12-31 00:26:45 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2004-12-31 00:26:45 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_hsize() */
|
2004-12-04 11:36:08 +08:00
|
|
|
|
2005-01-07 06:30:10 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_unsigned(): Test H5SL (skip list) code.
|
|
|
|
** Tests using unsigned for keys in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_unsigned(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2005-01-07 06:30:10 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
|
|
|
unsigned sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90};
|
2022-07-27 05:45:46 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List With unsigned Keys\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, 10, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sorted_data[u], "H5SL_next");
|
2005-01-07 06:30:10 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2005-01-07 06:30:10 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_unsigned() */
|
|
|
|
|
2011-10-19 05:27:58 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_obj(): Test H5SL (skip list) code.
|
|
|
|
** Tests using H5_obj_t's for keys in skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_obj(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2011-10-19 05:27:58 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
H5_obj_t data[10] = {{10, 12}, {20, 12}, {10, 32}, {10, 11}, {50, 1},
|
|
|
|
{8, 12}, {31, 12}, {20, 11}, {31, 11}, {8, 32}};
|
|
|
|
H5_obj_t sorted_data[10] = {{8, 12}, {8, 32}, {10, 11}, {10, 12}, {10, 32},
|
|
|
|
{20, 11}, {20, 12}, {31, 11}, {31, 12}, {50, 1}};
|
2022-07-27 05:45:46 +08:00
|
|
|
H5_obj_t *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2011-10-19 05:27:58 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List With H5_obj_t Keys\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
|
|
|
slist = H5SL_create(H5SL_TYPE_OBJ, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2011-10-19 05:27:58 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2011-10-19 05:27:58 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
VERIFY(num, 10, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (H5_obj_t *)H5SL_item(node);
|
|
|
|
VERIFY(found_item->fileno, sorted_data[u].fileno, "H5SL_next");
|
|
|
|
VERIFY(found_item->addr, sorted_data[u].addr, "H5SL_next");
|
2011-10-19 05:27:58 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2011-10-19 05:27:58 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_obj() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_generic(): Test H5SL (skip list) code.
|
|
|
|
** Tests using generic keys in skip lists. Define
|
|
|
|
** structure for keys, and define comparison using
|
|
|
|
** key.a-key.b.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
typedef struct generic_t {
|
|
|
|
unsigned a;
|
|
|
|
unsigned b;
|
|
|
|
} generic_t;
|
|
|
|
|
|
|
|
static int
|
|
|
|
test_skiplist_generic_cmp(const void *_key1, const void *_key2)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
const generic_t *key1 = (const generic_t *)_key1;
|
|
|
|
const generic_t *key2 = (const generic_t *)_key2;
|
|
|
|
long long result =
|
|
|
|
(long long)(key1->a) - (long long)(key1->b) - (long long)(key2->a) + (long long)(key2->b);
|
2011-10-19 05:27:58 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (result < 0)
|
2011-10-19 05:27:58 +08:00
|
|
|
return -1;
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (result > 0)
|
2011-10-19 05:27:58 +08:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
} /* end test_skiplist_generic_cmp */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_skiplist_generic(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2011-10-19 05:27:58 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
generic_t data[10] = {{10, 1}, {20, 13}, {15, 32}, {5, 2}, {50, 37},
|
|
|
|
{30, 100}, {31, 38}, {32, 34}, {80, 32}, {90, 0}};
|
|
|
|
generic_t sorted_data[10] = {{30, 100}, {15, 32}, {31, 38}, {32, 34}, {5, 2},
|
|
|
|
{20, 13}, {10, 1}, {50, 37}, {80, 32}, {90, 0}};
|
2022-07-27 05:45:46 +08:00
|
|
|
generic_t *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2011-10-19 05:27:58 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List With generic Keys\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
|
|
|
slist = H5SL_create(H5SL_TYPE_GENERIC, test_skiplist_generic_cmp);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2011-10-19 05:27:58 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2011-10-19 05:27:58 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
VERIFY(num, 10, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_first(slist);
|
|
|
|
u = 0;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (generic_t *)H5SL_item(node);
|
|
|
|
VERIFY(found_item->a, sorted_data[u].a, "H5SL_next");
|
|
|
|
VERIFY(found_item->b, sorted_data[u].b, "H5SL_next");
|
2011-10-19 05:27:58 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2011-10-19 05:27:58 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2011-10-19 05:27:58 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_generic() */
|
|
|
|
|
2005-01-07 06:30:10 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_lastprev(): Test H5SL (skip list) code.
|
|
|
|
** Tests iterating over nodes in skip list with last/prev calls.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_lastprev(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Iterating Over Skip List With Last/Prev\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Check that the skip list has no elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Check that the list appears empty */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_last(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_last");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert many objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Iterate over all the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_last(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_last");
|
2020-09-30 22:27:10 +08:00
|
|
|
u = NUM_ELEMS - 1;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (int *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sort_rand_num[u], "H5SL_prev");
|
2005-01-07 06:30:10 +08:00
|
|
|
u--;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_prev(node);
|
2005-01-07 06:30:10 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Release all the items from the list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_release(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_release");
|
|
|
|
|
|
|
|
/* Check that the list appears empty again */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_last(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_last");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_lastprev() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_find(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'find' operation in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_find(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2005-01-07 06:30:10 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
|
|
|
unsigned sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90};
|
2022-07-27 05:45:46 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned find_item; /* Item to find in skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Find' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Find the element with key==30 in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 30;
|
|
|
|
node = H5SL_find(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_find");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Iterate over the rest of the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
u = 4;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sorted_data[u], "H5SL_next");
|
2005-01-07 06:30:10 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2005-01-07 06:30:10 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Check for trying to locate non-existent item */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 81;
|
|
|
|
node = H5SL_find(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_find");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_find() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_add(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'add' operation in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_add(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2005-01-07 06:30:10 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
|
|
|
unsigned sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90};
|
2022-07-27 05:45:46 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned new_item; /* Item to add to skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Add' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Add the element with key==12 in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
new_item = 12;
|
|
|
|
node = H5SL_add(slist, &new_item, &new_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_add");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Advance to next node in list */
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_next");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Iterate over the rest of the nodes in the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
u = 2;
|
|
|
|
while (node != NULL) {
|
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
|
|
|
VERIFY(*found_item, sorted_data[u], "H5SL_item");
|
2005-01-07 06:30:10 +08:00
|
|
|
u++;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_next(node);
|
2005-01-07 06:30:10 +08:00
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_add() */
|
|
|
|
|
|
|
|
static herr_t
|
2015-06-02 03:38:09 +08:00
|
|
|
test_skiplist_destroy_free(void *item, void H5_ATTR_UNUSED *key, void *op_data)
|
2005-01-07 06:30:10 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned *free_count = (unsigned *)op_data;
|
2005-01-07 06:30:10 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
VERIFY(*(int *)item, sort_rand_num[*free_count], "H5SL_destroy");
|
2005-01-07 06:30:10 +08:00
|
|
|
(*free_count)++;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
return (0);
|
2005-01-07 06:30:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_destroy(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'destroy' operation in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_destroy(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
2005-01-07 06:30:10 +08:00
|
|
|
unsigned free_count; /* Number of items freed */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Destroy' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Destroy the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
free_count = 0;
|
|
|
|
ret = H5SL_destroy(slist, test_skiplist_destroy_free, &free_count);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_destroy");
|
|
|
|
VERIFY(free_count, NUM_ELEMS, "H5SL_destroy");
|
|
|
|
|
|
|
|
} /* end test_skiplist_destroy() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_free(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'free' operation in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_free(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t num; /* Number of elements in skip list */
|
|
|
|
size_t u; /* Local index variable */
|
2005-01-07 06:30:10 +08:00
|
|
|
unsigned free_count; /* Number of items freed */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Free' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Destroy the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
free_count = 0;
|
|
|
|
ret = H5SL_free(slist, test_skiplist_destroy_free, &free_count);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_destroy");
|
|
|
|
VERIFY(free_count, NUM_ELEMS, "H5SL_free");
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, 0, "H5SL_count");
|
|
|
|
|
|
|
|
/* Insert objects into the skip list again */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check that the skip list has correct # of elements */
|
2020-09-30 22:27:10 +08:00
|
|
|
num = H5SL_count(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
VERIFY(num, NUM_ELEMS, "H5SL_count");
|
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_free() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_less(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'less' operation in skip lists.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2005-01-07 06:30:10 +08:00
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
static void
|
2005-01-07 06:30:10 +08:00
|
|
|
test_skiplist_less(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
2005-01-07 06:30:10 +08:00
|
|
|
/* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
|
|
|
unsigned find_item; /* Item to add to skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Less' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for exact match of items in various positions */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 20;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, find_item, "H5SL_less");
|
|
|
|
find_item = 90;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, find_item, "H5SL_less");
|
|
|
|
find_item = 5;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, find_item, "H5SL_less");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Find item less than a missing key, in various positions */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 19;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, 15, "H5SL_less");
|
|
|
|
find_item = 89;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, 80, "H5SL_less");
|
|
|
|
find_item = 100;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, 90, "H5SL_less");
|
|
|
|
find_item = 9;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
|
|
|
VERIFY(*found_item, 5, "H5SL_less");
|
|
|
|
find_item = 4;
|
|
|
|
found_item = (unsigned *)H5SL_less(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_less");
|
2005-01-07 06:30:10 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
ret = H5SL_close(slist);
|
2005-01-07 06:30:10 +08:00
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_less() */
|
|
|
|
|
2006-03-12 05:59:01 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_greater(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'greater' operation in skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_greater(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
2006-03-12 05:59:01 +08:00
|
|
|
/* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
|
|
|
unsigned find_item; /* Item to add to skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Greater' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
2006-03-12 05:59:01 +08:00
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for exact match of items in various positions */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 20;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 90;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 5;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_greater");
|
|
|
|
|
|
|
|
/* Find item greater than a missing key, in various positions */
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 19;
|
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, 20, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 89;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, 90, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 100;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 6;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, 10, "H5SL_greater");
|
2020-09-30 22:27:10 +08:00
|
|
|
find_item = 4;
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_greater(slist, &find_item);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, 5, "H5SL_greater");
|
|
|
|
|
|
|
|
/* Close the skip list */
|
|
|
|
ret = H5SL_close(slist);
|
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_greater() */
|
|
|
|
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_below(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'below' operation in skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_below(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
/* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
|
|
|
unsigned find_item; /* Item to add to skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
2009-04-09 01:02:09 +08:00
|
|
|
MESSAGE(7, ("Testing Skip List 'Below' Operation\n"));
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for exact match of items in various positions */
|
|
|
|
find_item = 20;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_below");
|
|
|
|
find_item = 90;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_below");
|
|
|
|
find_item = 5;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_below");
|
|
|
|
|
|
|
|
/* Find item less than a missing key, in various positions */
|
|
|
|
find_item = 19;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 15, "H5SL_below");
|
|
|
|
find_item = 89;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 80, "H5SL_below");
|
|
|
|
find_item = 100;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 90, "H5SL_below");
|
|
|
|
find_item = 9;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_below(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_below");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 5, "H5SL_below");
|
|
|
|
find_item = 4;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = (H5SL_node_t *)H5SL_less(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_below");
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
|
|
|
ret = H5SL_close(slist);
|
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_below() */
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_above(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'above' operation in skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_above(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
H5SL_node_t *node; /* Skip list node */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
/* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned *found_item; /* Item found in skip list */
|
|
|
|
unsigned find_item; /* Item to add to skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
2009-04-09 01:02:09 +08:00
|
|
|
MESSAGE(7, ("Testing Skip List 'Above' Operation\n"));
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for exact match of items in various positions */
|
|
|
|
find_item = 20;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_above");
|
|
|
|
find_item = 90;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_above");
|
|
|
|
find_item = 5;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, find_item, "H5SL_above");
|
|
|
|
|
|
|
|
/* Find item greater than a missing key, in various positions */
|
|
|
|
find_item = 19;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 20, "H5SL_above");
|
|
|
|
find_item = 89;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 90, "H5SL_above");
|
|
|
|
find_item = 100;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(node, "H5SL_above");
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
find_item = 6;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 10, "H5SL_above");
|
|
|
|
find_item = 4;
|
2020-09-30 22:27:10 +08:00
|
|
|
node = H5SL_above(slist, &find_item);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(node, "H5SL_above");
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_item(node);
|
[svn-r15800] Description:
Bring file free space branch changes through r15795 into trunk, which
includes a fair bit of code cleanup & rearrangement along with a couple of
bug fixes also.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-07 12:17:35 +08:00
|
|
|
VERIFY(*found_item, 5, "H5SL_above");
|
|
|
|
|
|
|
|
/* Close the skip list */
|
|
|
|
ret = H5SL_close(slist);
|
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_above() */
|
|
|
|
|
2006-03-12 05:59:01 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_remote_first(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'remove first' operation in skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_remove_first(void)
|
|
|
|
{
|
2022-07-27 05:45:46 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
|
|
|
|
unsigned sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90};
|
|
|
|
unsigned *found_item; /* Item found in skip list */
|
|
|
|
herr_t ret; /* Generic return value */
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
2009-04-09 01:02:09 +08:00
|
|
|
MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n"));
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
2006-03-12 05:59:01 +08:00
|
|
|
ret = H5SL_insert(slist, &data[u], &data[u]);
|
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Remove objects from the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < 10; u++) {
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_remove_first(slist);
|
2006-03-12 05:59:01 +08:00
|
|
|
VERIFY(*found_item, sorted_data[u], "H5SL_remove_first");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for removing object from empty list */
|
2011-10-19 05:27:58 +08:00
|
|
|
found_item = (unsigned *)H5SL_remove_first(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_remove_first");
|
2006-03-12 05:59:01 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
|
|
|
ret = H5SL_close(slist);
|
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_remove_first() */
|
|
|
|
|
2009-04-09 01:02:09 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_remote_first_many(): Test H5SL (skip list) code.
|
|
|
|
** Tests 'remove first' operation in large skip lists.
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_remove_first_many(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5SL_t *slist; /* Skip list created */
|
|
|
|
size_t u; /* Local index variable */
|
2022-07-27 05:45:46 +08:00
|
|
|
int *found_item; /* Item found in skip list */
|
2009-04-09 01:02:09 +08:00
|
|
|
int prev_item = INT_MIN; /* Previously found item in skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret; /* Generic return value */
|
2009-04-09 01:02:09 +08:00
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n"));
|
|
|
|
|
|
|
|
/* Create a skip list */
|
2011-10-19 05:27:58 +08:00
|
|
|
slist = H5SL_create(H5SL_TYPE_INT, NULL);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR(slist, "H5SL_create");
|
2009-04-09 01:02:09 +08:00
|
|
|
|
|
|
|
/* Insert objects into the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
2009-04-09 01:02:09 +08:00
|
|
|
ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]);
|
|
|
|
CHECK(ret, FAIL, "H5SL_insert");
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Remove objects from the skip list */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < NUM_ELEMS; u++) {
|
2009-04-09 01:02:09 +08:00
|
|
|
found_item = (int *)H5SL_remove_first(slist);
|
2023-09-06 04:11:52 +08:00
|
|
|
VERIFY(*found_item > prev_item, true, "H5SL_remove_first");
|
2009-04-09 01:02:09 +08:00
|
|
|
prev_item = *found_item;
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Check for removing object from empty list */
|
|
|
|
found_item = (int *)H5SL_remove_first(slist);
|
2017-11-27 10:13:18 +08:00
|
|
|
CHECK_PTR_NULL(found_item, "H5SL_remove_first");
|
2009-04-09 01:02:09 +08:00
|
|
|
|
|
|
|
/* Close the skip list */
|
|
|
|
ret = H5SL_close(slist);
|
|
|
|
CHECK(ret, FAIL, "H5SL_close");
|
|
|
|
|
|
|
|
} /* end test_skiplist_remove_first() */
|
|
|
|
|
2016-09-28 01:29:16 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist_term(): Test H5SL (skiplist) code.
|
|
|
|
** Release data for skip list testing
|
|
|
|
**
|
|
|
|
****************************************************************/
|
|
|
|
static void
|
|
|
|
test_skiplist_term(void)
|
|
|
|
{
|
|
|
|
/* Release arrays */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (rand_num)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(rand_num);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (sort_rand_num)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(sort_rand_num);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (rev_sort_rand_num)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(rev_sort_rand_num);
|
2016-09-28 01:29:16 +08:00
|
|
|
} /* end test_skiplist_term() */
|
|
|
|
|
2004-11-28 00:07:11 +08:00
|
|
|
/****************************************************************
|
|
|
|
**
|
|
|
|
** test_skiplist(): Main H5SL testing routine.
|
2005-08-14 04:53:35 +08:00
|
|
|
**
|
2004-11-28 00:07:11 +08:00
|
|
|
****************************************************************/
|
|
|
|
void
|
|
|
|
test_skiplist(void)
|
|
|
|
{
|
|
|
|
/* Output message about test being performed */
|
|
|
|
MESSAGE(5, ("Testing Skip Lists\n"));
|
|
|
|
|
|
|
|
/* Initialize skip list testing data */
|
|
|
|
test_skiplist_init();
|
|
|
|
|
|
|
|
/* Actual skip list tests */
|
2020-09-30 22:27:10 +08:00
|
|
|
test_skiplist_create(); /* Test skip list creation */
|
|
|
|
test_skiplist_insert(); /* Test basic skip list insertion */
|
|
|
|
test_skiplist_insert_many(); /* Test insertion of many items into skip list */
|
|
|
|
test_skiplist_remove(); /* Test basic skip list removal */
|
|
|
|
test_skiplist_remove_many(); /* Test removal of many items from skip list */
|
|
|
|
test_skiplist_firstnext(); /* Test iteration over skip list nodes with first/next */
|
|
|
|
test_skiplist_string(); /* Test skip list string keys */
|
|
|
|
test_skiplist_iterate(); /* Test iteration over skip list nodes with callback */
|
|
|
|
test_skiplist_hsize(); /* Test skip list hsize_t keys */
|
|
|
|
test_skiplist_unsigned(); /* Test skip list unsigned keys */
|
|
|
|
test_skiplist_obj(); /* Test skip list H5_obj_t keys */
|
|
|
|
test_skiplist_generic(); /* Test skip list generic keys */
|
|
|
|
test_skiplist_lastprev(); /* Test iteration over skip list nodes with last/prev */
|
|
|
|
test_skiplist_find(); /* Test 'find' operation */
|
|
|
|
test_skiplist_add(); /* Test 'add' operation */
|
|
|
|
test_skiplist_destroy(); /* Test 'destroy' operation */
|
|
|
|
test_skiplist_free(); /* Test 'free' operation */
|
|
|
|
test_skiplist_less(); /* Test 'less' operation */
|
|
|
|
test_skiplist_greater(); /* Test 'greater' operation */
|
|
|
|
test_skiplist_below(); /* Test 'below' operation */
|
|
|
|
test_skiplist_above(); /* Test 'above' operation */
|
|
|
|
test_skiplist_remove_first(); /* Test 'remove first' operation */
|
|
|
|
test_skiplist_remove_first_many(); /* Test 'remove first' operation on large skip lists */
|
2004-11-28 00:07:11 +08:00
|
|
|
|
2016-09-28 01:29:16 +08:00
|
|
|
/* Release skip list testing data */
|
|
|
|
test_skiplist_term();
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
} /* end test_skiplist() */
|