File: testutil.sh

package info (click to toggle)
libhdf4 4.1r3-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 24,092 kB
  • ctags: 26,163
  • sloc: ansic: 204,415; fortran: 29,237; sh: 7,807; makefile: 7,417; cpp: 2,186; pascal: 1,498; asm: 1,027; yacc: 680; lex: 202; sed: 153
file content (401 lines) | stat: -rwxr-xr-x 12,957 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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#!/bin/sh 
# HDF Utilities Test script
# Usage: testutil.sh [machine-type]

machinetype="$1"

# Check if target machine supports 32 bits datatype.
# "true" is TRUE; "" means FALSE.
case $machinetype in
    *unicos*) has32="";;
    *) has32="true";;
esac

# initialize errors variable
errors=0
haserr=0

# setup hdfed command which is used often
HDFED='./hdfed'
HDFEDCMD="$HDFED -batch"		# use -batch mode for no prompt
SED="sed -e /library/,/String/d"  # filter out the library version

echo ""
echo "=============================="
echo "HDF Utilities tests started"
echo "=============================="

# hdf24to8
if [ -f hdf24to8 -a -f hdftor8 ]; then
echo "** Testing hdf24to8  ***"
/bin/rm -f head.r24 head.r8 head8.hdf img001-263.328 pal001
cp testfiles/head.r24.Z testfiles/head.r8.Z .
uncompress head.r24.Z head.r8.Z
./hdf24to8 head.r24 head8.hdf
./hdftor8 head8.hdf
cmp img001-263.328 head.r8 || errors=1
/bin/rm -f head.r24 head.r8 head8.hdf img001-263.328 pal001
else
echo "** hdf24to8 or hdftor8 is not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
  echo " hdf24to8 might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
  echo " please run the following by hand to verify "
  echo " "
  echo " /bin/rm -f head.r24 head.r8 head8.hdf img001-263.328 pal001"
  echo " cp testfiles/head.r24.Z testfiles/head.r8.Z . "
  echo " uncompress head.r24.Z head.r8.Z "
  echo " ./hdf24to8 head.r24 head8.hdf "
  echo " ./hdftor8 head8.hdf "
  echo " cmp img001-263.328 head.r8 " 
  echo " ******* END NOTE *************"
  echo ""
  errors=0
fi

# hdfed
if [ -f $HDFED ]; then
echo "** Testing hdfed  ***"
/bin/rm -f storm110.hdf ntcheck.hdf hdfed.tmp
cp testfiles/storm110.hdf testfiles/ntcheck.hdf .
$HDFEDCMD < hdfed.input1 > hdfed.tmp 2>&1
diff hdfed.tmp hdfed.out1 || errors=1
/bin/rm -f storm110.hdf ntcheck.hdf hdfed.tmp
else
echo "** hdfed not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
   echo " ********* NOTE ***************"
   echo " hdfed might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
   echo " please run the following by hand to verify "
   echo " "
   echo "/bin/rm -f storm110.hdf ntcheck.hdf hdfed.tmp "
   echo "cp testfiles/storm110.hdf testfiles/ntcheck.hdf . "
   echo "$HDFEDCMD < hdfed.input1 >& hdfed.tmp "
   echo "diff hdfed.tmp hdfed.out1 "
  echo " ******* END NOTE *************"
  echo ""
   errors=0
fi

# ristosds
if [ -f ristosds -a -f $HDFED ]; then
echo "** Testing ristosds  ***"
/bin/rm -f storm*.hdf hdfed.tmp1
cp testfiles/storm110.hdf testfiles/storm120.hdf testfiles/storm130.hdf .
./ristosds storm*.hdf -o storm.hdf > /dev/null 2>&1
$HDFEDCMD < ristosds.input1 > hdfed.tmp1 2>&1
diff  hdfed.tmp1 ristosds.out1 || errors=1
/bin/rm -f storm*.hdf hdfed.tmp1
else
echo "** ristosds or hdfed not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
  echo " ristosds might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
  echo " please run the following by hand to verify "
  echo " "
  echo " /bin/rm -f storm*.hdf hdfed.tmp1 "
  echo " cp testfiles/storm110.hdf testfiles/storm120.hdf testfiles/storm130.hdf . "
  echo "./ristosds storm*.hdf -o storm.hdf "
  echo "$HDFEDCMD < ristosds.input1 >& hdfed.tmp1 "
  echo " diff  hdfed.tmp1 ristosds.out1"
  echo " ******* END NOTE *************"
  echo ""
  errors=0
