Skip to content

Commit 8d5a2a1

Browse files
committed
Add h5* compiler wrapper testing for CMake HDFGroup#4605
1 parent bf843c5 commit 8d5a2a1

File tree

5 files changed

+839
-1
lines changed

5 files changed

+839
-1
lines changed

HDF5Examples/C/H5D/test-pc.sh

+221
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
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://www.hdfgroup.org/licenses.
10+
# If you do not have access to either file, you may request a copy from
11+
# help@hdfgroup.org.
12+
13+
# This file is for use of h5cc created with the CMake process
14+
# HDF5_HOME is expected to be set
15+
16+
srcdir=..
17+
builddir=.
18+
verbose=yes
19+
nerrors=0
20+
21+
# HDF5 compile commands, assuming they are in your $PATH.
22+
H5CC=$HDF5_HOME/bin/h5cc
23+
LD_LIBRARY_PATH=$HDF5_HOME/lib
24+
export LD_LIBRARY_PATH
25+
26+
if ! test -f $H5CC; then
27+
echo "Set paths for H5CC and LD_LIBRARY_PATH in test.sh"
28+
echo "Set environment variable HDF5_HOME to the hdf5 install dir"
29+
echo "h5cc was not found at $H5CC"
30+
exit $EXIT_FAILURE
31+
fi
32+
33+
H5DUMP=`echo $H5CC | sed -e 's/\/[^/]*$/\/h5dump/'`;
34+
H5_LIBVER=$($H5CC -showconfig | grep -i "HDF5 Version:" | sed 's/^.* //g' | sed 's/[-].*//g')
35+
H5_APIVER=$($H5CC -showconfig | grep -i "Default API mapping:" | sed 's/^.* //g' | sed 's/v//g' | sed 's/1/1_/')
36+
37+
H5_MAJORVER=$(echo $H5_LIBVER | cut -f1 -d'.' | sed -E 's/\./_/g')
38+
H5_MINORVER=$(echo $H5_LIBVER | cut -f2 -d'.' | sed -E 's/\./_/g')
39+
H5_RELEASEVER=$(echo $H5_LIBVER | cut -f3 -d'.' | sed -E 's/\./_/g')
40+
H5_LIBVER_DIR=$H5_MAJORVER$H5_MINORVER
41+
42+
# Shell commands used in Makefiles
43+
RM="rm -rf"
44+
DIFF="diff -c"
45+
CMP="cmp -s"
46+
GREP='grep'
47+
CP="cp -p" # Use -p to preserve mode,ownership,timestamps
48+
DIRNAME='dirname'
49+
LS='ls'
50+
AWK='awk'
51+
52+
# setup plugin path
53+
ENVCMD="env HDF5_PLUGIN_PATH=$LD_LIBRARY_PATH/plugin"
54+
55+
TESTDIR=$builddir
56+
57+
58+
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
59+
*c*,-n*) ECHO_N= ECHO_C='
60+
' ;;
61+
*c*,* ) ECHO_N=-n ECHO_C= ;;
62+
*) ECHO_N= ECHO_C='\c' ;;
63+
esac
64+
ECHO_N="echo $ECHO_N"
65+
66+
67+
exout() {
68+
$*
69+
}
70+
71+
dumpout() {
72+
$H5DUMP $*
73+
}
74+
75+
# compare current version, required version.
76+
# returns if cur_ver < req_ver is true.
77+
version_compare() {
78+
version_lt=0
79+
if [ ! "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]; then
80+
version_lt=1
81+
fi
82+
}
83+
84+
85+
topics="alloc checksum chunk compact extern fillval gzip hyper \
86+
rdwr shuffle szip unlimadd unlimgzip unlimmod"
87+
topics18=""
88+
89+
version_compare "$H5_LIBVER" "1.8.0"
90+
# check if HDF5 version is < 1.8.0
91+
if [ "$version_lt" = 1 ]; then
92+
dir16="/16"
93+
else
94+
dir16=""
95+
topics18="nbit sofloat soint transform"
96+
fi
97+
98+
return_val=0
99+
100+
#Remove external data file from h5ex_d_extern
101+
rm -f h5ex_d_extern.data
102+
103+
for topic in $topics
104+
do
105+
$H5CC $srcdir/h5ex_d_$topic.c -o h5ex_d_$topic
106+
done
107+
108+
for topic in $topics
109+
do
110+
fname=h5ex_d_$topic
111+
$ECHO_N "Testing C/H5D/$fname...$ECHO_C"
112+
exout .$dir16/$fname >tmp.test
113+
status=$?
114+
if test $status -eq 1
115+
then
116+
echo " Unsupported feature"
117+
status=0
118+
else
119+
cmp -s tmp.test $srcdir/tfiles/16/$fname.tst
120+
status=$?
121+
if test $status -ne 0
122+
then
123+
echo " FAILED!"
124+
else
125+
dumpout $fname.h5 >tmp.test
126+
rm -f $fname.h5
127+
cmp -s tmp.test $srcdir/tfiles/16/$fname.ddl
128+
status=$?
129+
if test $status -ne 0
130+
then
131+
echo " FAILED!"
132+
else
133+
echo " Passed"
134+
fi
135+
fi
136+
return_val=`expr $status + $return_val`
137+
fi
138+
done
139+
140+
#######Non-standard tests#######
141+
USE_ALT=""
142+
### Set default tfiles directory for tests
143+
nbitdir="18"
144+
version_compare "$H5_LIBVER" "1.8.23"
145+
# check if HDF5 version is < 1.8.23
146+
if [ "$version_lt" = 1 ]; then
147+
USE_ALT="22"
148+
else
149+
# check if HDF5 version is >= 1.10.0 and < 1.10.8
150+
version_compare "$H5_LIBVER" "1.10.0"
151+
if [ "$version_lt" = 0 ]; then
152+
version_compare "$H5_LIBVER" "1.10.8"
153+
if [ "$version_lt" = 1 ]; then
154+
USE_ALT="07"
155+
nbitdir="110"
156+
fi
157+
fi
158+
fi
159+
160+
for topic in $topics18
161+
do
162+
$H5CC $srcdir/h5ex_d_$topic.c -o h5ex_d_$topic
163+
done
164+
165+
for topic in $topics18
166+
do
167+
fname=h5ex_d_$topic
168+
$ECHO_N "Testing C/H5D/$fname...$ECHO_C"
169+
exout ./$fname >tmp.test
170+
status=$?
171+
if test $status -eq 1
172+
then
173+
echo " Unsupported feature"
174+
status=0
175+
else
176+
if [[ $fname == "h5ex_d_nbit" ]]
177+
then
178+
tdir=$nbitdir
179+
if [[ $USE_ALT == "" ]]
180+
then
181+
### set USE_ALT=07 if not set above
182+
USE_ALT="07"
183+
fi
184+
else
185+
tdir=18
186+
### unset USE_ALT for the other topics
187+
USE_ALT=""
188+
fi
189+
cmp -s tmp.test $srcdir/tfiles/18/$fname.tst
190+
status=$?
191+
if test $status -ne 0
192+
then
193+
echo " FAILED!"
194+
else
195+
if [[ $fname == "h5ex_d_transform" ]]
196+
then
197+
targ="-n"
198+
else
199+
targ=""
200+
fi
201+
dumpout $targ $fname.h5 >tmp.test
202+
rm -f $fname.h5
203+
cmp -s tmp.test $srcdir/tfiles/$tdir/$fname$USE_ALT.ddl
204+
status=$?
205+
if test $status -ne 0
206+
then
207+
echo " FAILED!"
208+
else
209+
echo " Passed"
210+
fi
211+
fi
212+
return_val=`expr $status + $return_val`
213+
fi
214+
done
215+
216+
217+
#Remove external data file from h5ex_d_extern
218+
rm -f h5ex_d_extern.data
219+
rm -f tmp.test
220+
echo "$return_val tests failed in C/H5D/"
221+
exit $return_val

0 commit comments

Comments
 (0)