File: hrepack.sh.in

package info (click to toggle)
libhdf4 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 29,892 kB
  • sloc: ansic: 128,688; sh: 14,969; fortran: 12,444; java: 5,864; xml: 1,305; makefile: 900; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (357 lines) | stat: -rw-r--r-- 10,861 bytes parent folder | download | duplicates (7)
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#! /bin/sh
#

srcdir=@srcdir@


# Determine whether the szip library is available
USE_COMP_SZIP="@USE_COMP_SZIP@"
SZIP_HAS_ENCODER="@SZIP_HAS_ENCODER@"

TESTNAME=hrepack
EXIT_SUCCESS=0
EXIT_FAILURE=1

HREPACK='./hrepack'               # The tool name
HREPACK_BIN="${TESTS_ENVIRONMENT} "`pwd`/$HREPACK    # The path of the tool binary

HDIFF='../hdiff/hdiff'         # The hdiff tool name 
HDIFF_BIN="${TESTS_ENVIRONMENT} "`pwd`/$HDIFF        # The path of the hdiff tool binary

HDP='../dumper/hdp'               # The dumper tool name
HDP_BIN="${TESTS_ENVIRONMENT} "`pwd`/$HDP        # The path of the tool binary

RM='rm -f'
DIFF=diff
CMP='cmp -s'
nerrors=0       # number of errors (0)
quitonerr=0     # quit on error (not)
noclean=0       # no cleaning temp. files (yes)
only=""         # dumper sub-command to test only
except=""       # dumper sub-command to test not

# 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() {
    MESSAGE "Testing $*"
}

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

# Print a message that a test has been skipped (because a required filter
# was unavailable)
SKIP() {
    TESTING $HREPACK $@
    echo " -SKIP-"
}

# Call the hdiff tool
#
DIFFTEST() 
{
    VERIFY hdiff output $@
    (
        $RUNSERIAL $HDIFF_BIN  "$@" 
    )
    RET=$?
    if [ $RET != 0 ] ; then
         echo "*FAILED*"
         nerrors="`expr $nerrors + 1`"
    else
         echo " PASSED"
    fi
        
}

# Call hrepack
#


# call TOOLTEST_MAIN and delete $output file
TOOLTEST() 
{
    infile=$2
    outfile=out-$1.$2
    shift
    shift

    # Run test.
    TESTING $HREPACK $@
    (
        $RUNSERIAL $HREPACK_BIN -v -i $infile -o $outfile "$@"
    )
    RET=$?
    if [ $RET != 0 ] ; then
        echo "*FAILED*"
        nerrors="`expr $nerrors + 1`"
    else
        echo " PASSED"
        DIFFTEST $infile $outfile
    fi
    rm -f $outfile
}

# ADD_HELP_TEST
TOOLTEST_HELP() {

    expect="$1"
    actual="`basename $1 .txt`.out"
    actual_err="`basename $1 .txt`.err"
    shift

    # Run test.
    TESTING $HREPACK $@
    (
      $RUNSERIAL $HREPACK_BIN "$@"
    ) >$actual 2>$actual_err
    cat $actual_err >> $actual

    if [ ! -f $expect ]; then
    # Create the expect data file if it doesn't yet exist.
      echo " CREATED"
      cp $actual $expect-CREATED
    elif cmp -s $expect $actual; then
      echo " PASSED"
    else
      echo "*FAILED*"
      echo "    Expected output (*.txt) differs from actual output (*.out)"
      nerrors="`expr $nerrors + 1`"
    fi
    
    # Clean up output file
    if test -z "$HDF_NOCLEANUP"; then
     rm -f $actual $actual_err
    fi

}

# This is different from $srcdir/../../bin/output_filter.sh
STDOUT_FILTER() {
    result_file=$1
    tmp_file=/tmp/htest_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
}

#
# The tests
# We use the files generated by test_hrepack
# Each run generates "<file>.out.hdf" and the tool hdiff is used to
# compare the input and output files
#
# the tests are the same as the program hrepacktst, but run from the CLI 
#

##############################################################################
###			  T H E   T E S T S                               
##############################################################################
# prepare for test

#TOOLTEST_HELP hrepack-help.txt -h

   #-------------------------------------------------------------------------
   # test1:  
   # HUFF
   #-------------------------------------------------------------------------
   #
    TOOLTEST HUFF hrepacktst1.hdf -t "dset7:HUFF 1" -c dset7:10x8x6
    
#    if ( sds_verifiy_comp("dset7",COMP_CODE_SKPHUFF, 1) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset7",HDF_CHUNK|HDF_COMP,3,in_chunk_lengths) == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test2: 
   # RLE
   #-------------------------------------------------------------------------
   #
    TOOLTEST RLE hrepacktst1.hdf -t dset4:RLE -c dset4:10x8
    
#    if ( sds_verifiy_comp("dset4",COMP_CODE_RLE, 0) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset4",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#        goto out;
    
   #-------------------------------------------------------------------------
   # test3:  
   # SDS SELECTED with GZIP, chunking SELECTED
   #-------------------------------------------------------------------------
   #
    TOOLTEST SDSGZIP_CHUNK hrepacktst1.hdf -t "dset4:GZIP 6" -c dset4:10x8
    
#    if ( sds_verifiy_comp("dset4",COMP_CODE_DEFLATE, 6) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset4",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test4:  
   # SDS SELECTED with SZIP, chunking SELECTED
   #-------------------------------------------------------------------------
   #
    if test $SZIP_HAS_ENCODER != "yes"; then
        SKIP SDSSZIP_CHUNK hrepacktst1.hdf -c dset4:10x8
    else
        TOOLTEST SDSSZIP_CHUNK hrepacktst1.hdf -t "dset4:SZIP 8,EC" -c dset4:10x8
    fi
