Fix GCC 4.3 warning about uninitialized structure member.
[pspp] / tests / command / autorecod.sh
1 #!/bin/sh
2
3 # This program tests the autorecode command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8
9 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
14
15 # ensure that top_srcdir is absolute
16 top_srcdir=`cd $top_srcdir; pwd`
17
18 STAT_CONFIG_PATH=$top_srcdir/config
19 export STAT_CONFIG_PATH
20
21 LANG=C
22 export LANG
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 program"
63 cat > $TESTFILE <<EOF
64 /* Tries AUTORECODE on some random but similar strings of characters.
65 data list /X 1-5(a) Y 7.
66 begin data.
67 lasdj 1 1                                                           3
68 asdfk 0 3 <---- These are the numbers that should be produced for a 4
69 asdfj 2 4                                                           2
70 asdfj 1 4                                                           3
71 asdfk 2 3                                                           2
72 asdfj 9 4                                                           1
73 lajks 9 2                                                           1
74 asdfk 0 3 These are the numbers that should be produced for b ----> 4
75 asdfk 1 3                                                           3
76 end data.
77
78 autorecode x y into A B/descend.
79
80 list.
81 /* Just to make sure it works on second & subsequent executions,
82 /* try it again.
83 compute Z=trunc(y/2).
84 autorecode z into W.
85 list.
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 activity="run program"
90 $SUPERVISOR $PSPP --testing-mode $TESTFILE
91 if [ $? -ne 0 ] ; then no_result ; fi
92
93 activity="test output"
94 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
95 diff -b $TEMPDIR/pspp.list - <<EOF
96 1.1 DATA LIST.  Reading 1 record from INLINE.
97 +--------+------+-------+------+
98 |Variable|Record|Columns|Format|
99 #========#======#=======#======#
100 |X       |     1|  1-  5|A5    |
101 |Y       |     1|  7-  7|F1.0  |
102 +--------+------+-------+------+
103     X Y        A        B
104 ----- - -------- --------
105 lasdj 1     1.00     3.00 
106 asdfk 0     3.00     4.00 
107 asdfj 2     4.00     2.00 
108 asdfj 1     4.00     3.00 
109 asdfk 2     3.00     2.00 
110 asdfj 9     4.00     1.00 
111 lajks 9     2.00     1.00 
112 asdfk 0     3.00     4.00 
113 asdfk 1     3.00     3.00 
114     X Y        A        B        Z        W
115 ----- - -------- -------- -------- --------
116 lasdj 1     1.00     3.00      .00     1.00 
117 asdfk 0     3.00     4.00      .00     1.00 
118 asdfj 2     4.00     2.00     1.00     2.00 
119 asdfj 1     4.00     3.00      .00     1.00 
120 asdfk 2     3.00     2.00     1.00     2.00 
121 asdfj 9     4.00     1.00     4.00     3.00 
122 lajks 9     2.00     1.00     4.00     3.00 
123 asdfk 0     3.00     4.00      .00     1.00 
124 asdfk 1     3.00     3.00      .00     1.00 
125 EOF
126 if [ $? -ne 0 ] ; then fail ; fi
127
128 pass
129
130
131