Added a signal handler for SIGFPE
[pspp-builds.git] / tests / bugs / big-input-2.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused  a crash when 
4 # very large files are presented.
5
6
7 TEMPDIR=/tmp/pspp-tst-$$
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="delete data"
51 rm -f $TEMPDIR/large.dat
52 if [ $? -ne 0 ] ; then no_result ; fi
53
54 printf "Creating input data.  Please wait"
55 activity="create data"
56 i=0
57 while [ $i -lt 100000 ] ; do 
58         echo AB12 >> $TEMPDIR/large.dat;
59         i=$[$i + 1];
60 done;
61 printf '.'
62 i=0
63 while [ $i -lt 100000 ] ; do 
64         echo AB04 >> $TEMPDIR/large.dat;
65         i=$[$i + 1];
66 done;
67 if [ $? -ne 0 ] ; then no_result ; fi
68 printf "\n";
69
70 activity="create program"
71 cat > $TEMPDIR/large.sps <<EOF
72 DATA LIST FILE='$TEMPDIR/large.dat' /S 1-2 (A) X 3 .
73
74
75 AGGREGATE /BREAK=X /A=N.
76
77
78 EXAMINE /A BY /X.
79 EOF
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="run program"
83 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/large.sps > /dev/null
84 if [ $? -ne 0 ] ; then fail ; fi
85
86
87 activity="appending to data"
88 # Put another 100,000 cases into large.dat
89 i=0
90 while [ $i -lt 50000 ] ; do 
91         echo AB04 >> $TEMPDIR/large.dat;
92         echo AB12 >> $TEMPDIR/large.dat;
93         i=$[$i + 1];
94 done;
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97 activity="run program"
98 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/large.sps > /dev/null
99 if [ $? -ne 0 ] ; then fail ; fi
100
101
102
103 pass;