657e53834933b31f147b64cc75015659c3755eeb
[pspp-builds.git] / tests / bugs / piechart.sh
1 #!/bin/sh
2
3 # This program tests for a bug which crashed pspp when a
4 # piechart with too many segments was requested.
5
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      chmod u+w $TEMPDIR
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 test syntax"
63 cat > $TESTFILE <<EOF
64 data list list /x * w *.
65 begin data.
66 1  4
67 34 10
68 -9 15
69 232 6
70 11  4
71 134 1
72 9  5
73 32 16
74 -2 6
75 2  16
76 20  6
77 end data.
78
79 weight by w.
80
81 frequencies /x
82         /piechart.
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86
87 activity="run program 1"
88 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
89 if [ $? -ne 0 ] ; then fail ; fi
90
91
92 pass;