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 *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
|
/*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Tuesday, November 24, 1998
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Test local heaps used by symbol tables (groups).
|
|
|
|
|
*/
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "h5test.h"
|
2005-07-03 00:36:15 +08:00
|
|
|
|
#include "H5ACprivate.h"
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "H5HLprivate.h"
|
|
|
|
|
#include "H5Iprivate.h"
|
1998-11-25 22:58:22 +08:00
|
|
|
|
|
|
|
|
|
const char *FILENAME[] = {
|
|
|
|
|
"lheap",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NOBJS 40
|
|
|
|
|
|
2004-07-17 04:48:40 +08:00
|
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: main
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: zero
|
|
|
|
|
*
|
|
|
|
|
* Failure: non-zero
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Tuesday, November 24, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
main(void)
|
|
|
|
|
{
|
2001-10-25 02:02:27 +08:00
|
|
|
|
hid_t fapl=H5P_DEFAULT; /*file access properties */
|
1998-11-25 22:58:22 +08:00
|
|
|
|
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 */
|
2007-05-11 04:35:35 +08:00
|
|
|
|
H5HL_t *heap = NULL; /*local heap */
|
1998-11-25 22:58:22 +08:00
|
|
|
|
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 */
|
2006-08-01 03:46:16 +08:00
|
|
|
|
const char *envval = NULL; /*value from environment */
|
1998-11-25 22:58:22 +08:00
|
|
|
|
|
|
|
|
|
/* Reset library */
|
|
|
|
|
h5_reset();
|
|
|
|
|
fapl = h5_fileaccess();
|
|
|
|
|
|
[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);
|
|
|
|
|
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
|
|
|
|
|
goto error;
|
2006-10-31 08:13:27 +08:00
|
|
|
|
if(NULL == (f = H5I_object(file))) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
1998-11-25 22:58:22 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
2006-10-31 08:13:27 +08:00
|
|
|
|
if(H5HL_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)0, &heap_addr/*out*/) < 0) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
1998-11-25 22:58:22 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
2007-05-11 04:35:35 +08:00
|
|
|
|
if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC_WRITE))) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2006-10-31 08:13:27 +08:00
|
|
|
|
for(i = 0; i < NOBJS; i++) {
|
1998-11-25 22:58:22 +08:00
|
|
|
|
sprintf(buf, "%03d-", i);
|
|
|
|
|
for (j=4; j<i; j++) buf[j] = '0' + j%10;
|
|
|
|
|
if (j>4) buf[j] = '\0';
|
|
|
|
|
|
2007-05-11 04:35:35 +08:00
|
|
|
|
if ((size_t)(-1)==(obj[i]=H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap, strlen(buf)+1, buf))) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
1998-11-25 22:58:22 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-11 04:35:35 +08:00
|
|
|
|
if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
1998-11-25 22:58:22 +08:00
|
|
|
|
if (H5Fclose(file)<0) goto error;
|
|
|
|
|
PASSED();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test reading from the heap...
|
|
|
|
|
*/
|
2001-10-25 02:02:27 +08:00
|
|
|
|
|
2006-08-01 03:46:16 +08:00
|
|
|
|
/* Don't run this test using the core file driver */
|
|
|
|
|
envval = HDgetenv("HDF5_DRIVER");
|
|
|
|
|
if (envval == NULL)
|
|
|
|
|
envval = "nomatch";
|
|
|
|
|
if (HDstrcmp(envval, "core")) {
|
|
|
|
|
TESTING("local heap read");
|
|
|
|
|
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
|
|
|
|
if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error;
|
|
|
|
|
if (NULL==(f=H5I_object(file))) {
|
2003-09-19 03:27:45 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
2003-09-19 03:27:45 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
2006-08-01 03:46:16 +08:00
|
|
|
|
for (i=0; i<NOBJS; i++) {
|
|
|
|
|
sprintf(buf, "%03d-", i);
|
|
|
|
|
for (j=4; j<i; j++) buf[j] = '0' + j%10;
|
|
|
|
|
if (j>4) buf[j] = '\0';
|
|
|
|
|
|
2007-04-20 02:43:10 +08:00
|
|
|
|
if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC_READ))) {
|
2006-08-01 03:46:16 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
2006-08-01 03:46:16 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NULL == (s = H5HL_offset_into(f, heap, obj[i]))) {
|
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
2006-08-01 03:46:16 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(s, buf)) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" i=%d, heap offset=%lu\n", i, (unsigned long)(obj[i]));
|
|
|
|
|
printf(" got: \"%s\"\n", s);
|
|
|
|
|
printf(" ans: \"%s\"\n", buf);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 04:35:35 +08:00
|
|
|
|
if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) {
|
2006-08-01 03:46:16 +08:00
|
|
|
|
H5_FAILED();
|
2007-04-12 09:59:45 +08:00
|
|
|
|
H5Eprint2(H5E_DEFAULT, stdout);
|
2006-08-01 03:46:16 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
1998-11-25 22:58:22 +08:00
|
|
|
|
}
|
2003-09-19 03:27:45 +08:00
|
|
|
|
|
2006-08-01 03:46:16 +08:00
|
|
|
|
if (H5Fclose(file)<0) goto error;
|
|
|
|
|
PASSED();
|
|
|
|
|
puts("All local heap tests passed.");
|
|
|
|
|
h5_cleanup(FILENAME, fapl);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SKIPPED();
|
|
|
|
|
puts(" Test not compatible with current Virtual File Driver");
|
1998-11-25 22:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
puts("*** TESTS FAILED ***");
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Fclose(file);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|