summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c118
1 files changed, 60 insertions, 58 deletions
diff --git a/test/h5test.c b/test/h5test.c
index deca1fc..23a9ce2 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -11,6 +11,8 @@
#undef NDEBUG /*override -DNDEBUG */
#include "h5test.h"
+#include <sys/types.h>
+#include <sys/stat.h>
#ifdef WIN32
#include <process.h>
@@ -127,7 +129,7 @@ h5_cleanup(const char *base_name[], hid_t fapl)
hid_t driver;
#endif /* H5_WANT_H5_V1_2_COMPAT */
- if (!getenv("HDF5_NOCLEANUP")) {
+ if (!HDgetenv("HDF5_NOCLEANUP")) {
for (i = 0; base_name[i]; i++) {
if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL)
continue;
@@ -139,25 +141,25 @@ h5_cleanup(const char *base_name[], hid_t fapl)
case H5F_LOW_SPLIT:
HDsnprintf(temp, sizeof(temp), "%s.raw", filename);
- remove(temp);
+ HDremove(temp);
HDsnprintf(temp, sizeof(temp), "%s.meta", filename);
- remove(temp);
+ HDremove(temp);
break;
case H5F_LOW_FAMILY:
for (j = 0; /*void*/; j++) {
HDsnprintf(temp, sizeof(temp), filename, j);
- if (access(temp, F_OK) < 0)
+ if (HDaccess(temp, F_OK) < 0)
break;
- remove(temp);
+ HDremove(temp);
}
break;
default:
- remove(filename);
+ HDremove(filename);
break;
}
#else /* H5_WANT_H5_V1_2_COMPAT */
@@ -168,10 +170,10 @@ h5_cleanup(const char *base_name[], hid_t fapl)
for (j = 0; /*void*/; j++) {
HDsnprintf(temp, sizeof temp, filename, j);
- if (access(temp, F_OK) < 0)
+ if (HDaccess(temp, F_OK) < 0)
break;
- remove(temp);
+ HDremove(temp);
}
} else if (driver == H5FD_CORE) {
/*void*/
@@ -182,10 +184,10 @@ h5_cleanup(const char *base_name[], hid_t fapl)
for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) {
HDsnprintf(temp, sizeof temp, "%s-%c.h5",
filename, multi_letters[mt]);
- remove(temp); /*don't care if it fails*/
+ HDremove(temp); /*don't care if it fails*/
}
} else {
- remove(filename);
+ HDremove(filename);
}
#endif /* H5_WANT_H5_V1_2_COMPAT */
}
@@ -217,8 +219,8 @@ h5_reset(void)
{
char filename[1024];
- fflush(stdout);
- fflush(stderr);
+ HDfflush(stdout);
+ HDfflush(stderr);
H5close();
H5Eset_auto (h5_errors, NULL);
@@ -233,7 +235,7 @@ h5_reset(void)
hid_t grp = H5Gcreate(file, "emit", 0);
H5Gclose(grp);
H5Fclose(file);
- unlink(filename);
+ HDunlink(filename);
} H5E_END_TRY;
}
@@ -313,7 +315,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
/* For serial:
* First use the environment variable, then try the constant
*/
- prefix = getenv("HDF5_PREFIX");
+ prefix = HDgetenv("HDF5_PREFIX");
#ifdef HDF5_PREFIX
if (!prefix)
@@ -348,7 +350,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
/* For serial:
* First use the environment variable, then try the constant
*/
- prefix = getenv("HDF5_PREFIX");
+ prefix = HDgetenv("HDF5_PREFIX");
#ifdef HDF5_PREFIX
if (!prefix)
@@ -367,14 +369,14 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
/* This is a parallel system */
char *subdir;
- if (!strcmp(prefix, HDF5_PARAPREFIX)) {
+ if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) {
/* If the prefix specifies the HDF5_PARAPREFIX directory, then
* default to using the "/tmp/$USER" or "/tmp/$LOGIN"
* directory instead. */
char *user, *login;
- user = getenv("USER");
- login = getenv("LOGIN");
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
subdir = (user ? user : login);
if (subdir) {
@@ -390,22 +392,22 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
if (!fullname[0])
/* We didn't append the prefix yet */
- strncpy(fullname, prefix, MIN(strlen(prefix), size));
+ HDstrncpy(fullname, prefix, MIN(strlen(prefix), size));
- if (strlen(fullname) + strlen(base_name) + 1 < size) {
+ if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) {
/* Append the base_name with a slash first. Multiple slashes are
* handled below. */
struct stat buf;
- if (stat(fullname, &buf) < 0)
+ if (HDstat(fullname, &buf) < 0)
/* The directory doesn't exist just yet */
- if (mkdir(fullname, 0755) < 0 && errno != EEXIST)
+ if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST)
/* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
* Default to PREFIX's original prefix value. */
- strcpy(fullname, prefix);
+ HDstrcpy(fullname, prefix);
- strcat(fullname, "/");
- strcat(fullname, base_name);
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
} else {
/* Buffer is too small */
return NULL;
@@ -415,11 +417,11 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
/* Buffer is too small */
return NULL;
}
- } else if (strlen(base_name) >= size) {
+ } else if (HDstrlen(base_name) >= size) {
/* Buffer is too small */
return NULL;
} else {
- strcpy(fullname, base_name);
+ HDstrcpy(fullname, base_name);
}
#ifdef H5_WANT_H5_V1_2_COMPAT
@@ -428,25 +430,25 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
return NULL;
switch (driver) {
- case H5F_LOW_SPLIT:
- case H5F_LOW_CORE:
- suffix = NULL;
- break;
- case H5F_LOW_FAMILY:
- suffix = "%05d.h5";
- break;
- default:
- suffix = ".h5";
- break;
+ case H5F_LOW_SPLIT:
+ case H5F_LOW_CORE:
+ suffix = NULL;
+ break;
+ case H5F_LOW_FAMILY:
+ suffix = "%05d.h5";
+ break;
+ default:
+ suffix = ".h5";
+ break;
}
#endif /* H5_WANT_H5_V1_2_COMPAT */
/* Append a suffix */
if (suffix) {
- if (strlen(fullname) + strlen(suffix) >= size)
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
return NULL;
- strcat(fullname, suffix);
+ HDstrcat(fullname, suffix);
}
/* Remove any double slashes in the filename */
@@ -491,7 +493,7 @@ h5_fileaccess(void)
H5FD_mem_t mt;
/* First use the environment variable, then the constant */
- val = getenv("HDF5_DRIVER");
+ val = HDgetenv("HDF5_DRIVER");
#ifdef HDF5_DRIVER
if (!val) val = HDF5_DRIVER;
#endif
@@ -499,26 +501,26 @@ h5_fileaccess(void)
if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
if (!val || !*val) return fapl; /*use default*/
- strncpy(s, val, sizeof s);
+ HDstrncpy(s, val, sizeof s);
s[sizeof(s)-1] = '\0';
- if (NULL==(name=strtok(s, " \t\n\r"))) return fapl;
+ if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl;
- if (!strcmp(name, "sec2")) {
+ if (!HDstrcmp(name, "sec2")) {
/* Unix read() and write() system calls */
if (H5Pset_fapl_sec2(fapl)<0) return -1;
- } else if (!strcmp(name, "stdio")) {
+ } else if (!HDstrcmp(name, "stdio")) {
/* Standard C fread() and fwrite() system calls */
if (H5Pset_fapl_stdio(fapl)<0) return -1;
- } else if (!strcmp(name, "core")) {
+ } else if (!HDstrcmp(name, "core")) {
/* In-core temporary file with 1MB increment */
if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1;
- } else if (!strcmp(name, "split")) {
+ } else if (!HDstrcmp(name, "split")) {
/* Split meta data and raw data each using default driver */
if (H5Pset_fapl_split(fapl,
"-m.h5", H5P_DEFAULT,
"-r.h5", H5P_DEFAULT)<0)
return -1;
- } else if (!strcmp(name, "multi")) {
+ } else if (!HDstrcmp(name, "multi")) {
/* Multi-file driver, general case of the split driver */
H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
hid_t memb_fapl[H5FD_MEM_NTYPES];
@@ -526,12 +528,12 @@ h5_fileaccess(void)
char sv[H5FD_MEM_NTYPES][1024];
haddr_t memb_addr[H5FD_MEM_NTYPES];
- memset(memb_map, 0, sizeof memb_map);
- memset(memb_fapl, 0, sizeof memb_fapl);
- memset(memb_name, 0, sizeof memb_name);
- memset(memb_addr, 0, sizeof memb_addr);
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(strlen(multi_letters)==H5FD_MEM_NTYPES);
+ assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
memb_fapl[mt] = H5P_DEFAULT;
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
@@ -543,16 +545,16 @@ h5_fileaccess(void)
memb_addr, FALSE)<0) {
return -1;
}
- } else if (!strcmp(name, "family")) {
+ } else if (!HDstrcmp(name, "family")) {
/* Family of files, each 1MB and using the default driver */
- if ((val=strtok(NULL, " \t\n\r"))) {
- fam_size = strtod(val, NULL) * 1024*1024;
+ if ((val=HDstrtok(NULL, " \t\n\r"))) {
+ fam_size = HDstrtod(val, NULL) * 1024*1024;
}
if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1;
- } else if (!strcmp(name, "log")) {
+ } else if (!HDstrcmp(name, "log")) {
/* Log file access */
- if ((val = strtok(NULL, " \t\n\r")))
- verbosity = strtol(val, NULL, 0);
+ if ((val = HDstrtok(NULL, " \t\n\r")))
+ verbosity = HDstrtol(val, NULL, 0);
if (H5Pset_fapl_log(fapl, NULL, (int)verbosity) < 0)
return -1;