Arith.test.in 1.43 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
#! @BASH@
Uwe Schulzweida's avatar
Uwe Schulzweida committed
2
3
4
5
6
echo 1..4 # Number of tests to be executed.
#
test -n "$CDO"      || CDO=cdo
test -n "$DATAPATH" || DATAPATH=./data
#
7
8
CDOOUT=cout$$
CDOERR=cerr$$
Uwe Schulzweida's avatar
Uwe Schulzweida committed
9
10
11
12
13
14
15
16
FORMAT="-f srv -b 32"
STATS="add sub mul div"
#
NTEST=1
#
for STAT in $STATS; do
  RSTAT=0

Uwe Schulzweida's avatar
Uwe Schulzweida committed
17
  RFILE=$DATAPATH/arith${STAT}_ref
Uwe Schulzweida's avatar
Uwe Schulzweida committed
18

Uwe Schulzweida's avatar
Uwe Schulzweida committed
19
20
  CDOTEST="$STAT"
  echo "Running test: $NTEST - $CDOTEST"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
21

Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
# stat vars mask
Uwe Schulzweida's avatar
Uwe Schulzweida committed
23

Uwe Schulzweida's avatar
Uwe Schulzweida committed
24
25
26
  IFILE1=$DATAPATH/arith1.srv
  IFILE2=$DATAPATH/arithmask.srv
  OFILE=arith${STAT}_res
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27

Uwe Schulzweida's avatar
Uwe Schulzweida committed
28
29
  CDOCOMMAND="$CDO $FORMAT ${STAT} $IFILE1 $IFILE2 $OFILE"
  echo $CDOCOMMAND
Uwe Schulzweida's avatar
Uwe Schulzweida committed
30

Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
32
  $CDOCOMMAND
  test $? -eq 0 || let RSTAT+=1
Uwe Schulzweida's avatar
Uwe Schulzweida committed
33

Uwe Schulzweida's avatar
Uwe Schulzweida committed
34
35
36
37
  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
  test $? -eq 0 || let RSTAT+=1
  test -s $CDOOUT && let RSTAT+=1
  cat $CDOOUT $CDOERR
Uwe Schulzweida's avatar
Uwe Schulzweida committed
38

Uwe Schulzweida's avatar
Uwe Schulzweida committed
39
  rm -f $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
40

Uwe Schulzweida's avatar
Uwe Schulzweida committed
41
# expr,instr var
Uwe Schulzweida's avatar
Uwe Schulzweida committed
42

Uwe Schulzweida's avatar
Uwe Schulzweida committed
43
44
45
46
47
  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
Uwe Schulzweida's avatar
Uwe Schulzweida committed
48

Uwe Schulzweida's avatar
Uwe Schulzweida committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  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"

  $CDOCOMMAND
  test $? -eq 0 || let RSTAT+=1

  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
  test $? -eq 0 || let RSTAT+=1
  test -s $CDOOUT && let RSTAT+=1
  cat $CDOOUT $CDOERR
Uwe Schulzweida's avatar
Uwe Schulzweida committed
63

Uwe Schulzweida's avatar
Uwe Schulzweida committed
64
  rm -f $OFILE
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65
66
67
68
69
70
71
72
73
74

  test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
  test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"

  let NTEST+=1
done
#
rm -f $CDOOUT $CDOERR
#
exit 0