Commit 69000e84 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

simplified tests and cleaned them up

parent fdea742d
......@@ -7,9 +7,9 @@ HAS_CGRIBEX=`${CDO} --config has-cgribex`
#
AFTERTESTFILE=ECHAM5_T42L19.grb
if [ -f "$CDOTESTDATA/$AFTERTESTFILE" -a "${HAS_CGRIBEX}" = yes ]; then
echo 1..4 # Number of tests to be executed.
echo 1..4 # Number of tests to be executed.
else
echo 1..1 # Number of tests to be executed.
echo 1..1 # Number of tests to be executed.
fi
#
ABSLIMMAX=0.0001
......@@ -101,15 +101,13 @@ test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=$ABSLIMMAX $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
#
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
let NTEST+=1
rm -f $OFILE
#
######################################################
SELECT=atm2
IFILE=$CDOTESTDATA/$AFTERTESTFILE
......
#! @BASH@
. ./cdoTestFunctions.test
echo 1..8 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
......@@ -10,69 +11,59 @@ STATS="add sub mul div"
NTEST=1
#
for STAT in $STATS; do
RSTAT=0
if [ -z "$1" ] || [ $NTEST == $1 ]; then
RSTAT=0
RFILE=$DATAPATH/arith${STAT}_ref
CDOTEST="$STAT"
IFILE1=$DATAPATH/arith1.srv
IFILE2=$DATAPATH/arithmask.srv
OFILE=arith${STAT}_res
RFILE=$DATAPATH/arith${STAT}_ref
CDOTEST="$STAT"
echo "Running test: $NTEST - arith $CDOTEST"
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE1 $IFILE2 $OFILE"
TESTCOMMAND="$CDO diff $OFILE $RFILE"
# stat vars mask
IFILE1=$DATAPATH/arith1.srv
IFILE2=$DATAPATH/arithmask.srv
OFILE=arith${STAT}_res
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE1 $IFILE2 $OFILE"
echo $CDOCOMMAND
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
runTest "$NTEST" "$CDOTEST" "$CDOCOMMAND" "$TESTCOMMAND"
fi
let NTEST+=1
done
for STAT in $STATS; do
RSTAT=0
if [ -z "$1" ] || [ $NTEST == $1 ]; then
RSTAT=0
# expr,instr var
# expr,instr var
OP=""
if [ "$STAT" = add ] ; then OP='+' ; fi
if [ "$STAT" = sub ] ; then OP='-' ; fi
if [ "$STAT" = mul ] ; then OP='*' ; fi
if [ "$STAT" = div ] ; then OP='/' ; fi
RFILE=$DATAPATH/arith${STAT}_ref
OP=""
if [ "$STAT" = add ] ; then OP='+' ; fi
if [ "$STAT" = sub ] ; then OP='-' ; fi
if [ "$STAT" = mul ] ; then OP='*' ; fi
if [ "$STAT" = div ] ; then OP='/' ; fi
RFILE=$DATAPATH/arith${STAT}_ref
CDOTEST="$STAT"
echo "Running test: $NTEST - expr $CDOTEST"
CDOTEST="$STAT"
echo "Running test: $NTEST - expr $CDOTEST"
IFILE=$DATAPATH/expr1.srv
OFILE=expr${STAT}_res
IFILE=$DATAPATH/expr1.srv
OFILE=expr${STAT}_res
INSTR="var215=var215${OP}var3;var216=var216${OP}var3;"
echo $INSTR
CDOCOMMAND="$CDO $FORMAT expr,$INSTR $IFILE $OFILE"
INSTR="var215=var215${OP}var3;var216=var216${OP}var3;"
echo $INSTR
CDOCOMMAND="$CDO $FORMAT expr,$INSTR $IFILE $OFILE"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE
rm -f $OFILE
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
fi
let NTEST+=1
let NTEST+=1
done
#
exit 0
......@@ -13,67 +13,65 @@ IFILE=$DATAPATH/pl_data
NTEST=1
#
for STAT in $STATS; do
RSTAT=0
RSTAT=0
OFILE=stat${STAT}_res
for VAR in -777 -1 0 1 777; do
if [ -z "$1" ] || [ $NTEST == $1 ]; then
VAL=1
CFILE=constval
$CDO -f srv -b 64 const,$VAL,$IFILE $CFILE
OFILE=stat${STAT}_res
# stat var const
for VAR in -777 -1 0 1 777; do
VAL=1
CFILE=constval
$CDO -f srv -b 64 const,$VAL,$IFILE $CFILE
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE $CFILE $OFILE"
# stat var const
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE $CFILE $OFILE"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
# stat,const var
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
OFILE2=stat${STAT}c_res
CDOCOMMAND="$CDO $FORMAT ${STAT}c,$VAL $IFILE $OFILE2"
# stat,const var
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
OFILE2=stat${STAT}c_res
CDOCOMMAND="$CDO $FORMAT ${STAT}c,$VAL $IFILE $OFILE2"
$CDO diff $OFILE $OFILE2
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
# expr,instr var
$CDO diff $OFILE $OFILE2
test $? -eq 0 || let RSTAT+=1
OP=""
if [ "$STAT" = add ] ; then OP='+' ; fi
if [ "$STAT" = sub ] ; then OP='-' ; fi
if [ "$STAT" = mul ] ; then OP='*' ; fi
if [ "$STAT" = div ] ; then OP='/' ; fi
OFILE3=arithc_expr${STAT}_res
INSTR="var130=var130${OP}${VAL};var152=var152${OP}${VAL};var129=var129${OP}${VAL};"
echo $INSTR
CDOCOMMAND="$CDO $FORMAT expr,$INSTR $IFILE $OFILE3"
# expr,instr var
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
OP=""
if [ "$STAT" = add ] ; then OP='+' ; fi
if [ "$STAT" = sub ] ; then OP='-' ; fi
if [ "$STAT" = mul ] ; then OP='*' ; fi
if [ "$STAT" = div ] ; then OP='/' ; fi
OFILE3=arithc_expr${STAT}_res
INSTR="var130=var130${OP}${VAL};var152=var152${OP}${VAL};var129=var129${OP}${VAL};"
echo $INSTR
CDOCOMMAND="$CDO $FORMAT expr,$INSTR $IFILE $OFILE3"
$CDO diff $OFILE $OFILE3
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $OFILE3
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE $OFILE2 $OFILE3 $CFILE
done
rm -f $OFILE $OFILE2 $OFILE3 $CFILE
fi
done
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
let NTEST+=1
done
#
......
......@@ -4,7 +4,7 @@ echo 1..1 # Number of tests to be executed.
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
STATS="cat"
FORMAT="-f srv -b 32"
RSTAT=0
......@@ -21,7 +21,7 @@ cat $IFILE >> ${RFILE}
rm -f ${OFILE}
#
CDOTEST="cat"
CDOCOMMAND="$CDO cat $IFILE ${OFILE}"
CDOCOMMAND="$CDO $STATS $IFILE ${OFILE}"
#
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
......
......@@ -11,7 +11,7 @@ FORMAT="-f srv -b 32"
declare -a SHOW
declare -a STATS
WHAT_TO_SHOW=("showcode" "showname" "showunit" "showlevel")
TEST_CALLS=("chcode,-1,101" "chname,topo,newname" "chunit,m,km" "chlevel,0,101")
STATS=("chcode,-1,101" "chname,topo,newname" "chunit,m,km" "chlevel,0,101")
EXPECTED_RESULTS=("101" "newname" "km" "101")
IFILE="-topo"
CDOCALL="$CDO $FORMAT"
......@@ -19,17 +19,19 @@ CDOCALL="$CDO $FORMAT"
RSTAT=0
for i in {0..3};
do
CDOCOMMAND="$CDOCALL ${WHAT_TO_SHOW[$i]} -${TEST_CALLS[$i]} $IFILE $OUTFILE"
if [ -z "$1" ] || [ $NTEST == $1 ]; then
CDOCOMMAND="$CDOCALL ${WHAT_TO_SHOW[$i]} -${STATS[$i]} $IFILE $OUTFILE"
RESULT=$($CDOCOMMAND | sed 's/ //g')
test $? -eq 0 || let RSTAT=-1
if [ "$RESULT" == "${EXPECTED_RESULTS[$i]}" ]
then
echo "ok $NTEST - ${WHAT_TO_SHOW[$i]}"
else
echo "$CDOCOMMAND"
echo "Expected ${EXPECTED_RESULTS[$i]} got $RESULT"
echo "not ok $NTEST - ${SHOW[$i]}"
RESULT=$($CDOCOMMAND | sed 's/ //g')
test $? -eq 0 || let RSTAT=-1
if [ "$RESULT" == "${EXPECTED_RESULTS[$i]}" ]
then
echo "ok $NTEST - ${WHAT_TO_SHOW[$i]}"
else
echo "$CDOCOMMAND"
echo "Expected ${EXPECTED_RESULTS[$i]} got $RESULT"
echo "not ok $NTEST - ${SHOW[$i]}"
fi
fi
done
......@@ -14,46 +14,50 @@ NTEST=1
HAS_NETCDF=`${CDO} --config has-nc`
#
for GRIDTYPE in $GRIDTYPES; do
for DIST in $DISTS; do
RSTAT=0
for DIST in $DISTS; do
if [ -z "$1" ] || [ $NTEST == $1 ]; then
RSTAT=0
GT=$(echo $GRIDTYPE | cut -c1)
FILE=data${GT}.nc
IFILE=$DATAPATH/${FILE}
OFILE=${OPERATOR}_${FILE}
GT=$(echo $GRIDTYPE | cut -c1)
FILE=data${GT}.nc
IFILE=$DATAPATH/${FILE}
OFILE=${OPERATOR}_${FILE}
CDO_DEBUG=""
CDO_DEBUG=""
CDOTEST="$GRIDTYPE $DIST"
CDOTEST="$GRIDTYPE $DIST"
if [ "${HAS_NETCDF}" = yes ] ; then
nx=$(echo $DIST | sed 's/,.*//')
NX=""
if [ $FILE != datar.nc ] ; then NX=",$nx" ; fi
if [ "${HAS_NETCDF}" = yes ] ; then
nx=$(echo $DIST | sed 's/,.*//')
NX=""
if [ $FILE != datar.nc ] ; then
NX=",$nx" ;
fi
CDOCOMMAND="$CDO $STATS$NX xxx* $OFILE"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
CDOCOMMAND="$CDO $STATS$NX xxx* $OFILE"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
$CDO distgrid,$DIST $IFILE xxx
test $? -eq 0 || let RSTAT+=1
$CDO distgrid,$DIST $IFILE xxx
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $IFILE $OFILE
test $? -eq 0 || let RSTAT+=1
$CDO diff $IFILE $OFILE
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE xxx*
rm -f $OFILE xxx*
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
else
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP netCDF not enabled"
fi
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
else
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP netCDF not enabled"
fi
let NTEST+=1
done
fi
let NTEST+=1
done
done
#
exit 0
......@@ -14,28 +14,29 @@ CFILE=constdata
$CDO $FORMAT const,${CONST},${IFILE} $CFILE
#
for STAT in $STATS; do
RSTAT=0
if [ -z "$1" ] || [ $NTEST == $1 ]; then
RSTAT=0
RFILE=$DATAPATH/comp_${STAT}c_ref
OFILE=comp_${STAT}_res
RFILE=$DATAPATH/comp_${STAT}c_ref
OFILE=comp_${STAT}_res
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE $CFILE $OFILE"
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE $CFILE $OFILE"
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
let NTEST+=1
rm -f $OFILE
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
rm -f $OFILE
fi
let NTEST+=1
done
#
rm -f $CFILE
......
......@@ -14,31 +14,28 @@ IFILE=$DATAPATH/comptest.srv
NTEST=1
#
for STAT in $STATS; do
RSTAT=0
if [ -z "$1" ] || [ $NTEST == $1 ]; then
RSTAT=0
RFILE=$DATAPATH/comp_${STAT}_ref
OFILE=comp_${STAT}_res
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT},${CONST} $IFILE $OFILE"
RFILE=$DATAPATH/comp_${STAT}_ref
OFILE=comp_${STAT}_res
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
CDOTEST="$STAT"
CDOCOMMAND="$CDO $FORMAT ${STAT},${CONST} $IFILE $OFILE"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
echo "Running test: $NTEST - $CDOTEST"
echo "$CDOCOMMAND"
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
let NTEST+=1
rm -f $OFILE
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
rm -f $OFILE
fi
let NTEST+=1
done
#
......
......@@ -4,7 +4,7 @@ echo 1..5 # Number of tests to be executed.
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
#
STATS="copy"
#
FILES="datar.nc datag.nc datac.nc datau.nc testfile01c.nc"
......@@ -13,38 +13,36 @@ NTEST=1
#
HAS_NETCDF=`${CDO} --config has-nc`
#
for OPERATOR in copy; do
for FILE in $FILES; do
RSTAT=0
for OPERATOR in $STATS; do
for FILE in $FILES; do
RSTAT=0
IFILE=$DATAPATH/${FILE}
OFILE=${OPERATOR}_${FILE}
IFILE=$DATAPATH/${FILE}
OFILE=${OPERATOR}_${FILE}
CDOTEST="$OPERATOR $FILE"
CDOCOMMAND="$CDO $OPERATOR $IFILE $OFILE"
CDOTEST="$OPERATOR $FILE"
CDOCOMMAND="$CDO $OPERATOR $IFILE $OFILE"
if [ "${HAS_NETCDF}" = yes ] ; then
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
if [ "${HAS_NETCDF}" = yes ] ; then
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
$CDO diff $IFILE $OFILE
test $? -eq 0 || let RSTAT+=1
$CDO diff $IFILE $OFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
else
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP netCDF not enabled"
fi
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
else
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP netCDF not enabled"
fi
let NTEST+=1
rm -f $OFILE
done
let NTEST+=1
rm -f $OFILE
done
done
#
......
......@@ -2,9 +2,10 @@
echo 1..2 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data"
#
declare -a STATS
STATS=("detrend" "trend" "subtrend")
#
IFILE=$DATAPATH/detrend_data
......@@ -16,8 +17,7 @@ OFILE=detrend_res
#
# detrend
#
CDOTEST="detrend"
CDOCOMMAND="$CDO $CDOTEST $IFILE $OFILE"
CDOCOMMAND="$CDO ${STATS[0]} $IFILE $OFILE"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
......@@ -28,8 +28,6 @@ test $? -eq 0 || let RSTAT+=1
$CDO diff $OFILE $RFILE
test $? -eq 0 || let RSTAT+=1
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
......@@ -38,8 +36,7 @@ rm -f $OFILE
#
# trend
#
CDOTEST="trend/subtrend"
CDOCOMMAND="$CDO trend $IFILE ta tb"
CDOCOMMAND="$CDO ${STATS[1]} $IFILE ta tb"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
......@@ -47,7 +44,7 @@ echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
#
CDOCOMMAND="$CDO subtrend $IFILE ta tb $OFILE"
CDOCOMMAND="$CDO ${STATS[2]} $IFILE ta tb $OFILE"
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
......
#! @BASH@
#
echo 1..4 # Number of tests to be executed.
echo 1..8 # Number of tests to be executed.
#
test -n "$CDO" || CDO="@abs_top_builddir@/src/cdo $CDO_DEBUG"
test -n "$DATAPATH" || DATAPATH="@abs_top_srcdir@/test/data/"
......@@ -22,49 +22,53 @@ OFILE1=eval_res
OFILE2=eof_res
OFILE3=res_pcoeff
#
DIM=""
declare -a STATS
STATS=("eof" "eofcoeff" "eof3d" "eofcoeff3d")
#
for X in 1 2; do
if [ $X = 2 ] ; then DIM=3d ; fi
for MODE in jacobi danielson_lanczos; do
export CDO_SVD_MODE=$MODE
RSTAT=0
CDOTEST="eof${DIM}/eofcoeff${DIM} - $MODE"
CDOCOMMAND="$CDO $FORMAT eof${DIM},1 $IFILE $OFILE1 $OFILE2"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=1e-8 $OFILE1 $RFILE1
test $? -eq 0 || let RSTAT+=1
RSTAT=0
#
$CDO diff,abslim=1e-7 -abs $OFILE2 -abs $RFILE2
test $? -eq 0 || let RSTAT+=1
CDOCOMMAND="$CDO $FORMAT eofcoeff${DIM} $OFILE2 $IFILE $OFILE3"
echo "$CDOCOMMAND"
$CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
#
$CDO diff,abslim=0.02 -abs ${OFILE3}00000 -abs $RFILE3
test $? -eq 0 || let RSTAT+=1
#
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
let NTEST+=1
rm -f $OFILE1 $OFILE2 ${OFILE3}00000
done