forked from Unidata/netcdf-c
/
run_filter.sh
executable file
·199 lines (177 loc) · 5.81 KB
/
run_filter.sh
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
#!/bin/bash
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
. "$srcdir/test_nczarr.sh"
set -e
testset() {
# Which test cases to exercise
testapi $1
#testng $1
#testncp $1
#testunk $1
#testngc $1
#testmisc $1
#testmulti $1
#testrep $1
#testorder $1
}
# Function to remove selected -s attributes from file;
# These attributes might be platform dependent
sclean() {
cat $1 \
| sed -e '/:_IsNetcdf4/d' \
| sed -e '/:_Endianness/d' \
| sed -e '/_NCProperties/d' \
| sed -e '/_SuperblockVersion/d' \
| cat > $2
}
# Function to extract _Filter attribute from a file
# These attributes might be platform dependent
getfilterattr() {
sed -e '/var.*:_Filter/p' -ed <$1 >$2
}
# Function to extract _Codecs attribute from a file
# These attributes might be platform dependent
getcodecsattr() {
sed -e '/var.*:_Codecs/p' -ed <$1 >$2
}
trimleft() {
sed -e 's/[ ]*\([^ ].*\)/\1/' <$1 >$2
}
# Locate the plugin path and the library names; argument order is critical
# Find bzip2 and capture
findplugin h5bzip2
BZIP2LIB="${HDF5_PLUGIN_LIB}"
BZIP2PATH="${HDF5_PLUGIN_PATH}/${BZIP2LIB}"
# Find misc and capture
findplugin h5misc
MISCPATH="${HDF5_PLUGIN_PATH}/${HDF5_PLUGIN_LIB}"
# Verify
if ! test -f ${BZIP2PATH} ; then echo "Unable to locate ${BZIP2PATH}"; exit 1; fi
if ! test -f ${MISCPATH} ; then echo "Unable to locate ${MISCPATH}"; exit 1; fi
# Execute the specified tests
testapi() {
zext=$1
echo "*** Testing dynamic filters using API for map=$zext"
deletemap $zext tmp_api
fileargs tmp_api
${execdir}/testfilter $fileurl
${NCDUMP} -s -n bzip2 $fileurl > ./tmp_api_$zext.txt
# Remove irrelevant -s output
sclean ./tmp_api_$zext.txt ./tmp_api_$zext.dump
diff -b -w ${srcdir}/ref_bzip2.cdl ./tmp_api_$zext.dump
echo "*** Pass: API dynamic filter for map=$zext"
}
testmisc() {
zext=$1
echo "*** Testing dynamic filters parameter passing for map $zext"
deletemap $zext tmp_misc
fileargs tmp_misc
${execdir}/testfilter_misc $fileurl
# Verify the parameters via ncdump
${NCDUMP} -s $fileurl > ./tmp_misc_$zext.txt
# Extract the parameters
getfilterattr ./tmp_misc_$zext.txt ./tmp_misc2_$zext.txt
rm -f ./tmp_misc_$zext.txt
trimleft ./tmp_misc2_$zext.txt ./tmp_misc_$zext.txt
rm -f ./tmp_misc2_$zext.txt
cat >./tmp_misc2_$zext.txt <<EOF
var:_Filter = "32768,2,239,23,65511,27,77,93,1145389056,3287505826,1097305129,1,2147483648,4294967295,4294967295" ;
EOF
diff -b -w ./tmp_misc_$zext.txt ./tmp_misc_$zext.txt
echo "*** Pass: parameter passing for map $zext"
}
testng() {
zext=$1
echo "*** Testing dynamic filters using ncgen for map $zext"
deletemap $zext tmp_misc
fileargs tmp_misc
${NCGEN} -lb -4 -o $fileurl ${srcdir}/../nc_test4/bzip2.cdl
${NCDUMP} -s -n bzip2 $fileurl > ./tmp_ng_$zext.txt
# Remove irrelevant -s output
sclean ./tmp_ng_$zext.txt ./tmp_ng2_$zext.txt
diff -b -w ${srcdir}/ref_bzip2.cdl ./tmp_ng2_$zext.txt
echo "*** Pass: ncgen dynamic filter for map $zext"
}
testncp() {
zext=$1
echo "*** Testing dynamic filters using nccopy for map $zext"
deletemap $zext tmp_misc
fileargs tmp_unfiltered
# Create our input test files
${NCGEN} -4 -lb -o $fileurl ${srcdir}/../nc_test4/ref_unfiltered.cdl
fileurl0=$fileurl
fileargs tmp_filtered
${NCCOPY} -M0 -F "/g/var,307,9,4" $fileurl0 $fileurl
${NCDUMP} -s -n filtered $fileurl > ./tmp_ncp_$zext.txt
# Remove irrelevant -s output
sclean ./tmp_ncp_$zext.txt ./tmp_ncp_$zext.dump
diff -b -w ${srcdir}/ref_filtered.cdl ./tmp_ncp_$zext.dump
echo " *** Pass: nccopy simple filter for map $zext"
}
testunk() {
zext=$1
echo "*** Testing access to filter info when filter implementation is not available for map $zext"
deletemap $zext tmp_known
fileargs tmp_known
# build bzip2.nc
${NCGEN} -lb -4 -o $fileurl ${srcdir}/../nc_test4/bzip2.cdl
# dump and clean bzip2.nc header when filter is avail
${NCDUMP} -hs $fileurl > ./tmp_known_$zext.txt
# Remove irrelevant -s output
sclean ./tmp_known_$zext.txt tmp_known_$zext.dump
# Now hide the filter code
mv ${BZIP2PATH} ./${BZIP2LIB}.save
# dump and clean bzip2.nc header when filter is not avail
${NCDUMP} -hs $fileurl > ./tmp_unk_$zext.txt
# Restore the filter code
mv ./${BZIP2LIB}.save ${BZIP2PATH}
# Verify that the filter is no longer defined
UNK=`sed -e '/var:_Filter/p' -e d ./tmp_unk_$zext.txt`
test "x$UNK" = x
echo "*** Pass: ncgen dynamic filter for map $zext"
}
testngc() {
zext=$1
echo "*** Testing dynamic filters using ncgen with -lc for map $zext"
deletemap $zext tmp_ngc
fileargs tmp_ngc
${NCGEN} -lc -4 ${srcdir}/../nc_test4/bzip2.cdl > tmp_ngc.c
diff -b -w ${srcdir}/../nc_test4/../nc_test4/ref_bzip2.c ./tmp_ngc.c
echo "*** Pass: ncgen dynamic filter for map $zext"
}
testmulti() {
zext=$1
echo "*** Testing multiple filters for map $zext"
deletemap $zext tmp_multi
fileargs tmp_multi
${execdir}/testfilter_multi $fileurl
${NCDUMP} -hs -n multifilter $fileurl >./tmp_multi_$zext.cdl
# Remove irrelevant -s output
sclean ./tmp_multi_$zext.cdl ./tmp_smulti_$zext.cdl
diff -b -w ${srcdir}/ref_multi.cdl ./tmp_smulti_$zext.cdl
echo "*** Pass: multiple filters for map $zext"
}
testrep() {
zext=$1
echo "*** Testing filter re-definition invocation for map $zext"
deletemap $zext tmp_rep
fileargs tmp_rep
${execdir}/testfilter_repeat $fileurl >tmp_rep_$zext.txt
diff -b -w ${srcdir}/../nc_test4/ref_filter_repeat.txt tmp_rep_$zext.txt
}
testorder() {
zext=$1
echo "*** Testing multiple filter order of invocation on create for map $zext"
deletemap $zext tmp_order
fileargs tmp_order
${execdir}/testfilter_order create $fileurl >tmp_order_$zext.txt
diff -b -w ${srcdir}/../nc_test4/ref_filter_order_create.txt tmp_order_$zext.txt
echo "*** Testing multiple filter order of invocation on read for map $zext"
${execdir}/testfilter_order read $fileurl >tmp_order_rd_$zext.txt
diff -b -w ${srcdir}/../nc_test4/ref_filter_order_read.txt tmp_order_rd_$zext.txt
}
testset file
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then testset zip ; fi
if test "x$FEATURE_S3TESTS" = xyes ; then testset s3 ; fi
exit 0