Checkin of new directory structure.
[pspp-builds.git] / tests / command / flip.sh
1 #!/bin/sh
2
3 # This program tests the flip 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
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19
20 cleanup()
21 {
22      cd /
23      rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54 activity="create flip.stat"
55 cat > $TEMPDIR/flip.stat <<EOF
56 data list /N 1 (a) A B C D 2-9.
57 list.
58 begin data.
59 v 1 2 3 4 5
60 w 6 7 8 910
61 x1112131415
62 y1617181920
63 z2122232425
64 end data.
65 flip newnames=n.
66 list.
67 flip.
68 list.
69 EOF
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72
73 activity="run program"
74 $SUPERVISOR $top_builddir/src/pspp -o raw-ascii $TEMPDIR/flip.stat
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="compare output"
78 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
79 diff  -b  $TEMPDIR/pspp.list - << EOF
80 1.1 DATA LIST.  Reading 1 record from INLINE.
81 +--------+------+-------+------+
82 |Variable|Record|Columns|Format|
83 #========#======#=======#======#
84 |N       |     1|  1-  1|A1    |
85 |A       |     1|  2-  3|F2.0  |
86 |B       |     1|  4-  5|F2.0  |
87 |C       |     1|  6-  7|F2.0  |
88 |D       |     1|  8-  9|F2.0  |
89 +--------+------+-------+------+
90 N  A  B  C  D
91 - -- -- -- --
92 v  1  2  3  4 
93 w  6  7  8  9 
94 x 11 12 13 14 
95 y 16 17 18 19 
96 z 21 22 23 24 
97 CASE_LBL        V        W        X        Y        Z
98 -------- -------- -------- -------- -------- --------
99 A            1.00     6.00    11.00    16.00    21.00 
100 B            2.00     7.00    12.00    17.00    22.00 
101 C            3.00     8.00    13.00    18.00    23.00 
102 D            4.00     9.00    14.00    19.00    24.00 
103 CASE_LBL        A        B        C        D
104 -------- -------- -------- -------- --------
105 V            1.00     2.00     3.00     4.00 
106 W            6.00     7.00     8.00     9.00 
107 X           11.00    12.00    13.00    14.00 
108 Y           16.00    17.00    18.00    19.00 
109 Z           21.00    22.00    23.00    24.00 
110 EOF
111 if [ $? -ne 0 ] ; then fail ; fi
112
113
114 pass;