64d63a8e056604447f3c064d144c2fd9da36d320
[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      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create file"
51 cat > $TEMPDIR/foobar <<EOF
52 xyzzy
53 EOF
54 if [ $? -ne 0 ] ; then no_result ; fi
55
56 activity="check for file 1"
57 if [ ! -f $TEMPDIR/foobar ] ; then no_result ; fi 
58
59
60 activity="create program 1"
61 cat > $TESTFILE <<EOF
62 set safer on
63
64 erase FILE='foobar'.
65
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 # foobar must still exist
70 activity="check for file 2"
71 if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi 
72
73 # This command must fail
74 activity="run prog 1"
75 $SUPERVISOR $here/../src/pspp $TESTFILE > /dev/null
76 if [ $? -eq 0 ] ; then fail ; fi
77
78
79 activity="create program 2"
80 cat > $TESTFILE <<EOF
81
82 erase FILE='foobar'.
83
84 EOF
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="run prog 1"
89 $SUPERVISOR $here/../src/pspp $TESTFILE
90 if [ $? -ne 0 ] ; then fail ; fi
91
92 # foobar should now be gone
93 if [ -f $TEMPDIR/foobar ] ; then fail ; fi 
94
95
96 pass;