Only taint casereader if case size is unknown.
[pspp] / 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 # 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
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
56 activity="create program"
57 cat > $TEMPDIR/sample.stat <<EOF
58 set seed=3
59
60 data list notable /A 1-2.
61 begin data.
62 1
63 2
64 3
65 4
66 5
67 6
68 7
69 8
70 9
71 10
72 end data.
73 sample .5.
74 list.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78
79 activity="run program"
80 $SUPERVISOR $PSPP -o raw-ascii --testing-mode $TEMPDIR/sample.stat 
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="create head"
84 grep -v '^\ *$' $TEMPDIR/pspp.list | head -2 > $TEMPDIR/head
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87 activity="extract data"
88 grep  '[0-9][0-9]*' $TEMPDIR/pspp.list > $TEMPDIR/data
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91
92 activity="compare head"
93 perl -pi -e 's/^\s*$//g' $TEMPDIR/head
94 diff -b $TEMPDIR/head - << EOF
95  A
96 --
97 EOF
98 if [ $? -ne 0 ] ; then fail ; fi
99
100 activity="compare data"
101 diff -w $TEMPDIR/data - << EOF > $TEMPDIR/diffs
102 1
103 2
104 3
105 4
106 5
107 6
108 7
109 8
110 9
111 10
112 EOF
113 # note   vv 
114 if [ $? -eq 0 ] ; then fail ; fi
115
116 # Check that there was nothing added
117 grep '^<' $TEMPDIR/diffs
118 # note   vv
119 if [ $? -eq 0 ] ; then fail ; fi
120
121
122 pass;