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
|
#!/bin/bash
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Override option processing
#NOOPTIONS=1
#. ${srcdir}/d4test_common.sh
set +e
defaults() {
# Set defaults
CHECKSUM="false"
SVC="192.168.56.1:8083"
#SVC="remotetest.unidata.ucar.edu"
fileset
constrainedfileset
}
usage() {
echo "usage: bt.sh \
[-h|--help]\
[-S|--svc <server>]\
[-I|--input \"<input-files>\"]\
[-C|--ce \"<constraint-files>\"]\
[-c|-checksum]\
[--data]\
[actions]\
"
echo "where actions is a sequence of: \
reset\
|build\
|dmr\
|dap\
|cdl\
|install\
|cleanup\
"
exit 1
}
options() {
while test "$#" -gt 0 ; do
case "$1" in
-h|--help) usage ; shift ;;
-S|--svc) shift; SVC="$1"; shift ;;
-I|--input) shift; unset CE; F="$1"; shift ;;
-C|--ce) shift; unset F; CE="$1"; shift ;;
-c|--checksum) CHECKSUM="true"; shift ;;
--data) SHOWDATA="true"; shift ;;
reset) ACTIONS="$ACTIONS reset" ; shift ;;
build) ACTIONS="$ACTIONS build" ; shift ;;
dmr) ACTIONS="$ACTIONS dmr"; shift ;;
dap) ACTIONS="$ACTIONS dap" ; shift ;;
cdl) ACTIONS="$ACTIONS cdl" ; shift ;;
install) ACTIONS="$ACTIONS install"; shift ;;
cleanup) ACTIONS="$ACTIONS cleanup"; shift ;;
*) echo "unknown option $1" ; break ;;
esac
done
}
setup() {
if test "x$CHECKSUM" = xtrue ; then
CSUM="dap4.checksum=true"
else
CSUM="dap4.checksum=false"
fi
AMPCSYM="&${CSUM}"
excludedfiles
}
excludedfiles() {
# make sure each name is surrounded with a blank
# so we can do proper substring test
XCDL=" \
test_vlen9 \
test_vlen10 \
"
XDMR="$XCDL"
XDAP="$XCDL"
}
excluded() {
local X KIND R EX
X="$1"
KIND="$2"
R=0
if test "x$KIND" = xdmr ; then EX="$XDMR" ;
elif test "x$KIND" = xdap ; then EX="$XDAP" ;
elif test "x$KIND" = xcdl ; then EX="$XCDL" ;
else
echo "Unknown exclusion kined: $KIND"
exit 1
fi
for ex in $EX ; do
if test "x$ex" = "x$X" ; then R=1 ; fi
done
return $R
}
fileset() {
local TMP x X
# Total file set
TMP=`ls -1 ${srcdir}/cdltestfiles/*.cdl`
for x in $TMP ; do
X=`basename $x .cdl`
F="$F $X"
done
# Mac echo does not support -n flag
F=`echon $F | cut -f1-`
}
constrainedfileset() {
# Constrained tests
CE=" \
test_atomic_array?/vu8[1][0:2:2];/vd[1];/vs[1][0];/vo[0][1]=1 \
test_atomic_array?/v16[0:1,3]=2 \
test_atomic_array?/v16[3,0:1]=3 \
test_one_vararray?/t[1]=4 \
test_one_vararray?/t[0:1]=5 \
test_enum_array?/primary_cloud[1:2:4]=6 \
test_opaque_array?/vo2[1][0:1]=7 \
test_struct_array?/s[0:2:3][0:1]=8 \
"
}
splitce() {
local expr tmp
expr="$1"
CE_F=`echon $expr | cut -d'?' -f1`
CE_INDEX=`echon $expr | cut -d'=' -f2`
tmp=`echon $expr | cut -d'?' -f2`
CE_CE=`echon $tmp | cut -d'=' -f1`
}
ceescape() {
CEX=`echon "$1" | sed -e 's|\[|%5b|g' -e 's|]|%5d|g'`
}
build() {
# Build the unconstrained .nc files and .ncdump files
for f in $F ; do
excluded ${f} cdl
if test $? = 0 ; then
${NCGEN} -4 -o "${srcdir}/downloads/${f}.nc" "${srcdir}/cdltestfiles/${f}.cdl"
${NCDUMP} "${srcdir}/downloads/${f}.nc" > ${srcdir}/downloads/${f}.ncdump
fi
done
}
capturedmr() {
local TARGET
for f in $F ; do
excluded ${f} dmr
if test $? = 0 ; then
TARGET="downloads/${f}.nc.dmr"
wget -t2 -O ${TARGET} "http://$SVC/d4ts/testfiles/${f}.nc.dmr.xml?$CSUM"
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
for e in $CE ; do
splitce $e # Split CE
excluded ${CE_F} dmr
if test $? = 0 ; then
TARGET="downloads/${CE_F}.$CE_INDEX.nc.dmr"
ceescape ${CE_CE}
wget -t2 -O ${TARGET} "http://$SVC/d4ts/testfiles/${CE_F}.nc.dmr.xml?$CSUM&dap4.ce=${CEX}"
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
}
capturedap() {
local TARGET
for f in $F ; do
excluded ${f} dap
if test "x$?" = x0 ; then
TARGET="downloads/${f}.nc.dap"
wget -t2 -O ${TARGET} "http://$SVC/d4ts/testfiles/${f}.nc.dap?$CSUM"
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
for e in $CE ; do
splitce $e # Split CE
excluded ${CE_F} dap
if test $? = 0 ; then
TARGET="downloads/${CE_F}.$CE_INDEX.nc.dap"
ceescape "$CE_CE"
wget -t2 -O ${TARGET} "http://$SVC/d4ts/testfiles/${CE_F}.nc.dap?$CSUM&dap4.ce=${CEX}"
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
}
capturecdl() {
local TARGET
for f in $F ; do
excluded ${f} cdl
if test "x$?" = x0 ; then
TARGET="downloads/${f}.nc.cdl"
if test "x$SHOWDATA" = xtrue ; then HOPT="-h" ; fi
${NCDUMP} $HOPT "http://$SVC/d4ts/testfiles/${f}.nc?$CSUM#dap4" >${TARGET}
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
for e in $CE ; do
splitce $e # Split CE
excluded ${CE_F} dap
if test $? = 0 ; then
TARGET="downloads/${CE_F}.nc.$CE_INDEX.cdl"
if test "x$SHOWDATA" = xtrue ; then HOPT="-h" ; fi
${NCDUMP} $HOPT "http://$SVC/d4ts/testfiles/${CE_F}.nc?$CSUM&dap4.ce=${CE_CE}#dap4" >${TARGET}
if test "x$?" != x0 ; then
echo ">>> wget failed: ${TARGET}"
rm -f ${TARGET}
fi
fi
done
}
install() {
local ret
ret=0
if test "x$DMR" = x1 ; then
rm -f dmrtestfiles/*.dmr
cp downloads/*.dmr dmrtestfiles
fi
if test "x$DAP" = x1 ; then
rm -f daptestfiles/*.dap
cp downloads/*.dap daptestfiles
fi
return $ret
}
cleanup() {
rm -fr downloads
}
actions() {
for a in $ACTIONS ; do
case "$a" in
reset) rm -fr downloads; mkdir downloads ;;
cleanup) cleanup ;;
build) build ;;
install) install ;;
dmr) capturedmr ;;
dap) capturedap ;;
cdl) capturecdl ;;
esac
done
}
main() {
defaults
options "$@"
setup
actions
}
main "$@"
|