[svn-r21976] Added sb_verify and replaced the exisiting compatability checks with sb_verify calls.
This commit is contained in:
2
MANIFEST
2
MANIFEST
@@ -677,6 +677,8 @@
|
||||
./src/H5FDmpiposix.h
|
||||
./src/H5FDmulti.c
|
||||
./src/H5FDmulti.h
|
||||
./src/H5FDnull.c
|
||||
./src/H5FDnull.h
|
||||
./src/H5FDpkg.h
|
||||
./src/H5FDprivate.h
|
||||
./src/H5FDpublic.h
|
||||
|
||||
2
configure
vendored
2
configure
vendored
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
# From configure.in Id: configure.in 21857 2012-01-01 15:46:54Z hdftest .
|
||||
# From configure.in Id: configure.in 21867 2012-01-08 16:39:01Z hdftest .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.68 for HDF5 1.9.106.
|
||||
#
|
||||
|
||||
43
src/H5FD.c
43
src/H5FD.c
@@ -557,6 +557,49 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5FD_sb_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_null_sb_verify
|
||||
*
|
||||
* Purpose: Verify that the driver is compatable with the driver
|
||||
* that created the file. driver_id is the driver identifier
|
||||
* field stored in the superblock. This is called when
|
||||
* reopening a file and ensures that the driver is able to
|
||||
* decode the superblock info.
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Jacob Gruber
|
||||
* Friday, January 13, 2012
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5FD_sb_verify(H5FD_t *file, const char *driver_id)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5FD_sb_verify, FAIL)
|
||||
|
||||
HDassert(file && file->cls);
|
||||
|
||||
/* Delegate to the driver if possible. If driver doesn't implement
|
||||
* this function, it means that it can't support files with driver info
|
||||
* in the superblock.
|
||||
*/
|
||||
if(file->cls->sb_verify) {
|
||||
if((file->cls->sb_verify)(file, driver_id) < 0)
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_verify request failed")
|
||||
}
|
||||
else
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver doesn't support sb_verify")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5FD_sb_verify() */
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_pl_copy
|
||||
|
||||
@@ -137,6 +137,7 @@ static const H5FD_class_t H5FD_core_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
sizeof(H5FD_core_fapl_t), /*fapl_size */
|
||||
H5FD_core_fapl_get, /*fapl_get */
|
||||
NULL, /*fapl_copy */
|
||||
|
||||
@@ -181,6 +181,7 @@ static const H5FD_class_t H5FD_direct_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
sizeof(H5FD_direct_fapl_t), /*fapl_size */
|
||||
H5FD_direct_fapl_get, /*fapl_get */
|
||||
H5FD_direct_fapl_copy, /*fapl_copy */
|
||||
|
||||
@@ -99,6 +99,7 @@ static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/,
|
||||
unsigned char *buf/*out*/);
|
||||
static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name,
|
||||
const unsigned char *buf);
|
||||
static herr_t H5FD_family_sb_verify(H5FD_t *_file, const char *driver_id);
|
||||
static H5FD_t *H5FD_family_open(const char *name, unsigned flags,
|
||||
hid_t fapl_id, haddr_t maxaddr);
|
||||
static herr_t H5FD_family_close(H5FD_t *_file);
|
||||
@@ -124,6 +125,7 @@ static const H5FD_class_t H5FD_family_g = {
|
||||
H5FD_family_sb_size, /*sb_size */
|
||||
H5FD_family_sb_encode, /*sb_encode */
|
||||
H5FD_family_sb_decode, /*sb_decode */
|
||||
H5FD_family_sb_verify, /*sb_verify */
|
||||
sizeof(H5FD_family_fapl_t), /*fapl_size */
|
||||
H5FD_family_fapl_get, /*fapl_get */
|
||||
H5FD_family_fapl_copy, /*fapl_copy */
|
||||
@@ -704,6 +706,44 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5FD_family_sb_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_family_sb_verify
|
||||
*
|
||||
* Purpose: Verify that the family driver is compatable with the driver
|
||||
* that created the file. driver_id is the driver identifier
|
||||
* field stored in the superblock. This is called when
|
||||
* reopening a file and ensures that the driver is able to
|
||||
* decode the superblock info.
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Jacob Gruber
|
||||
* Friday, January 13, 2012
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5FD_family_sb_verify(H5FD_t UNUSED *_file, const char *driver_id)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5FD_family_sb_verify, FAIL)
|
||||
|
||||
if(HDstrncmp(driver_id, "NCSAfami", (size_t)8)) {
|
||||
char err_msg[128];
|
||||
|
||||
HDsnprintf(err_msg, sizeof(err_msg), "File type %s not supported by the family driver",
|
||||
driver_id);
|
||||
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg)
|
||||
}
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5FD_family_sb_verify() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_family_open
|
||||
|
||||
@@ -209,6 +209,7 @@ static const H5FD_class_t H5FD_log_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
sizeof(H5FD_log_fapl_t), /*fapl_size */
|
||||
H5FD_log_fapl_get, /*fapl_get */
|
||||
H5FD_log_fapl_copy, /*fapl_copy */
|
||||
|
||||
@@ -103,6 +103,7 @@ static const H5FD_class_mpi_t H5FD_mpio_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
sizeof(H5FD_mpio_fapl_t), /*fapl_size */
|
||||
H5FD_mpio_fapl_get, /*fapl_get */
|
||||
H5FD_mpio_fapl_copy, /*fapl_copy */
|
||||
@@ -2096,3 +2097,4 @@ done:
|
||||
}
|
||||
|
||||
#endif /* H5_HAVE_PARALLEL */
|
||||
|
||||
|
||||
@@ -212,6 +212,7 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
sizeof(H5FD_mpiposix_fapl_t), /*fapl_size */
|
||||
H5FD_mpiposix_fapl_get, /*fapl_get */
|
||||
H5FD_mpiposix_fapl_copy, /*fapl_copy */
|
||||
|
||||
@@ -123,6 +123,7 @@ static herr_t H5FD_multi_sb_encode(H5FD_t *file, char *name/*out*/,
|
||||
unsigned char *buf/*out*/);
|
||||
static herr_t H5FD_multi_sb_decode(H5FD_t *file, const char *name,
|
||||
const unsigned char *buf);
|
||||
static herr_t H5FD_multi_sb_verify(H5FD_t *file, const char *driver_id);
|
||||
static void *H5FD_multi_fapl_get(H5FD_t *file);
|
||||
static void *H5FD_multi_fapl_copy(const void *_old_fa);
|
||||
static herr_t H5FD_multi_fapl_free(void *_fa);
|
||||
@@ -157,6 +158,7 @@ static const H5FD_class_t H5FD_multi_g = {
|
||||
H5FD_multi_sb_size, /*sb_size */
|
||||
H5FD_multi_sb_encode, /*sb_encode */
|
||||
H5FD_multi_sb_decode, /*sb_decode */
|
||||
H5FD_multi_sb_verify, /*sb_verify */
|
||||
sizeof(H5FD_multi_fapl_t), /*fapl_size */
|
||||
H5FD_multi_fapl_get, /*fapl_get */
|
||||
H5FD_multi_fapl_copy, /*fapl_copy */
|
||||
@@ -980,6 +982,40 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
|
||||
return 0;
|
||||
} /* end H5FD_multi_sb_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_multi_sb_verify
|
||||
*
|
||||
* Purpose: Verify that the multi driver is compatable with the driver
|
||||
* that created the file. driver_id is the driver identifier
|
||||
* field stored in the superblock. This is called when
|
||||
* reopening a file and ensures that the driver is able to
|
||||
* decode the superblock info.
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Jacob Gruber
|
||||
* Friday, January 13, 2012
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5FD_multi_sb_verify(H5FD_t *_file, const char *driver_id)
|
||||
{
|
||||
static const char *func = "H5FD_multi_sb_verify";
|
||||
|
||||
if(strncmp(driver_id, "NCSAmult", (size_t)8)) {
|
||||
char err_msg[128];
|
||||
|
||||
snprintf(err_msg, sizeof(err_msg), "File type %s not supported by the multi driver",
|
||||
driver_id);
|
||||
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, err_msg, -1);
|
||||
}
|
||||
return 0;
|
||||
} /* end H5FD_family_sb_verify() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_multi_fapl_get
|
||||
|
||||
@@ -71,6 +71,7 @@ static herr_t H5FD_null_sb_encode(H5FD_t *_file, char *name/*out*/,
|
||||
unsigned char *buf/*out*/);
|
||||
static herr_t H5FD_null_sb_decode(H5FD_t *_file, const char *name,
|
||||
const unsigned char *buf);
|
||||
static herr_t H5FD_null_sb_verify(H5FD_t *_file, const char *driver_id);
|
||||
static H5FD_t *H5FD_null_open(const char *name, unsigned flags,
|
||||
hid_t fapl_id, haddr_t maxaddr);
|
||||
static herr_t H5FD_null_close(H5FD_t *_file);
|
||||
@@ -101,6 +102,7 @@ static const H5FD_class_t H5FD_null_g = {
|
||||
H5FD_null_sb_size, /* sb_size */
|
||||
H5FD_null_sb_encode, /* sb_encode */
|
||||
H5FD_null_sb_decode, /* sb_decode */
|
||||
H5FD_null_sb_verify, /* sb_verify */
|
||||
sizeof(H5FD_null_fapl_t), /* fapl_size */
|
||||
H5FD_null_fapl_get, /* fapl_get */
|
||||
H5FD_null_fapl_copy, /* fapl_copy */
|
||||
@@ -634,6 +636,44 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5FD_null_sb_decode() */
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_null_sb_verify
|
||||
*
|
||||
* Purpose: Verify that the inner driver is compatable with the driver
|
||||
* that created the file. driver_id is the driver identifier
|
||||
* field stored in the superblock. This is called when
|
||||
* reopening a file and ensures that the driver is able to
|
||||
* decode the superblock info.
|
||||
*
|
||||
* Return: Success: Non-negative
|
||||
* Failure: Negative
|
||||
*
|
||||
* Programmer: Jacob Gruber
|
||||
* Friday, January 13, 2012
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5FD_null_sb_verify(H5FD_t *_file, const char *driver_id)
|
||||
{
|
||||
H5FD_null_t *file = (H5FD_null_t*)_file;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5FD_null_sb_verify, FAIL)
|
||||
|
||||
HDassert(file);
|
||||
|
||||
/* Delegate to the inner driver */
|
||||
if(H5FD_sb_verify(file->inner_file, driver_id) < 0)
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner driver sb_verify failed")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_null_open
|
||||
|
||||
@@ -70,6 +70,7 @@ H5_DLL H5FD_class_t *H5FD_get_class(hid_t id);
|
||||
H5_DLL hsize_t H5FD_sb_size(H5FD_t *file);
|
||||
H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf);
|
||||
H5_DLL herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf);
|
||||
H5_DLL herr_t H5FD_sb_verify(H5FD_t *file, const char *driver_id);
|
||||
H5_DLL void *H5FD_fapl_get(H5FD_t *file);
|
||||
H5_DLL herr_t H5FD_fapl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info);
|
||||
H5_DLL herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl);
|
||||
|
||||
@@ -236,6 +236,7 @@ typedef struct H5FD_class_t {
|
||||
herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/,
|
||||
unsigned char *p/*out*/);
|
||||
herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
|
||||
herr_t (*sb_verify)(H5FD_t *f, const char *name);
|
||||
size_t fapl_size;
|
||||
void * (*fapl_get)(H5FD_t *file);
|
||||
void * (*fapl_copy)(const void *fapl);
|
||||
|
||||
@@ -167,6 +167,7 @@ static const H5FD_class_t H5FD_sec2_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
0, /*fapl_size */
|
||||
NULL, /*fapl_get */
|
||||
NULL, /*fapl_copy */
|
||||
|
||||
@@ -189,6 +189,7 @@ static const H5FD_class_t H5FD_stdio_g = {
|
||||
NULL, /*sb_size */
|
||||
NULL, /*sb_encode */
|
||||
NULL, /*sb_decode */
|
||||
NULL, /*sb_verify */
|
||||
0, /*fapl_size */
|
||||
NULL, /*fapl_get */
|
||||
NULL, /*fapl_copy */
|
||||
|
||||
@@ -363,10 +363,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
/* Check if driver matches driver information saved. Unfortunately, we can't push this
|
||||
* function to each specific driver because we're checking if the driver is correct.
|
||||
*/
|
||||
if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used")
|
||||
if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used")
|
||||
if(H5FD_sb_verify(lf, drv_name) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file")
|
||||
|
||||
/* Read in variable-sized portion of driver info block */
|
||||
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0)
|
||||
@@ -525,10 +523,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
/* Check if driver matches driver information saved. Unfortunately, we can't push this
|
||||
* function to each specific driver because we're checking if the driver is correct.
|
||||
*/
|
||||
if(!HDstrncmp(drvinfo.name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used")
|
||||
if(!HDstrncmp(drvinfo.name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used")
|
||||
if(H5FD_sb_verify(lf, drvinfo.name) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file")
|
||||
|
||||
/* Decode driver information */
|
||||
if(H5FD_sb_decode(lf, drvinfo.name, drvinfo.buf) < 0)
|
||||
|
||||
231
test/vfd.c
231
test/vfd.c
@@ -51,6 +51,8 @@ const char *FILENAME[] = {
|
||||
"stdio_file", /*7*/
|
||||
"windows_file", /*8*/
|
||||
"new_multi_file_v16",/*9*/
|
||||
"null_core_file", /*10*/
|
||||
"null_family_file", /*11*/
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1292,6 +1294,229 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_null
|
||||
*
|
||||
* Purpose: Tests the file handle interface for the NULL driver.
|
||||
* The first component of this test is to wrap the null driver
|
||||
* around the core driver and run the core test suite.
|
||||
* Since the core driver does not implement all VFD features,
|
||||
* other drivers need to be tested as well.
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Jacob Gruber
|
||||
* Friday, January 5, 2012
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_null(void)
|
||||
{
|
||||
hid_t file=(-1), null_fapl, core_fapl, family_fapl;
|
||||
hid_t null_fapl2=(-1), core_fapl2=(-1), family_fapl2=(-1);
|
||||
hid_t dset1=(-1), space1=(-1);
|
||||
char filename[1024];
|
||||
void *fhandle=NULL;
|
||||
hsize_t file_size, dims1[2];
|
||||
int i, j, n, *points, *check, *p1, *p2;
|
||||
|
||||
TESTING("NULL file driver");
|
||||
|
||||
/* Set property list for the CORE driver */
|
||||
core_fapl = h5_fileaccess();
|
||||
if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Stack the null driver on top of the core driver. */
|
||||
null_fapl = h5_fileaccess();
|
||||
if(H5Pset_fapl_null(null_fapl, core_fapl) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Set the file name in the core driver */
|
||||
h5_fixname(FILENAME[10], null_fapl, filename, sizeof filename);
|
||||
|
||||
/* Create the file with the null driver */
|
||||
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, null_fapl)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Retrieve the top access property list... */
|
||||
if((null_fapl2 = H5Fget_access_plist(file)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Retrieve the bottom access property list */
|
||||
if (H5Pget_fapl_null(null_fapl2, &core_fapl2) < 0)
|
||||
TEST_ERROR;
|
||||
if (core_fapl2 < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
|
||||
/* Check that the top driver is correct */
|
||||
if(H5FD_NULL != H5Pget_driver(null_fapl2))
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check that the bottom driver is correct */
|
||||
if(H5FD_CORE != H5Pget_driver(core_fapl2))
|
||||
TEST_ERROR;
|
||||
|
||||
/* Close the bottom property list */
|
||||
if (H5Pclose(core_fapl2) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* ...and close the top property list */
|
||||
if (H5Pclose(null_fapl2) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check the file handle API */
|
||||
if(H5Fget_vfd_handle(file, H5P_DEFAULT, &fhandle) < 0)
|
||||
TEST_ERROR;
|
||||
if(fhandle == NULL)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check file size API */
|
||||
if(H5Fget_filesize(file, &file_size) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* There is no garantee the size of metadata in file is constant.
|
||||
* Just try to check if it's reasonable. Why is this 4KB?
|
||||
*/
|
||||
if(file_size<2*KB || file_size>6*KB)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Close the file */
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Turn off the backing store in the core driver. This is done
|
||||
* to increase the speed of the test. The nul driver only stores
|
||||
* a reference to this fapl, so the change is immediately
|
||||
* recognized.
|
||||
*/
|
||||
if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Open the file with the null driver */
|
||||
if((file=H5Fopen(filename, H5F_ACC_RDWR, null_fapl)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Allocate memory for data set. */
|
||||
points=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int));
|
||||
check=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int));
|
||||
|
||||
/* Initialize the dset1 */
|
||||
p1 = points;
|
||||
for(i = n = 0; i < DSET1_DIM1; i++)
|
||||
for(j = 0; j < DSET1_DIM2; j++)
|
||||
*p1++ = n++;
|
||||
|
||||
/* Create the data space1 */
|
||||
dims1[0] = DSET1_DIM1;
|
||||
dims1[1] = DSET1_DIM2;
|
||||
if((space1 = H5Screate_simple(2, dims1, NULL)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Create the dset1 */
|
||||
if((dset1 = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Write the data to the dset1 */
|
||||
if(H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Close the dset */
|
||||
if(H5Dclose(dset1) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Reopen the dset */
|
||||
if((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Read the data back from dset1 */
|
||||
if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check that the values read are the same as the values written */
|
||||
p1 = points;
|
||||
p2 = check;
|
||||
for(i = 0; i < DSET1_DIM1; i++)
|
||||
for(j = 0; j < DSET1_DIM2; j++)
|
||||
if(*p1++ != *p2++) {
|
||||
H5_FAILED();
|
||||
printf(" Read different values than written in data set 1.\n");
|
||||
printf(" At index %d,%d\n", i, j);
|
||||
TEST_ERROR;
|
||||
} /* end if */
|
||||
|
||||
/* Clean up */
|
||||
if(H5Sclose(space1) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Dclose(dset1) < 0)
|
||||
TEST_ERROR;
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR;
|
||||
if(points)
|
||||
free(points);
|
||||
if(check)
|
||||
free(check);
|
||||
if(H5Pclose(core_fapl) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
h5_cleanup(FILENAME, null_fapl);
|
||||
|
||||
/* Test the superblock fucntions. The superblock is only used when
|
||||
* testing the compatibility of the family and multi drivers, so
|
||||
* a separate test is needed.
|
||||
*/
|
||||
|
||||
/* Set up family FAPL */
|
||||
family_fapl = h5_fileaccess();
|
||||
if(H5Pset_fapl_family(family_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Wrap null around family driver */
|
||||
null_fapl = h5_fileaccess();
|
||||
if(H5Pset_fapl_null(null_fapl, family_fapl) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Set the file name. Thsi must be done with the family driver so that
|
||||
* the member numbers are properly set up.
|
||||
*/
|
||||
h5_fixname(FILENAME[11], family_fapl, filename, sizeof filename);
|
||||
|
||||
/* Create file with the null driver*/
|
||||
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, null_fapl)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* close file */
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Reopen file, testing suplerblocks for compatability */
|
||||
if((file=H5Fopen(filename, H5F_ACC_RDWR, null_fapl)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Cleanup */
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
h5_cleanup(FILENAME, family_fapl);
|
||||
if(H5Pclose(null_fapl) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
H5Pclose (core_fapl);
|
||||
H5Pclose (null_fapl);
|
||||
H5Fclose(file);
|
||||
} H5E_END_TRY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_log
|
||||
@@ -1412,6 +1637,11 @@ test_stdio(void)
|
||||
if((access_fapl = H5Fget_access_plist(file)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check that the driver is correct */
|
||||
/* Retrieve the access property list... */
|
||||
if((access_fapl = H5Fget_access_plist(file)) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check that the driver is correct */
|
||||
if(H5FD_STDIO != H5Pget_driver(access_fapl))
|
||||
TEST_ERROR;
|
||||
@@ -1573,6 +1803,7 @@ main(void)
|
||||
nerrors += test_family_compat() < 0 ? 1 : 0;
|
||||
nerrors += test_multi() < 0 ? 1 : 0;
|
||||
nerrors += test_multi_compat() < 0 ? 1 : 0;
|
||||
nerrors += test_null() < 0 ? 1 : 0;
|
||||
nerrors += test_direct() < 0 ? 1 : 0;
|
||||
nerrors += test_log() < 0 ? 1 : 0;
|
||||
nerrors += test_stdio() < 0 ? 1 : 0;
|
||||
|
||||
Reference in New Issue
Block a user