Added the permissions command.
[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
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48
49 activity="Create file"
50 echo HEllo > foobar
51 chmod 777 foobar
52 if [ $? -ne 0 ] ; then no_result ; fi
53
54 activity="Create program"
55 cat > per.sps <<EOF
56 PERMISSIONS /FILE='foobar'
57    PERMISSIONS = READONLY.
58 EOF
59 if [ $? -ne 0 ] ; then no_result ; fi
60
61 activity="run program"
62 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65 activity="Check Permissions"
66 ls -l foobar | grep '^-r-xr-xr-x'  > /dev/null
67 if [ $? -ne 0 ] ; then fail ; fi
68
69
70 activity="Create program"
71 cat > per.sps <<EOF
72 PERMISSIONS /FILE='foobar'
73    PERMISSIONS = WRITEABLE.
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="run program"
78 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/per.sps
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="Check Permissions"
82 ls -l foobar | grep '^-rwxr-xr-x'  > /dev/null
83 if [ $? -ne 0 ] ; then fail ; fi
84
85
86
87 pass;