diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2007-04-19 16:18:07 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2007-04-19 16:18:07 (GMT) |
commit | 52d6bf13e665e60420e03b995f9de65664ac5029 (patch) | |
tree | 048a6b0061fa24af7a64ceba36d9d5fd670bdc54 /test/big.c | |
parent | 2645021a3d2cfd5716f5cdd8e71b0560aaef59c4 (diff) | |
download | hdf5-52d6bf13e665e60420e03b995f9de65664ac5029.zip hdf5-52d6bf13e665e60420e03b995f9de65664ac5029.tar.gz hdf5-52d6bf13e665e60420e03b995f9de65664ac5029.tar.bz2 |
[svn-r13689] 1. changed the HDlseek to be lseek64 and HDfseek to be fseeko if available, to support big
files. 2. added a check in test/big.c to make sure the system supports big file.
Tested on liberty, smirom, copper, and sol.
Diffstat (limited to 'test/big.c')
-rw-r--r-- | test/big.c | 61 |
1 files changed, 57 insertions, 4 deletions
@@ -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 @@ -133,6 +136,46 @@ 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 @@ -548,13 +591,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) @@ -567,7 +621,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); |