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