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