summaryrefslogtreecommitdiffstats
path: root/hl/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 /hl/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 'hl/test')
-rw-r--r--hl/test/H5srcdir.h.in52
-rw-r--r--hl/test/Makefile.in8
-rw-r--r--hl/test/test_ds.c22
-rw-r--r--hl/test/test_image.c44
-rw-r--r--hl/test/test_lite.c10
-rw-r--r--hl/test/test_table.c11
6 files changed, 64 insertions, 83 deletions
diff --git a/hl/test/H5srcdir.h.in b/hl/test/H5srcdir.h.in
new file mode 100644
index 0000000..b7a75af
--- /dev/null
+++ b/hl/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/hl/test/Makefile.in b/hl/test/Makefile.in
index a364c75..a7f118f 100644
--- a/hl/test/Makefile.in
+++ b/hl/test/Makefile.in
@@ -53,8 +53,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(top_srcdir)/config/commence.am \
+DIST_COMMON = $(srcdir)/H5srcdir.h.in $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am COPYING
check_PROGRAMS = $(am__EXEEXT_1)
@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2)
@@ -66,7 +66,7 @@ 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 =
+CONFIG_CLEAN_FILES = H5srcdir.h
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = test_lite$(EXEEXT) test_image$(EXEEXT) \
test_table$(EXEEXT) test_ds$(EXEEXT) test_packet$(EXEEXT)
@@ -448,6 +448,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
+H5srcdir.h: $(top_builddir)/config.status $(srcdir)/H5srcdir.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index 8576b2a..e3d7fe4 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -2143,15 +2143,7 @@ static int test_foreign_scaleattached(const char *fileforeign)
hid_t fid = -1;
hid_t did = -1;
hid_t dsid = -1;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char filename[512]=""; /* buffer to hold name of existing file */
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if (srcdir) {
- strcpy(filename,srcdir);
- strcat(filename,"/");
- }
- strcat(filename, fileforeign);
+ const char *filename = H5_get_srcdir_filename(fileforeign);
TESTING2("test_foreign_scaleattached");
@@ -4856,19 +4848,9 @@ static int read_data( const char* fname,
size_t nelms;
FILE *f;
float val;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]; /* buffer to hold name of existing data file */
+ const char *data_file = H5_get_srcdir_filename(fname);
- strcpy(data_file, "");
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if(srcdir)
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
/* read first data file */
- strcat(data_file,fname);
-
f = fopen(data_file, "r");
if( f == NULL )
{
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 426ae1d..d87946c 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -510,8 +510,7 @@ static int test_generate(void)
int imax, jmax, kmax;
float valex, xmin, xmax, value;
FILE *f;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing data file */
+ const char *data_file = H5_get_srcdir_filename(DATA_FILE4);
int i;
/* create a file using default properties */
@@ -521,17 +520,6 @@ static int test_generate(void)
printf("Testing read and process data and make indexed images\n");
/*-------------------------------------------------------------------------
- * compose the name of the file to open, using the srcdir, if appropriate
- *-------------------------------------------------------------------------
- */
- if ( srcdir )
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
- strcat(data_file,DATA_FILE4);
-
- /*-------------------------------------------------------------------------
* read data; the file data format is described below
*-------------------------------------------------------------------------
*/
@@ -723,20 +711,7 @@ static int read_data( const char* fname, /*IN*/
char str[20];
FILE *f;
int w, h;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing data file */
-
- /*-------------------------------------------------------------------------
- * compose the name of the file to open, using "srcdir", if appropriate
- *-------------------------------------------------------------------------
- */
- strcpy(data_file, "");
- if (srcdir)
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
- strcat(data_file,fname);
+ const char *data_file = H5_get_srcdir_filename(fname);
/*-------------------------------------------------------------------------
* read
@@ -811,20 +786,7 @@ static int read_palette(const char* fname,
unsigned int green;
unsigned int blue;
unsigned nentries;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]; /* buffer to hold name of existing data file */
-
- /*-------------------------------------------------------------------------
- * compose the name of the file to open, using "srcdir", if appropriate
- *-------------------------------------------------------------------------
- */
- strcpy(data_file, "");
- if (srcdir)
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
- strcat(data_file,fname);
+ const char *data_file = H5_get_srcdir_filename(fname);
/* ensure the given palette is valid */
if (!palette)
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 2012e8f..27da0ab 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1538,18 +1538,10 @@ static int test_complicated_compound(void)
char *line = NULL;
FILE *fp = NULL;
size_t size = 1024;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char filename[1024]="";
+ const char *filename = H5_get_srcdir_filename(INPUT_FILE);
TESTING3(" text for complicated compound types");
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if(srcdir) {
- strcpy(filename, srcdir);
- strcat(filename, "/");
- }
- strcat(filename, INPUT_FILE);
-
/* Open input file */
fp = fopen(filename, "r");
if(fp == NULL) {
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index 3438f15..0e87a7f 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -123,16 +123,7 @@ static hid_t h5file_open(const char *fname, unsigned flags)
{
hid_t fid; /* identifier for the file */
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing file */
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if (srcdir)
- {
- strcpy(data_file,srcdir);
- strcat(data_file,"/");
- }
- strcat(data_file,fname);
+ const char *data_file = H5_get_srcdir_filename(fname);
/* open */
if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0)