2016-06-28 05:04:52 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
* Copyright by The HDF Group. *
|
|
|
|
|
* 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 *
|
|
|
|
|
* 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. *
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Spring 2016
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Tests the basic operation of the evict-on-close cache
|
|
|
|
|
* behavior. Tests that ensure the tagging is handled correctly
|
|
|
|
|
* are located in cache.c.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#define H5C_FRIEND /*suppress error about including H5Cpkg */
|
|
|
|
|
#define H5D_FRIEND /*suppress error about including H5Dpkg */
|
|
|
|
|
#define H5D_TESTING
|
|
|
|
|
#define H5F_FRIEND /*suppress error about including H5Fpkg */
|
|
|
|
|
#define H5F_TESTING
|
2016-10-30 09:12:07 +08:00
|
|
|
|
#define H5G_FRIEND /*suppress error about including H5Gpkg */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#define H5I_FRIEND /*suppress error about including H5Ipkg */
|
|
|
|
|
#define H5I_TESTING
|
|
|
|
|
|
|
|
|
|
|
2016-06-28 05:04:52 +08:00
|
|
|
|
#include "h5test.h"
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#include "H5Cpkg.h"
|
|
|
|
|
#include "H5Dpkg.h"
|
|
|
|
|
#include "H5Fpkg.h"
|
2016-10-30 09:12:07 +08:00
|
|
|
|
#include "H5Gpkg.h"
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#include "H5Ipkg.h"
|
|
|
|
|
|
|
|
|
|
/* Uncomment to manually inspect cache states */
|
2016-09-30 16:26:39 +08:00
|
|
|
|
/* #define EOC_MANUAL_INSPECTION */
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
const char *FILENAMES[] = {
|
|
|
|
|
"evict-on-close", /* 0 */
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
#define FILENAME_BUF_SIZE 1024
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/* Group names */
|
2016-11-28 12:42:08 +08:00
|
|
|
|
#define GROUP_OLD_STYLE_NAME "old_style_groups"
|
|
|
|
|
#define GROUP_NEW_STYLE_NAME "new_style_groups"
|
2016-10-29 03:58:18 +08:00
|
|
|
|
|
2016-09-30 15:24:44 +08:00
|
|
|
|
/* Dataset names */
|
|
|
|
|
#define DSET_COMPACT_NAME "compact"
|
|
|
|
|
#define DSET_CONTIGUOUS_NAME "contiguous"
|
|
|
|
|
#define DSET_BTREE_NAME "v1_btree"
|
|
|
|
|
#define DSET_EARRAY_NAME "earray"
|
|
|
|
|
#define DSET_BT2_NAME "v2_btree"
|
|
|
|
|
#define DSET_FARRAY_NAME "farray"
|
|
|
|
|
#define DSET_SINGLE_NAME "single"
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Number of data elements in a dataset */
|
2016-09-30 15:24:44 +08:00
|
|
|
|
#define NELEMENTS 1024
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Number of subgroups in each style of group */
|
|
|
|
|
#define NSUBGROUPS 128
|
|
|
|
|
|
|
|
|
|
/* Max size of subgroup name, not including NULL */
|
|
|
|
|
#define SUBGROUP_NAME_SIZE 16
|
|
|
|
|
|
|
|
|
|
/* Prototypes */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
static hbool_t verify_tag_not_in_cache(H5F_t *f, haddr_t tag);
|
2016-06-28 05:04:52 +08:00
|
|
|
|
static herr_t check_evict_on_close_api(void);
|
2016-09-30 01:26:32 +08:00
|
|
|
|
static hid_t generate_eoc_test_file(hid_t fapl_id);
|
2016-10-30 09:12:07 +08:00
|
|
|
|
static herr_t check_dset_scheme(hid_t fid, const char *dset_name);
|
2016-11-28 12:42:08 +08:00
|
|
|
|
static herr_t check_group_layout(hid_t fid, const char *group_name);
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: verify_tag_not_in_cache()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Ensure that metadata cache entries with a given tag are not
|
|
|
|
|
* present in the cache.
|
|
|
|
|
*
|
|
|
|
|
* Return: TRUE/FALSE
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Fall 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static hbool_t
|
|
|
|
|
verify_tag_not_in_cache(H5F_t *f, haddr_t tag)
|
|
|
|
|
{
|
|
|
|
|
H5C_t *cache_ptr = NULL; /* cache pointer */
|
|
|
|
|
int i = 0; /* iterator */
|
|
|
|
|
|
2016-11-07 04:08:19 +08:00
|
|
|
|
/* Get Internal Cache Pointers */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
cache_ptr = f->shared->cache;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < H5C__HASH_TABLE_LEN; i++) {
|
2016-11-07 04:08:19 +08:00
|
|
|
|
H5C_cache_entry_t *entry_ptr; /* entry pointer */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
|
|
|
|
entry_ptr = cache_ptr->index[i];
|
|
|
|
|
while(entry_ptr != NULL) {
|
2016-11-07 15:14:10 +08:00
|
|
|
|
if(tag == entry_ptr->tag_info->tag)
|
2016-09-30 01:26:32 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
else
|
|
|
|
|
entry_ptr = entry_ptr->ht_next;
|
|
|
|
|
} /* end while */
|
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
} /* end verify_tag_not_in_cache() */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: generate_eoc_test_file()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Generate the evict-on-close test file.
|
|
|
|
|
*
|
2016-09-30 01:26:32 +08:00
|
|
|
|
* Return: Success: The file ID of the created file
|
|
|
|
|
* Failure: -1
|
2016-09-24 14:54:27 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Fall 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2016-09-30 01:26:32 +08:00
|
|
|
|
static hid_t
|
2016-09-24 14:54:27 +08:00
|
|
|
|
generate_eoc_test_file(hid_t fapl_id)
|
|
|
|
|
{
|
|
|
|
|
char filename[FILENAME_BUF_SIZE]; /* decorated file name */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
hid_t fid = -1; /* file ID (returned) */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
hid_t fapl_copy_id = -1; /* ID of copied fapl */
|
2016-10-29 03:58:18 +08:00
|
|
|
|
hid_t gid1 = -1, gid2 = -1; /* group IDs */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
hid_t sid = -1; /* dataspace ID */
|
|
|
|
|
hid_t dcpl_id = -1; /* dataset creation plist */
|
|
|
|
|
hid_t did = -1; /* dataset ID */
|
|
|
|
|
int rank; /* # of array dimensions */
|
|
|
|
|
hsize_t current_dims[2]; /* current dataset size */
|
|
|
|
|
hsize_t maximum_dims[2]; /* maximum dataset size */
|
|
|
|
|
hsize_t chunk_dims[2]; /* chunk dimensions */
|
2016-09-30 15:24:44 +08:00
|
|
|
|
H5D_chunk_index_t idx_type; /* dataset chunk index type */
|
|
|
|
|
H5D_layout_t layout_type; /* dataset layout type */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
int *data = NULL; /* buffer for fake data */
|
|
|
|
|
int n; /* # of data elements */
|
2016-11-28 12:42:08 +08:00
|
|
|
|
int i; /* iterator (# subgroups) */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
TESTING("generating evict-on-close test file");
|
|
|
|
|
|
|
|
|
|
/* Get a VFD-specific filename */
|
|
|
|
|
h5_fixname(FILENAMES[0], fapl_id, filename, sizeof(filename));
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/* Copy the fapl and set the latest file format */
|
|
|
|
|
if((fapl_copy_id = H5Pcopy(fapl_id)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pset_libver_bounds(fapl_copy_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create a data buffer for dataset writes */
|
|
|
|
|
if(NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int))))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/* Create file */
|
|
|
|
|
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/*******************************************/
|
|
|
|
|
/* CREATE OBJECTS WITH THE OLD FILE FORMAT */
|
|
|
|
|
/*******************************************/
|
|
|
|
|
|
2016-10-30 09:12:07 +08:00
|
|
|
|
/*******************/
|
|
|
|
|
/* Generate groups */
|
|
|
|
|
/*******************/
|
2016-10-29 03:58:18 +08:00
|
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
|
/* Old-style (version 1 B-tree + local heap) */
|
|
|
|
|
/*********************************************/
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* A single group is created in the root group, followed
|
|
|
|
|
* by a large number of groups in the new group. This will
|
|
|
|
|
* ensure that the file data structures for groups include
|
|
|
|
|
* multiple cache entries.
|
|
|
|
|
*/
|
|
|
|
|
if((gid1 = H5Gcreate2(fid, GROUP_OLD_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2016-10-29 03:58:18 +08:00
|
|
|
|
TEST_ERROR;
|
2016-11-28 12:42:08 +08:00
|
|
|
|
|
|
|
|
|
/* Create sub-groups */
|
|
|
|
|
for(i = 0; i < NSUBGROUPS; i++) {
|
|
|
|
|
char subgroup_name[SUBGROUP_NAME_SIZE];
|
|
|
|
|
|
|
|
|
|
/* Create the group name */
|
|
|
|
|
HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE);
|
|
|
|
|
if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0)
|
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
|
|
if((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Gclose(gid2) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
} /* end for */
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
if(H5Gclose(gid1) < 0)
|
|
|
|
|
TEST_ERROR;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/********************************************************************/
|
|
|
|
|
/* Generate datasets and ensure that the chunking scheme is correct */
|
|
|
|
|
/********************************************************************/
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
|
/* Old file format data structures */
|
|
|
|
|
/***********************************/
|
2016-09-30 15:24:44 +08:00
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/********************/
|
|
|
|
|
/* Version 1 B-tree */
|
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
2016-09-30 15:24:44 +08:00
|
|
|
|
n = NELEMENTS;
|
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = H5S_UNLIMITED;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up chunking */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
chunk_dims[0] = 1;
|
|
|
|
|
if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_BTREE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct chunk indexing scheme */
|
|
|
|
|
if(H5D__layout_idx_type_test(did, &idx_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(idx_type != H5D_CHUNK_IDX_BTREE)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using version 1 B-tree as the chunk index");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
|
/* CREATE OBJECTS WITH THE LATEST FILE FORMAT */
|
|
|
|
|
/**********************************************/
|
2016-09-30 15:24:44 +08:00
|
|
|
|
|
|
|
|
|
/* Close the file */
|
|
|
|
|
if(H5Fclose(fid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/* Reopen the file with the "latest file format" fapl */
|
|
|
|
|
if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_copy_id)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-10-30 09:12:07 +08:00
|
|
|
|
/*******************/
|
|
|
|
|
/* Generate groups */
|
|
|
|
|
/*******************/
|
2016-10-29 03:58:18 +08:00
|
|
|
|
|
|
|
|
|
/***********************************************/
|
|
|
|
|
/* New-style (version 2 B-tree + fractal heap) */
|
|
|
|
|
/***********************************************/
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* A single group is created in the root group, followed
|
|
|
|
|
* by a large number of groups in the new group. This will
|
|
|
|
|
* ensure that the file data structures for groups include
|
|
|
|
|
* multiple cache entries.
|
|
|
|
|
*/
|
|
|
|
|
if((gid1 = H5Gcreate2(fid, GROUP_NEW_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2016-10-29 03:58:18 +08:00
|
|
|
|
TEST_ERROR;
|
2016-11-28 12:42:08 +08:00
|
|
|
|
|
|
|
|
|
/* Create sub-groups */
|
|
|
|
|
for(i = 0; i < NSUBGROUPS; i++) {
|
|
|
|
|
char subgroup_name[SUBGROUP_NAME_SIZE];
|
|
|
|
|
|
|
|
|
|
/* Create the group name */
|
|
|
|
|
HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE);
|
|
|
|
|
if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0)
|
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
|
|
if((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Gclose(gid2) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
} /* end for */
|
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
if(H5Gclose(gid1) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
2016-10-29 03:58:18 +08:00
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Generate datasets and ensure that the chunking scheme is correct */
|
2016-10-29 03:58:18 +08:00
|
|
|
|
/********************************************************************/
|
2016-09-30 15:24:44 +08:00
|
|
|
|
|
|
|
|
|
/********************/
|
|
|
|
|
/* Extensible Array */
|
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = NELEMENTS;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = H5S_UNLIMITED;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up chunking */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
chunk_dims[0] = 1;
|
|
|
|
|
if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_EARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct chunk indexing scheme */
|
|
|
|
|
if(H5D__layout_idx_type_test(did, &idx_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(idx_type != H5D_CHUNK_IDX_EARRAY)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using extensible array as the chunk index");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/********************/
|
|
|
|
|
/* Version 2 B-Tree */
|
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = NELEMENTS;
|
|
|
|
|
rank = 2;
|
|
|
|
|
current_dims[0] = (hsize_t)2;
|
|
|
|
|
current_dims[1] = (hsize_t)(n/2);
|
|
|
|
|
maximum_dims[0] = H5S_UNLIMITED;
|
|
|
|
|
maximum_dims[1] = H5S_UNLIMITED;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up chunking */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
chunk_dims[0] = 1;
|
|
|
|
|
chunk_dims[1] = 1;
|
|
|
|
|
if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_BT2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct chunk indexing scheme */
|
|
|
|
|
if(H5D__layout_idx_type_test(did, &idx_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(idx_type != H5D_CHUNK_IDX_BT2)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using version 2 B-tree as the chunk index");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/***************/
|
|
|
|
|
/* Fixed Array */
|
|
|
|
|
/***************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = NELEMENTS;
|
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = (hsize_t)n;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up chunking */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
chunk_dims[0] = 1;
|
|
|
|
|
chunk_dims[1] = 1;
|
|
|
|
|
if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_FARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct chunk indexing scheme */
|
|
|
|
|
if(H5D__layout_idx_type_test(did, &idx_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(idx_type != H5D_CHUNK_IDX_FARRAY)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using fixed array as the chunk index");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
|
/* Single Chunk */
|
|
|
|
|
/****************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = NELEMENTS;
|
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = (hsize_t)n;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up chunking */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
chunk_dims[0] = (hsize_t)n;
|
|
|
|
|
chunk_dims[1] = (hsize_t)n;
|
|
|
|
|
if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_SINGLE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct chunk indexing scheme */
|
|
|
|
|
if(H5D__layout_idx_type_test(did, &idx_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(idx_type != H5D_CHUNK_IDX_SINGLE)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using single chunk as the chunk index");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/**************/
|
|
|
|
|
/* Contiguous */
|
|
|
|
|
/**************/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = NELEMENTS;
|
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = (hsize_t)n;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_CONTIGUOUS_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct layout scheme */
|
|
|
|
|
if(H5D__layout_type_test(did, &layout_type) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(layout_type != H5D_CONTIGUOUS)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using contiguous layout");
|
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/***********/
|
|
|
|
|
/* Compact */
|
|
|
|
|
/***********/
|
|
|
|
|
|
|
|
|
|
/* Create dataspace */
|
|
|
|
|
n = 1;
|
|
|
|
|
rank = 1;
|
|
|
|
|
current_dims[0] = (hsize_t)n;
|
|
|
|
|
maximum_dims[0] = (hsize_t)n;
|
|
|
|
|
if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dcpl and set up compact layout */
|
|
|
|
|
if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pset_layout(dcpl_id, H5D_COMPACT) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create dataset */
|
2016-10-01 19:23:57 +08:00
|
|
|
|
if((did = H5Dcreate2(fid, DSET_COMPACT_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
|
2016-09-30 15:24:44 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Ensure we're using the correct layout scheme */
|
|
|
|
|
if(H5D__layout_type_test(did, &layout_type) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-09-30 15:24:44 +08:00
|
|
|
|
if(layout_type != H5D_COMPACT)
|
|
|
|
|
FAIL_PUTS_ERROR("should be using compact layout");
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
/* Write a bunch of fake data */
|
|
|
|
|
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Close IDs for this dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Sclose(sid) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(H5Pclose(dcpl_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-09-30 15:24:44 +08:00
|
|
|
|
/********/
|
|
|
|
|
/* DONE */
|
|
|
|
|
/********/
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
2016-09-30 01:26:32 +08:00
|
|
|
|
/* Close/free everything else */
|
2016-09-30 15:24:44 +08:00
|
|
|
|
if(H5Pclose(fapl_copy_id) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
HDfree(data);
|
|
|
|
|
|
|
|
|
|
PASSED();
|
2016-09-30 01:26:32 +08:00
|
|
|
|
return fid;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
2016-11-28 12:42:08 +08:00
|
|
|
|
H5Gclose(gid1);
|
|
|
|
|
H5Gclose(gid2);
|
2016-09-24 14:54:27 +08:00
|
|
|
|
H5Fclose(fid);
|
|
|
|
|
H5Dclose(did);
|
|
|
|
|
H5Sclose(sid);
|
|
|
|
|
H5Pclose(dcpl_id);
|
|
|
|
|
H5Pclose(fapl_copy_id);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
|
|
HDfree(data);
|
|
|
|
|
|
|
|
|
|
H5_FAILED();
|
2016-09-30 01:26:32 +08:00
|
|
|
|
return -1;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
} /* end generate_eoc_test_file() */
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2016-10-30 09:12:07 +08:00
|
|
|
|
* Function: check_group_layout()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Verify that the evict-on-close feature works for a given
|
2016-11-28 12:42:08 +08:00
|
|
|
|
* group layout (new-style vs. old-style).
|
2016-10-30 09:12:07 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Fall 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2016-11-28 12:42:08 +08:00
|
|
|
|
check_group_layout(hid_t fid, const char *group_name)
|
2016-10-30 09:12:07 +08:00
|
|
|
|
{
|
|
|
|
|
H5F_t *file_ptr = NULL; /* ptr to internal file struct */
|
|
|
|
|
hid_t gid1 = -1, gid2 = -1; /* group IDs */
|
|
|
|
|
H5G_t *grp_ptr = NULL; /* ptr to internal group struct */
|
|
|
|
|
haddr_t tag1, tag2; /* MD cache tags for groups */
|
2017-01-28 12:35:14 +08:00
|
|
|
|
uint32_t before, during, after; /* cache sizes */
|
2016-11-28 12:42:08 +08:00
|
|
|
|
int i; /* iterator */
|
2016-10-30 09:12:07 +08:00
|
|
|
|
|
|
|
|
|
/* NOTE: The TESTING() macro is called in main() */
|
|
|
|
|
|
|
|
|
|
/* Get a pointer to the file struct */
|
|
|
|
|
if(NULL == (file_ptr = (H5F_t *)H5I_object_verify(fid, H5I_FILE)))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
|
|
|
|
before = file_ptr->shared->cache->index_len;
|
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE BEFORE GROUP OPEN:\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", before);
|
2016-10-30 09:12:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Open the main group and get its tag */
|
2016-10-30 09:12:07 +08:00
|
|
|
|
if((gid1 = H5Gopen2(fid, group_name, H5P_DEFAULT)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(NULL == (grp_ptr = (H5G_t *)H5I_object_verify(gid1, H5I_GROUP)))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
tag1 = grp_ptr->oloc.addr;
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
|
|
|
|
|
/* Open and close all sub-groups */
|
|
|
|
|
for(i = 0; i < NSUBGROUPS; i++) {
|
|
|
|
|
char subgroup_name[SUBGROUP_NAME_SIZE];
|
|
|
|
|
|
|
|
|
|
/* Create the group name */
|
|
|
|
|
HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE);
|
|
|
|
|
if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0)
|
|
|
|
|
TEST_ERROR
|
|
|
|
|
|
|
|
|
|
if((gid2 = H5Gopen2(gid1, subgroup_name, H5P_DEFAULT)) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
if(NULL == (grp_ptr = (H5G_t *)H5I_object_verify(gid2, H5I_GROUP)))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
tag2 = grp_ptr->oloc.addr;
|
|
|
|
|
|
|
|
|
|
if(H5Gclose(gid2) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
if(TRUE == verify_tag_not_in_cache(file_ptr, tag2))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
} /* end for */
|
2016-10-30 09:12:07 +08:00
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
2016-11-28 12:42:08 +08:00
|
|
|
|
during = file_ptr->shared->cache->index_len;
|
2016-10-30 09:12:07 +08:00
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE AFTER OPENING GROUPS (WHILE OPEN):\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
2016-11-28 12:42:08 +08:00
|
|
|
|
HDprintf("MAIN GROUP TAG: %#X\n", tag1);
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", during);
|
2016-10-30 09:12:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Close the main group */
|
2016-10-30 09:12:07 +08:00
|
|
|
|
if(H5Gclose(gid1) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
|
|
|
|
after = file_ptr->shared->cache->index_len;
|
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE AFTER CLOSING GROUPS:\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", after);
|
2016-10-30 09:12:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Ensure that the cache does not contain entries with the tag */
|
2016-10-30 09:12:07 +08:00
|
|
|
|
if(TRUE == verify_tag_not_in_cache(file_ptr, tag1))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
/* Compare the number of cache entries */
|
|
|
|
|
if(before != after || before == during)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Gclose(gid1);
|
|
|
|
|
H5Gclose(gid2);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
|
|
} /* end check_group_layout() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: check_dset_scheme()
|
2016-09-30 01:26:32 +08:00
|
|
|
|
*
|
2016-09-30 16:26:39 +08:00
|
|
|
|
* Purpose: Verify that the evict-on-close feature works for a given
|
|
|
|
|
* dataset layout and/or chunk index.
|
2016-09-30 01:26:32 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Fall 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2016-10-30 09:12:07 +08:00
|
|
|
|
check_dset_scheme(hid_t fid, const char *dset_name)
|
2016-09-30 01:26:32 +08:00
|
|
|
|
{
|
|
|
|
|
H5F_t *file_ptr = NULL; /* ptr to internal file struct */
|
|
|
|
|
hid_t did = -1; /* dataset ID */
|
|
|
|
|
H5D_t *dset_ptr = NULL; /* ptr to internal dset struct */
|
|
|
|
|
haddr_t tag; /* MD cache tag for dataset */
|
|
|
|
|
int *data = NULL; /* buffer for fake data */
|
2017-01-28 12:35:14 +08:00
|
|
|
|
uint32_t before, during, after; /* cache sizes */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
2016-09-30 16:26:39 +08:00
|
|
|
|
/* NOTE: The TESTING() macro is called in main() */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
|
|
|
|
/* Get a pointer to the file struct */
|
|
|
|
|
if(NULL == (file_ptr = (H5F_t *)H5I_object_verify(fid, H5I_FILE)))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Create the data buffer */
|
2016-09-30 15:24:44 +08:00
|
|
|
|
if(NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int))))
|
2016-09-30 01:26:32 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
|
|
|
|
before = file_ptr->shared->cache->index_len;
|
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE BEFORE DATASET OPEN:\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", before);
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Open dataset and get the metadata tag */
|
2016-09-30 16:26:39 +08:00
|
|
|
|
if((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0)
|
2016-09-30 01:26:32 +08:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
if(NULL == (dset_ptr = (H5D_t *)H5I_object_verify(did, H5I_DATASET)))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
tag = dset_ptr->oloc.addr;
|
|
|
|
|
|
2016-10-30 09:12:07 +08:00
|
|
|
|
/* Read data from the dataset so the cache gets populated with chunk entries
|
2016-09-30 16:26:39 +08:00
|
|
|
|
* and the like.
|
|
|
|
|
*/
|
2016-09-30 01:26:32 +08:00
|
|
|
|
if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
|
|
|
|
during = file_ptr->shared->cache->index_len;
|
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE AFTER DATA READ (WHILE OPEN):\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
HDprintf("TAG: %#X\n", tag);
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", during);
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Close the dataset */
|
|
|
|
|
if(H5Dclose(did) < 0)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Record the number of cache entries */
|
|
|
|
|
after = file_ptr->shared->cache->index_len;
|
|
|
|
|
|
|
|
|
|
#ifdef EOC_MANUAL_INSPECTION
|
|
|
|
|
HDprintf("\nCACHE AFTER DATASET CLOSE:\n");
|
|
|
|
|
if(H5AC_dump_cache(file_ptr) < 0)
|
|
|
|
|
TEST_ERROR;
|
2017-01-28 12:35:14 +08:00
|
|
|
|
HDprintf("NUMBER OF CACHE ENTRIES: %u\n", after);
|
2016-09-30 01:26:32 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-30 09:12:07 +08:00
|
|
|
|
/* Ensure that the cache does not contain entries with the tag */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
if(TRUE == verify_tag_not_in_cache(file_ptr, tag))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
/* Compare the number of cache entries */
|
|
|
|
|
if(before != after || before == during)
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
|
|
|
|
HDfree(data);
|
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Dclose(did);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
return FAIL;
|
|
|
|
|
|
2016-10-30 09:12:07 +08:00
|
|
|
|
} /* check_dset_scheme() */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: check_evict_on_close_api()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Verify that the H5Pset/get_evict_on_close() calls behave
|
|
|
|
|
* correctly.
|
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Spring 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
|
|
|
|
check_evict_on_close_api(void)
|
|
|
|
|
{
|
|
|
|
|
hid_t fapl_id = -1;
|
|
|
|
|
hid_t dapl_id = -1;
|
|
|
|
|
hbool_t evict_on_close;
|
|
|
|
|
herr_t status;
|
|
|
|
|
|
|
|
|
|
TESTING("evict on close API");
|
|
|
|
|
|
|
|
|
|
/* Create a fapl */
|
|
|
|
|
if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
/* Check the default */
|
|
|
|
|
evict_on_close = TRUE;
|
|
|
|
|
if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
if(evict_on_close != FALSE)
|
|
|
|
|
FAIL_PUTS_ERROR("Incorrect default evict on close value.");
|
|
|
|
|
|
|
|
|
|
/* Set the evict on close property */
|
|
|
|
|
evict_on_close = TRUE;
|
|
|
|
|
if(H5Pset_evict_on_close(fapl_id, evict_on_close) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
/* Make sure we can get it back out */
|
|
|
|
|
evict_on_close = FALSE;
|
|
|
|
|
if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
if(evict_on_close != TRUE)
|
|
|
|
|
FAIL_PUTS_ERROR("Incorrect evict on close value.");
|
|
|
|
|
|
|
|
|
|
/* close fapl */
|
|
|
|
|
if(H5Pclose(fapl_id) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
|
/* Trying passing in a non-fapl property list */
|
|
|
|
|
/**********************************************/
|
|
|
|
|
|
|
|
|
|
if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
/* ensure using an incorrect access plist fails */
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
status = H5Pset_evict_on_close(dapl_id, evict_on_close);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if(status >= 0)
|
|
|
|
|
FAIL_PUTS_ERROR("H5Pset_evict_on_close() accepted invalid access plist.");
|
|
|
|
|
|
|
|
|
|
/* ensure an invalid plist fails */
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
status = H5Pget_evict_on_close((hid_t)-1, &evict_on_close);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if(status >= 0)
|
|
|
|
|
FAIL_PUTS_ERROR("H5Pget_evict_on_close() accepted invalid hid_t.");
|
|
|
|
|
|
|
|
|
|
/* close dapl */
|
|
|
|
|
if(H5Pclose(dapl_id) < 0)
|
2016-09-24 14:54:27 +08:00
|
|
|
|
TEST_ERROR;
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
|
|
} /* check_evict_on_close_api() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: main
|
|
|
|
|
*
|
|
|
|
|
* Return: EXIT_FAILURE/EXIT_SUCCESS
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* Spring 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
main(void)
|
|
|
|
|
{
|
2016-09-30 01:26:32 +08:00
|
|
|
|
hid_t fapl_id = -1; /* VFD-specific fapl */
|
|
|
|
|
hid_t fid = -1; /* file ID */
|
|
|
|
|
unsigned nerrors = 0; /* number of test errors */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
2016-10-29 03:58:18 +08:00
|
|
|
|
HDprintf("Testing evict-on-close cache behavior\n");
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/* Initialize */
|
|
|
|
|
h5_reset();
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/* Test H5P call to set up EoC (does not require VFD-specific fapl) */
|
2016-06-28 05:04:52 +08:00
|
|
|
|
nerrors += check_evict_on_close_api() < 0 ? 1 : 0;
|
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/* Set up VFD-specific fapl */
|
|
|
|
|
if((fapl_id = h5_fileaccess()) < 0) {
|
|
|
|
|
nerrors++;
|
|
|
|
|
PUTS_ERROR("Unable to get VFD-specific fapl\n");
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/* Set evict-on-close property */
|
|
|
|
|
if(H5Pset_evict_on_close(fapl_id, TRUE) < 0) {
|
|
|
|
|
nerrors++;
|
|
|
|
|
PUTS_ERROR("Unable to set evict-on-close property\n");
|
|
|
|
|
} /* end if */
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
2016-09-24 14:54:27 +08:00
|
|
|
|
/* Generate the test file */
|
2016-09-30 01:26:32 +08:00
|
|
|
|
if((fid = generate_eoc_test_file(fapl_id)) < 0) {
|
2016-09-24 14:54:27 +08:00
|
|
|
|
nerrors++;
|
|
|
|
|
PUTS_ERROR("Unable to generate test file\n");
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
2016-09-30 16:26:39 +08:00
|
|
|
|
/* Run tests with a variety of dataset configurations
|
|
|
|
|
* PASSED() and H5_FAILED() are handled in check_configuration()
|
|
|
|
|
*/
|
|
|
|
|
TESTING("evict on close with version 1 B-tree chunk index");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_BTREE_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with extensible array chunk index");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_EARRAY_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with version 2 B-tree chunk index");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_BT2_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with fixed array chunk index");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_FARRAY_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with \'single chunk\' chunk index");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_SINGLE_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with contiguous layout");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_CONTIGUOUS_NAME) < 0 ? 1 : 0;
|
2016-09-30 16:26:39 +08:00
|
|
|
|
TESTING("evict on close with compact layout");
|
2016-10-30 09:12:07 +08:00
|
|
|
|
nerrors += check_dset_scheme(fid, DSET_COMPACT_NAME) < 0 ? 1 : 0;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
2016-11-28 12:42:08 +08:00
|
|
|
|
/* Run tests with old- and new-style groups
|
|
|
|
|
* PASSED() and H5_FAILED() are handled in check_configuration()
|
|
|
|
|
*/
|
|
|
|
|
TESTING("evict on close with old-style groups");
|
|
|
|
|
nerrors += check_group_layout(fid, GROUP_OLD_STYLE_NAME) < 0 ? 1 : 0;
|
|
|
|
|
TESTING("evict on close with new-style groups");
|
|
|
|
|
nerrors += check_group_layout(fid, GROUP_NEW_STYLE_NAME) < 0 ? 1 : 0;
|
|
|
|
|
|
2016-09-30 01:26:32 +08:00
|
|
|
|
/* Close the test file */
|
|
|
|
|
if(H5Fclose(fid) < 0) {
|
|
|
|
|
nerrors++;
|
|
|
|
|
PUTS_ERROR("Unable to close the test file.\n");
|
|
|
|
|
} /* end if */
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
/* Clean up files and close the VFD-specific fapl */
|
2016-11-03 23:31:02 +08:00
|
|
|
|
h5_delete_all_test_files(FILENAMES, fapl_id);
|
2016-09-24 14:54:27 +08:00
|
|
|
|
if(H5Pclose(fapl_id) < 0) {
|
|
|
|
|
nerrors++;
|
2016-09-30 01:26:32 +08:00
|
|
|
|
PUTS_ERROR("Unable to close VFD-specific fapl.\n");
|
2016-09-24 14:54:27 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
if(nerrors)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
HDprintf("All evict-on-close tests passed.\n");
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2016-09-24 14:54:27 +08:00
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
|
|
|
|
HDprintf("***** %u evict-on-close test%s FAILED! *****\n",
|
|
|
|
|
nerrors, nerrors > 1 ? "S" : "");
|
|
|
|
|
|
2016-11-03 23:31:02 +08:00
|
|
|
|
h5_delete_all_test_files(FILENAMES, fapl_id);
|
2016-09-24 14:54:27 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2016-09-30 01:26:32 +08:00
|
|
|
|
H5Fclose(fid);
|
2016-09-24 14:54:27 +08:00
|
|
|
|
H5Pclose(fapl_id);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
|
|
} /* end main() */
|
2016-06-28 05:04:52 +08:00
|
|
|
|
|