fi


#hdfpack
if [ -f hdfpack -a -f hdfls ]; then
echo "** Testing hdfpack  ***"
/bin/rm -f test.hdf test.blk test.pck hdfls.tmp1
cp testfiles/test.hdf .
./hdfpack test.hdf test.pck
./hdfpack -b test.hdf test.blk
(./hdfls test.hdf | $SED ) > hdfls.tmp1 2>&1
(./hdfls test.pck | $SED ) >> hdfls.tmp1 2>&1
diff  hdfls.tmp1 hdfpack.out1 || errors=1
/bin/rm -f test.hdf test.blk test.pck hdfls.tmp1
else
echo "** hdfpack or hdfls not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
    echo " ********* NOTE ***************"
    echo " hdfpack might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
    echo " please run the following by hand to verify "
    echo " "
    echo "/bin/rm -f test.hdf test.blk test.pck hdfls.tmp1 "
    echo " cp testfiles/test.hdf . "
    echo "./hdfpack test.hdf test.pck "
    echo "./hdfpack -b test.hdf test.blk "
    echo "(./hdfls test.hdf | $SED ) >& hdfls.tmp1"
    echo "(./hdfls test.pck | $SED ) >>& hdfls.tmp1"
    echo " diff hdfls.tmp1 hdfpack.out1 "
  echo " ******* END NOTE *************"
  echo ""
    errors=0
fi

#hdftopal/paltohdf
if [ -f  hdftopal -a -f paltohdf ]; then
echo "** Testing hdftopal/paltohdf  ***"
/bin/rm -f palette.* 
cp testfiles/palette.raw .
./paltohdf palette.raw palette.hdf
./hdftopal palette.hdf palette.raw.new
cmp palette.raw palette.raw.new || errors=1
/bin/rm -f palette.* 
else
echo "** hdftopal or paltohdf not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
    echo " hdftopal or paltohdf might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
    echo " please run the following by hand to verify "
    echo " "
    echo " /bin/rm -f palette.* "
    echo " cp testfiles/palette.raw . "
    echo "./paltohdf palette.raw palette.hdf "
    echo "./hdftopal palette.hdf palette.raw.new "
    echo "cmp palette.raw palette.raw.new "
  echo " ******* END NOTE *************"
  echo ""
   errors=0
fi

# r8tohdf/hdftor8
if [ -f r8tohdf -a -f hdftor8 -a -f hdfls ]; then
echo "** Testing r8tohdf/hdftor8  ***"
/bin/rm -f storm* img* palette.raw hdfls.tmp2 pal005
cp testfiles/storm*.raw testfiles/palette.raw .
./r8tohdf 57 57 storm.hdf storm*.raw
./r8tohdf 57 57 storm.hdf -p palette.raw -i storm110.raw
./hdftor8 storm.hdf
(./hdfls -l storm.hdf | $SED) > hdfls.tmp2 2>&1
diff  hdfls.tmp2 hdftor8.out1 || errors=1
cmp img001-057.057  storm110.raw || errors=1
cmp img002-057.057  storm120.raw || errors=1
cmp img003-057.057  storm130.raw || errors=1
cmp img004-057.057  storm140.raw || errors=1
/bin/rm -f storm* img* palette.raw hdfls.tmp2 pal005
else
echo "** r8tohdf, hdftor8 or hdfls not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
    echo " r8tohdf or hdftor8 might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
    echo " please run the following by hand to verify "
    echo " "
    echo "/bin/rm -f storm* img* palette.raw hdfls.tmp2 pal005 "
    echo "cp testfiles/storm*.raw testfiles/palette.raw . "
    echo "./r8tohdf 57 57 storm.hdf storm*.raw "
    echo "./r8tohdf 57 57 storm.hdf -p palette.raw -i storm110.raw "
    echo "./hdftor8 storm.hdf "
    echo "(./hdfls -l storm.hdf | $SED) >& hdfls.tmp2 "
    echo " diff hdfls.tmp2 hdftor8.out1 "
    echo "cmp img001-057.057  storm110.raw "
    echo "cmp img002-057.057  storm120.raw "
    echo "cmp img003-057.057  storm130.raw "
    echo "cmp img004-057.057  storm140.raw "
  echo " ******* END NOTE *************"
  echo ""
   errors=0
fi

