From f40a245ce239b9597efa815d70d1d9f005fbafdc Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sat, 26 Dec 2009 03:36:37 -0500 Subject: [svn-r18055] Bug fix: 1192 Description: Fixed exit code (sometimes return code in Main) to follow the HDF5 standards. Tested: H5committested plus serial test in Jam. --- tools/h5copy/h5copy.c | 4 +-- tools/h5copy/testh5copy.sh | 13 ++++++--- tools/h5diff/testh5diff.sh | 13 ++++++--- tools/h5diff/testph5diff.sh | 14 +++++----- tools/h5dump/testh5dump.sh.in | 15 ++++++----- tools/h5dump/testh5dumpxml.sh.in | 14 ++++++---- tools/h5import/h5import.c | 2 +- tools/h5import/h5importtestutil.sh | 23 ++++++++-------- tools/h5jam/h5jam.c | 2 +- tools/h5jam/testh5jam.sh.in | 12 ++++++--- tools/h5repack/h5repack.sh.in | 12 ++++++--- tools/h5stat/testh5stat.sh.in | 14 ++++++---- tools/misc/h5mkgrp.c | 2 +- tools/misc/h5repart.c | 54 +++++++++++++++++++------------------- tools/misc/h5repart_gentest.c | 20 +++++++------- tools/misc/testh5mkgrp.sh | 13 ++++++--- tools/misc/testh5repart.sh.in | 16 +++++++---- 17 files changed, 146 insertions(+), 97 deletions(-) diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index f2a41ae..2d5b95d 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -428,7 +428,7 @@ main (int argc, const char *argv[]) h5tools_close(); - return 0; + return EXIT_SUCCESS; error: printf("Error in copy...Exiting\n"); @@ -449,6 +449,6 @@ error: h5tools_close(); - return 1; + return EXIT_FAILURE; } diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index c374e08..4f1d8cc 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -19,6 +19,10 @@ # Thursday, July 20, 2006 # +TESTNAME=h5copy +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + H5COPY=h5copy # The tool name H5COPY_BIN=`pwd`/$H5COPY # The path of the tool binary H5DIFF=h5diff # The h5diff tool name @@ -300,8 +304,9 @@ COPYOBJECTS if test $nerrors -eq 0 ; then - echo "All h5copy 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/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index d6550fd..f95e260 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -56,6 +56,10 @@ FILE10="$INDIR/$SRCFILE10" FILE11="$INDIR/$SRCFILE11" +TESTNAME=h5diff +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + H5DIFF=h5diff # The tool name H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary @@ -80,6 +84,7 @@ test -d ./testfiles || mkdir ./testfiles while [ $# -gt 0 ]; do case "$1" in -p) # reset the tool name and bin to run ph5diff tests + TESTNAME=ph5diff H5DIFF=ph5diff # The tool name H5DIFF_BIN=`pwd`/$H5DIFF pmode=yes @@ -616,7 +621,9 @@ TOOLTEST h5diff_207.txt -c $FILE2 $FILE2 g2/dset8 g2/dset9 # ############################################################################## if test $nerrors -eq 0 ; then - echo "All $H5DIFF 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/h5diff/testph5diff.sh b/tools/h5diff/testph5diff.sh index 1375756..0734d21 100755 --- a/tools/h5diff/testph5diff.sh +++ b/tools/h5diff/testph5diff.sh @@ -19,6 +19,10 @@ if test -z "$srcdir"; then srcdir=. fi +TESTNAME=ph5diff +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + TOOL=${srcdir}/testh5diff.sh nerrors=0 @@ -53,12 +57,10 @@ TOOLTEST() { # testphdf5 test using the MPI-POSIX VFL driver TOOLTEST -p -# Emit message about testing status +# no need to print any message since this is just a shell to invoke +# testh5diff.sh which has already printed the result. Just exit. if test $nerrors -eq 0 ; then - echo "All $TEST_APP tests passed." + exit $EXIT_SUCCESS else - echo "ERROR! One or more $TOOL tests failed." + exit $EXIT_FAILURE fi - -# Propagate a useful exit code -exit $nerrors diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 9e6cb01..82d09fc 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -23,6 +23,10 @@ USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" USE_FILTER_NBIT="@USE_FILTER_NBIT@" USE_FILTER_SCALEOFFSET="@USE_FILTER_SCALEOFFSET@" +TESTNAME=h5dump +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + DUMPER=h5dump # The tool name DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary TESTDIR=`pwd`/../testfiles @@ -509,11 +513,10 @@ TOOLTEST textlinksrc.ddl textlinksrc.h5 TOOLTEST textlinkfar.ddl textlinkfar.h5 - - if test $nerrors -eq 0 ; then - echo "All $DUMPER 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/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in index 3e81a05..c4c8657 100755 --- a/tools/h5dump/testh5dumpxml.sh.in +++ b/tools/h5dump/testh5dumpxml.sh.in @@ -15,6 +15,10 @@ # # Tests for the h5dump tool +TESTNAME=h5dumpxml +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + H5_LONE_COLON="@H5_LONE_COLON@" DUMPER=h5dump # The tool name @@ -185,10 +189,10 @@ TOOLTEST torderattr3.h5.xml --xml -H --sort_by=creation_order --sort_order=ascen TOOLTEST torderattr4.h5.xml --xml -H --sort_by=creation_order --sort_order=descending torderattr.h5 - - if test $nerrors -eq 0 ; then - echo "All $DUMPER 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/h5import/h5import.c b/tools/h5import/h5import.c index 60ef494..e9e7dac 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) case 6: /* -h found; help, then exit */ help(argv[0]); - exit(0); + exit(EXIT_SUCCESS); break; case 7: /* -d found; look for dimensions */ diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index ca445ed..d8b54a7 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -16,8 +16,12 @@ # HDF Utilities Test script # Usage: h5importtestutil.sh [machine-type] +TESTNAME=h5import +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + # initialize errors variable -errors=0 +nerrors=0 TESTING() { SPACES=" " @@ -37,7 +41,7 @@ cd .. cmp -s tmp_testfiles/log1 log2 || err=1 rm -f log2 tmp_testfiles/log1 if [ $err -eq 1 ]; then -errors="` expr $errors + 1 `"; +nerrors="` expr $nerrors + 1 `"; echo "*FAILED*" else echo " PASSED" @@ -120,18 +124,15 @@ rm -f *.txt *.bin *.h5 rm -rf tmp_testfiles else echo "** h5import or h5importtest not available ***" - errors="` expr $errors + 1 `"; + nerrors="` expr $nerrors + 1 `"; fi # # Check errors result -if [ $errors -eq 0 ]; then - echo "======================================" - echo " H5IMPORT Utilities tests have passed." - echo "======================================" +if test $nerrors -eq 0 ; then + echo "All $TESTNAME tests passed." + exit $EXIT_SUCCESS else - echo "*********************************************" - echo " H5IMPORT Utilities tests encountered errors" - echo "*********************************************" + echo "$TESTNAME tests failed with $nerrors errors." + exit $EXIT_FAILURE fi -exit $errors diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index c6fdb5c..cceed75 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -454,7 +454,7 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout, if (nchars <= 0) { printf ("huh? \n"); - exit (1); + exit (EXIT_FAILURE); } /*ncw = */ HDwrite (outfid, buf, (unsigned) nchars); diff --git a/tools/h5jam/testh5jam.sh.in b/tools/h5jam/testh5jam.sh.in index e17c860..cfefcdc 100644 --- a/tools/h5jam/testh5jam.sh.in +++ b/tools/h5jam/testh5jam.sh.in @@ -21,6 +21,10 @@ USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" USE_FILTER_SHUFFLE="@USE_FILTER_SHUFFLE@" USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" +TESTNAME=h5jam/h5unjam +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + DUMPER=h5dump # The dumper to use DUMPER_BIN=`pwd`/../$DUMPER # The path of the dumper binary JAM=h5jam # Tool to test @@ -526,7 +530,9 @@ CLEANUP tac3.h5 taj3.h5 if test $nerrors -eq 0 ; then - echo "All $JAM 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/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index e9aae81..69f5059 100755 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -27,6 +27,10 @@ USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" USE_FILTER_NBIT="@USE_FILTER_NBIT@" USE_FILTER_SCALEOFFSET="@USE_FILTER_SCALEOFFSET@" +TESTNAME=h5repack +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + H5REPACK=h5repack # The tool name H5REPACK_BIN=`pwd`/$H5REPACK # The path of the tool binary @@ -528,8 +532,10 @@ TOOLTEST $FILE15 TOOLTEST1 $FILE16 if test $nerrors -eq 0 ; then - echo "All $H5REPACK 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/h5stat/testh5stat.sh.in b/tools/h5stat/testh5stat.sh.in index 66d05be..e387eb1 100644 --- a/tools/h5stat/testh5stat.sh.in +++ b/tools/h5stat/testh5stat.sh.in @@ -23,6 +23,10 @@ USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" USE_FILTER_NBIT="@USE_FILTER_NBIT@" USE_FILTER_SCALEOFFSET="@USE_FILTER_SCALEOFFSET@" +TESTNAME=h5stat +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + STAT=h5stat # The tool name STAT_BIN=`pwd`/$STAT # The path of the tool binary @@ -124,12 +128,12 @@ TOOLTEST h5stat_filters-dT.ddl -dT h5stat_filters.h5 TOOLTEST h5stat_tsohm.ddl h5stat_tsohm.h5 # h5stat_newgrat.h5 is generated by h5stat_gentest.c TOOLTEST h5stat_newgrat.ddl h5stat_newgrat.h5 -echo if test $nerrors -eq 0 ; then - echo "All $STAT 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/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; isrc_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 -- cgit v0.12