summaryrefslogtreecommitdiffstats
path: root/test/use_append_mchunks.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/use_append_mchunks.c')
-rw-r--r--test/use_append_mchunks.c110
1 files changed, 72 insertions, 38 deletions
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index 9ee37cb..0414628 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -117,10 +117,13 @@ 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){
- Hgoto_error(1);
+ Hgoto_error(1);
}
/* Determine the need to send/wait message file*/
@@ -138,20 +141,20 @@ main(int argc, char *argv[])
/* Create file */
/* ============*/
if (UC_opts.launch != UC_READER){
- printf("Creating skeleton data file for test...\n");
+ HDprintf("Creating skeleton data file for test...\n");
if (create_uc_file() < 0){
- fprintf(stderr, "***encounter error\n");
+ HDfprintf(stderr, "***encounter error\n");
Hgoto_error(1);
}else
- printf("File created.\n");
+ HDprintf("File created.\n");
}
if (UC_opts.launch==UC_READWRITE){
- /* fork process */
- if((childpid = fork()) < 0) {
- perror("fork");
- Hgoto_error(1);
- };
+ /* fork process */
+ if((childpid = fork()) < 0) {
+ perror("fork");
+ Hgoto_error(1);
+ };
};
mypid = getpid();
@@ -159,53 +162,84 @@ main(int argc, char *argv[])
/* launch reader */
/* ============= */
if (UC_opts.launch != UC_WRITER){
- /* child process launch the reader */
- if(0 == childpid) {
- printf("%d: launch reader process\n", mypid);
- if (read_uc_file(send_wait) < 0){
- fprintf(stderr, "read_uc_file encountered error\n");
- exit(1);
- }
- exit(0);
- }
+ /* child process launch the reader */
+ if(0 == childpid) {
+ HDprintf("%d: launch reader process\n", mypid);
+ if (read_uc_file(send_wait) < 0){
+ HDfprintf(stderr, "read_uc_file encountered error\n");
+ HDexit(1);
+ }
+ HDexit(0);
+ }
}
/* ============= */
/* launch writer */
/* ============= */
/* 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);
+ HDprintf("%d: continue as the writer process\n", mypid);
+
+ 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) {
+ HDfprintf(stderr, "H5Fopen failed\n");
+ Hgoto_error(1);
+ }
+
+ if(write_uc_file(send_wait, fid) < 0) {
+ HDfprintf(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) {
+ HDfprintf(stderr, "Failed to close file id\n");
+ Hgoto_error(1);
+ }
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0) {
+ HDfprintf(stderr, "Failed to close the property list\n");
+ Hgoto_error(1);
+ }
+
+ if (WIFEXITED(child_status)){
+ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+ HDprintf("%d: child process exited with non-zero code (%d)\n",
+ mypid, child_ret_value);
+ Hgoto_error(1);
+ }
+ } else {
+ HDprintf("%d: child process terminated abnormally\n", mypid);
+ Hgoto_error(2);
+ }
}
done:
/* Print result and exit */
if (ret_value != 0){
- printf("Error(s) encountered\n");
+ HDprintf("Error(s) encountered\n");
}else{
- printf("All passed\n");
+ HDprintf("All passed\n");
}
return(ret_value);