2007-01-07 04:54:19 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2007-01-07 04:54:19 +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. *
|
2007-01-07 04:54:19 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Created: H5Ftest.c
|
|
|
|
*
|
|
|
|
* Purpose: File testing routines.
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
/* Module Setup */
|
|
|
|
/****************/
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
#include "H5Fmodule.h" /* This source code file is part of the H5F module */
|
|
|
|
#define H5F_TESTING /* Suppress warning about H5F testing funcs */
|
|
|
|
#define H5G_FRIEND /* Suppress error about including H5Gpkg.h */
|
|
|
|
#define H5G_TESTING /* Suppress warning about H5G testing funcs */
|
|
|
|
#define H5SM_FRIEND /* Suppress error about including H5SMpkg.h */
|
|
|
|
#define H5SM_TESTING /* Suppress warning about H5SM testing funcs */
|
2007-01-07 04:54:19 +08:00
|
|
|
|
|
|
|
/***********/
|
|
|
|
/* Headers */
|
|
|
|
/***********/
|
2020-09-30 22:27:10 +08:00
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
#include "H5CXprivate.h" /* API Contexts */
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
#include "H5Fpkg.h" /* File access */
|
|
|
|
#include "H5Gpkg.h" /* Groups */
|
|
|
|
#include "H5Iprivate.h" /* IDs */
|
|
|
|
#include "H5SMpkg.h" /* Shared object header messages */
|
|
|
|
#include "H5VLprivate.h" /* Virtual Object Layer */
|
2007-01-07 04:54:19 +08:00
|
|
|
|
|
|
|
/****************/
|
|
|
|
/* Local Macros */
|
|
|
|
/****************/
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
/* Local Typedefs */
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
/********************/
|
|
|
|
/* Package Typedefs */
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
/********************/
|
|
|
|
/* Local Prototypes */
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
/*********************/
|
|
|
|
/* Package Variables */
|
|
|
|
/*********************/
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Library Private Variables */
|
|
|
|
/*****************************/
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
/* Local Variables */
|
|
|
|
/*******************/
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2018-09-21 01:40:51 +08:00
|
|
|
* Function: H5F__get_sohm_mesg_count_test
|
2007-01-07 04:54:19 +08:00
|
|
|
*
|
|
|
|
* Purpose: Retrieve the number of shared messages of a given type in a file
|
|
|
|
*
|
2018-09-21 01:40:51 +08:00
|
|
|
* Return: SUCCEED/FAIL
|
2007-01-07 04:54:19 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2018-09-21 01:40:51 +08:00
|
|
|
H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count)
|
2007-01-07 04:54:19 +08:00
|
|
|
{
|
2023-09-06 05:52:30 +08:00
|
|
|
H5F_t *file; /* File info */
|
|
|
|
bool api_ctx_pushed = false; /* Whether API context pushed */
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2007-01-07 04:54:19 +08:00
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
FUNC_ENTER_PACKAGE
|
2007-01-07 04:54:19 +08:00
|
|
|
|
|
|
|
/* Check arguments */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2018-03-19 11:51:19 +08:00
|
|
|
|
|
|
|
/* Push API context */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5CX_push() < 0)
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context");
|
2023-09-06 05:52:30 +08:00
|
|
|
api_ctx_pushed = true;
|
2007-01-07 04:54:19 +08:00
|
|
|
|
|
|
|
/* Retrieve count for message type */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5SM__get_mesg_count_test(file, type_id, mesg_count) < 0)
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve shared message count");
|
2007-01-07 04:54:19 +08:00
|
|
|
|
|
|
|
done:
|
2023-09-06 05:52:30 +08:00
|
|
|
if (api_ctx_pushed && H5CX_pop(false) < 0)
|
2023-07-25 05:18:04 +08:00
|
|
|
HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context");
|
2018-03-19 11:51:19 +08:00
|
|
|
|
2007-01-07 04:54:19 +08:00
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2018-09-21 01:40:51 +08:00
|
|
|
} /* end H5F__get_sohm_mesg_count_test() */
|
2007-01-07 04:54:19 +08:00
|
|
|
|
2009-04-09 05:53:31 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2018-09-21 01:40:51 +08:00
|
|
|
* Function: H5F__check_cached_stab_test
|
2009-04-09 05:53:31 +08:00
|
|
|
*
|
|
|
|
* Purpose: Check that a file's superblock contains a cached symbol
|
|
|
|
* table entry, that the entry matches that in the root
|
|
|
|
* group's object header, and check that the addresses are
|
|
|
|
* valid.
|
|
|
|
*
|
2018-09-21 01:40:51 +08:00
|
|
|
* Return: SUCCEED/FAIL
|
2009-04-09 05:53:31 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2018-09-21 01:40:51 +08:00
|
|
|
H5F__check_cached_stab_test(hid_t file_id)
|
2009-04-09 05:53:31 +08:00
|
|
|
{
|
2023-09-06 05:52:30 +08:00
|
|
|
H5F_t *file; /* File info */
|
|
|
|
bool api_ctx_pushed = false; /* Whether API context pushed */
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2009-04-09 05:53:31 +08:00
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
FUNC_ENTER_PACKAGE
|
2009-04-09 05:53:31 +08:00
|
|
|
|
|
|
|
/* Check arguments */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2018-03-19 11:51:19 +08:00
|
|
|
|
|
|
|
/* Push API context */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5CX_push() < 0)
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context");
|
2023-09-06 05:52:30 +08:00
|
|
|
api_ctx_pushed = true;
|
2009-04-09 05:53:31 +08:00
|
|
|
|
|
|
|
/* Verify the cached stab info */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5G__verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0)
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to verify cached symbol table info");
|
2009-04-09 05:53:31 +08:00
|
|
|
|
|
|
|
done:
|
2023-09-06 05:52:30 +08:00
|
|
|
if (api_ctx_pushed && H5CX_pop(false) < 0)
|
2023-07-25 05:18:04 +08:00
|
|
|
HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context");
|
2018-03-19 11:51:19 +08:00
|
|
|
|
2009-04-09 05:53:31 +08:00
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2018-09-21 01:40:51 +08:00
|
|
|
} /* end H5F__check_cached_stab_test() */
|
2009-04-09 05:53:31 +08:00
|
|
|
|
2009-06-11 11:28:57 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2018-09-21 01:40:51 +08:00
|
|
|
* Function: H5F__get_maxaddr_test
|
2009-06-11 11:28:57 +08:00
|
|
|
*
|
|
|
|
* Purpose: Retrieve the maximum address for a file
|
|
|
|
*
|
2018-09-21 01:40:51 +08:00
|
|
|
* Return: SUCCEED/FAIL
|
2009-06-11 11:28:57 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2018-09-21 01:40:51 +08:00
|
|
|
H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr)
|
2009-06-11 11:28:57 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5F_t *file; /* File info */
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2009-06-11 11:28:57 +08:00
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
FUNC_ENTER_PACKAGE
|
2009-06-11 11:28:57 +08:00
|
|
|
|
|
|
|
/* Check arguments */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2009-06-11 11:28:57 +08:00
|
|
|
|
|
|
|
/* Retrieve maxaddr for file */
|
|
|
|
*maxaddr = file->shared->maxaddr;
|
|
|
|
|
|
|
|
done:
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2018-09-21 01:40:51 +08:00
|
|
|
} /* end H5F__get_maxaddr_test() */
|
2009-06-11 11:28:57 +08:00
|
|
|
|
2016-11-07 15:14:10 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2018-09-21 01:40:51 +08:00
|
|
|
* Function: H5F__get_sbe_addr_test
|
2016-11-07 15:14:10 +08:00
|
|
|
*
|
|
|
|
* Purpose: Retrieve the address of a superblock extension's object header
|
2018-09-21 01:40:51 +08:00
|
|
|
* for a file
|
2016-11-07 15:14:10 +08:00
|
|
|
*
|
2018-09-21 01:40:51 +08:00
|
|
|
* Return: SUCCEED/FAIL
|
2016-11-07 15:14:10 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2018-09-21 01:40:51 +08:00
|
|
|
H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr)
|
2016-11-07 15:14:10 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5F_t *file; /* File info */
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2016-11-07 15:14:10 +08:00
|
|
|
|
2018-09-21 01:40:51 +08:00
|
|
|
FUNC_ENTER_PACKAGE
|
2016-11-07 15:14:10 +08:00
|
|
|
|
|
|
|
/* Check arguments */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2016-11-07 15:14:10 +08:00
|
|
|
|
|
|
|
/* Retrieve maxaddr for file */
|
|
|
|
*sbe_addr = file->shared->sblock->ext_addr;
|
|
|
|
|
|
|
|
done:
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2018-09-21 01:40:51 +08:00
|
|
|
} /* end H5F__get_sbe_addr_test() */
|
2016-11-07 15:14:10 +08:00
|
|
|
|
2018-10-25 12:52:47 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: H5F__same_file_test
|
|
|
|
*
|
|
|
|
* Purpose: Check if two file IDs refer to the same underlying file.
|
|
|
|
*
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
|
|
|
H5F__same_file_test(hid_t file_id1, hid_t file_id2)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
H5F_t *file1, *file2; /* File info */
|
|
|
|
htri_t ret_value = FAIL; /* Return value */
|
2018-10-25 12:52:47 +08:00
|
|
|
|
|
|
|
FUNC_ENTER_PACKAGE
|
|
|
|
|
|
|
|
/* Check arguments */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file1 = (H5F_t *)H5VL_object_verify(file_id1, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == (file2 = (H5F_t *)H5VL_object_verify(file_id2, H5I_FILE)))
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
|
2018-10-25 12:52:47 +08:00
|
|
|
|
|
|
|
/* If they are using the same underlying "shared" file struct, they are the same file */
|
|
|
|
ret_value = (file1->shared == file2->shared);
|
|
|
|
|
|
|
|
done:
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
} /* end H5F__same_file_test() */
|
|
|
|
|
2020-08-04 00:11:27 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: H5F__reparse_file_lock_variable_test
|
|
|
|
*
|
|
|
|
* Purpose: Re-parse the file locking environment variable.
|
|
|
|
*
|
|
|
|
* Since getenv(3) is fairly expensive, we only parse it once,
|
|
|
|
* when the library opens. This test function is used to
|
|
|
|
* re-parse the environment variable after we've changed it
|
|
|
|
* with setnev(3).
|
|
|
|
*
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
|
|
|
H5F__reparse_file_lock_variable_test(void)
|
|
|
|
{
|
|
|
|
herr_t ret_value = SUCCEED;
|
|
|
|
|
|
|
|
FUNC_ENTER_PACKAGE
|
|
|
|
|
|
|
|
/* Check the file locking environment variable */
|
2024-02-23 04:52:36 +08:00
|
|
|
if (H5F__parse_file_lock_env_var(&use_locks_env_g, &ignore_disabled_locks_g) < 0)
|
2023-08-02 21:39:15 +08:00
|
|
|
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to parse file locking environment variable");
|
2020-08-04 00:11:27 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
} /* end H5F__reparse_file_lock_variable_test() */
|