# hdfcomp
if [ -f  hdfcomp -a -f hdfls ]; then
echo "** Testing hdfcomp  ***"
/bin/rm -f storm*.hdf all*.hdf hdfls.tmp3
cp testfiles/storm*.hdf .
./hdfcomp allstorms.hdf storm*.hdf
./hdfcomp allcomp.hdf -c storm*.hdf
(./hdfls -l allstorms.hdf | $SED) > hdfls.tmp3 2>&1
(./hdfls -l allcomp.hdf | $SED) >> hdfls.tmp3 2>&1
diff  hdfls.tmp3 hdfcomp.out1 || errors=1
/bin/rm -f storm*.hdf all*.hdf hdfls.tmp3
else
echo "** hdfcomp or hdfls not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
    echo " hdfcomp might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
    echo " please run the following by hand to verify "
    echo " "
    echo "/bin/rm -f storm*.hdf all*.hdf hdfls.tmp3 "
    echo "cp testfiles/storm*.hdf . "
    echo "./hdfcomp allstorms.hdf storm*.hdf "
    echo "./hdfcomp allcomp.hdf -c storm*.hdf "
    echo "(./hdfls -l allstorms.hdf | $SED) >& hdfls.tmp3 "
    echo "(./hdfls -l allcomp.hdf | $SED) >>& hdfls.tmp3 "
    echo "diff hdfls.tmp3 hdfcomp.out1 "
  echo " ******* END NOTE *************"
  echo ""
   errors=0
fi

#jpeg2hdf/hdf2jpeg
if [ -f jpeg2hdf -a -f hdf2jpeg -a -f hdfls ]; then
echo "** Testing jpeg2hdf/hdf2jpeg  ***"
/bin/rm -f jpeg.hdf jpeg_img.jpg jpeg2.jpg hdfls.tmp4
cp testfiles/jpeg_img.jpg .
./jpeg2hdf jpeg_img.jpg jpeg.hdf
./hdf2jpeg jpeg.hdf jpeg2.jpg
(./hdfls -l jpeg.hdf | $SED) > hdfls.tmp4 2>&1
diff  hdfls.tmp4 jpeg2hdf.out1 || errors=1
cmp jpeg_img.jpg jpeg2.jpg || errors=1
/bin/rm -f jpeg.hdf jpeg_img.jpg jpeg2.jpg hdfls.tmp4
else
echo "** jpeg2hdf, hdf2jpeg or hdfls  not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
    echo " jpeg2hdf or hdf2jpeg might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
    echo " please run the following by hand to verify "
    echo " "
    echo "/bin/rm -f jpeg.hdf jpeg_img.jpg jpeg2.jpg hdfls.tmp4 "
    echo "cp testfiles/jpeg_img.jpg . "
    echo "./jpeg2hdf jpeg_img.jpg jpeg.hdf "
    echo "./hdf2jpeg jpeg.hdf jpeg2.jpg "
    echo "(./hdfls -l jpeg.hdf | $SED) >& hdfls.tmp4 "
    echo "diff hdfls.tmp4 jpeg2hdf.out1 "
    echo "cmp jpeg_img.jpg jpeg2.jpg "
  echo " ******* END NOTE *************"
  echo ""
   errors=0
fi

# fp2hdf
if [ -f fp2hdf -a -f hdfls -a -f $HDFED ]; then
echo "** Testing fp2hdf  ***"
if [ ! "$has32" ]; then
    echo "    $machinetype does not support float32."
    echo "    float32 tests skipped."
fi

