73f9325be7321eb7d90e7ade6f9236b801d53496
[pspp-builds.git] / tests / command / permissions.sh
1 #!/bin/sh
2
3 # This program tests the PERMISSIONS 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
51 activity="Create file"
52 echo HEllo > foobar
53 chmod 777 foobar
54 if [ $? -ne 0 ] ; then no_result ; fi
55
56 activity="Create program"
57 cat > per.sps <<EOF
58 PERMISSIONS /FILE='foobar'
59    PERMISSIONS = READONLY.
60 EOF
61 if [ $? -ne 0 ] ; then no_result ; fi
62
63 activity="run program"
64 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 activity="Check Permissions"
68 ls -l foobar | grep '^-r-xr-xr-x'  > /dev/null
69 if [ $? -ne 0 ] ; then fail ; fi
70
71
72 activity="Create program"
73 cat > per.sps <<EOF
74 PERMISSIONS /FILE='foobar'
75    PERMISSIONS = WRITEABLE.
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="run program"
80 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="Check Permissions"
84 ls -l foobar | grep '^-rwxr-xr-x'  > /dev/null
85 if [ $? -ne 0 ] ; then fail ; fi
86
87
88
89 pass;