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