/bin/rm -f ctxtr* cb* *.hdf hdfls.tmp5 hdfed.tmp6
./fptest
./fp2hdf ctxtr2 -o ctxtr2.hdf
./fp2hdf ctxtr3 -o ctxtr3.hdf
if [ "$has32" ]; then
./fp2hdf cb32r2 -o cb32r2.hdf
./fp2hdf cb32r3 -o cb32r3.hdf
fi
./fp2hdf cb64r2 -o cb64r2.hdf
./fp2hdf cb64r3 -o cb64r3.hdf
./fp2hdf ctxtr2 -o ctxtr2_ris.hdf -raster -e 50 50
./fp2hdf cb64r2 -o cb64r2_ris.hdf -raster -i 50 50 -f
(./hdfls -l ctxtr2.hdf | $SED) > hdfls.tmp5 2>&1
(./hdfls -l ctxtr3.hdf | $SED) >> hdfls.tmp5 2>&1
if [ "$has32" ]; then
(./hdfls -l cb32r2.hdf | $SED) >> hdfls.tmp5 2>&1
(./hdfls -l cb32r3.hdf | $SED) >> hdfls.tmp5 2>&1
fi
(./hdfls -l cb64r2.hdf | $SED) >> hdfls.tmp5 2>&1
(./hdfls -l cb64r3.hdf | $SED) >> hdfls.tmp5 2>&1
(./hdfls -l ctxtr2_ris.hdf | $SED) >> hdfls.tmp5 2>&1
(./hdfls -l cb64r2_ris.hdf | $SED) >> hdfls.tmp5 2>&1
if [ "$has32" ]; then
    diff  hdfls.tmp5 fp2hdf.out1 || errors=1
    $HDFEDCMD < fp2hdf.input1 > hdfed.tmp6 2>&1
    diff  hdfed.tmp6 fp2hdf.out2 || errors=1
else
    diff  hdfls.tmp5 fp2hdf.out1-32 || errors=1
    $HDFEDCMD < fp2hdf.input1-32 > hdfed.tmp6 2>&1
    diff  hdfed.tmp6 fp2hdf.out2-32 || errors=1
fi
/bin/rm -f ctxtr* cb* *.hdf hdfls.tmp5 hdfed.tmp6
else
echo "** fp2hdf, hdfed or hdfls not available ***"
fi

if [ $errors -eq 1 ]; then
  haserr=1
  echo " ********* NOTE ***************"
  echo " fp2hdf might have failed ***"
  echo " The above errors could be formatting "
  echo " problems which can be ignored "
  echo " please run the following by hand to verify "
  echo " "
  echo "  /bin/rm -f ctxtr* cb* *.hdf hdfls.tmp5 hdfed.tmp6"
  echo " ./fptest "
  echo " ./fp2hdf ctxtr2 -o ctxtr2.hdf "
  echo " ./fp2hdf ctxtr3 -o ctxtr3.hdf "
  if [ "$has32" ]; then
  echo " ./fp2hdf cb32r2 -o cb32r2.hdf "
  echo " ./fp2hdf cb32r3 -o cb32r3.hdf "
  fi
  echo " ./fp2hdf cb64r2 -o cb64r2.hdf "
  echo " ./fp2hdf cb64r3 -o cb64r3.hdf "
  echo " ./fp2hdf ctxtr2 -o ctxtr2_ris.hdf -raster -e 50 50 "
  echo " ./fp2hdf cb64r2 -o cb64r2_ris.hdf -raster -i 50 50 -f "
  echo "( ./hdfls -l ctxtr2.hdf | $SED) >&  hdfls.tmp5 "
  echo "( ./hdfls -l ctxtr3.hdf | $SED) >>& hdfls.tmp5 "
  if [ "$has32" ]; then
  echo "( ./hdfls -l cb32r2.hdf | $SED) >>& hdfls.tmp5 "
  echo "( ./hdfls -l cb32r3.hdf | $SED) >>& hdfls.tmp5 "
  fi
  echo "( ./hdfls -l cb64r2.hdf | $SED) >>& hdfls.tmp5 "
  echo "( ./hdfls -l cb64r3.hdf | $SED) >>& hdfls.tmp5 "
  echo "( ./hdfls -l ctxtr2_ris.hdf | $SED) >>& hdfls.tmp5 "
  echo "( ./hdfls -l cb64r2_ris.hdf | $SED) >>& hdfls.tmp5 "
  if [ "$has32" ]; then
  echo " diff hdfls.tmp5 fp2hdf.out1 "
  echo " $HDFEDCMD < fp2hdf.input1 >& hdfed.tmp6 "
  echo " diff hdfed.tmp6 fp2hdf.out2 "
  else
  echo " diff hdfls.tmp5 fp2hdf.out1-32 "
  echo " $HDFEDCMD < fp2hdf.input1-32 >& hdfed.tmp6 "
  echo " diff hdfed.tmp6 fp2hdf.out2-32 "
  fi
  echo " ******* END NOTE *************"
  echo ""
  errors=0
fi

#
# Check errors result
if [ $haserr -eq 0 ]; then
    echo "=============================="
    echo "HDF Utilities tests passed."
    echo "=============================="
else
    echo "**************************************"
    echo "HDF Utilities tests encountered errors"
    echo "**************************************"
fi
echo ""
exit 0