1#! /bin/sh
2#
3# Copyright by The HDF Group.
4# All rights reserved.
5#
6# This file is part of HDF5.  The full HDF5 copyright notice, including
7# terms governing use, modification, and redistribution, is contained in
8# the COPYING file, which can be found at the root of the source code
9# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
10# If you do not have access to either file, you may request a copy from
11# help@hdfgroup.org.
12
13#
14#  This file:  run-hlc-ex.sh
15# Written by:  Larry Knox
16#       Date:  May 11, 2010
17#
18# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
19#                                                                               #
20# This script will compile and run the c examples from source files installed   #
21# in .../share/hdf5_examples/hl/c using h5cc or h5pc.  The order for running    #
22# programs with RunTest in the MAIN section below is taken from the Makefile.   #
23# The order is important since some of the test programs use data files created #
24# by earlier test programs.  Any future additions should be placed accordingly. #
25#                                                                               #
26# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
27
28# Initializations
29EXIT_SUCCESS=0
30EXIT_FAILURE=1
31
32# Where the tool is installed.
33# default is relative path to installed location of the tools
34prefix="${prefix:-../../../..}"
35PARALLEL=@PARALLEL@             # Am I in parallel mode?
36AR="@AR@"
37RANLIB="@RANLIB@"
38if [ "$PARALLEL" = no ]; then
39    H5TOOL="h5cc"               # The tool name
40else
41    H5TOOL="h5pcc"               # The tool name
42fi
43H5TOOL_BIN="${prefix}/bin/${H5TOOL}"   # The path of the tool binary
44
45#### Run test ####
46RunTest()
47{
48    TEST_EXEC=$1
49    Test=$1".c"
50
51    echo
52    echo "#################  $1  #################"
53    ${H5TOOL_BIN} -o $TEST_EXEC $Test
54    if [ $? -ne 0 ]
55    then
56        echo "messed up compiling $Test"
57        exit 1
58    fi
59    ./$TEST_EXEC
60}
61
62
63
64##################  MAIN  ##################
65
66# Run tests
67if [ $? -eq 0 ]
68then
69    if (RunTest ex_lite1 &&\
70        rm ex_lite1 &&\
71        RunTest ex_lite2 &&\
72        rm ex_lite2 &&\
73        RunTest ex_lite3 &&\
74        rm ex_lite3 &&\
75        RunTest ptExampleFL &&\
76        rm ptExampleFL &&\
77        RunTest ex_image1 &&\
78        rm ex_image1 &&\
79        RunTest ex_image2 &&\
80        rm ex_image2 &&\
81        RunTest ex_table_01 &&\
82        rm ex_table_01 &&\
83        RunTest ex_table_02 &&\
84        rm ex_table_02 &&\
85        RunTest ex_table_03 &&\
86        rm ex_table_03 &&\
87        RunTest ex_table_04 &&\
88        rm ex_table_04 &&\
89        RunTest ex_table_05 &&
90        rm ex_table_05 &&
91        RunTest ex_table_06 &&\
92        rm ex_table_06 &&\
93        RunTest ex_table_07 &&\
94        rm ex_table_07 &&\
95        RunTest ex_table_08 &&\
96        rm ex_table_08 &&\
97        RunTest ex_table_09 &&\
98        rm ex_table_09 &&\
99        RunTest ex_table_10 &&\
100        rm ex_table_10 &&\
101        RunTest ex_table_11 &&\
102        rm ex_table_11 &&\
103        RunTest ex_table_12 &&\
104        rm ex_table_12 &&\
105        RunTest ex_ds1 &&\
106        rm ex_ds1); then
107        EXIT_VALUE=${EXIT_SUCCESS}
108    else
109        EXIT_VALUE=${EXIT_FAILURE}
110    fi
111fi
112
113# Cleanup
114rm *.o
115rm *.h5
116echo
117
118exit $EXIT_VALUE
119
120