summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST2
-rwxr-xr-xconfigure5
-rw-r--r--configure.in1
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.in31
-rw-r--r--test/links.c104
-rw-r--r--test/links_env.c192
-rw-r--r--test/testlinks_env.sh.in41
9 files changed, 267 insertions, 119 deletions
diff --git a/MANIFEST b/MANIFEST
index e4cf1b8..02b211b 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -834,6 +834,7 @@
./test/external.c
./test/error_test.c
./test/err_compat.c
+./test/links_env.c
./test/family_v16_00000.h5
./test/family_v16_00001.h5
./test/family_v16_00002.h5
@@ -905,6 +906,7 @@
./test/tcoords.c
./test/testcheck_version.sh.in
./test/testerror.sh.in
+./test/testlinks_env.sh.in
./test/testframe.c
./test/testhdf5.c
./test/testhdf5.h
diff --git a/configure b/configure
index e5c7c22..01ba7ab 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Id: configure.in 19701 2010-10-31 14:11:50Z hdftest .
+# From configure.in Id: configure.in 19740 2010-11-07 14:31:35Z hdftest .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.67 for HDF5 1.9.80.
#
@@ -28419,7 +28419,7 @@ if test -n "$TESTPARALLEL"; then
fi
fi
-ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh"
+ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh"
cat >confcache <<\_ACEOF
@@ -29653,6 +29653,7 @@ do
"test/testerror.sh") CONFIG_FILES="$CONFIG_FILES test/testerror.sh" ;;
"test/H5srcdir_str.h") CONFIG_FILES="$CONFIG_FILES test/H5srcdir_str.h" ;;
"test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;;
+ "test/testlinks_env.sh") CONFIG_FILES="$CONFIG_FILES test/testlinks_env.sh" ;;
"testpar/Makefile") CONFIG_FILES="$CONFIG_FILES testpar/Makefile" ;;
"testpar/testph5.sh") CONFIG_FILES="$CONFIG_FILES testpar/testph5.sh" ;;
"perform/Makefile") CONFIG_FILES="$CONFIG_FILES perform/Makefile" ;;
diff --git a/configure.in b/configure.in
index 3361961..0271a2f 100644
--- a/configure.in
+++ b/configure.in
@@ -4285,6 +4285,7 @@ AC_CONFIG_FILES([src/libhdf5.settings
test/testerror.sh
test/H5srcdir_str.h
test/testlibinfo.sh
+ test/testlinks_env.sh
testpar/Makefile
testpar/testph5.sh
perform/Makefile
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0d60993..b39de38 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -287,6 +287,7 @@ SET (H5_TESTS
err_compat
tcheck_version
testmeta
+ links_env
)
FOREACH (test ${H5_TESTS})
@@ -398,6 +399,7 @@ IF (HDF5_TEST_VFD)
err_compat
tcheck_version
testmeta
+ links_env
)
IF (DIRECT_VFD)
diff --git a/test/Makefile.am b/test/Makefile.am
index 9464d46..6993a35 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -24,9 +24,9 @@ include $(top_srcdir)/config/commence.am
INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh
check_SCRIPTS = $(TEST_SCRIPT)
-SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
+SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT)
# These are our main targets. They should be listed in the order to be
@@ -50,7 +50,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
# 'make check' doesn't run them directly, so they are not included in TEST_PROG.
# Also build testmeta, which is used for timings test. It builds quickly,
# and this lets automake keep all its test programs in one place.
-check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta
+check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta links_env
# These programs generate test files for the tests. They don't need to be
@@ -134,6 +134,6 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
tvlstr.c tvltypes.c
# Temporary files.
-DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh
+DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks.sh
include $(top_srcdir)/config/conclude.am
diff --git a/test/Makefile.in b/test/Makefile.in
index 8748032..b083741 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -55,10 +55,11 @@ host_triplet = @host@
DIST_COMMON = $(srcdir)/H5srcdir_str.h.in $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/testcheck_version.sh.in \
$(srcdir)/testerror.sh.in $(srcdir)/testlibinfo.sh.in \
- $(top_srcdir)/config/commence.am \
+ $(srcdir)/testlinks_env.sh.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \
- err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT)
+ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT) \
+ links_env$(EXEEXT)
@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
subdir = test
@@ -69,7 +70,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/H5config.h
CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh H5srcdir_str.h \
- testlibinfo.sh
+ testlibinfo.sh testlinks_env.sh
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libh5test_la_LIBADD =
@@ -298,6 +299,10 @@ links_SOURCES = links.c
links_OBJECTS = links.$(OBJEXT)
links_LDADD = $(LDADD)
links_DEPENDENCIES = libh5test.la $(LIBHDF5)
+links_env_SOURCES = links_env.c
+links_env_OBJECTS = links_env.$(OBJEXT)
+links_env_LDADD = $(LDADD)
+links_env_DEPENDENCIES = libh5test.la $(LIBHDF5)
mf_SOURCES = mf.c
mf_OBJECTS = mf.$(OBJEXT)
mf_LDADD = $(LDADD)
@@ -399,8 +404,8 @@ SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \
gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
- istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \
- objcopy.c ohdr.c pool.c reserved.c set_extent.c \
+ istore.c lheap.c links.c links_env.c mf.c mount.c mtime.c \
+ ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c \
space_overflow.c stab.c tcheck_version.c $(testhdf5_SOURCES) \
testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
@@ -414,8 +419,8 @@ DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \
gen_new_mtime.c gen_new_super.c gen_noencoder.c \
gen_nullspace.c gen_sizes_lheap.c gen_specmetaread.c \
gen_udlinks.c getname.c gheap.c hyperslab.c istore.c lheap.c \
- links.c mf.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
- reserved.c set_extent.c space_overflow.c stab.c \
+ links.c links_env.c mf.c mount.c mtime.c ntypes.c objcopy.c \
+ ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \
tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
$(ttsafe_SOURCES) unlink.c vfd.c
ETAGS = etags
@@ -723,9 +728,9 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
# Test script for error_test and err_compat
-TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh
+TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh
check_SCRIPTS = $(TEST_SCRIPT)
-SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
+SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT)
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
@@ -778,7 +783,7 @@ testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
# Temporary files.
-DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh
+DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh testlinks.sh
# Automake needs to be taught how to build lib, progs, and tests targets.
# These will be filled in automatically for the most part (e.g.,
@@ -837,6 +842,8 @@ H5srcdir_str.h: $(top_builddir)/config.status $(srcdir)/H5srcdir_str.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
testlibinfo.sh: $(top_builddir)/config.status $(srcdir)/testlibinfo.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+testlinks_env.sh: $(top_builddir)/config.status $(srcdir)/testlinks_env.sh.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@@ -1016,6 +1023,9 @@ lheap$(EXEEXT): $(lheap_OBJECTS) $(lheap_DEPENDENCIES)
links$(EXEEXT): $(links_OBJECTS) $(links_DEPENDENCIES)
@rm -f links$(EXEEXT)
$(LINK) $(links_OBJECTS) $(links_LDADD) $(LIBS)
+links_env$(EXEEXT): $(links_env_OBJECTS) $(links_env_DEPENDENCIES)
+ @rm -f links_env$(EXEEXT)
+ $(LINK) $(links_env_OBJECTS) $(links_env_LDADD) $(LIBS)
mf$(EXEEXT): $(mf_OBJECTS) $(mf_DEPENDENCIES)
@rm -f mf$(EXEEXT)
$(LINK) $(mf_OBJECTS) $(mf_LDADD) $(LIBS)
@@ -1126,6 +1136,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/istore.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/links.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/links_env.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtime.Po@am__quote@
diff --git a/test/links.c b/test/links.c
index 3596f1f..e4aead6 100644
--- a/test/links.c
+++ b/test/links.c
@@ -2707,110 +2707,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format)
return -1;
} /* end external_link_dangling() */
-
-
-/*-------------------------------------------------------------------------
- * Function: external_link_env: test 1
- *
- * Purpose:
- * 1. target link: "extlinks1"
- * 2. main file: "extlinks0"
- * 3. target file: "tmp/extlinks1"
- * 4. The environment variable "HDF5_EXT_PREFIX" should be set to ".:tmp"
- * Should be able to access the target file in tmp directory through searching
- * the pathnames set in HDF5_EXT_PREFIX.
- * This test will be skipped if HDF5_EXT_PREFIX is not set as expected.
- *
- *
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: Vailin Choi
- * Feb. 20, 2008
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-external_link_env(hid_t fapl, hbool_t new_format)
-{
- hid_t fid = (-1); /* File ID */
- hid_t gid = (-1); /* Group IDs */
- const char *envval = NULL;
-
- char filename1[NAME_BUF_SIZE],
- filename2[NAME_BUF_SIZE],
- filename3[NAME_BUF_SIZE];
-
- if(new_format)
- TESTING("external links via environment variable (w/new group format)")
- else
- TESTING("external links via environment variable")
-
- if ((envval = HDgetenv("HDF5_EXT_PREFIX")) == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, ".:tmp")) {
- SKIPPED();
- return(0);
- }
-
- /* set up name for main file:"extlinks0" */
- h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
- /* set up name for external linked target file: "extlinks1" */
- h5_fixname(FILENAME[14], fapl, filename2, sizeof filename2);
-
- if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
- TEST_ERROR
-
- /* set up name for target file: "tmp/extlinks1" */
- h5_fixname(FILENAME[15], fapl, filename3, sizeof filename3);
-
- /* Create the target file */
- if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
-
- /* closing for target file */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
-
-
- /* Create the main file */
- if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
-
- /* Create external link to target file */
- if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Open object through external link */
- H5E_BEGIN_TRY {
- gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
- } H5E_END_TRY;
-
- /* should be able to find the target file from pathnames set via environment variable */
- if (gid < 0) {
- H5_FAILED();
- puts(" Should have found the file in tmp directory.");
- goto error;
- }
-
- /* closing for main file */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
-
- PASSED();
- return 0;
-
- error:
- H5E_BEGIN_TRY {
- H5Gclose (gid);
- H5Fclose (fid);
- } H5E_END_TRY;
- return -1;
-} /* end external_link_env() */
-
/*-------------------------------------------------------------------------
- * Function: external_link_prefix: test 2
+ * Function: external_link_prefix
*
* Purpose: 1. target link: "extlinks2"
* 2. main file: "extlinks0"
@@ -14015,7 +13914,6 @@ main(void)
nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
/* tests for external link */
- nerrors += external_link_env(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
diff --git a/test/links_env.c b/test/links_env.c
new file mode 100644
index 0000000..c792386
--- /dev/null
+++ b/test/links_env.c
@@ -0,0 +1,192 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: Tests hard, soft (symbolic) & external links.
+ */
+
+#define H5G_PACKAGE
+#define H5G_TESTING
+
+#include "h5test.h"
+#include "H5srcdir.h"
+#include "H5Gpkg.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+
+#ifdef H5_VMS
+#define TMPDIR "[.tmp]"
+#else /* H5_VMS */
+#define TMPDIR "tmp/"
+#endif /* H5_VMS */
+#define NAME_BUF_SIZE 1024
+
+const char *FILENAME[] = {
+ "extlinks_env0", /* 0: main file */
+ "extlinks_env1", /* 1: target file */
+ TMPDIR "extlinks_env1", /* 2 */
+ NULL
+};
+
+static int external_link_env(hid_t fapl, hbool_t new_format);
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_link_env (moved from links.c)
+ *
+ * Purpose: Verify that the target file is found successfully in "tmp" directory
+ * via searching the pathnames set in the environment variable HDF5_EXT_PREFIX.
+ * 1. Target link: "extlinks_env1"
+ * 2. Main file: "extlinks_env0"
+ * 3. Target file is created in: "tmp/extlinks_env1"
+ * 4. The environment variable "HDF5_EXT_PREFIX" is set to ".:tmp"
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Feb. 20, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_link_env(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ const char *envval = NULL; /* Pointer to environment variable */
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ filename3[NAME_BUF_SIZE]; /* Holders for filename */
+
+ if(new_format)
+ TESTING("external links via environment variable (w/new group format)")
+ else
+ TESTING("external links via environment variable")
+
+ if ((envval = HDgetenv("HDF5_EXT_PREFIX")) == NULL)
+ envval = "nomatch";
+ if (HDstrcmp(envval, ".:tmp")) TEST_ERROR
+
+ /* Set up name for main file:"extlinks_env0" */
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+
+ /* Set up name for external linked target file: "extlinks_env1" */
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
+
+ /* Create "tmp" directory */
+ if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+
+ /* Set up name (location) for the target file: "tmp/extlinks1" */
+ h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3);
+
+ /* Create the target file in "tmp" directory */
+ if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Closing for target file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file */
+ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Open object through external link */
+ H5E_BEGIN_TRY {
+ gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ /* Should be able to find the target file from pathnames set via HDF5_EXT_PREFIX */
+ if (gid < 0) {
+ H5_FAILED();
+ puts(" Should have found the file in tmp directory.");
+ goto error;
+ }
+
+ /* closing for main file */
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Gclose (gid);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_link_env() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Test external link with environment variable HDF5_EXT_PREFIX
+ *
+ * Return: Success: exit(0)
+ * Failure: exit(non-zero)
+ *
+ * Programmer: Vailin Choi; Nov 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fapl; /* File access property lists */
+ int nerrors = 0; /* Error from tests */
+ const char *env_h5_drvr; /* File Driver value from environment */
+
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
+
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ nerrors += external_link_env(fapl, FALSE) < 0 ? 1 : 0;
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ nerrors += external_link_env(fapl, TRUE) < 0 ? 1 : 0;
+
+ h5_cleanup(FILENAME, fapl);
+
+ /* Results */
+ if(nerrors) {
+ printf("***** %d External Link (HDF5_EXT_PREFIX) test%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "s");
+ exit(1);
+ }
+ printf("All external Link (HDF5_EXT_PREFIX) tests passed.\n");
+
+ /* clean up tmp directory created by external link tests */
+ HDrmdir(TMPDIR);
+
+ return 0;
+
+error:
+ puts("*** TESTS FAILED ***");
+ return 1;
+}
diff --git a/test/testlinks_env.sh.in b/test/testlinks_env.sh.in
new file mode 100644
index 0000000..9ea85b1
--- /dev/null
+++ b/test/testlinks_env.sh.in
@@ -0,0 +1,41 @@
+#! /bin/sh
+#
+# 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.
+#
+# Test for external link with environment variable: HDF5_EXT_PREFIX
+
+nerrors=0
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+
+# test for external links with HDF5_EXT_PREFIX
+echo "Testing external link with HDF5_EXT_PREFIX"
+env "HDF5_EXT_PREFIX=.:tmp" links_env
+exitcode=$?
+if [ $exitcode -eq 0 ]; then
+ echo "Test for HDF5_EXT_PREFIX PASSED"
+ else
+ nerrors="`expr $nerrors + 1`"
+ echo "***Error encountered for HDF5_EXT_PREFIX test***"
+fi
+exit $nerrors