diff options
Diffstat (limited to 'tools/misc')
-rw-r--r-- | tools/misc/h5mkgrp.c | 2 | ||||
-rw-r--r-- | tools/misc/h5repart.c | 54 | ||||
-rw-r--r-- | tools/misc/h5repart_gentest.c | 20 | ||||
-rw-r--r-- | tools/misc/testh5mkgrp.sh | 13 | ||||
-rw-r--r-- | tools/misc/testh5repart.sh.in | 16 |
5 files changed, 58 insertions, 47 deletions
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c index 1452a64..a6fdc56 100644 --- a/tools/misc/h5mkgrp.c +++ b/tools/misc/h5mkgrp.c @@ -319,6 +319,6 @@ main(int argc, const char *argv[]) /* Shut down h5tools lib */ h5tools_close(); - return 0; + return EXIT_SUCCESS; } /* end main() */ diff --git a/tools/misc/h5repart.c b/tools/misc/h5repart.c index 91df7b6..2374059 100644 --- a/tools/misc/h5repart.c +++ b/tools/misc/h5repart.c @@ -98,7 +98,7 @@ usage (const char *progname) "`k' for kB.\n"); fprintf(stderr, "File family names include an integer printf " "format such as `%%d'\n"); - exit (1); + exit (EXIT_FAILURE); } @@ -262,12 +262,12 @@ main (int argc, char *argv[]) if ((src=HDopen(src_name, O_RDONLY,0))<0) { perror (src_name); - exit (1); + exit (EXIT_FAILURE); } if (HDfstat(src, &sb)<0) { perror ("fstat"); - exit (1); + exit (EXIT_FAILURE); } src_size = src_act_size = sb.st_size; if (verbose) fprintf (stderr, "< %s\n", src_name); @@ -282,7 +282,7 @@ main (int argc, char *argv[]) if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { perror (dst_name); - exit (1); + exit (EXIT_FAILURE); } if (verbose) fprintf (stderr, "> %s\n", dst_name); @@ -308,10 +308,10 @@ main (int argc, char *argv[]) n = (size_t)MIN ((off_t)n, src_act_size-src_offset); if ((nio=HDread (src, buf, n))<0) { perror ("read"); - exit (1); + exit (EXIT_FAILURE); } else if ((size_t)nio!=n) { fprintf (stderr, "%s: short read\n", src_name); - exit (1); + exit (EXIT_FAILURE); } for (i=0; i<n; i++) { if (buf[i]) break; @@ -331,14 +331,14 @@ main (int argc, char *argv[]) if (need_write) { if (need_seek && HDlseek (dst, dst_offset, SEEK_SET)<0) { perror ("HDlseek"); - exit (1); + exit (EXIT_FAILURE); } if ((nio=HDwrite (dst, buf, n))<0) { perror ("write"); - exit (1); + exit (EXIT_FAILURE); } else if ((size_t)nio!=n) { fprintf (stderr, "%s: short write\n", dst_name); - exit (1); + exit (EXIT_FAILURE); } need_seek = FALSE; } else { @@ -366,11 +366,11 @@ main (int argc, char *argv[]) break; } else if (src<0) { perror (src_name); - exit (1); + exit (EXIT_FAILURE); } if (HDfstat (src, &sb)<0) { perror ("fstat"); - exit (1); + exit (EXIT_FAILURE); } src_act_size = sb.st_size; if (src_act_size>src_size) { @@ -391,26 +391,26 @@ main (int argc, char *argv[]) if (0==dst_membno) { if (HDlseek (dst, dst_size-1, SEEK_SET)<0) { perror ("HDHDlseek"); - exit (1); + exit (EXIT_FAILURE); } if (HDread (dst, buf, 1)<0) { perror ("read"); - exit (1); + exit (EXIT_FAILURE); } if (HDlseek (dst, dst_size-1, SEEK_SET)<0) { perror ("HDlseek"); - exit (1); + exit (EXIT_FAILURE); } if (HDwrite (dst, buf, 1)<0) { perror ("write"); - exit (1); + exit (EXIT_FAILURE); } } HDclose (dst); sprintf (dst_name, dst_gen_name, ++dst_membno); if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { perror (dst_name); - exit (1); + exit (EXIT_FAILURE); } dst_offset = 0; need_seek = FALSE; @@ -426,19 +426,19 @@ main (int argc, char *argv[]) if (need_seek) { if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) { perror ("HDlseek"); - exit (1); + exit (EXIT_FAILURE); } if (HDread (dst, buf, 1)<0) { perror ("read"); - exit (1); + exit (EXIT_FAILURE); } if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) { perror ("HDlseek"); - exit (1); + exit (EXIT_FAILURE); } if (HDwrite (dst, buf, 1)<0) { perror ("write"); - exit (1); + exit (EXIT_FAILURE); } } HDclose (dst); @@ -447,7 +447,7 @@ main (int argc, char *argv[]) * These private properties are for this tool only. */ if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) { perror ("H5Pcreate"); - exit (1); + exit (EXIT_FAILURE); } if(family_to_sec2) { @@ -456,7 +456,7 @@ main (int argc, char *argv[]) * driver information saved in the superblock. */ if(H5Pset(fapl, H5F_ACS_FAMILY_TO_SEC2_NAME, &family_to_sec2) < 0) { perror ("H5Pset"); - exit (1); + exit (EXIT_FAILURE); } } else { /* Modify family size saved in superblock through private property. It signals @@ -464,14 +464,14 @@ main (int argc, char *argv[]) * This private property is for this tool only. */ if(H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) { perror ("H5Pset_fapl_family"); - exit (1); + exit (EXIT_FAILURE); } /* Set the property of the new member size as hsize_t */ hdsize = dst_size; if(H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) { perror ("H5Pset"); - exit (1); + exit (EXIT_FAILURE); } } @@ -488,16 +488,16 @@ main (int argc, char *argv[]) if(file>=0) { if(H5Fclose(file)<0) { perror ("H5Fclose"); - exit (1); + exit (EXIT_FAILURE); } } if(H5Pclose(fapl)<0) { perror ("H5Pclose"); - exit (1); + exit (EXIT_FAILURE); } /* Free resources and return */ free (buf); - return 0; + return EXIT_SUCCESS; } diff --git a/tools/misc/h5repart_gentest.c b/tools/misc/h5repart_gentest.c index 9fcc9c8..8420da5 100644 --- a/tools/misc/h5repart_gentest.c +++ b/tools/misc/h5repart_gentest.c @@ -39,29 +39,29 @@ int main(void) /* Set property list and file name for FAMILY driver */ if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) { perror ("H5Pcreate"); - exit (1); + exit (EXIT_FAILURE); } if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) { perror ("H5Pset_fapl_family"); - exit (1); + exit (EXIT_FAILURE); } if((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { perror("H5Fcreate"); - exit(1); + exit(EXIT_FAILURE); } /* Create and write dataset */ if((space = H5Screate_simple(2, dims, NULL)) < 0) { perror("H5Screate_simple"); - exit(1); + exit(EXIT_FAILURE); } if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { perror("H5Dcreate2"); - exit(1); + exit(EXIT_FAILURE); } @@ -71,28 +71,28 @@ int main(void) if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) { perror("H5Dwrite"); - exit(1); + exit(EXIT_FAILURE); } if(H5Sclose(space) < 0) { perror ("H5Sclose"); - exit (1); + exit (EXIT_FAILURE); } if(H5Dclose(dset) < 0) { perror ("H5Dclose"); - exit (1); + exit (EXIT_FAILURE); } if(H5Pclose(fapl) < 0) { perror ("H5Pclose"); - exit (1); + exit (EXIT_FAILURE); } if(H5Fclose(file) < 0) { perror ("H5Fclose"); - exit (1); + exit (EXIT_FAILURE); } puts(" PASSED"); fflush(stdout); diff --git a/tools/misc/testh5mkgrp.sh b/tools/misc/testh5mkgrp.sh index 50ac23b..e6cb96e 100644 --- a/tools/misc/testh5mkgrp.sh +++ b/tools/misc/testh5mkgrp.sh @@ -19,6 +19,10 @@ # Tuesday, February 13, 2007 # +TESTNAME=h5mkgrp +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + H5MKGRP=h5mkgrp # The tool name H5MKGRP_BIN=`pwd`/$H5MKGRP # The path of the tool binary H5LS=h5ls # The h5ls tool name @@ -182,8 +186,9 @@ RUNTEST h5mkgrp_nested_mult_latest.h5 "-lp" /one/two /three/four if test $nerrors -eq 0 ; then - echo "All h5mkgrp tests passed." + echo "All $TESTNAME tests passed." + exit $EXIT_SUCCESS +else + echo "$TESTNAME tests failed with $nerrors errors." + exit $EXIT_FAILURE fi - -exit $nerrors - diff --git a/tools/misc/testh5repart.sh.in b/tools/misc/testh5repart.sh.in index 62c99d7..7d4e020 100644 --- a/tools/misc/testh5repart.sh.in +++ b/tools/misc/testh5repart.sh.in @@ -15,6 +15,10 @@ # # Tests for the h5repart tool +TESTNAME=h5repart +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + REPART=h5repart # The tool name REPART_BIN=`pwd`/$REPART # The path of the tool binary @@ -100,14 +104,16 @@ TOOLTEST -m 20000 -family_to_sec2 family_file%05d.h5 $actual_dir/family_to_sec2. OUTPUTTEST echo -if test $nerrors -eq 0 ; then - echo "All $REPART tests passed." -fi - # Clean up output file if test -z "$HDF5_NOCLEANUP"; then cd $actual_dir rm -f fst_family*.h5 scd_family*.h5 family_to_sec2.h5 fi -exit $nerrors +if test $nerrors -eq 0 ; then + echo "All $TESTNAME tests passed." + exit $EXIT_SUCCESS +else + echo "$TESTNAME tests failed with $nerrors errors." + exit $EXIT_FAILURE +fi |