Fixed numerous memory leaks. Changed many of the test cases to use a canonical
[pspp-builds.git] / tests / command / tabs.sh
1 #!/bin/sh
2
3 # This program tests that tab characters can be used in string input
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program 1"
50 cat > $TEMPDIR/tabs.stat <<EOF
51 data list /x 1-80 (a).
52 begin data.
53 EOF
54 if [ $? -ne 0 ] ; then no_result ; fi
55
56 activity="create program 2"
57 printf  "\t1\t12\t123\t1234\t12345\n" >> $TEMPDIR/tabs.stat
58 if [ $? -ne 0 ] ; then no_result ; fi
59
60
61 activity="create program 3"
62 cat >> $TEMPDIR/tabs.stat <<EOF
63 end data.
64 print /x.
65 execute.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 activity="run program"
71 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/tabs.stat
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 diff -B -b $TEMPDIR/pspp.list - << EOF
76 1.1 DATA LIST.  Reading 1 record from the command file.
77 +--------+------+-------+------+
78 |Variable|Record|Columns|Format|
79 #========#======#=======#======#
80 |X       |     1|  1- 80|A80   |
81 +--------+------+-------+------+
82     1   12  123 1234    12345
83 EOF
84 if [ $? -ne 0 ] ; then fail ; fi
85
86 pass;