Fixed numerous memory leaks. Changed many of the test cases to use a canonical
[pspp-builds.git] / tests / command / erase.sh
1 #!/bin/sh
2
3 # This program tests the ERASE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create file"
50 cat > $TEMPDIR/foobar <<EOF
51 xyzzy
52 EOF
53 if [ $? -ne 0 ] ; then no_result ; fi
54
55 activity="check for file 1"
56 if [ ! -f $TEMPDIR/foobar ] ; then no_result ; fi 
57
58
59 activity="create program 1"
60 cat > $TESTFILE <<EOF
61 set safer on
62
63 erase FILE='foobar'.
64
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68 # foobar must still exist
69 activity="check for file 2"
70 if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi 
71
72 # This command must fail
73 activity="run prog 1"
74 $SUPERVISOR $here/../src/pspp $TESTFILE > /dev/null
75 if [ $? -eq 0 ] ; then fail ; fi
76
77
78 activity="create program 2"
79 cat > $TESTFILE <<EOF
80
81 erase FILE='foobar'.
82
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86
87 activity="run prog 1"
88 $SUPERVISOR $here/../src/pspp $TESTFILE
89 if [ $? -ne 0 ] ; then fail ; fi
90
91 # foobar should now be gone
92 if [ -f $TEMPDIR/foobar ] ; then fail ; fi 
93
94
95 pass;