mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
Fix for HDFFV-10554 use_append_chunks in swmr use case test failure
Fix the timing issue of the test by moving the open/close of the test file for the writer to use_append_chunk.c and use_append_mchunks.c.
This commit is contained in:
parent
3145690c95
commit
d1d2cf776d
@ -58,6 +58,6 @@ int setup_parameters(int argc, char * const argv[]);
|
||||
void show_parameters(void);
|
||||
void usage(const char *prog);
|
||||
int create_uc_file(void);
|
||||
int write_uc_file(hbool_t tosend);
|
||||
int write_uc_file(hbool_t tosend, hid_t fid);
|
||||
int read_uc_file(hbool_t towait);
|
||||
|
||||
|
@ -124,6 +124,9 @@ main(int argc, char *argv[])
|
||||
int ret_value = 0;
|
||||
int child_ret_value;
|
||||
hbool_t send_wait = FALSE;
|
||||
hid_t fapl = -1; /* File access property list */
|
||||
hid_t fid = -1; /* File ID */
|
||||
char *name; /* Test file name */
|
||||
|
||||
/* initialization */
|
||||
if (setup_parameters(argc, argv) < 0){
|
||||
@ -182,29 +185,59 @@ main(int argc, char *argv[])
|
||||
/* ============= */
|
||||
/* this process continues to launch the writer */
|
||||
printf("%d: continue as the writer process\n", mypid);
|
||||
if (write_uc_file(send_wait) < 0){
|
||||
fprintf(stderr, "write_uc_file encountered error\n");
|
||||
Hgoto_error(1);
|
||||
|
||||
name = UC_opts.filename;
|
||||
|
||||
/* Set file access proeprty list */
|
||||
if((fapl = h5_fileaccess()) < 0)
|
||||
Hgoto_error(1);
|
||||
|
||||
if(UC_opts.use_swmr)
|
||||
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
||||
Hgoto_error(1);
|
||||
|
||||
/* Open the file */
|
||||
if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
|
||||
fprintf(stderr, "H5Fopen failed\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
if(write_uc_file(send_wait, fid) < 0) {
|
||||
fprintf(stderr, "write_uc_file encountered error\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
/* If readwrite, collect exit code of child process */
|
||||
/* ================================================ */
|
||||
if (UC_opts.launch == UC_READWRITE){
|
||||
if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
|
||||
HDperror("waitpid");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
if (WIFEXITED(child_status)){
|
||||
if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
|
||||
printf("%d: child process exited with non-zero code (%d)\n",
|
||||
mypid, child_ret_value);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
} else {
|
||||
printf("%d: child process terminated abnormally\n", mypid);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
|
||||
HDperror("waitpid");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if(H5Fclose(fid) < 0) {
|
||||
fprintf(stderr, "Failed to close file id\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
/* Close the property list */
|
||||
if(H5Pclose(fapl) < 0) {
|
||||
fprintf(stderr, "Failed to property list\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
if (WIFEXITED(child_status)){
|
||||
if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
|
||||
printf("%d: child process exited with non-zero code (%d)\n",
|
||||
mypid, child_ret_value);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
} else {
|
||||
printf("%d: child process terminated abnormally\n", mypid);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -117,6 +117,9 @@ main(int argc, char *argv[])
|
||||
int ret_value = 0;
|
||||
int child_ret_value;
|
||||
hbool_t send_wait = 0;
|
||||
hid_t fapl = -1; /* File access property list */
|
||||
hid_t fid = -1; /* File ID */
|
||||
char *name; /* Test file name */
|
||||
|
||||
/* initialization */
|
||||
if (setup_parameters(argc, argv) < 0){
|
||||
@ -175,29 +178,60 @@ main(int argc, char *argv[])
|
||||
/* ============= */
|
||||
/* this process continues to launch the writer */
|
||||
printf("%d: continue as the writer process\n", mypid);
|
||||
if (write_uc_file(send_wait) < 0){
|
||||
fprintf(stderr, "write_uc_file encountered error\n");
|
||||
Hgoto_error(1);
|
||||
|
||||
name = UC_opts.filename;
|
||||
|
||||
/* Set the file access property list */
|
||||
if((fapl = h5_fileaccess()) < 0)
|
||||
Hgoto_error(1);
|
||||
|
||||
if(UC_opts.use_swmr)
|
||||
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
||||
Hgoto_error(1);
|
||||
|
||||
/* Open the file */
|
||||
if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
|
||||
fprintf(stderr, "H5Fopen failed\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
if(write_uc_file(send_wait, fid) < 0) {
|
||||
fprintf(stderr, "write_uc_file encountered error\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
|
||||
/* ================================================ */
|
||||
/* If readwrite, collect exit code of child process */
|
||||
/* ================================================ */
|
||||
if (UC_opts.launch == UC_READWRITE){
|
||||
if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
|
||||
perror("waitpid");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
if (WIFEXITED(child_status)){
|
||||
if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
|
||||
printf("%d: child process exited with non-zero code (%d)\n",
|
||||
mypid, child_ret_value);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
} else {
|
||||
printf("%d: child process terminated abnormally\n", mypid);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
|
||||
perror("waitpid");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if(H5Fclose(fid) < 0) {
|
||||
fprintf(stderr, "Failed to close file id\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
/* Close the property list */
|
||||
if(H5Pclose(fapl) < 0) {
|
||||
fprintf(stderr, "Failed to property list\n");
|
||||
Hgoto_error(1);
|
||||
}
|
||||
|
||||
if (WIFEXITED(child_status)){
|
||||
if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
|
||||
printf("%d: child process exited with non-zero code (%d)\n",
|
||||
mypid, child_ret_value);
|
||||
Hgoto_error(1);
|
||||
}
|
||||
} else {
|
||||
printf("%d: child process terminated abnormally\n", mypid);
|
||||
Hgoto_error(2);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -252,13 +252,10 @@ int create_uc_file(void)
|
||||
*
|
||||
* Return: 0 succeed; -1 fail.
|
||||
*/
|
||||
int write_uc_file(hbool_t tosend)
|
||||
int write_uc_file(hbool_t tosend, hid_t fid)
|
||||
{
|
||||
hid_t fid; /* File ID for new HDF5 file */
|
||||
hid_t dsid; /* dataset ID */
|
||||
hid_t fapl; /* File access property list */
|
||||
hid_t dcpl; /* Dataset creation property list */
|
||||
char *name;
|
||||
UC_CTYPE *buffer, *bufptr; /* data buffer */
|
||||
hsize_t cz=UC_opts.chunksize; /* Chunk size */
|
||||
hid_t f_sid; /* dataset file space id */
|
||||
@ -270,19 +267,6 @@ int write_uc_file(hbool_t tosend)
|
||||
hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */
|
||||
hsize_t i, j, k;
|
||||
|
||||
name = UC_opts.filename;
|
||||
|
||||
/* Open the file */
|
||||
if((fapl = h5_fileaccess()) < 0)
|
||||
return -1;
|
||||
if(UC_opts.use_swmr)
|
||||
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
||||
return -1;
|
||||
if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0){
|
||||
fprintf(stderr, "H5Fopen failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(tosend)
|
||||
/* Send a message that H5Fopen is complete--releasing the file lock */
|
||||
h5_send_message(WRITER_MESSAGE, NULL, NULL);
|
||||
@ -427,14 +411,6 @@ int write_uc_file(hbool_t tosend)
|
||||
fprintf(stderr, "Failed to close file space\n");
|
||||
return -1;
|
||||
}
|
||||
if (H5Pclose(fapl) < 0){
|
||||
fprintf(stderr, "Failed to property list\n");
|
||||
return -1;
|
||||
}
|
||||
if (H5Fclose(fid) < 0){
|
||||
fprintf(stderr, "Failed to close file id\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -645,6 +621,12 @@ int read_uc_file(hbool_t towait)
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if(H5Fclose(fid) < 0) {
|
||||
fprintf(stderr, "H5Fclose failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nreadererr)
|
||||
return -1;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user