New implementation of long variable names. Each variable has a
[pspp-builds.git] / tests / command / sample.sh
1 #!/bin/sh
2
3 # This program tests the SAMPLE function
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
50 activity="create program"
51 cat > $TEMPDIR/sample.stat <<EOF
52 set seed=3
53
54 data list notable /A 1-2.
55 begin data.
56 1
57 2
58 3
59 4
60 5
61 6
62 7
63 8
64 9
65 10
66 end data.
67 sample .5.
68 list.
69 EOF
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72
73 activity="run program"
74 $SUPERVISOR $here/../src/pspp -o raw-ascii --testing-mode $TEMPDIR/sample.stat 
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="create head"
78 grep -v '^\ *$' $TEMPDIR/pspp.list | head -2 > $TEMPDIR/head
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="extract data"
82 grep  '[0-9][0-9]*' $TEMPDIR/pspp.list > $TEMPDIR/data
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85
86 activity="compare head"
87 diff -B -b $TEMPDIR/head - << EOF
88  A
89 --
90 EOF
91 if [ $? -ne 0 ] ; then fail ; fi
92
93 activity="compare data"
94 diff -w $TEMPDIR/data - << EOF > $TEMPDIR/diffs
95 1
96 2
97 3
98 4
99 5
100 6
101 7
102 8
103 9
104 10
105 EOF
106 # note   vv 
107 if [ $? -eq 0 ] ; then fail ; fi
108
109 # Check that there was nothing added
110 grep '^<' $TEMPDIR/diffs
111 # note   vv
112 if [ $? -eq 0 ] ; then fail ; fi
113
114
115 pass;