AUTORECODE: Use Autotest for test suite.
[pspp] / tests / command / vector.sh
1 #!/bin/sh
2
3 # This program tests the VECTOR command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR" 
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create prog"
63 cat > $TEMPDIR/vector.stat <<EOF
64 data list notable/x 1.
65 vector v(4).
66 display vector.
67
68 data list notable/x 1.
69 vector #vec(4, comma10.2).
70 display vector.
71
72 input program.
73 vector x(5).
74 data list/x5 x2 x3 x1 x4 1-5.
75 end input program.
76 display vector.
77
78 data list notable/u w x y z 1-5.
79 vector a=u to y.
80 vector b=x to z.
81 vector c=all.
82 display vector.
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="run program"
87 $SUPERVISOR $PSPP -o pspp.csv -e $TEMPDIR/stdout $TEMPDIR/vector.stat
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="compare stdout"
91 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
92 diff -b $TEMPDIR/stdout  - <<EOF
93 EOF
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 activity="compare results"
97 diff -c $TEMPDIR/pspp.csv  - <<EOF
98 Vector,Position,Variable,Print Format
99 v,1,v1,F8.2
100 ,2,v2,F8.2
101 ,3,v3,F8.2
102 ,4,v4,F8.2
103
104 Vector,Position,Variable,Print Format
105 #vec,1,#vec1,COMMA10.2
106 ,2,#vec2,COMMA10.2
107 ,3,#vec3,COMMA10.2
108 ,4,#vec4,COMMA10.2
109
110 Table: Reading 1 record from INLINE.
111 Variable,Record,Columns,Format
112 x5,1,1-  1,F1.0
113 x2,1,2-  2,F1.0
114 x3,1,3-  3,F1.0
115 x1,1,4-  4,F1.0
116 x4,1,5-  5,F1.0
117
118 Vector,Position,Variable,Print Format
119 x,1,x1,F8.2
120 ,2,x2,F8.2
121 ,3,x3,F8.2
122 ,4,x4,F8.2
123 ,5,x5,F8.2
124
125 Vector,Position,Variable,Print Format
126 a,1,u,F1.0
127 ,2,w,F1.0
128 ,3,x,F1.0
129 ,4,y,F1.0
130 b,1,x,F1.0
131 ,2,y,F1.0
132 ,3,z,F1.0
133 c,1,u,F1.0
134 ,2,w,F1.0
135 ,3,x,F1.0
136 ,4,y,F1.0
137 ,5,z,F1.0
138 EOF
139 if [ $? -ne 0 ] ; then fail ; fi
140
141
142 pass;