1c010d8c0c3b441647325e79ffa1803fe0f3c028
[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 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
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="create file"
52 cat > $TEMPDIR/foobar <<EOF
53 xyzzy
54 EOF
55 if [ $? -ne 0 ] ; then no_result ; fi
56
57 activity="check for file 1"
58 if [ ! -f $TEMPDIR/foobar ] ; then no_result ; fi 
59
60
61 activity="create program 1"
62 cat > $TESTFILE <<EOF
63 set safer on
64
65 erase FILE='foobar'.
66
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 # foobar must still exist
71 activity="check for file 2"
72 if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi 
73
74 # This command must fail
75 activity="run prog 1"
76 $SUPERVISOR $here/../src/pspp $TESTFILE > /dev/null
77 if [ $? -eq 0 ] ; then fail ; fi
78
79
80 activity="create program 2"
81 cat > $TESTFILE <<EOF
82
83 erase FILE='foobar'.
84
85 EOF
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88
89 activity="run prog 1"
90 $SUPERVISOR $here/../src/pspp $TESTFILE
91 if [ $? -ne 0 ] ; then fail ; fi
92
93 # foobar should now be gone
94 if [ -f $TEMPDIR/foobar ] ; then fail ; fi 
95
96
97 pass;