Checkin of new directory structure.
[pspp-builds.git] / 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
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
21 cleanup()
22 {
23      cd /
24      rm -rf $TEMPDIR
25 }
26
27
28 fail()
29 {
30     echo $activity
31     echo FAILED
32     cleanup;
33     exit 1;
34 }
35
36
37 no_result()
38 {
39     echo $activity
40     echo NO RESULT;
41     cleanup;
42     exit 2;
43 }
44
45 pass()
46 {
47     cleanup;
48     exit 0;
49 }
50
51 mkdir -p $TEMPDIR
52
53 cd $TEMPDIR
54
55 activity="create program"
56 cat > $TESTFILE <<EOF
57 /* Tries AUTORECODE on some random but similar strings of characters.
58 data list /X 1-5(a) Y 7.
59 begin data.
60 lasdj 1 1                                                           3
61 asdfk 0 3 <---- These are the numbers that should be produced for a 4
62 asdfj 2 4                                                           2
63 asdfj 1 4                                                           3
64 asdfk 2 3                                                           2
65 asdfj 9 4                                                           1
66 lajks 9 2                                                           1
67 asdfk 0 3 These are the numbers that should be produced for b ----> 4
68 asdfk 1 3                                                           3
69 end data.
70
71 autorecode x y into A B/descend.
72
73 list.
74 /* Just to make sure it works on second & subsequent executions,
75 /* try it again.
76 compute Z=trunc(y/2).
77 autorecode z into W.
78 list.
79 EOF
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="run program"
83 $SUPERVISOR $top_builddir/src/pspp    -o raw-ascii $TESTFILE
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="test output"
87 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
88 diff -b $TEMPDIR/pspp.list - <<EOF
89 1.1 DATA LIST.  Reading 1 record from INLINE.
90 +--------+------+-------+------+
91 |Variable|Record|Columns|Format|
92 #========#======#=======#======#
93 |X       |     1|  1-  5|A5    |
94 |Y       |     1|  7-  7|F1.0  |
95 +--------+------+-------+------+
96     X Y        A        B
97 ----- - -------- --------
98 lasdj 1     1.00     3.00 
99 asdfk 0     3.00     4.00 
100 asdfj 2     4.00     2.00 
101 asdfj 1     4.00     3.00 
102 asdfk 2     3.00     2.00 
103 asdfj 9     4.00     1.00 
104 lajks 9     2.00     1.00 
105 asdfk 0     3.00     4.00 
106 asdfk 1     3.00     3.00 
107     X Y        A        B        Z        W
108 ----- - -------- -------- -------- --------
109 lasdj 1     1.00     3.00      .00     1.00 
110 asdfk 0     3.00     4.00      .00     1.00 
111 asdfj 2     4.00     2.00     1.00     2.00 
112 asdfj 1     4.00     3.00      .00     1.00 
113 asdfk 2     3.00     2.00     1.00     2.00 
114 asdfj 9     4.00     1.00     4.00     3.00 
115 lajks 9     2.00     1.00     4.00     3.00 
116 asdfk 0     3.00     4.00      .00     1.00 
117 asdfk 1     3.00     3.00      .00     1.00 
118 EOF
119 if [ $? -ne 0 ] ; then fail ; fi
120
121 pass
122
123
124