File: test.sh.in

package info (click to toggle)
hdf5-filter-plugin 0.0~git20221111.49e3b65-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,848 kB
  • sloc: ansic: 14,374; sh: 11,445; cpp: 1,463; makefile: 100; python: 19; xml: 6
file content (243 lines) | stat: -rw-r--r-- 6,338 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#! /bin/sh
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the files COPYING and Copyright.html.  COPYING can be found at the root
# of the source code distribution tree; Copyright.html can be found at the
# root level of an installed copy of the electronic HDF5 document set and
# is linked from the top-level documents page.  It can also be found at
# http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.

srcdir=@srcdir@
builddir=@builddir@
verbose=yes
nerrors=0

# HDF5 compile commands, assuming they are in your $PATH.
H5CC=@H5CC@

case $H5CC in
*/*)    H5DUMP=`echo $H5CC | sed -e 's/\/[^/]*$/\/h5dump/'`;
        test -x $H5DUMP || H5DUMP=h5dump;
        H5REPACK=`echo $H5CC | sed -e 's/\/[^/]*$/\/h5repack/'`;
        test -x $H5REPACK || H5REPACK=h5repack;;
*)      H5DUMP=h5dump;
        H5REPACK=h5repack;;
esac

# Shell commands used in Makefiles
RM="rm -rf"
DIFF="diff -c"
CMP="cmp -s"
GREP='grep'
CP='cp'
DIRNAME='dirname'
LS='ls'
AWK='awk'

ENVCMD="env HDF5_PLUGIN_PATH=`pwd`/../src/.libs"

TESTDIR=$builddir
SRC_TESTFILES="$srcdir/testfiles"
LIST_TEST_FILES="
$SRC_TESTFILES/h5repack_layout.h5
$SRC_TESTFILES/h5ex_d_bzip2.ddl
$SRC_TESTFILES/h5ex_d_bzip2.tst
$SRC_TESTFILES/h5repack_layout.h5-ud_convert.ddl
$SRC_TESTFILES/ud_convert.h5repack_layout.h5.tst
"

#
# copy test files and expected output files from source dirs to test dir
#
COPY_TESTFILES="$LIST_TEST_FILES"

COPY_TESTFILES_TO_TESTDIR()
{
    # copy test files. Used -f to make sure get a new copy
    for tstfile in $COPY_TESTFILES
    do
        # ignore '#' comment
        echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
        RET=$?
        if [ $RET -eq 1 ]; then
            # skip cp if srcdir is same as destdir
            # this occurs when build/test performed in source dir and
            # make cp fail
            SDIR=`$DIRNAME $tstfile`
            INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
            INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
            if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
                $CP -f $tstfile $TESTDIR
                if [ $? -ne 0 ]; then
                    echo "Error: FAILED to copy $tstfile ."
                
                    # Comment out this to CREATE expected file
                    exit $EXIT_FAILURE
                fi
            fi
        fi
    done
}

# Print a $* message left justified in a field of 70 characters
#
MESSAGE() {
   SPACES="                                                               "
   echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
}

# Print a line-line message left justified in a field of 70 characters
# beginning with the word "Testing".
#
TESTING() {
    SPACES="                                                               "
    echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
}

# Print a line-line message left justified in a field of 70 characters
# beginning with the word "Verifying".
#
VERIFY() {
    MESSAGE "Verifying $*"
}

# This is different from $srcdir/../../bin/output_filter.sh
STDOUT_FILTER() {
    result_file=$1
    tmp_file=/tmp/h5test_tmp_$$
    # Filter name of files.
    cp $result_file $tmp_file
    sed -e '/^Opening file/d' -e '/^Making file/d' \
    < $tmp_file > $result_file
    # cleanup
    rm -f $tmp_file
}

# Compare the two text files
# PASS if same
# FAIL if different, and show the diff
#
# Assumed arguments:
# $1 is text file1 (expected output)
# $2 is text file2 (actual output)
CMP_OUTPUT()
{
    expect=$1
    actual=$2

    VERIFY $@
    if [ ! -f $expect ]; then
        # Create the expect file if it doesn't yet exist.
        echo " CREATED"
        cp $actual "$expect.new"
    elif $CMP $expect $actual; then
        echo " PASSED"
    else
        echo "*FAILED*"
        echo "    Expected output differs from actual output"
        nerrors="`expr $nerrors + 1`"
        test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/    /'
    fi
}


# Run a test and print PASS or *FAIL*.  If a test fails then increment
# the `nerrors' global variable and (if $verbose is set) display the
# difference between the actual output and the expected output. The
# expected output is given as the first argument to this function and
# the actual output file is calculated by replacing the `.ddl' with
# `.out'.  The actual output is not removed if $HDF5_NOCLEANUP has a
# non-zero value.
# ADD_H5_TEST
DUMPTEST() {
    expect="$1"
    actual="`basename $1 .ddl`.out"
    actual_err="`basename $1 .ddl`.err"
    shift

    # Run test.
    TESTING $DUMPER $@
    (
      $ENVCMD $H5DUMP "$@"
    ) >$actual 2>$actual_err
    cat $actual_err >> $actual

    CMP_OUTPUT $expect $actual
    
    # Clean up output file
#    rm -f $actual $actual_err

}

REPACKTEST() 
{
    infile=$1
    outfile=$2
    expect="$2.tst"
    actual="$2.out1"
    actual_err="$2.err1"
    shift
    shift

    # Run test.
    TESTING $H5REPACK $@
    (
        $ENVCMD $H5REPACK "$@" $infile $outfile
    ) >$actual 2>$actual_err
    RET=$?
    STDOUT_FILTER $actual
    cat $actual_err >> $actual
    
     if [ $RET != 0 ] ; then
        echo "*FAILED*"
        nerrors="`expr $nerrors + 1`"
    else
        echo " PASSED"

        CMP_OUTPUT $expect $actual
    fi
#    rm -f $actual $actual_err
}


EXETEST() {
    fname=$1
    expect="$2"
    actual="`basename $2 .tst`.out1"
    actual_err="`basename $2 .tst`.err1"

    # Run test.
    TESTING $fname 
    (
      $ENVCMD ./$fname
    ) >$actual 2>$actual_err
    cat $actual_err >> $actual

    CMP_OUTPUT $expect $actual
#    rm -f $actual $actual_err
}

################################
#########  THE TESTS   #########
################################

COPY_TESTFILES_TO_TESTDIR

EXETEST h5ex_d_bzip2 h5ex_d_bzip2.tst

DUMPTEST h5ex_d_bzip2.ddl h5ex_d_bzip2.h5

REPACKTEST h5repack_layout.h5 out-ud_convert.h5repack_layout.h5 -v -f UD=307,1,9

DUMPTEST h5repack_layout.h5-ud_convert.ddl -pH out-ud_convert.h5repack_layout.h5

#rm -f ud_convert.h5repack_layout.h5

echo "$nerrors tests failed in example"
exit $nerrors