Fixed numerous memory leaks. Changed many of the test cases to use a canonical
[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 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 export STAT_CONFIG_PATH=$top_srcdir/config
16
17
18 cleanup()
19 {
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="delete data"
52 rm -f $TEMPDIR/large.dat
53 if [ $? -ne 0 ] ; then no_result ; fi
54
55 printf "Creating input data.  Please wait"
56 activity="create data"
57 ( while true ; do 
58         echo AB12;
59 done )  | head -100000 >> $TEMPDIR/large.dat
60 if [ $? -ne 0 ] ; then no_result ; fi
61 printf '.'
62 ( while true ; do 
63         echo AB04;
64 done )  | head -100000 >> $TEMPDIR/large.dat
65 if [ $? -ne 0 ] ; then no_result ; fi
66 printf "\n";
67
68 activity="create program"
69 cat > $TESTFILE <<EOF
70 DATA LIST FILE='$TEMPDIR/large.dat' /S 1-2 (A) X 3 .
71
72
73 AGGREGATE /BREAK=X /A=N.
74
75
76 EXAMINE /A BY /X.
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="run program"
81 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE > /dev/null
82 if [ $? -ne 0 ] ; then fail ; fi
83
84 activity="appending to data"
85 # Put another 100,000 cases into large.dat
86 ( while true ; do 
87         echo AB04 
88         echo AB12 
89 done )  | head -50000 >> $TEMPDIR/large.dat
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92 activity="run program"
93 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE > /dev/null
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 pass;