2003-04-01 01:59:04 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 01:59:04 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
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. *
|
2003-04-01 01:59:04 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
/*
|
2020-08-07 08:58:07 +08:00
|
|
|
* Programmer: Robb Matzke
|
1998-11-25 22:58:22 +08:00
|
|
|
* Tuesday, November 24, 1998
|
|
|
|
*
|
2019-08-16 05:46:00 +08:00
|
|
|
* Purpose: Test local heaps used by symbol tables (groups).
|
1998-11-25 22:58:22 +08:00
|
|
|
*/
|
2001-04-04 02:09:16 +08:00
|
|
|
#include "h5test.h"
|
2010-07-17 00:32:49 +08:00
|
|
|
#include "H5srcdir.h"
|
2005-07-03 00:36:15 +08:00
|
|
|
#include "H5ACprivate.h"
|
2020-09-30 22:27:10 +08:00
|
|
|
#include "H5CXprivate.h" /* API Contexts */
|
2001-04-04 02:09:16 +08:00
|
|
|
#include "H5HLprivate.h"
|
|
|
|
#include "H5Iprivate.h"
|
2020-09-30 22:27:10 +08:00
|
|
|
#include "H5VLprivate.h" /* Virtual Object Layer */
|
1998-11-25 22:58:22 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
const char *FILENAME[] = {"lheap", NULL};
|
1998-11-25 22:58:22 +08:00
|
|
|
|
2010-07-17 00:32:49 +08:00
|
|
|
#define TESTFILE "tsizeslheap.h5"
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
#define NOBJS 40
|
2019-08-16 05:46:00 +08:00
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2015-12-11 10:17:20 +08:00
|
|
|
* Function: main
|
1998-11-25 22:58:22 +08:00
|
|
|
*
|
2015-12-11 10:17:20 +08:00
|
|
|
* Purpose: Create a file, create a local heap, write data into the local
|
|
|
|
* heap, close the file, open the file, read data out of the
|
|
|
|
* local heap, close the file.
|
1998-11-25 22:58:22 +08:00
|
|
|
*
|
2018-09-21 01:40:51 +08:00
|
|
|
* Return: EXIT_SUCCESS/EXIT_FAILURE
|
1998-11-25 22:58:22 +08:00
|
|
|
*
|
2015-12-11 10:17:20 +08:00
|
|
|
* Programmer: Robb Matzke
|
1998-11-25 22:58:22 +08:00
|
|
|
* Tuesday, November 24, 1998
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t fapl = H5P_DEFAULT; /* file access properties */
|
|
|
|
hid_t file = -1; /* hdf5 file */
|
|
|
|
H5F_t * f = NULL; /* hdf5 file pointer */
|
|
|
|
char filename[1024]; /* file name */
|
|
|
|
haddr_t heap_addr; /* local heap address */
|
|
|
|
H5HL_t * heap = NULL; /* local heap */
|
|
|
|
size_t obj[NOBJS]; /* offsets within the heap */
|
|
|
|
int i, j; /* miscellaneous counters */
|
|
|
|
char buf[1024]; /* the value to store */
|
|
|
|
const char *s; /* value to read */
|
|
|
|
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
|
1998-11-25 22:58:22 +08:00
|
|
|
|
|
|
|
/* Reset library */
|
|
|
|
h5_reset();
|
|
|
|
fapl = h5_fileaccess();
|
|
|
|
|
2018-03-19 11:51:19 +08:00
|
|
|
/* Push API context */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5CX_push() < 0)
|
|
|
|
FAIL_STACK_ERROR
|
2018-03-19 11:51:19 +08:00
|
|
|
api_ctx_pushed = TRUE;
|
[svn-r11008] Purpose:
Feature: tests now use parallel make and only run once
Description:
When make is invoked in parallel (using the -j option), several tests will
now be run simultaneously. This should speed up testing on a number of
systems.
When a test passes, it creates a foo.chkexe or foo.chksh file, which prevents
the test from running again unless the test or library changes.
Solution:
Most of the changes live in config/conclude.am. Added *.chkexe and *.chksh
files to the list of files to be cleaned at "make mostlyclean" time.
Parallel tests still run one at a time, but use the same make instructions
as serial tests.
Platforms tested:
mir, eirene, sleipnir, pommier, copper, modi4 (some errors occurred, probably
due to the test being run before updating hdf5. Will re-run tests after
checkin.)
2005-07-01 07:35:32 +08:00
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
/*
|
|
|
|
* Test writing to the heap...
|
|
|
|
*/
|
|
|
|
TESTING("local heap write");
|
|
|
|
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == (file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)))
|
2015-12-11 10:17:20 +08:00
|
|
|
goto error;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (f = (H5F_t *)H5VL_object(file))) {
|
2015-12-11 10:17:20 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
1998-11-25 22:58:22 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == H5AC_ignore_tags(f)) {
|
2015-12-11 10:17:20 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
2010-06-16 04:00:22 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == H5HL_create(f, (size_t)0, &heap_addr /*out*/)) {
|
2015-12-11 10:17:20 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
1998-11-25 22:58:22 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__NO_FLAGS_SET))) {
|
2007-05-11 04:35:35 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < NOBJS; i++) {
|
2019-08-16 05:46:00 +08:00
|
|
|
HDsprintf(buf, "%03d-", i);
|
2020-09-30 22:27:10 +08:00
|
|
|
for (j = 4; j < i; j++)
|
2016-04-30 14:10:38 +08:00
|
|
|
buf[j] = (char)('0' + j % 10);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (j > 4)
|
[svn-r18030] Description:
Bring "brush clearing" changes (whitespace & style issues, mostly) from
metadata_journaling branch to the "merging" branch, to converge the trunk and
the metadata_journaling branch.
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-17 23:07:35 +08:00
|
|
|
buf[j] = '\0';
|
1998-11-25 22:58:22 +08:00
|
|
|
|
2021-05-12 00:05:03 +08:00
|
|
|
if (H5HL_insert(f, heap, HDstrlen(buf) + 1, buf, &obj[i]) < 0) {
|
2015-12-11 10:17:20 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
1998-11-25 22:58:22 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == H5HL_unprotect(heap)) {
|
2007-05-11 04:35:35 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
2015-12-11 10:17:20 +08:00
|
|
|
if (FAIL == H5Fclose(file))
|
|
|
|
goto error;
|
1998-11-25 22:58:22 +08:00
|
|
|
PASSED();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test reading from the heap...
|
|
|
|
*/
|
2001-10-25 02:02:27 +08:00
|
|
|
|
2007-06-16 03:11:59 +08:00
|
|
|
TESTING("local heap read");
|
|
|
|
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == (file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)))
|
2015-12-11 10:17:20 +08:00
|
|
|
goto error;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (f = (H5F_t *)H5VL_object(file))) {
|
2007-06-16 03:11:59 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
2006-08-01 03:46:16 +08:00
|
|
|
}
|
2015-12-11 10:17:20 +08:00
|
|
|
if (FAIL == H5AC_ignore_tags(f)) {
|
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
2010-06-16 04:00:22 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < NOBJS; i++) {
|
2019-08-16 05:46:00 +08:00
|
|
|
HDsprintf(buf, "%03d-", i);
|
2020-09-30 22:27:10 +08:00
|
|
|
for (j = 4; j < i; j++)
|
2016-04-30 14:10:38 +08:00
|
|
|
buf[j] = (char)('0' + j % 10);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (j > 4)
|
[svn-r18030] Description:
Bring "brush clearing" changes (whitespace & style issues, mostly) from
metadata_journaling branch to the "merging" branch, to converge the trunk and
the metadata_journaling branch.
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-17 23:07:35 +08:00
|
|
|
buf[j] = '\0';
|
2007-06-16 03:11:59 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) {
|
2007-06-16 03:11:59 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
[svn-r18072] Description:
Bring r18071 from metadata journaling merge branch:
Refactor local heap routines with changes from metadata journaling
branch, along with other misc. changes as the changes on the metadata journaling
branch are being converged with the current state of the trunk.
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 (amani) 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
2010-01-08 06:45:21 +08:00
|
|
|
if (NULL == (s = (const char *)H5HL_offset_into(heap, obj[i]))) {
|
2007-06-16 03:11:59 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:42:35 +08:00
|
|
|
if (HDstrcmp(s, buf) != 0) {
|
2007-06-16 03:11:59 +08:00
|
|
|
H5_FAILED();
|
2016-07-28 00:56:42 +08:00
|
|
|
HDprintf(" i=%d, heap offset=%lu\n", i, (unsigned long)(obj[i]));
|
|
|
|
HDprintf(" got: \"%s\"\n", s);
|
|
|
|
HDprintf(" ans: \"%s\"\n", buf);
|
2007-06-16 03:11:59 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (FAIL == H5HL_unprotect(heap)) {
|
2007-06-16 03:11:59 +08:00
|
|
|
H5_FAILED();
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
goto error;
|
|
|
|
}
|
1998-11-25 22:58:22 +08:00
|
|
|
}
|
|
|
|
|
2015-12-11 10:17:20 +08:00
|
|
|
if (FAIL == H5Fclose(file))
|
|
|
|
goto error;
|
2007-06-16 03:11:59 +08:00
|
|
|
PASSED();
|
2010-07-17 00:32:49 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
if (!h5_driver_uses_modified_filename()) {
|
|
|
|
/* Check opening existing file non-default sizes of lengths and addresses */
|
|
|
|
TESTING("opening pre-created file with non-default sizes");
|
|
|
|
{
|
|
|
|
const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
|
|
|
|
hid_t dset = -1;
|
|
|
|
file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
|
|
if (file >= 0) {
|
|
|
|
if ((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if (H5Dclose(dset) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
if (H5Fclose(file) < 0)
|
|
|
|
TEST_ERROR
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
H5_FAILED();
|
|
|
|
HDprintf("***cannot open the pre-created non-default sizes test file (%s)\n", testfile);
|
|
|
|
goto error;
|
|
|
|
} /* end else */
|
2010-07-17 00:32:49 +08:00
|
|
|
}
|
2021-09-30 02:28:12 +08:00
|
|
|
PASSED();
|
2010-07-17 00:32:49 +08:00
|
|
|
}
|
|
|
|
|
2011-04-16 06:05:23 +08:00
|
|
|
/* Verify symbol table messages are cached */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (h5_verify_cached_stabs(FILENAME, fapl) < 0)
|
|
|
|
TEST_ERROR
|
2011-04-16 06:05:23 +08:00
|
|
|
|
2018-03-19 11:51:19 +08:00
|
|
|
/* Pop API context */
|
2020-12-02 00:15:34 +08:00
|
|
|
if (api_ctx_pushed && H5CX_pop(FALSE) < 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
FAIL_STACK_ERROR
|
2018-03-19 11:51:19 +08:00
|
|
|
api_ctx_pushed = FALSE;
|
|
|
|
|
2016-07-28 00:56:42 +08:00
|
|
|
HDputs("All local heap tests passed.");
|
2007-06-16 03:11:59 +08:00
|
|
|
h5_cleanup(FILENAME, fapl);
|
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
return EXIT_SUCCESS;
|
1998-11-25 22:58:22 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
error:
|
2016-07-28 00:56:42 +08:00
|
|
|
HDputs("*** TESTS FAILED ***");
|
2021-03-17 23:25:39 +08:00
|
|
|
H5E_BEGIN_TRY
|
|
|
|
{
|
|
|
|
H5Fclose(file);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
H5E_END_TRY;
|
2018-03-19 11:51:19 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (api_ctx_pushed)
|
2020-12-02 00:15:34 +08:00
|
|
|
H5CX_pop(FALSE);
|
2018-03-19 11:51:19 +08:00
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
return EXIT_FAILURE;
|
1998-11-25 22:58:22 +08:00
|
|
|
}
|