diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2007-04-06 23:39:47 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2007-04-06 23:39:47 (GMT) |
commit | 265ec07488535b7b44018543ec2ddce0810970d6 (patch) | |
tree | 28dc0a9849ef8652b9e410f550dacacbaa5153b6 /examples | |
parent | 15de1c640768d43568a1f57c70e22bfa9b7b382c (diff) | |
download | hdf5-265ec07488535b7b44018543ec2ddce0810970d6.zip hdf5-265ec07488535b7b44018543ec2ddce0810970d6.tar.gz hdf5-265ec07488535b7b44018543ec2ddce0810970d6.tar.bz2 |
[svn-r13606] Purpose:
new feature.
Description:
Changed it from using the -show to really compile and build the applications.
Tested:
kagiso.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/testh5cc.sh.in | 190 |
1 files changed, 138 insertions, 52 deletions
diff --git a/examples/testh5cc.sh.in b/examples/testh5cc.sh.in index a0ea4ba..f1f794d 100755 --- a/examples/testh5cc.sh.in +++ b/examples/testh5cc.sh.in @@ -19,10 +19,18 @@ # Modification: # +# Initializations # Where the tool is installed. prefix="@prefix@" -H5TOOL="h5cc" # The tool name -H5TOOL_BIN="${prefix}/bin/h5cc -show" # The path of the tool binary +PARALLEL=@PARALLEL@ # Am I in parallel mode? +AR=@AR@ +RANLIB=@RANLIB@ +if [ "$PARALLEL" = no ]; then + H5TOOL="h5cc" # The tool name +else + H5TOOL="h5pcc" # The tool name +fi +H5TOOL_BIN="${prefix}/bin/${H5TOOL}" # The path of the tool binary CMP='cmp -s' DIFF='diff -c' @@ -35,6 +43,92 @@ if test -z "$srcdir"; then srcdir=. fi +# Generate some source files and library for tests. +hdf5main=${H5TOOL}_hdf5main.c +hdf5main_o=${H5TOOL}_hdf5main.o +appmain=${H5TOOL}_appmain.c +appmain_o=${H5TOOL}_appmain.o +prog1=${H5TOOL}_prog1.c +prog1_o=${H5TOOL}_prog1.o +prog2=${H5TOOL}_prog2.c +prog2_o=${H5TOOL}_prog2.o +applib=libapp${H5TOOL}.a + +# short hands +temp_SRC="$hdf5main $appmain $prog1 $prog2" +temp_OBJ=`echo $temp_SRC | sed -e 's/\.c/.o/g'` +temp_FILES="a.out *.h5 $applib" + +# Generate appmain: +# An application Main that calls hdf5 and application's own functions. +cat > $appmain <<EOF +#include "hdf5.h" +#define H5FILE_NAME "tmp.h5" +int +main (void) +{ + hid_t file; /* file and dataset handles */ + + /* + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ + sub1(); + sub2(); + file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + H5Fclose(file); + + printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME); + remove(H5FILE_NAME); + + return 0; +} +EOF + +# generate prog1 +cat > $prog1 <<EOF +sub1(void) +{ + printf("in sub1\n"); +} +EOF + +# generate prog2 +cat > $prog2 <<EOF +sub2(void) +{ + printf("in sub2\n"); +} +EOF + +# Generate HDF5 Main Program: +# An HDF5 sample program that calls hdf5 functions. +cat > $hdf5main <<EOF +#include "hdf5.h" +#define H5FILE_NAME "tmp.h5" +int +main (void) +{ + hid_t file; /* file and dataset handles */ + + /* + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ + file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + H5Fclose(file); + + printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME); + remove(H5FILE_NAME); + + return 0; +} +EOF + + + # Parse option # None @@ -80,62 +174,29 @@ DPRINT() { # $2-$: remainign arguments # TOOLTEST() { - dummy_c=zzdummy.c - dummy_o=`echo $dummy_c | sed -e s/.c$/.o/` - expect=test_$H5TOOL_$$.expected - actual=test_$H5TOOL_$$.result - - cmdtype=$1 - shift - - # figure out compiling prefix and suffix - xcommand="`$H5TOOL_BIN -c $dummy_c`" - DPRINT xcommand=$xcommand - compile_prefix="`echo $xcommand | sed -e s/-c\ ${dummy_c}.*//`" - compile_suffix="`echo $xcommand | sed -e s/.*\ -c\ ${dummy_c}//`" - DPRINT compile_prefix=$compile_prefix - DPRINT compile_suffix=$compile_suffix - - # figure out linking prefix and suffix - xcommand="`$H5TOOL_BIN $dummy_o`" - link_prefix="`echo $xcommand | sed -e s/${dummy_o}.*//`" - link_suffix="`echo $xcommand | sed -e s/.*${dummy_o}//`" - DPRINT link_prefix=$link_prefix - DPRINT link_suffix=$link_suffix - - # create the expected result - cp /dev/null $expect # empty it - if [ $cmdtype = -C -o $cmdtype = -CL ]; then - echo $compile_prefix $* > $expect - fi - if [ $cmdtype = -L -o $cmdtype = -CL ]; then - echo $link_prefix $* $link_suffix > $expect - fi + out=test_$H5TOOL_$$.out + err=test_$H5TOOL_$$.err # Run test. - # Tflops interprets "$@" as "" when no parameter is given (e.g., the - # case of missing file name). Changed it to use $@ till Tflops fixes it. TESTING $H5TOOL $@ - $H5TOOL_BIN $* > $actual 2>&1 - - if $CMP $expect $actual; then + $H5TOOL_BIN $@ > $out 2>&1 + result=$? + if [ $result = 0 ]; then echo " PASSED" else echo "*FAILED*" nerrors="`expr $nerrors + 1`" test yes = "$verbose" && \ - ( echo "========== Expected results ($expect) ==========="; cat $expect; - echo "========== Actual results ($actual) ==========="; cat $actual; + ( echo "========== results ==========="; cat $out; echo "===============================================") |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $expect + rm -f $out fi } - # Print a "SKIP" message SKIP() { TESTING $H5TOOL $@ @@ -146,16 +207,41 @@ SKIP() { ############################################################################## ### T H E T E S T S ### ############################################################################## -TOOLTEST -C -c A.c -TOOLTEST -C -c A.c B.c -TOOLTEST -L A.o -TOOLTEST -L A.o B.o -TOOLTEST -L A.o B.o L.a -SKIP -CL A.c B.c L.a - -# ############################################################################## -# # END -# ############################################################################## +# +# HDF5 program that calls HDF5 APIs. +echo "***"Simple Compile and Link in one step. +TOOLTEST $hdf5main +# Application program that calls HDF5 and its own functions. +TOOLTEST $appmain $prog1 $prog2 + +# Compile, then link. +echo "***"Compile and Link in two steps. +TOOLTEST -c $hdf5main +TOOLTEST $hdf5main_o +TOOLTEST -c $appmain $prog1 $prog2 +TOOLTEST $appmain_o $prog1_o $prog2_o + +# Build external library, then link with it. +echo "***"Build external library and link with it. +TOOLTEST -c $prog1 $prog2 +$AR cru $applib $prog1_o $prog2_o +$RANLIB $applib +TOOLTEST $appmain $applib +TOOLTEST $appmain_o $applib + +# Just cpp, no compile, no link. +echo "***"Just cpp, no compile, no link. +TOOLTEST -E $hdf5main +TOOLTEST -E $appmain $prog1 $prog2 + +############################################################################## +# END +############################################################################## + +# Clean up file +if test -z "$HDF5_NOCLEANUP"; then + rm -f $temp_SRC $temp_OBJ $temp_FILES +fi if test $nerrors -eq 0 ; then echo "All $H5TOOL tests passed." |