2007-05-02 05:00:52 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by The HDF Group. *
|
|
|
|
* 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. *
|
2007-05-02 05:00:52 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Purpose: This program is run to generate an HDF5 data file with several
|
|
|
|
* datasets that have "bogus" messages in their object header.
|
|
|
|
*/
|
2014-04-26 05:27:37 +08:00
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
#include "hdf5.h"
|
2016-02-25 05:30:35 +08:00
|
|
|
#include "H5private.h"
|
2007-05-02 05:00:52 +08:00
|
|
|
#include "H5Oprivate.h"
|
|
|
|
|
[svn-r18031] Description:
Bring r18030 from merge_metadata_journaling branch to trunk:
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.
Also, some other minor cleanups along the way.
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-18 06:21:08 +08:00
|
|
|
#ifdef H5O_ENABLE_BOGUS
|
2007-05-02 05:00:52 +08:00
|
|
|
#define FILENAME "tbogus.h5"
|
[svn-r18031] Description:
Bring r18030 from merge_metadata_journaling branch to trunk:
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.
Also, some other minor cleanups along the way.
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-18 06:21:08 +08:00
|
|
|
#endif /* H5O_ENABLE_BOGUS */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2023-09-06 04:11:52 +08:00
|
|
|
#ifndef true
|
|
|
|
#define true 1
|
|
|
|
#endif /* true */
|
|
|
|
#ifndef false
|
|
|
|
#define false 0
|
|
|
|
#endif /* false */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
#ifdef H5O_ENABLE_BOGUS
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
/*
|
2020-04-21 07:12:00 +08:00
|
|
|
* Create datasets in the location (in "/" or "/group") with
|
2016-02-25 05:30:35 +08:00
|
|
|
* message id: (a) H5O_BOGUS_VALID_ID or (b)H5O_BOGUS_INVALID_ID
|
|
|
|
* and various unknown message flags
|
|
|
|
*/
|
|
|
|
static int
|
2020-04-21 07:12:00 +08:00
|
|
|
generate_datasets(hid_t loc_id, unsigned bogus_id)
|
2016-02-25 05:30:35 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t sid = -1; /* Dataspace ID */
|
|
|
|
hid_t dcpl = -1; /* Dataset creation property list ID */
|
|
|
|
hid_t did = -1; /* Dataset ID */
|
|
|
|
uint8_t bogus_flags = 0; /* Flags for bogus message */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
/* Create dataspace for datasets */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sid = H5Screate(H5S_SCALAR)) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
/* Create dataset creation property list */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
/* Add property for bogus message flags */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pinsert2(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, H5O_BOGUS_MSG_FLAGS_SIZE, &bogus_flags, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2016-02-25 05:30:35 +08:00
|
|
|
/* Add property for bogus message ID */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pinsert2(dcpl, H5O_BOGUS_MSG_ID_NAME, H5O_BOGUS_MSG_ID_SIZE, &bogus_id, NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL) < 0)
|
|
|
|
goto error;
|
2016-02-25 05:30:35 +08:00
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
/* Create dataset with "bogus" message, but no message flags */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((did = H5Dcreate2(loc_id, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
|
|
|
if (H5Dclose(did) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2015-06-27 13:51:04 +08:00
|
|
|
/* Set "fail if unknown and open for write" message flag for bogus message */
|
2015-01-21 01:17:05 +08:00
|
|
|
bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
/* Create second dataset, with "fail if unknown" message flag */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((did = H5Dcreate2(loc_id, "Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
|
|
|
if (H5Dclose(did) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2015-06-27 13:51:04 +08:00
|
|
|
/* Set "fail if unknown always" message flag for bogus message */
|
|
|
|
bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0)
|
|
|
|
goto error;
|
2015-06-27 13:51:04 +08:00
|
|
|
|
|
|
|
/* Create third dataset, with "fail if unknown always" message flag */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((did = H5Dcreate2(loc_id, "Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
|
|
|
if (H5Dclose(did) < 0)
|
|
|
|
goto error;
|
2015-06-27 13:51:04 +08:00
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
/* Set "mark if unknown" message flag for bogus message */
|
|
|
|
bogus_flags = H5O_MSG_FLAG_MARK_IF_UNKNOWN;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2015-06-27 13:51:04 +08:00
|
|
|
/* Create fourth dataset, with "mark if unknown" message flag */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((did = H5Dcreate2(loc_id, "Dataset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
|
|
|
if (H5Dclose(did) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
2019-01-08 05:20:11 +08:00
|
|
|
/* Set "shareable" message flag for bogus message */
|
|
|
|
bogus_flags = H5O_MSG_FLAG_SHAREABLE;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0)
|
|
|
|
goto error;
|
2019-01-08 05:20:11 +08:00
|
|
|
|
|
|
|
/* Create fourth dataset, with "shareable" message flag */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((did = H5Dcreate2(loc_id, "Dataset5", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
|
|
|
if (H5Dclose(did) < 0)
|
|
|
|
goto error;
|
2019-01-08 05:20:11 +08:00
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
/* Close dataset creation property list */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pclose(dcpl) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
/* Close dataspace */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(sid) < 0)
|
|
|
|
goto error;
|
2007-05-02 05:00:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2020-09-30 22:27:10 +08:00
|
|
|
H5E_BEGIN_TRY
|
|
|
|
{
|
2007-05-02 05:00:52 +08:00
|
|
|
H5Dclose(did);
|
|
|
|
H5Sclose(sid);
|
|
|
|
H5Pclose(dcpl);
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
2023-06-16 12:49:02 +08:00
|
|
|
H5E_END_TRY
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
} /* generate_datasets() */
|
|
|
|
#endif
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
int
|
|
|
|
main(void)
|
2016-02-25 05:30:35 +08:00
|
|
|
{
|
|
|
|
#ifdef H5O_ENABLE_BOGUS
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t fid = -1; /* File ID */
|
|
|
|
hid_t gid = -1; /* Group ID */
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
/* Create file for test datasets */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
goto error;
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
/* Create datasets in "/" group with bogus message H5O_BOGUS_VALID_ID */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (generate_datasets(fid, H5O_BOGUS_VALID_ID) < 0)
|
2016-02-25 05:30:35 +08:00
|
|
|
goto error;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2016-02-25 05:30:35 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Create datasets in "/group" with bogus message H5O_BOGUS_INVALID_ID */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (generate_datasets(gid, H5O_BOGUS_INVALID_ID) < 0)
|
2016-02-25 05:30:35 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Close the group */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Gclose(gid) < 0)
|
|
|
|
goto error;
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
/* Close file */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Fclose(fid) < 0)
|
|
|
|
goto error;
|
2016-02-25 05:30:35 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2020-09-30 22:27:10 +08:00
|
|
|
H5E_BEGIN_TRY
|
|
|
|
{
|
2016-02-25 05:30:35 +08:00
|
|
|
H5Gclose(gid);
|
2007-05-02 05:00:52 +08:00
|
|
|
H5Fclose(fid);
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
2023-06-16 12:49:02 +08:00
|
|
|
H5E_END_TRY
|
2021-01-29 20:55:18 +08:00
|
|
|
#else /* H5O_ENABLE_BOGUS */
|
2007-05-02 05:00:52 +08:00
|
|
|
HDputs("H5O_ENABLE_BOGUS compiler macro not defined!");
|
|
|
|
#endif /* H5O_ENABLE_BOGUS */
|
|
|
|
return 1;
|
|
|
|
}
|