summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSongyu Lu <songyulu@hdfgroup.org>2019-04-09 21:20:19 (GMT)
committerSongyu Lu <songyulu@hdfgroup.org>2019-04-09 21:20:19 (GMT)
commit477dda3c0daea39cdf409684e7dad0fd9367dd45 (patch)
tree08f8d1653aec4e356fb069ae3a7d8768009901e2
parentd8ff8da46cb49098c41b421427967eb736e15236 (diff)
downloadhdf5-477dda3c0daea39cdf409684e7dad0fd9367dd45.zip
hdf5-477dda3c0daea39cdf409684e7dad0fd9367dd45.tar.gz
hdf5-477dda3c0daea39cdf409684e7dad0fd9367dd45.tar.bz2
HDFFV-10658 - setting and getting properties in API context:
1. switched to use the existing H5F_prefix_open_t for enum type; 2. put the common private function used by external.c and external_env.c into external_common.c
-rw-r--r--MANIFEST4
-rw-r--r--src/H5Dint.c22
-rw-r--r--src/H5Fprivate.h7
-rw-r--r--src/H5VLnative_dataset.c1
-rw-r--r--test/Makefile.am4
-rw-r--r--test/external_common.c (renamed from test/external.h)35
-rw-r--r--test/external_common.h45
-rw-r--r--test/external_env.c9
8 files changed, 75 insertions, 52 deletions
diff --git a/MANIFEST b/MANIFEST
index 7cb2cfd..0a389a1 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -991,6 +991,9 @@
./test/evict_on_close.c
./test/extend.c
./test/external.c
+./test/external_common.c
+./test/external_common.h
+./test/external_env.c
./test/error_test.c
./test/err_compat.c
./test/filter_error.h5
@@ -1115,6 +1118,7 @@
./test/tcoords.c
./test/testabort_fail.sh.in
./test/testcheck_version.sh.in
+./test/testexternal_env.sh.in
./test/testerror.sh.in
./test/testlinks_env.sh.in
./test/test_filter_plugin.sh.in
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 6ace085..208d879 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -43,12 +43,6 @@
/* Local Typedefs */
/******************/
-/* Type of prefix for file */
-typedef enum {
- H5D_PREFIX_TYPE_UNKNOWN=0,
- H5D_PREFIX_TYPE_EXT=1,
- H5D_PREFIX_TYPE_VDS=2
-} H5D_prefix_type_t;
/********************/
/* Local Prototypes */
@@ -60,7 +54,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons
static herr_t H5D__cache_dataspace_info(const H5D_t *dset);
static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space);
static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id);
-static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix);
+static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix);
static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id);
static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite,
hsize_t old_dim[]);
@@ -1094,7 +1088,7 @@ done:
*--------------------------------------------------------------------------
*/
static herr_t
-H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/)
+H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/)
{
char *prefix = NULL; /* prefix used to look for the file */
char *filepath = NULL; /* absolute path of directory the HDF5 file is in */
@@ -1115,14 +1109,14 @@ H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **
/* XXX: Future thread-safety note - getenv is not required
* to be reentrant.
*/
- if(H5D_PREFIX_TYPE_VDS == prefix_type) {
+ if(H5F_PREFIX_VDS == prefix_type) {
prefix = (char *)H5D_prefix_vds_env;
if(prefix == NULL || *prefix == '\0') {
if(H5CX_get_vds_prefix(&prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file")
}
- } else if(H5D_PREFIX_TYPE_EXT == prefix_type) {
+ } else if(H5F_PREFIX_EFILE == prefix_type) {
prefix = (char *)H5D_prefix_ext_env;
if(prefix == NULL || *prefix == '\0') {
@@ -1338,11 +1332,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property")
/* Set the external file prefix */
- if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0)
+ if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix")
/* Set the VDS file prefix */
- if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0)
+ if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix")
/* Add the dataset to the list of opened objects in the file */
@@ -1497,11 +1491,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path")
/* Get the external file prefix */
- if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0)
+ if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix")
/* Get the VDS prefix */
- if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0)
+ if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix")
/* Check if dataset was already open */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index e3860a0..553e16b 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -702,8 +702,11 @@ typedef enum H5F_mem_page_t {
/* Type of prefix for opening prefixed files */
typedef enum H5F_prefix_open_t {
- H5F_PREFIX_VDS, /* Virtual dataset prefix */
- H5F_PREFIX_ELINK /* External link prefix */
+ H5D_PREFIX_ERROR = -1, /* Error */
+ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */
+ H5F_PREFIX_ELINK = 1, /* External link prefix */
+ H5F_PREFIX_EFILE = 2, /* External file prefix */
+ H5F_PREFIX_NONE = 3 /* Must be the last */
} H5F_prefix_open_t;
diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c
index aa65e54..8f7351c 100644
--- a/src/H5VLnative_dataset.c
+++ b/src/H5VLnative_dataset.c
@@ -61,6 +61,7 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params,
if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
+ /* Get creation properties */
if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0)
diff --git a/test/Makefile.am b/test/Makefile.am
index 68b9394..55b5a88 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -63,7 +63,7 @@ TEST_PROG= testhdf5 \
flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \
enc_dec_plist_cross_platform getname vfd ntypes dangle dtransform \
reserved cross_read freespace mf vds file_image unregister \
- cache_logging cork swmr vol
+ cache_logging cork swmr vol_tst
# List programs to be built when testing here.
# error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh.
@@ -135,7 +135,7 @@ else
noinst_LTLIBRARIES=libh5test.la
endif
-libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c
+libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c
# Use libhd5test.la to compile all of the tests
LDADD=libh5test.la $(LIBHDF5)
diff --git a/test/external.h b/test/external_common.c
index 1c660e1..e43a713 100644
--- a/test/external.h
+++ b/test/external_common.c
@@ -12,34 +12,13 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@hdfgroup.org>
- * Wednesday, March 17, 2010
+ * Programmer: Raymond Lu <songyulu@hdfgroup.org>
+ * April, 2019
*
- * Purpose: srcdir querying support.
+ * Purpose: Private function for external.c and external_env.c
*/
-#ifndef _EXTERNAL_H
-#define _EXTERNAL_H
-/* Include test header files */
-#include "h5test.h"
-
-const char *FILENAME[] = {
- "extern_1",
- "extern_2",
- "extern_3",
- "extern_4",
- "extern_dir/file_1",
- "extern_5",
- NULL
-};
-
-/* A similar collection of files is used for the tests that
- * perform file I/O.
- */
-#define N_EXT_FILES 4
-#define PART_SIZE 25
-#define TOTAL_SIZE 100
-#define GARBAGE_PER_FILE 10
+#include "external_common.h"
/*-------------------------------------------------------------------------
@@ -55,7 +34,7 @@ const char *FILENAME[] = {
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
reset_raw_data_files(void)
{
int fd = 0; /* external file descriptor */
@@ -139,6 +118,4 @@ error:
if(garbage)
HDfree(garbage);
return FAIL;
-} /* end reset_raw_data_files() */
-#endif /* _EXTERNAL_H */
-
+}
diff --git a/test/external_common.h b/test/external_common.h
new file mode 100644
index 0000000..f1a15b5
--- /dev/null
+++ b/test/external_common.h
@@ -0,0 +1,45 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Raymond Lu <songyulu@hdfgroup.org>
+ * April, 2019
+ *
+ * Purpose: Private function for external.c and external_env.c
+ */
+#ifndef _EXTERNAL_COMMON_H
+#define _EXTERNAL_COMMON_H
+
+/* Include test header files */
+#include "h5test.h"
+
+static const char *EXT_FNAME[] = {
+ "extern_1",
+ "extern_2",
+ "extern_3",
+ "extern_4",
+ "extern_dir/file_1",
+ "extern_5",
+ NULL
+};
+
+/* A similar collection of files is used for the tests that
+ * perform file I/O.
+ */
+#define N_EXT_FILES 4
+#define PART_SIZE 25
+#define TOTAL_SIZE 100
+#define GARBAGE_PER_FILE 10
+
+herr_t reset_raw_data_files(void);
+#endif /* _EXTERNAL_COMMON_H */
diff --git a/test/external_env.c b/test/external_env.c
index 97daef2..2f5f838 100644
--- a/test/external_env.c
+++ b/test/external_env.c
@@ -17,8 +17,7 @@
*
* Purpose: Tests datasets stored in external raw files.
*/
-#include "h5test.h"
-#include "external.h"
+#include "external_common.h"
/*-------------------------------------------------------------------------
@@ -63,7 +62,7 @@ test_path_env(hid_t fapl)
if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST)
TEST_ERROR;
- h5_fixname(FILENAME[4], fapl, filename, sizeof(filename));
+ h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename));
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
@@ -156,7 +155,7 @@ main(void)
/* Get a fapl for the old (default) file format */
fapl_id_old = h5_fileaccess();
- h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename));
+ h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename));
/* Copy and set up a fapl for the latest file format */
if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0)
@@ -189,7 +188,7 @@ main(void)
HDputs("All external storage tests passed.");
/* Clean up files used by file set tests */
- if(h5_cleanup(FILENAME, fapl_id_old)) {
+ if(h5_cleanup(EXT_FNAME, fapl_id_old)) {
HDremove("extern_1r.raw");
HDremove("extern_2r.raw");
HDremove("extern_3r.raw");