SYSFILE INFO: Convert test to Autotest framework.
[pspp-builds.git] / tests / command / split-file.sh
1 #!/bin/sh
2
3 # This program tests the split file 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$EXEEXT
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 program"
63 cat > $TEMPDIR/split.stat <<EOF
64 title 'Test SPLIT FILE utility'.
65
66 data list notable /X 1 Y 2.
67 begin data.
68 12
69 16
70 17
71 19
72 15
73 14
74 27
75 20
76 26
77 25
78 28
79 29
80 24
81 end data.
82 split file by x.
83 list.
84 EOF
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87 activity="run program"
88 $SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/split.stat
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91 activity="compare results"
92 diff -c $TEMPDIR/pspp.csv - <<EOF
93 Title: Test SPLIT FILE utility
94
95 Variable,Value,Label
96 X,1,
97
98 Table: Data List
99 X,Y
100 1,2
101 1,6
102 1,7
103 1,9
104 1,5
105 1,4
106
107 Variable,Value,Label
108 X,2,
109
110 Table: Data List
111 X,Y
112 2,7
113 2,0
114 2,6
115 2,5
116 2,8
117 2,9
118 2,4
119 EOF
120 if [ $? -ne 0 ] ; then fail ; fi
121
122 pass;