diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2017-04-28 22:13:22 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2017-04-28 22:13:22 (GMT) |
commit | 734aebc39538039c6e81db63edd68eb3a2029cd2 (patch) | |
tree | a97a60916799024ba2646e7770ded47320d444c4 /test | |
parent | d3b664b6a79508d78974a347a9d450e72defb76b (diff) | |
download | hdf5-734aebc39538039c6e81db63edd68eb3a2029cd2.zip hdf5-734aebc39538039c6e81db63edd68eb3a2029cd2.tar.gz hdf5-734aebc39538039c6e81db63edd68eb3a2029cd2.tar.bz2 |
Rework of the POSIX file open permissions and macros to clean up
HDopen() calls.
Also fixed a minor const warning in the core VFD.
Diffstat (limited to 'test')
-rw-r--r-- | test/big.c | 6 | ||||
-rw-r--r-- | test/btree2.c | 8 | ||||
-rw-r--r-- | test/dsets.c | 4 | ||||
-rw-r--r-- | test/enc_dec_plist_cross_platform.c | 4 | ||||
-rw-r--r-- | test/external.c | 8 | ||||
-rw-r--r-- | test/file_image.c | 6 | ||||
-rw-r--r-- | test/fillval.c | 2 | ||||
-rw-r--r-- | test/gen_plist.c | 14 | ||||
-rw-r--r-- | test/h5test.c | 4 | ||||
-rw-r--r-- | test/istore.c | 2 | ||||
-rw-r--r-- | test/links.c | 12 | ||||
-rw-r--r-- | test/tfile.c | 8 | ||||
-rw-r--r-- | test/twriteorder.c | 12 |
13 files changed, 45 insertions, 45 deletions
@@ -172,7 +172,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; @@ -210,7 +210,7 @@ supports_big(void) int fd = -1; fsizes_t fsize = NO_FILE; - if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write a few byte at the beginning */ @@ -293,7 +293,7 @@ enough_room(hid_t fapl) /* Create files */ for (i=0; i<NELMTS(fd); i++) { HDsnprintf(name, sizeof(name), filename, i); - if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) { + if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { goto done; } if ((off_t)size != HDlseek(fd[i], (off_t)size, SEEK_SET)) { diff --git a/test/btree2.c b/test/btree2.c index 5d35cf2..4c820b3 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -8736,7 +8736,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Make a copy of the file in memory, in order to speed up deletion testing */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0000)) < 0) + if((fd = HDopen(filename, O_RDONLY)) < 0) TEST_ERROR /* Retrieve the file's size */ @@ -8833,7 +8833,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ @@ -8920,7 +8920,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ @@ -9005,7 +9005,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ diff --git a/test/dsets.c b/test/dsets.c index 4d2968e..c698033 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -569,7 +569,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) goto error; file = -1; - f = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; @@ -683,7 +683,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) goto error; file = -1; - f = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c index 5511828..1fbb41b 100644 --- a/test/enc_dec_plist_cross_platform.c +++ b/test/enc_dec_plist_cross_platform.c @@ -178,7 +178,7 @@ test_plists(const char *filename_prefix) /* Read file 1 */ testfile = H5_get_srcdir_filename(filename); - if((fd_1 = HDopen(testfile, O_RDONLY, 0666)) < 0) + if((fd_1 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR size_1 = (size_t)HDlseek(fd_1, (HDoff_t)0, SEEK_END); HDlseek(fd_1, (HDoff_t)0, SEEK_SET); @@ -195,7 +195,7 @@ test_plists(const char *filename_prefix) /* Read file 1 */ testfile = H5_get_srcdir_filename(filename); - if((fd_2 = HDopen(testfile, O_RDONLY, 0666)) < 0) + if((fd_2 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR size_2 = (size_t)HDlseek(fd_2, (HDoff_t)0, SEEK_END); HDlseek(fd_2, (HDoff_t)0, SEEK_SET); diff --git a/test/external.c b/test/external.c index d911f36..20a9ed8 100644 --- a/test/external.c +++ b/test/external.c @@ -59,9 +59,9 @@ files_have_same_contents(const char *name1, const char *name2) char buf1[1024], buf2[1024]; hbool_t ret = FALSE; /* not equal until proven otherwise */ - if((fd1 = HDopen(name1, O_RDONLY, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd1 = HDopen(name1, O_RDONLY)) < 0) goto out; - if((fd2 = HDopen(name2, O_RDONLY, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd2 = HDopen(name2, O_RDONLY)) < 0) goto out; /* Loop until files are empty or we encounter a problem */ @@ -137,7 +137,7 @@ reset_raw_data_files(void) /* Open file */ HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the @@ -171,7 +171,7 @@ reset_raw_data_files(void) /* Open file */ HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the diff --git a/test/file_image.c b/test/file_image.c index 8702b06..12f0a18 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -624,7 +624,7 @@ test_core(void) VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); /* Create file image buffer */ - fd = HDopen(copied_filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(copied_filename, O_RDONLY); VERIFY(fd > 0, "open failed"); ret = HDfstat(fd, &sb); VERIFY(ret == 0, "fstat failed"); @@ -814,7 +814,7 @@ test_get_file_image(const char * test_banner, HDsnprintf(member_file_name, 1024, file_name, i); /* open the test file using standard I/O calls */ - fd = HDopen(member_file_name, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(member_file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(size_remaining >= FAMILY_SIZE ){ @@ -862,7 +862,7 @@ test_get_file_image(const char * test_banner, VERIFY(file_image_ptr != NULL, "HDmalloc(2) failed."); /* open the test file using standard I/O calls */ - fd = HDopen(file_name, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); if(user) { diff --git a/test/fillval.c b/test/fillval.c index 8f1f53d..8c8e902 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1890,7 +1890,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) hsize_t nelmts; nelmts = max_size[0]*max_size[1]*max_size[2]*max_size[3]*max_size[4]; - if((fd=HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0 || + if((fd = HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || HDclose(fd) < 0) goto error; if(H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts*sizeof(int)) < 0) goto error; diff --git a/test/gen_plist.c b/test/gen_plist.c index 41f232d..62693bd 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -463,23 +463,23 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil /* Generate filename */ if((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, little_endian ? "le" : "be")) < 0) - assert(ret > 0); + HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); - assert(temp_buf); + HDassert(temp_buf); if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) - assert(ret > 0); + HDassert(ret > 0); - fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, 0666); - assert(fd > 0); + fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + HDassert(fd > 0); write_size = HDwrite(fd, temp_buf, temp_size); - assert(write_size == (ssize_t)temp_size); + HDassert(write_size == (ssize_t)temp_size); HDclose(fd); diff --git a/test/h5test.c b/test/h5test.c index a5cd674..8db4388 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1596,9 +1596,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) goto error; /* Copy old file into temporary file */ - if((fd_old = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd_old = HDopen(filename, O_RDONLY)) < 0) goto error; - if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666)) < 0) + if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Copy data */ diff --git a/test/istore.c b/test/istore.c index 18cf1de..c401e87 100644 --- a/test/istore.c +++ b/test/istore.c @@ -73,7 +73,7 @@ is_sparse(void) int fd; h5_stat_t sb; - if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) return 0; + if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; if (HDclose(fd) < 0) return 0; diff --git a/test/links.c b/test/links.c index 2d1ef03..7b3e37d 100644 --- a/test/links.c +++ b/test/links.c @@ -3730,7 +3730,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout") if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) - TEST_ERROR + TEST_ERROR /* * set up name for main file: @@ -3780,7 +3780,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Create external link to target file: ext_link->extlinks17:/A/Dataset */ if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* create fapl to be a "core" file without backing store */ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) @@ -3793,9 +3793,9 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* try to open the external linked target dataset */ did = H5Dopen2(fid, "ext_link", dapl_id); if(did < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening the target dataset"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening the target dataset"); + goto error; } /* Initialize the dataset */ @@ -3805,7 +3805,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* Write the data to the dataset */ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) - TEST_ERROR + TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR diff --git a/test/tfile.c b/test/tfile.c index 2d26874..50e3341 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1611,7 +1611,7 @@ test_file_ishdf5(void) /* Create non-HDF5 file and check it */ - fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666); + fd = HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd, FAIL, "HDopen"); /* Initialize information to write */ @@ -2657,7 +2657,7 @@ cal_chksum(const char *file, uint32_t *chksum) herr_t ret; /* Generic return value */ /* Open the file */ - fdes = HDopen(file, O_RDONLY, H5_POSIX_OPEN_MODE_0000); + fdes = HDopen(file, O_RDONLY); CHECK(fdes, FAIL, "HDopen"); /* Retrieve the file's size */ @@ -4340,9 +4340,9 @@ test_filespace_compatible(void) const char *filename = H5_get_srcdir_filename(OLD_FILENAME[j]); /* Corrected test file name */ /* Open and copy the test file into a temporary file */ - fd_old = HDopen(filename, O_RDONLY, H5_POSIX_OPEN_MODE_0666); + fd_old = HDopen(filename, O_RDONLY); CHECK(fd_old, FAIL, "HDopen"); - fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_OPEN_MODE_0666); + fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); CHECK(fd_new, FAIL, "HDopen"); /* Copy data */ diff --git a/test/twriteorder.c b/test/twriteorder.c index 3ecd3e0..4c86636 100644 --- a/test/twriteorder.c +++ b/test/twriteorder.c @@ -231,9 +231,9 @@ int create_wo_file(void) int ret_code; /* Create the data file */ - if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_OPEN_MODE_0666)) < 0) { - printf("WRITER: error from open\n"); - return -1; + if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) { + HDprintf("WRITER: error from open\n"); + return -1; } blkaddr=0; /* write it to partition 0 */ @@ -297,9 +297,9 @@ int read_wo_file(void) char buffer[BLOCKSIZE_DFT]; /* Open the data file */ - if ((read_fd = HDopen(DATAFILE, O_RDONLY, H5_POSIX_OPEN_MODE_0000)) < 0) { - printf("READER: error from open\n"); - return -1; + if ((read_fd = HDopen(DATAFILE, O_RDONLY)) < 0) { + HDprintf("READER: error from open\n"); + return -1; } /* keep reading the initial block address until it is non-zero before proceeding. */ while (blkaddr == 0){ |