#if defined (H4_HAVE_LIBSZ)
#    if (SZ_encoder_enabled()) 
#    {
#        
#        if ( sds_verifiy_comp("dset4",COMP_CODE_SZIP, 0) == -1) 
#            goto out;
#        if ( sds_verifiy_chunk("dset4",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#            goto out;
    
   #-------------------------------------------------------------------------
   # test4:  
   # SDS SELECTED with NONE, chunking SELECTED NONE
   #-------------------------------------------------------------------------
   #
    TOOLTEST SDSNONE_CHUNKNONE hrepacktst1.hdf -t dset_chunk_comp:NONE -t dset_chunk:NONE -c dset_chunk_comp:NONE -c dset_chunk:NONE
    
#    if ( sds_verifiy_comp("dset_chunk_comp",COMP_CODE_NONE, 0) == -1) 
#        goto out;
#    if ( sds_verifiy_comp("dset_chunk",COMP_CODE_NONE, 0) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset_chunk_comp",HDF_NONE,0,0) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset_chunk",HDF_NONE,0,0) == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test5:
   # SDS SELECTED with all types, chunking SELECTED
   #-------------------------------------------------------------------------
   #
    if test $SZIP_HAS_ENCODER != "yes"; then
        TOOLTEST SDS_CHUNK hrepacktst1.hdf -t "dset4:GZIP 9" -t dset5:RLE -t "dset6:HUFF 2" -c dset4:10x8 -c dset5:10x8 -c dset6:10x8
    else
        TOOLTEST SDS_CHUNK hrepacktst1.hdf -t "dset4:GZIP 9" -t dset5:RLE -t "dset6:HUFF 2" -t "dset7:SZIP 8,EC" -c dset4:10x8 -c dset5:10x8 -c dset6:10x8
    fi
    
#    if ( sds_verifiy_comp("dset4",COMP_CODE_DEFLATE, 9) == -1) 
#        goto out;
#    if ( sds_verifiy_comp("dset5",COMP_CODE_RLE, 0) == -1) 
#        goto out;
#    if ( sds_verifiy_comp("dset6",COMP_CODE_SKPHUFF, 2) == -1) 
#        goto out;
#if defined (H4_HAVE_LIBSZ)
#    if (SZ_encoder_enabled()) {
#        if ( sds_verifiy_comp("dset7",COMP_CODE_SZIP, 0) == -1) 
#            goto out;
#    }
#endif
#    if ( sds_verifiy_chunk("dset4",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset5",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset6",HDF_CHUNK|HDF_COMP,2,in_chunk_lengths) == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test6: 
   # SDS SELECTED with all types, no chunking
   #-------------------------------------------------------------------------
   #
    if test $SZIP_HAS_ENCODER != "yes"; then
        TOOLTEST SEL_NOCHUNK hrepacktst1.hdf -t "dset4:GZIP 9" -t dset5:RLE -t "dset6:HUFF 2"
    else
        TOOLTEST SEL_NOCHUNK hrepacktst1.hdf -t "dset4:GZIP 9" -t dset5:RLE -t "dset6:HUFF 2" -t "dset7:SZIP 4,EC"
    fi
    
#    if ( sds_verifiy_comp("dset4",COMP_CODE_DEFLATE, 9) == -1) 
#        goto out;
#    if ( sds_verifiy_comp("dset5",COMP_CODE_RLE, 0) == -1) 
#        goto out;
#    if ( sds_verifiy_comp("dset6",COMP_CODE_SKPHUFF, 2) == -1) 
#        goto out;
#if defined (H4_HAVE_LIBSZ)
#    if (SZ_encoder_enabled()) {
#        if ( sds_verifiy_comp("dset7",COMP_CODE_SZIP, 0) == -1) 
#            goto out;
#    }
#endif
    
    
   #-------------------------------------------------------------------------
   # test7:  
   # compressing SDS ALL, chunking SELECTED NONE
   #-------------------------------------------------------------------------
   #
    TOOLTEST COMPALL_CHUNKNONE hrepacktst1.hdf -t "*:GZIP 1" -c dset_chunk_comp:NONE -c dset_chunk:NONE
    
#    if ( sds_verifiy_comp_all(COMP_CODE_DEFLATE, 1) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset_chunk_comp",HDF_NONE,0,0) == -1) 
#        goto out;
#    if ( sds_verifiy_chunk("dset_chunk",HDF_NONE,0,0) == -1) 
#        goto out;
    
   #-------------------------------------------------------------------------
   # test8:
   # no compressing, chunking ALL
   #-------------------------------------------------------------------------
   #
    TOOLTEST NOCOMP_CHUNKALL hrepacktst1.hdf -c *:10x8
    
#    if ( sds_verifiy_chunk_all(HDF_CHUNK,2,in_chunk_lengths,"dset7") == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test9: 
   # compressing SDS ALL with GZIP
   #-------------------------------------------------------------------------
   #
    TOOLTEST GZIP hrepacktst1.hdf -t "*:GZIP 1"
    
#    if ( sds_verifiy_comp_all(COMP_CODE_DEFLATE, 1) == -1) 
#        goto out;
    
    
   #-------------------------------------------------------------------------
   # test10: 
   # repack a big file using hyperslab reading/writing
   #-------------------------------------------------------------------------
   #
    TOOLTEST HYPERSLAB hrepacktst2.hdf
    
   #-------------------------------------------------------------------------
   # test11: 
   # repack a file with vgroups
   #-------------------------------------------------------------------------
   #
    TOOLTEST VGROUP hrepacktst3.hdf


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