diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2007-04-04 19:59:00 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2007-04-04 19:59:00 (GMT) |
commit | 3431f74c438b25e7aeba9062ed1e948899457b46 (patch) | |
tree | ed7a1aa1282e74a0a4646762ce82f29b1749dbec /test/big.c | |
parent | ea63d5fb19e8b260178e6f76e8ed0504ded148a3 (diff) | |
download | hdf5-3431f74c438b25e7aeba9062ed1e948899457b46.zip hdf5-3431f74c438b25e7aeba9062ed1e948899457b46.tar.gz hdf5-3431f74c438b25e7aeba9062ed1e948899457b46.tar.bz2 |
[svn-r13588] A support of files bigger than 2GB for STDIO driver. Configure will
check if fseeko is available. Using it instead of fseek can support
big files because the offset is of type off_t not long int. Also
added the test for STDIO in big.c.
Diffstat (limited to 'test/big.c')
-rw-r--r-- | test/big.c | 50 |
1 files changed, 34 insertions, 16 deletions
@@ -21,6 +21,7 @@ const char *FILENAME[] = { "big", + "stdio", NULL }; @@ -122,7 +123,7 @@ is_sparse(void) if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666))<0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; - if (5!=HDwrite(fd, "hello", 5)) return 0; + if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd)<0) return 0; if (HDstat("x.h5", &sb)<0) return 0; if (HDunlink("x.h5")<0) return 0; @@ -176,7 +177,7 @@ enough_room(hid_t fapl) if ((off_t)size != HDlseek(fd[i], (off_t)size, SEEK_SET)) { goto done; } - if (1!=HDwrite(fd[i], "X", 1)) { + if (1!=HDwrite(fd[i], "X", (size_t)1)) { goto done; } } @@ -213,17 +214,16 @@ enough_room(hid_t fapl) *------------------------------------------------------------------------- */ static int -writer (hid_t fapl, int wrt_n) +writer (char* filename, hid_t fapl, int wrt_n) { hsize_t size1[4] = {8, 1024, 1024, 1024}; hsize_t size2[1] = {GB8LL}; hsize_t hs_start[1]; hsize_t hs_size[1]; hid_t file=-1, space1=-1, space2=-1, mem_space=-1, d1=-1, d2=-1; - int *buf = malloc (sizeof(int) * WRT_SIZE); + int *buf = (int*)malloc (sizeof(int) * WRT_SIZE); int i, j; FILE *out = fopen(DNAME, "w"); - char filename[1024]; hid_t dcpl; TESTING("large dataset write"); @@ -232,7 +232,6 @@ writer (hid_t fapl, int wrt_n) * We might be on a machine that has 32-bit files, so create an HDF5 file * which is a family of files. Each member of the family will be 1GB */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) { goto error; } @@ -324,22 +323,20 @@ writer (hid_t fapl, int wrt_n) *------------------------------------------------------------------------- */ static int -reader (hid_t fapl) +reader (char *filename, hid_t fapl) { FILE *script = NULL; hid_t file=-1, mspace=-1, fspace=-1, d2=-1; char ln[128], *s; hsize_t hs_offset[1]; hsize_t hs_size[1] = {WRT_SIZE}; - int *buf = malloc (sizeof(int) * WRT_SIZE); + int *buf = (int*)malloc (sizeof(int) * WRT_SIZE); int i, j, zero, wrong, nerrors=0; - char filename[1024]; /* Open script file */ script = fopen (DNAME, "r"); /* Open HDF5 file */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error; /* Open the dataset */ @@ -350,7 +347,7 @@ reader (hid_t fapl) if ((mspace = H5Screate_simple (1, hs_size, hs_size))<0) goto error; /* Read each region */ - while (fgets (ln, sizeof(ln), script)) { + while (fgets (ln, (int)sizeof(ln), script)) { if ('#'!=ln[0]) break; i = (int)strtol (ln+1, &s, 10); hs_offset[0] = HDstrtoll (s, NULL, 0); @@ -463,6 +460,7 @@ main (int ac, char **av) hsize_t family_size_def; /* default family file size */ double family_size_def_dbl; /* default family file size */ int cflag=1; /* check file system before test */ + char filename[1024]; /* parameters setup */ family_size_def = FAMILY_SIZE; @@ -501,7 +499,8 @@ main (int ac, char **av) h5_reset(); fapl = h5_fileaccess(); - /* The file driver must be the family driver */ + /* Test big file with the family driver */ + puts("Testing big file with the Family Driver "); if (H5FD_FAMILY!=H5Pget_driver(fapl)) { HDfprintf(stdout, "Changing file drivers to the family driver, %Hu bytes each\n", @@ -546,10 +545,29 @@ main (int ac, char **av) } } - /* Do the test */ - if (writer(fapl, WRT_N)) goto error; - if (reader(fapl)) goto error; - puts("All big tests passed."); + /* Do the test with the Family Driver */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + 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."); + + + /* Test big file with the STDIO driver */ + puts("\nTesting big file with the STDIO Driver "); + + fapl = h5_fileaccess(); + if(H5Pset_fapl_stdio(fapl)<0) + + HDmemset(filename, 0, sizeof(filename)); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + + if (writer(filename, fapl, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; + puts("Test passed with the STDIO Driver."); quit: /* End with normal exit code */ |