21e3041cd2f26a39955b04ae5fbbf2875d075cd0
[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 TESTFILE=$TEMPDIR/`basename $0`.sps
10 : ${PERL:=perl}
11
12 # ensure that top_builddir  are absolute
13 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
14 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
15 top_builddir=`cd $top_builddir; pwd`
16 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
17
18 # ensure that top_srcdir is absolute
19 top_srcdir=`cd $top_srcdir; pwd`
20
21 STAT_CONFIG_PATH=$top_srcdir/config
22 export STAT_CONFIG_PATH
23
24
25 cleanup()
26 {
27      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
28         echo "NOT cleaning $TEMPDIR" 
29         return ; 
30      fi
31      cd /
32      rm -rf $TEMPDIR
33 }
34
35
36 fail()
37 {
38     echo $activity
39     echo FAILED
40     cleanup;
41     exit 1;
42 }
43
44
45 no_result()
46 {
47     echo $activity
48     echo NO RESULT;
49     cleanup;
50     exit 2;
51 }
52
53 pass()
54 {
55     cleanup;
56     exit 0;
57 }
58
59 mkdir -p $TEMPDIR
60
61 cd $TEMPDIR
62
63 activity="delete data"
64 rm -f $TEMPDIR/large.dat
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 printf "Creating input data.  Please wait"
68 activity="create data"
69 $PERL -e 'for ($i=0; $i<100000; $i++) { print "AB12\n" };
70           for ($i=0; $i<100000; $i++) { print "AB04\n" };' > $TEMPDIR/large.dat
71 if [ $? -ne 0 ] ; then no_result ; fi
72 printf ".\n";
73
74 activity="create program"
75 cat > $TESTFILE <<EOF
76 DATA LIST FILE='$TEMPDIR/large.dat' /S 1-2 (A) X 3 .
77
78
79 AGGREGATE OUTFILE=* /BREAK=X /A=N.
80
81
82 EXAMINE /A BY /X.
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="run program"
87 $SUPERVISOR $PSPP -o pspp.csv -e /dev/null $TESTFILE 
88 if [ $? -ne 0 ] ; then fail ; fi
89
90 activity="appending to data"
91 # Put another 50,000 cases into large.dat
92 $PERL -e 'for ($i=0; $i<25000; $i++) { print "AB04\nAB12\n" };' >> $TEMPDIR/large.dat
93 if [ $? -ne 0 ] ; then no_result ; fi
94
95 activity="run program"
96 $SUPERVISOR $PSPP -o pspp.csv -e /dev/null $TESTFILE 
97 if [ $? -ne 0 ] ; then fail ; fi
98
99 pass;