summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-03-17 21:38:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-03-17 21:38:20 (GMT)
commitfd547cd11ffa59c66aa93a5c55f6b979792e76d7 (patch)
treefcca518af22b90099a766da4419e593d373cd390 /test
parent8a14f5dc0ecf2a550916d5fd8ff5804d6e641240 (diff)
downloadhdf5-fd547cd11ffa59c66aa93a5c55f6b979792e76d7.zip
hdf5-fd547cd11ffa59c66aa93a5c55f6b979792e76d7.tar.gz
hdf5-fd547cd11ffa59c66aa93a5c55f6b979792e76d7.tar.bz2
[svn-r18413] Description:
Unify srcdir handling for test executables and allow them to use the srcdir setting from configure time without requiring the 'srcdir' environment variable be set (although you still can, to override the built in setting). Attempted to get this right for Windows builds also. Also add dependency between src/H5Tinit.c and src/libhdf5.settings, so that the test/testcheck_version.sh script works correctly. Tested on: Linux/32 2.6 (jam) Mac OS X/32 10.6.2 (amazon)
Diffstat (limited to 'test')
-rw-r--r--test/H5srcdir.h.in52
-rw-r--r--test/Makefile.in12
-rwxr-xr-xtest/cross_read.c11
-rw-r--r--test/dsets.c28
-rw-r--r--test/external.c11
-rw-r--r--test/fillval.c11
-rw-r--r--test/h5test.c10
-rw-r--r--test/h5test.h1
-rw-r--r--test/links.c36
-rw-r--r--test/mtime.c16
-rwxr-xr-xtest/objcopy.c10
-rw-r--r--test/ohdr.c15
-rw-r--r--test/tarray.c9
-rw-r--r--test/tfile.c10
-rw-r--r--test/th5s.c9
-rw-r--r--test/tmisc.c40
16 files changed, 85 insertions, 196 deletions
diff --git a/test/H5srcdir.h.in b/test/H5srcdir.h.in
new file mode 100644
index 0000000..b7a75af
--- /dev/null
+++ b/test/H5srcdir.h.in
@@ -0,0 +1,52 @@
+/* If you are reading this file and it has a '.h' suffix, it was automatically
+ * generated from the '.in' version. Make changes there.
+ */
+
+/* Set the 'srcdir' path from configure time */
+static const char *config_srcdir = "@srcdir@";
+
+/* Buffer to construct path in and return pointer to */
+static char srcdir_path[1024] = "";
+
+/* Buffer to construct file in and return pointer to */
+static char srcdir_testpath[1024] = "";
+
+/* Append the test file name to the srcdir path and return the whole string */
+static const char *H5_get_srcdir_filename(const char *filename)
+{
+ const char *srcdir = HDgetenv("srcdir");
+
+ /* Check for using the srcdir from configure time */
+ if(NULL == srcdir)
+ srcdir = config_srcdir;
+
+ /* Build path to test file */
+ if((HDstrlen(srcdir) + HDstrlen(filename) + 2) < sizeof(srcdir_testpath)) {
+ HDstrcpy(srcdir_testpath, srcdir);
+ HDstrcat(srcdir_testpath, "/");
+ HDstrcat(srcdir_testpath, filename);
+ return(srcdir_testpath);
+ } /* end if */
+ else
+ return(NULL);
+}
+
+/* Just return the srcdir path */
+static const char *H5_get_srcdir(void)
+{
+ const char *srcdir = HDgetenv("srcdir");
+
+ /* Check for using the srcdir from configure time */
+ if(NULL == srcdir)
+ srcdir = config_srcdir;
+
+ /* Build path to all test files */
+ if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) {
+ HDstrcpy(srcdir_path, srcdir);
+ HDstrcat(srcdir_path, "/");
+ return(srcdir_path);
+ } /* end if */
+ else
+ return(NULL);
+}
+
diff --git a/test/Makefile.in b/test/Makefile.in
index 4777bf6..40f2bed 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -52,9 +52,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \
- $(srcdir)/testlibinfo.sh.in $(top_srcdir)/config/commence.am \
+DIST_COMMON = $(srcdir)/H5srcdir.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 \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \
err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT)
@@ -67,7 +68,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/H5config.h
-CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh testlibinfo.sh
+CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh H5srcdir.h \
+ testlibinfo.sh
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libh5test_la_LIBADD =
@@ -799,6 +801,8 @@ testcheck_version.sh: $(top_builddir)/config.status $(srcdir)/testcheck_version.
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
testerror.sh: $(top_builddir)/config.status $(srcdir)/testerror.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+H5srcdir.h: $(top_builddir)/config.status $(srcdir)/H5srcdir.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)/$@
diff --git a/test/cross_read.c b/test/cross_read.c
index b036217..6ce38f2 100755
--- a/test/cross_read.c
+++ b/test/cross_read.c
@@ -37,8 +37,7 @@ const char *FILENAME[] = {
static int read_data(char *fname)
{
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */
hid_t file, dataset; /* handles */
hid_t datatype;
hid_t dt;
@@ -47,14 +46,6 @@ static int read_data(char *fname)
int i, j;
unsigned nerrors = 0;
- pathname[0] = '\0';
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((strlen(srcdir) + strlen(fname) + 1) < sizeof(pathname))) {
- strcpy(pathname, srcdir);
- strcat(pathname, "/");
- }
- strcat(pathname, fname);
-
/*
* Data and output buffer initialization.
*/
diff --git a/test/dsets.c b/test/dsets.c
index 46355c1..c17e90c 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -2256,8 +2256,7 @@ test_missing_filter(hid_t file)
hsize_t dset_size; /* Dataset size */
size_t i,j; /* Local index variables */
herr_t ret; /* Generic return value */
- char testfile[512]=""; /* Buffer to hold name of existing test file */
- char *srcdir = HDgetenv("srcdir"); /* The source directory, if we are using the --srcdir configure option */
+ const char *testfile = H5_get_srcdir_filename(FILE_DEFLATE_NAME); /* Corrected test file name */
TESTING("dataset access with missing filter");
@@ -2403,13 +2402,6 @@ test_missing_filter(hid_t file)
/* Try reading existing dataset with deflate filter */
- /* Compose the name of the file to open, using the srcdir, if appropriate */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_DEFLATE_NAME) + 1) < sizeof(testfile))){
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, FILE_DEFLATE_NAME);
-
/* Open existing file */
if((fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
H5_FAILED();
@@ -5935,8 +5927,7 @@ test_filters_endianess(void)
hid_t dsid=-1; /* dataset ID */
hid_t sid=-1; /* dataspace ID */
hid_t dcpl=-1; /* dataset creation property list ID */
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing file */
+ const char *data_file = H5_get_srcdir_filename("test_filters_le.hdf5"); /* Corrected test file name */
TESTING("filters with big-endian/little-endian data");
@@ -5946,14 +5937,6 @@ test_filters_endianess(void)
*-------------------------------------------------------------------------
*/
- /* compose the name of the file to open, using the srcdir, if appropriate */
- HDstrcpy(data_file, "");
- if(srcdir) {
- HDstrcpy(data_file, srcdir);
- HDstrcat(data_file, "/");
- }
- HDstrcat(data_file, "test_filters_le.hdf5");
-
/* open */
if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -5969,12 +5952,7 @@ test_filters_endianess(void)
*/
/* compose the name of the file to open, using the srcdir, if appropriate */
- HDstrcpy(data_file, "");
- if(srcdir) {
- HDstrcpy(data_file, srcdir);
- HDstrcat(data_file, "/");
- }
- HDstrcat(data_file, "test_filters_be.hdf5");
+ data_file = H5_get_srcdir_filename("test_filters_be.hdf5"); /* Corrected test file name */
/* open */
if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
diff --git a/test/external.c b/test/external.c
index 68f81e8..24cd85b 100644
--- a/test/external.c
+++ b/test/external.c
@@ -845,8 +845,7 @@ test_4 (hid_t fapl)
hid_t xid = -1;
hid_t xid2 = -1;
char filename[1024]; /*file name */
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ const char *pathname = H5_get_srcdir_filename(LINKED_FILE); /* Corrected test file name */
TESTING("opening external link twice");
@@ -865,14 +864,6 @@ test_4 (hid_t fapl)
if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
goto error;
- pathname[0] = '\0';
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(LINKED_FILE) + 1) < sizeof(pathname))) {
- HDstrcpy(pathname, srcdir);
- HDstrcat(pathname, "/");
- }
- HDstrcat(pathname, LINKED_FILE);
-
/* Create an external link to an existing file*/
if(H5Lcreate_external(pathname, "/group", gid, " link", H5P_DEFAULT, H5P_DEFAULT) < 0)
goto error;
diff --git a/test/fillval.c b/test/fillval.c
index 2f58380..25c8bd1 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -1974,19 +1974,10 @@ test_compatible(void)
hsize_t dims[2], one[2]={1,1};
hsize_t hs_offset[2]={3,4};
H5D_fill_value_t status;
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
- char testfile[512]=""; /* test file name */
+ const char *testfile = H5_get_srcdir_filename(FILE_COMPATIBLE); /* Corrected test file name */
TESTING("contiguous dataset compatibility with v. 1.4");
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((strlen(srcdir) + strlen(FILE_COMPATIBLE) + 1) <
- sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, FILE_COMPATIBLE);
-
if((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
printf(" Could not open file %s. Try set $srcdir to point at the "
"source directory of test\n", testfile);
diff --git a/test/h5test.c b/test/h5test.c
index b9f3221..8e439cd 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -1114,18 +1114,10 @@ getenv_all(MPI_Comm comm, int root, const char* name)
hid_t
h5_make_local_copy(char *origfilename, char *local_copy_name)
{
- char filename[FILENAME_BUF_SIZE] = "";
+ const char *filename = H5_get_srcdir_filename(origfilename); /* Corrected test file name */
int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
ssize_t nread; /* Number of bytes read in */
char buf[READ_BUF_SIZE]; /* Buffer for copying data */
- char * srcdir = HDgetenv("srcdir"); /* The source directory */
-
- if(srcdir && ((HDstrlen(srcdir) +
- HDstrlen(origfilename) + 6) < FILENAME_BUF_SIZE)) {
- HDstrcpy(filename, srcdir);
- HDstrcat(filename, "/");
- }
- HDstrcat(filename, origfilename);
/* Copy old file into temporary file */
if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) return -1;
diff --git a/test/h5test.h b/test/h5test.h
index f984751..ed538cf 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -24,6 +24,7 @@
#include "hdf5.h"
#include "H5private.h"
+#include "H5srcdir.h"
#ifdef H5_STDC_HEADERS
# include <signal.h>
diff --git a/test/links.c b/test/links.c
index f636413..18c4caa 100644
--- a/test/links.c
+++ b/test/links.c
@@ -6214,34 +6214,19 @@ external_link_endian(hbool_t new_format)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1), gid2 = (-1); /* Group IDs */
hid_t lapl_id = (-1); /* Prop List ID */
- char * srcdir = getenv("srcdir"); /* The source directory */
- char pathbuf[NAME_BUF_SIZE]; /* Path to the files */
- char namebuf[NAME_BUF_SIZE];
+ const char *pathbuf = H5_get_srcdir(); /* Path to the files */
+ const char *namebuf;
if(new_format)
TESTING("endianness of external links (w/new group format)")
else
TESTING("endianness of external links")
- /*
- * Create the name of the file to open (in case we are using the --srcdir
- * option and the file is in a different directory from this test).
- */
- if (srcdir && ((HDstrlen(srcdir) + 2) < sizeof(pathbuf)) )
- {
- HDstrcpy(pathbuf, srcdir);
- HDstrcat(pathbuf, "/");
- }
- else
- HDstrcpy(pathbuf, "");
-
/* Create a link access property list with the path to the srcdir */
if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
if(H5Pset_elink_prefix(lapl_id, pathbuf) < 0) TEST_ERROR
- if(HDstrlen(pathbuf) + HDstrlen(LE_FILENAME) >= sizeof(namebuf)) TEST_ERROR
- HDstrcpy(namebuf, pathbuf);
- HDstrcat(namebuf, LE_FILENAME);
+ namebuf = H5_get_srcdir_filename(LE_FILENAME); /* Corrected test file name */
/* Test LE file; try to open a group through the external link */
if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -6255,9 +6240,7 @@ external_link_endian(hbool_t new_format)
if(H5Gclose(gid) < 0) TEST_ERROR
if(H5Fclose(fid) < 0) TEST_ERROR
- if(HDstrlen(pathbuf) + HDstrlen(BE_FILENAME) >= sizeof(namebuf)) TEST_ERROR
- HDstrcpy(namebuf, pathbuf);
- HDstrcat(namebuf, BE_FILENAME);
+ namebuf = H5_get_srcdir_filename(BE_FILENAME); /* Corrected test file name */
/* Test BE file; try to open a group through the external link */
if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
@@ -8300,8 +8283,7 @@ build_visit_file(hid_t fapl)
hid_t did = (-1); /* Dataset ID */
hid_t tid = (-1); /* Datatype ID */
char filename[NAME_BUF_SIZE];
- char pathname[1024]; /* Path of external link file */
- char *srcdir = getenv("srcdir"); /* where the src code is located */
+ const char *pathname = H5_get_srcdir_filename(LINKED_FILE); /* Corrected test file name */
h5_fixname(FILENAME[9], fapl, filename, sizeof filename);
@@ -8337,14 +8319,6 @@ build_visit_file(hid_t fapl)
if(H5Lcreate_hard(fid, "/", fid, "/Group1/Group2/hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Create external link to existing file */
- pathname[0] = '\0';
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(LINKED_FILE) + 1) < sizeof(pathname))) {
- HDstrcpy(pathname, srcdir);
- HDstrcat(pathname, "/");
- }
- HDstrcat(pathname, LINKED_FILE);
-
if(H5Lcreate_external(pathname, "/group", fid, "/ext_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Create dangling external link to non-existent file */
diff --git a/test/mtime.c b/test/mtime.c
index 741f09a..79c539c 100644
--- a/test/mtime.c
+++ b/test/mtime.c
@@ -131,14 +131,8 @@ main(void)
TESTING("accessing old modification time messages");
{
- char testfile[512]="";
- char *srcdir = HDgetenv("srcdir");
+ const char *testfile = H5_get_srcdir_filename(TESTFILE1); /* Corrected test file name */
- if(srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE1) + 1) < sizeof(testfile))){
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, TESTFILE1);
file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
if(file >= 0){
if(H5Oget_info_by_name(file, "/Dataset1", &oi1, H5P_DEFAULT) < 0)
@@ -167,14 +161,8 @@ main(void)
TESTING("accessing new modification time messages");
{
- char testfile[512]="";
- char *srcdir = HDgetenv("srcdir");
+ const char *testfile = H5_get_srcdir_filename(TESTFILE2); /* Corrected test file name */
- if(srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE2) + 1) < sizeof(testfile))){
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, TESTFILE2);
file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
if(file >= 0){
if(H5Oget_info_by_name(file, "/Dataset1", &oi2, H5P_DEFAULT) < 0)
diff --git a/test/objcopy.c b/test/objcopy.c
index 854006e..d540117 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -6076,19 +6076,11 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t did = -1, did2 = -1; /* Dataset IDs */
- char *srcdir = HDgetenv("srcdir"); /* Where the src code is located */
- char src_filename[NAME_BUF_SIZE] = "";
+ const char *src_filename = H5_get_srcdir_filename(FILE_OLD_LAYOUT); /* Corrected test file name */
char dst_filename[NAME_BUF_SIZE];
TESTING("H5Ocopy(): dataset with old layout format");
- /* Generate correct name for source file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_OLD_LAYOUT) + 1) < sizeof(src_filename))) {
- HDstrcpy(src_filename, srcdir);
- HDstrcat(src_filename, "/");
- } /* end if */
- HDstrcat(src_filename, FILE_OLD_LAYOUT);
-
/* Initialize the destination filename */
h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
diff --git a/test/ohdr.c b/test/ohdr.c
index c3b8f8b..69b61ea 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -362,20 +362,7 @@ main(void)
HDputs("Accessing objects with unknown header messages:");
{
hid_t file2; /* File ID for 'bogus' object file */
- char testpath[512] = "";
- char testfile[512] = "";
- char *srcdir = HDgetenv("srcdir");
-
- /* Build path to all test files */
- if(srcdir && ((HDstrlen(srcdir) + 2) < sizeof(testpath))) {
- HDstrcpy(testpath, srcdir);
- HDstrcat(testpath, "/");
- } /* end if */
-
- /* Build path to test file */
- if(srcdir && ((HDstrlen(testpath) + HDstrlen(FILE_BOGUS) + 1) < sizeof(testfile)))
- HDstrcpy(testfile, testpath);
- HDstrcat(testfile, FILE_BOGUS);
+ const char *testfile = H5_get_srcdir_filename(FILE_BOGUS);
TESTING("object with unknown header message and no flags set");
diff --git a/test/tarray.c b/test/tarray.c
index 590d48c..83528ff 100644
--- a/test/tarray.c
+++ b/test/tarray.c
@@ -1802,8 +1802,7 @@ test_compat(void)
long l[ARRAY1_DIM1];
double d;
} s3_t;
- char testfile[512]=""; /* Character buffer for corrected test file name */
- char *srcdir = getenv("srcdir"); /* Pointer to the directory the source code is located within */
+ const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t tid1; /* Array Datatype ID */
@@ -1831,12 +1830,6 @@ test_compat(void)
* changed, follow the instructions in gen_old_array.c for regenerating
* the tarrold.h5 file.
*/
- /* Generate the correct name for the test file, by prepending the source path */
- if (srcdir && ((strlen(srcdir) + strlen(TESTFILE) + 1) < sizeof(testfile))) {
- strcpy(testfile, srcdir);
- strcat(testfile, "/");
- }
- strcat(testfile, TESTFILE);
/* Open the testfile */
fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
diff --git a/test/tfile.c b/test/tfile.c
index 1d5cc0e..a981720 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -2957,7 +2957,6 @@ test_filespace_compatible(void)
int rdbuf[100]; /* Temporary buffer for reading in dataset data */
uint8_t buf[READ_OLD_BUFSIZE]; /* temporary buffer for reading */
ssize_t nread; /* Number of bytes read in */
- char *srcdir = HDgetenv("srcdir"); /* where the src code is located */
unsigned i, j; /* Local index variable */
hssize_t free_space; /* Amount of free space in the file */
hsize_t threshold; /* Free space section threshold */
@@ -2968,14 +2967,7 @@ test_filespace_compatible(void)
MESSAGE(5, ("Testing File space compatibility for 1.6 and 1.8 files\n"));
for(j = 0; j < NELMTS(OLD_FILENAME); j++) {
- char filename[FILENAME_LEN] = ""; /* old test file name */
-
- /* Generate correct name for test file by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(OLD_FILENAME[j]) + 1) < sizeof(filename))) {
- HDstrcpy(filename, srcdir);
- HDstrcat(filename, "/");
- }
- HDstrcat(filename, OLD_FILENAME[j]);
+ const char *filename = H5_get_srcdir_filename(OLD_FILENAME[j]); /* Corrected test file name */
/* Copy old file into test file */
fd_old = HDopen(filename, O_RDONLY, 0666);
diff --git a/test/th5s.c b/test/th5s.c
index a38e384..d999920 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -173,13 +173,8 @@ test_h5s_basic(void)
* the instructions in space_overflow.c for regenerating the th5s.h5 file.
*/
{
- char testfile[512]="";
- char *srcdir = HDgetenv("srcdir");
- if (srcdir && ((HDstrlen(srcdir) + HDstrlen(TESTFILE) + 1) < sizeof(testfile))){
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, TESTFILE);
+ const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
+
fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK_I(fid1, "H5Fopen");
if (fid1 >= 0){
diff --git a/test/tmisc.c b/test/tmisc.c
index 2752f42..728200e 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -1723,20 +1723,12 @@ test_misc10(void)
hid_t dataset, dataset_new; /* Dataset IDs for old & new datasets */
hid_t dcpl; /* Dataset creation property list */
hid_t space, type; /* Old dataset's dataspace & datatype */
- char testfile[512]=""; /* Character buffer for corrected test file name */
- char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */
+ const char *testfile = H5_get_srcdir_filename(MISC10_FILE_OLD); /* Corrected test file name */
herr_t ret;
/* Output message about test being performed */
MESSAGE(5, ("Testing using old dataset creation property list\n"));
- /* Generate the correct name for the test file, by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC10_FILE_OLD) + 1) < sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, MISC10_FILE_OLD);
-
/*
* Open the old file and the dataset and get old settings.
*/
@@ -3387,8 +3379,7 @@ test_misc20(void)
hsize_t small_dims[MISC20_SPACE_RANK]={MISC20_SPACE2_DIM0,MISC20_SPACE2_DIM1}; /* Small dimensions */
unsigned version; /* Version of storage layout info */
hsize_t contig_size; /* Size of contiguous storage size from layout into */
- char testfile[512]=""; /* Character buffer for corrected test file name */
- char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */
+ const char *testfile = H5_get_srcdir_filename(MISC20_FILE_OLD); /* Corrected test file name */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -3502,13 +3493,6 @@ test_misc20(void)
/* Verify that the storage size is computed correctly for older versions of layout info */
- /* Generate the correct name for the test file, by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC20_FILE_OLD) + 1) < sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, MISC20_FILE_OLD);
-
/*
* Open the old file and the dataset and get old settings.
*/
@@ -4630,20 +4614,12 @@ test_misc25b(void)
{
hid_t fid; /* File ID */
hid_t gid; /* Group ID */
- char testfile[512]="";
- char *srcdir = HDgetenv("srcdir");
+ const char *testfile = H5_get_srcdir_filename(MISC25B_FILE); /* Corrected test file name */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Exercise null object header message bug\n"));
- /* Build the name of the file, with the source directory */
- if (srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC25B_FILE) + 1) < sizeof(testfile))){
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, MISC25B_FILE);
-
/* Open file */
fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -4895,20 +4871,12 @@ test_misc27(void)
{
hid_t fid; /* File ID */
hid_t gid; /* Group ID */
- char testfile[512]=""; /* Character buffer for corrected test file name */
- char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */
+ const char *testfile = H5_get_srcdir_filename(MISC27_FILE); /* Corrected test file name */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Corrupt object header handling\n"));
- /* Generate the correct name for the test file, by prepending the source path */
- if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC27_FILE) + 1) < sizeof(testfile))) {
- HDstrcpy(testfile, srcdir);
- HDstrcat(testfile, "/");
- }
- HDstrcat(testfile, MISC27_FILE);
-
/* Open the file */
fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");