diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2013-10-08 06:11:44 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2013-10-08 06:11:44 (GMT) |
commit | 39fc26566e18ac81c43986ed2013676e2918ded2 (patch) | |
tree | d6241c1c75a5769ad876258b182e84ff02d33e41 /test | |
parent | 43fc25841e2b4b0ad163fe967e6e0750ad3c6bba (diff) | |
download | hdf5-39fc26566e18ac81c43986ed2013676e2918ded2.zip hdf5-39fc26566e18ac81c43986ed2013676e2918ded2.tar.gz hdf5-39fc26566e18ac81c43986ed2013676e2918ded2.tar.bz2 |
[svn-r24263] Changes to do re-reads for metadata with checksums when a file is opened with SWMR access.
There are debugging printfs which will be removed when coding is finalized.
Also some bug fixes:
1) accum.c--clean up some warning messages and use new_argv/new_envp for the call to execve.
2) hl/tools/h5watch--clean up some warning messages and a bug fix for h5watch.c.
This checkin is awaiting code review feedback.
Diffstat (limited to 'test')
-rw-r--r-- | test/accum.c | 133 | ||||
-rw-r--r-- | test/swmr_generator.c | 1 | ||||
-rw-r--r-- | test/testfiles/plist_files/fapl_be | bin | 1402 -> 1421 bytes | |||
-rw-r--r-- | test/testfiles/plist_files/fapl_le | bin | 1402 -> 1421 bytes | |||
-rw-r--r-- | test/testfiles/plist_files/lapl_be | bin | 1502 -> 1521 bytes | |||
-rw-r--r-- | test/testfiles/plist_files/lapl_le | bin | 1502 -> 1521 bytes | |||
-rw-r--r-- | test/tfile.c | 566 |
7 files changed, 635 insertions, 65 deletions
diff --git a/test/accum.c b/test/accum.c index 6c89765..1a218c6 100644 --- a/test/accum.c +++ b/test/accum.c @@ -168,7 +168,7 @@ test_write_read(void) /* Allocate buffers */ write_buf = (int *)HDmalloc(1024 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(1024, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)1024, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -179,7 +179,7 @@ test_write_read(void) /* Write 1KB at Address 0 */ if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -224,7 +224,7 @@ test_write_read_nonacc_front(void) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -238,7 +238,7 @@ test_write_read_nonacc_front(void) if(accum_reset() < 0) FAIL_STACK_ERROR; if(accum_write(1024, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -283,7 +283,7 @@ test_write_read_nonacc_end(void) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -297,7 +297,7 @@ test_write_read_nonacc_end(void) if(accum_reset() < 0) FAIL_STACK_ERROR; if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(1024, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -529,7 +529,7 @@ test_accum_overlap(void) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -701,7 +701,7 @@ test_accum_overlap_clean(void) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -880,7 +880,7 @@ test_accum_non_overlap_size(void) /* Allocate buffers */ wbuf = (int *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -947,7 +947,7 @@ test_accum_overlap_size(void) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -1054,11 +1054,11 @@ test_accum_adjust(void) /* Read back and verify first write */ if(accum_read((1024 * 1024), (1024 * 1024) - 1, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, (1024 * 1024) - 1) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)((1024 * 1024) - 1)) != 0) TEST_ERROR; /* Read back and verify second write */ if(accum_read((1024 * 1024) - 1024, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1084,10 +1084,10 @@ test_accum_adjust(void) /* Read back and verify both pieces of data */ if(accum_read(1048576, 1048575, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048576) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048576) != 0) TEST_ERROR; if(accum_read(5, 1048571, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048571) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048571) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1122,7 +1122,7 @@ test_accum_adjust(void) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 1, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1162,7 +1162,7 @@ test_accum_adjust(void) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1199,7 +1199,7 @@ test_accum_adjust(void) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 5, 10, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 10) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)10) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1231,7 +1231,7 @@ test_accum_adjust(void) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1314,7 +1314,7 @@ test_read_after(void) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(512, 512, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 128) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)128) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1356,13 +1356,13 @@ test_big(void) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf); - wbuf2 = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf2); - rbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + rbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(rbuf); - zbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + zbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(zbuf); /* Initialize write buffers */ @@ -1380,12 +1380,12 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1397,14 +1397,14 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + 1024, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 2048, (BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + 1024, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 2048, (size_t)(BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1024, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1416,13 +1416,13 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), 512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(BIG_BUF_SIZE - 512, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1434,13 +1434,13 @@ test_big(void) if(accum_read(512, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf + 512, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 512, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 512, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1457,12 +1457,12 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1479,13 +1479,13 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 512, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1506,14 +1506,14 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 1024, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1024); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1024)); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1535,13 +1535,13 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1536) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1536) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1536, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1562,13 +1562,13 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(512, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1589,14 +1589,14 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 1024, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 1024, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1617,8 +1617,8 @@ test_big(void) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1670,9 +1670,9 @@ test_random_write(void) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)malloc(RANDOM_BUF_SIZE); + wbuf = (uint8_t *)malloc((size_t)RANDOM_BUF_SIZE); HDassert(wbuf); - rbuf = (uint8_t *)calloc(RANDOM_BUF_SIZE, 1); + rbuf = (uint8_t *)calloc((size_t)RANDOM_BUF_SIZE, (size_t)1); HDassert(rbuf); /* Initialize write buffer */ @@ -1756,7 +1756,7 @@ HDfprintf(stderr, "Random # seed was: %u\n", seed); if(accum_read(RANDOM_BASE_OFF, RANDOM_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read back in */ - if(HDmemcmp(wbuf, rbuf, RANDOM_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)RANDOM_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; @@ -1810,6 +1810,8 @@ test_swmr_write_big(void) unsigned u; /* Local index variable */ pid_t pid; /* Process ID */ int status; /* Status returned from child process */ + char *new_argv[] = {NULL}; + char *new_envp[] = {NULL}; TESTING("SWMR write of large metadata"); @@ -1845,9 +1847,9 @@ test_swmr_write_big(void) FAIL_STACK_ERROR; /* Allocate space for the write & read buffers */ - if((wbuf2 = (uint8_t *)HDmalloc(BIG_BUF_SIZE)) == NULL) + if((wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) FAIL_STACK_ERROR; - if((rbuf = (uint8_t *)HDmalloc(BIG_BUF_SIZE)) == NULL) + if((rbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) FAIL_STACK_ERROR; /* Initialize wbuf with "0, 1, 2...1024"*/ @@ -1861,7 +1863,7 @@ test_swmr_write_big(void) if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5P_DATASET_XFER_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data read is correct */ - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Flush the data to disk */ if(H5F_accum_reset(rf, H5P_DATASET_XFER_DEFAULT, TRUE) < 0) FAIL_STACK_ERROR; @@ -1881,7 +1883,7 @@ test_swmr_write_big(void) if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5P_DATASET_XFER_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data read is correct */ - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* The data stays in the accumulator */ /* Write a large piece of metadata [2048, BIG_BUF_SIZE] with wbuf2 */ @@ -1891,7 +1893,7 @@ test_swmr_write_big(void) if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)2048, (size_t)BIG_BUF_SIZE, H5P_DATASET_XFER_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data read is correct */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Fork child process to verify that the data at [1024, 2014] does get written to disk */ if((pid = HDfork()) < 0) { @@ -1899,7 +1901,8 @@ test_swmr_write_big(void) FAIL_STACK_ERROR; } else if(0 == pid) { /* Child process */ /* Run the reader */ - status = HDexecve(SWMR_READER, NULL, NULL); + status = HDexecve(SWMR_READER, new_argv, new_envp); + printf("errno from execve = %s\n", strerror(errno)); FAIL_STACK_ERROR; } diff --git a/test/swmr_generator.c b/test/swmr_generator.c index f0fcee6..bad992b 100644 --- a/test/swmr_generator.c +++ b/test/swmr_generator.c @@ -332,6 +332,7 @@ int main(int argc, const char *argv[]) gettimeofday(&t, NULL); random_seed = (unsigned)((t.tv_sec * 1000) + t.tv_usec); } /* end if */ + /* random_seed = 125092666; */ srandom(random_seed); /* ALWAYS emit the random seed for possible debugging */ fprintf(stderr, "Using generator random seed (used in sparse test only): %u\n", random_seed); diff --git a/test/testfiles/plist_files/fapl_be b/test/testfiles/plist_files/fapl_be Binary files differindex 8fcefa2..24e944c 100644 --- a/test/testfiles/plist_files/fapl_be +++ b/test/testfiles/plist_files/fapl_be diff --git a/test/testfiles/plist_files/fapl_le b/test/testfiles/plist_files/fapl_le Binary files differindex 8fcefa2..24e944c 100644 --- a/test/testfiles/plist_files/fapl_le +++ b/test/testfiles/plist_files/fapl_le diff --git a/test/testfiles/plist_files/lapl_be b/test/testfiles/plist_files/lapl_be Binary files differindex 30f52a4..2ab61ed 100644 --- a/test/testfiles/plist_files/lapl_be +++ b/test/testfiles/plist_files/lapl_be diff --git a/test/testfiles/plist_files/lapl_le b/test/testfiles/plist_files/lapl_le Binary files differindex 30f52a4..2ab61ed 100644 --- a/test/testfiles/plist_files/lapl_le +++ b/test/testfiles/plist_files/lapl_le diff --git a/test/tfile.c b/test/tfile.c index 07e6ab1..200279c 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -3566,6 +3566,571 @@ test_swmr_read(void) /**************************************************************** ** +** test_read_attempts(): +** This test checks whether the public routines H5Pset_read_attempts() +** and H5Pget_read_attempts() work properly. +** +*****************************************************************/ +static void +test_read_attempts(void) +{ + hid_t fapl; /* File access property list */ + hid_t file_fapl; /* The file's access property list */ + hid_t fid, fid1, fid2, fid3; /* File IDs */ + unsigned attempts; /* The # of read attempts */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing H5Fget/set_read_attempts()\n")); + + /* + * Set A: + * Tests on verifying the # of read attempts when: + * --setting/getting read attemps from a copy of the + * file access property list. + */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Get # of read attempts -- should be the default: 1 */ + ret = H5Pget_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 1, "H5Pget_read_attempts"); + + /* Set the # of read attempts to 0--should fail */ + ret = H5Pset_read_attempts(fapl, 0); + VERIFY(ret, FAIL, "H5Pset_read_attempts"); + + /* Set the # of read attempts to a # > 0--should succeed */ + ret = H5Pset_read_attempts(fapl, 9); + VERIFY(ret, 0, "H5Pset_read_attempts"); + + /* Retrieve the # of read attempts -- should succeed and equal to 9 */ + ret = H5Pget_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 9, "H5Pget_read_attempts"); + + /* Set the # of read attempts to the non-SWMR access default: H5F_READ_ATTEMPTS --should succeed */ + ret = H5Pset_read_attempts(fapl, H5F_READ_ATTEMPTS); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + + /* Retrieve the # of read attempts -- should succeed and equal to H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Set the # of read attempts to the SWMR access default: H5F_SWMR_READ_ATEMPTS --should succeed */ + ret = H5Pset_read_attempts(fapl, H5F_SWMR_READ_ATTEMPTS); + VERIFY(ret, 0, "H5Pset_read_attempts"); + + /* Retrieve the # of read attempts -- should succeed and equal to H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* + * Set B: + * Tests on verifying read attempts when: + * --create a file with non-SWMR access + * --opening files with SWMR access + * --using default or non-default file access property list + */ + /* Test 1 */ + /* Create a file with non-SWMR access and default fapl */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 2 */ + /* Open the file with SWMR access and default fapl */ + fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Fget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 3 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open the file with SWMR access and fapl (non-default & set to 9) */ + fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be 9 */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 9, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 4 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 1); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open the file with SWMR access and fapl (non-default & set to 1) */ + fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should succeed and equal to 1 */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 1, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 5 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Open the file with SWMR_READ and fapl (non-default but unset) */ + fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* + * Set C: + * Tests on verifying read attempts when: + * --create a file with SWMR access + * --opening files with non-SWMR access + * --using default or non-default file access property list + */ + /* Test 1 */ + /* Create a file with non-SWMR access and default fapl */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 2 */ + /* Open the file with non-SWMR access and default fapl */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 3 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open the file with SWMR access and fapl (non-default & set to 9) */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 4 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 1); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open the file with SWMR access and fapl (non-default & set to 1) */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should succeed and equal to 1 */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 1, "H5Fget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Test 5 */ + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Open the file with SWMR_READ and fapl (non-default but unset) */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Pget_access_plist"); + + /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Fget_read_attempts"); + + /* Close the file */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + + + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Create a file */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open file again with SWMR access and default fapl */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open file again with SWMR access and default fapl */ + fid = H5Fopen(FILE1, H5F_ACC_SWMR_READ, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Set D: + * Tests on verifying read attempts when: + * --create with non-SWMR access + * --opening files with SWMR access + * --H5reopen the files + */ + + /* Create a file */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open file again with SWMR access and default fapl */ + fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open file again with SWMR access and fapl (non-default & set to 9) */ + fid2 = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); + CHECK(fid3, FAIL, "H5Fopen"); + + /* Re-open fid1 */ + fid = H5Freopen(fid1); + CHECK(fid, FAIL, "H5Freopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Fget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open fid2 */ + fid = H5Freopen(fid2); + CHECK(fid, FAIL, "H5Pclose"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should be 9 */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, 9, "H5Pget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close all the files */ + ret=H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + ret=H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Set E: + * Tests on verifying read attempts when: + * --create with SWMR access + * --opening files with non-SWMR access + * --H5reopen the files + */ + + /* Create a file */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open file again with non-SWMR access and default fapl */ + fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Create a copy of file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the # of read attempts */ + ret = H5Pset_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_read_attempts"); + + /* Open file again with non-SWMR access and fapl (non-default & set to 9) */ + fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid3, FAIL, "H5Fopen"); + + /* Re-open fid1 */ + fid = H5Freopen(fid1); + CHECK(fid, FAIL, "H5Freopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + /* Retrieve the # of read attempts from file fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Fget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open fid2 */ + fid = H5Freopen(fid2); + CHECK(fid, FAIL, "H5Freopen"); + + /* Get file's fapl */ + file_fapl = H5Fget_access_plist(fid); + CHECK(file_fapl, FAIL, "H5Fget_access_plist"); + + /* Retrieve the # of read attempts from file fapl -- should be H5F_READ_ATTEMPTS */ + ret = H5Pget_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_read_attempts"); + VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + + /* Close the file's fapl */ + ret = H5Pclose(file_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close all the files */ + ret=H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + ret=H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + + +} /* end test_read_attempts() */ + +/**************************************************************** +** ** test_deprec(): ** Test deprecated functionality. ** @@ -3749,6 +4314,7 @@ test_file(void) test_libver_macros2(); /* Test the macros for library version comparison */ test_swmr_write(); /* Tests for SWMR write access flag */ test_swmr_read(); /* Tests for SWMR read access flag */ + test_read_attempts(); /* Tests for public routine H5Fget/set_read_attempts() */ #ifndef H5_NO_DEPRECATED_SYMBOLS test_deprec(); /* Test deprecated routines */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ |