diff options
-rw-r--r-- | src/H5private.h | 12 | ||||
-rw-r--r-- | test/big.c | 60 |
2 files changed, 66 insertions, 6 deletions
diff --git a/src/H5private.h b/src/H5private.h index c9d92e5..17b6e75 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -593,7 +593,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfrexpl(X,N) frexp(X,N) #endif /* H5_HAVE_FREXPL */ /* fscanf() variable arguments */ -#define HDfseek(F,O,W) fseek(F,O,W) +#ifdef H5_HAVE_FSEEKO + #define HDfseek(F,O,W) fseeko(F,O,W) +#else + #define HDfseek(F,O,W) fseek(F,O,W) +#endif #define HDfsetpos(F,P) fsetpos(F,P) /* definitions related to the file stat utilities. * Windows have its own function names. @@ -677,7 +681,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDlseek(F,O,W) _lseeki64(F,O,W) #endif #else -#define HDlseek(F,O,W) lseek(F,O,W) + #ifdef H5_HAVE_FSEEK64 + #define HDlseek(F,O,W) lseek64(F,O,W) + #else + #define HDlseek(F,O,W) lseek(F,O,W) + #endif #endif #define HDmalloc(Z) malloc(Z) #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) @@ -31,6 +31,9 @@ const char *FILENAME[] = { #define WRT_SIZE 4*1024 #define FAMILY_SIZE 1024*1024*1024 +/* Define big file as 2GB */ +#define BIG_FILE 0x80000000UL + #define MAX_TRIES 100 #if H5_SIZEOF_LONG_LONG >= 8 @@ -136,6 +139,45 @@ is_sparse(void) /*------------------------------------------------------------------------- + * Function: supports_big + * + * Purpose: Determines if the file system of the current working + * directory supports big files. + * + * Return: Success: Non-zero if big files are supported; zero + * otherwise. + * + * Failure: zero + * + * Programmer: Raymond Lu + * Wednesday, April 18, 2007 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +supports_big(void) +{ + int fd; + + if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666))<0) return 0; + + /* Write a few bytes at 2GB */ + if (HDlseek(fd, BIG_FILE, SEEK_SET)!=BIG_FILE) return 0; + if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; + + /* Write a few bytes at 4GB */ + if (HDlseek(fd, 2*BIG_FILE, SEEK_SET) != 2*BIG_FILE) return 0; + if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; + + if (HDclose(fd)<0) return 0; + + return (1); +} + + +/*------------------------------------------------------------------------- * Function: enough_room * * Purpose: Tries to create a bunch of sparse files to see if quotas will @@ -551,13 +593,24 @@ main (int ac, char **av) if (writer(filename, fapl, WRT_N)) goto error; if (reader(filename, fapl)) goto error; - /* Clean up the test file */ - if (h5_cleanup(FILENAME, fapl)) remove(DNAME); puts("Test passed with the Family Driver."); + /* + * We shouldn't run this test if the file system doesn't support big files + * because we would generate multi-gigabyte files. + */ + puts("\nChecking if file system supports big files..."); + if (!supports_big()) { + puts("Tests for sec2 and stdio are skipped because file system does not support big files."); + usage(); + goto quit; + } + + /* Clean up the test file */ + if (h5_cleanup(FILENAME, fapl)) remove(DNAME); /* Test big file with the SEC2 driver */ - puts("\nTesting big file with the SEC2 Driver "); + puts("Testing big file with the SEC2 Driver "); fapl = h5_fileaccess(); if(H5Pset_fapl_sec2(fapl)<0) @@ -570,7 +623,6 @@ main (int ac, char **av) puts("Test passed with the SEC2 Driver."); - #ifdef H5_HAVE_FSEEKO /* Clean up the test file */ if (h5_cleanup(FILENAME, fapl)) remove(DNAME); |