PERMISSIONS: Convert test to Autotest framework.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Oct 2010 15:06:50 +0000 (08:06 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Oct 2010 22:46:06 +0000 (15:46 -0700)
tests/automake.mk
tests/command/permissions.sh [deleted file]
tests/language/utilities/permissions.at [new file with mode: 0644]

index 952411086cb4dcec31492ce0d13eb61d38d4282b..14b1194ccaee53f0a15ba59f76dd33ba1a9020d5 100644 (file)
@@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C
 TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
 
 dist_TESTS = \
-       tests/command/permissions.sh \
        tests/command/print.sh \
        tests/command/print-strings.sh \
        tests/command/rank.sh \
@@ -383,6 +382,7 @@ TESTSUITE_AT = \
        tests/language/stats/npar.at \
        tests/language/stats/oneway.at \
        tests/language/utilities/insert.at \
+       tests/language/utilities/permissions.at \
        tests/language/utilities/set.at \
        tests/language/utilities/title.at \
        tests/language/xforms/compute.at \
diff --git a/tests/command/permissions.sh b/tests/command/permissions.sh
deleted file mode 100755 (executable)
index 7c4504a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/sh
-
-# This program tests the PERMISSIONS command
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_builddir  are absolute
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-top_builddir=`cd $top_builddir; pwd`
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-# ensure that top_srcdir is absolute
-top_srcdir=`cd $top_srcdir; pwd`
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-
-cleanup()
-{
-     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR" 
-       return ; 
-     fi
-     cd /
-     rm -rf $TEMPDIR
-}
-
-
-fail()
-{
-    echo $activity
-    echo FAILED
-    cleanup;
-    exit 1;
-}
-
-
-no_result()
-{
-    echo $activity
-    echo NO RESULT;
-    cleanup;
-    exit 2;
-}
-
-pass()
-{
-    cleanup;
-    exit 0;
-}
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-
-activity="Create file"
-echo HEllo > foobar
-chmod 777 foobar
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="Create program"
-cat > per.sps <<EOF
-PERMISSIONS /FILE='foobar'
-   PERMISSIONS = READONLY.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/per.sps
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="Check Permissions"
-ls -l foobar | grep '^-r-xr-xr-x'  > /dev/null
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="Create program"
-cat > per.sps <<EOF
-PERMISSIONS /FILE='foobar'
-   PERMISSIONS = WRITEABLE.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/per.sps
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="Check Permissions"
-ls -l foobar | grep '^-rwxr-xr-x'  > /dev/null
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-
-pass;
diff --git a/tests/language/utilities/permissions.at b/tests/language/utilities/permissions.at
new file mode 100644 (file)
index 0000000..873057c
--- /dev/null
@@ -0,0 +1,25 @@
+AT_BANNER([PERMISSIONS])
+
+AT_SETUP([PERMISSIONS])
+AT_DATA([foobar], [Hello
+])
+
+chmod 666 foobar
+AT_CHECK([ls -l foobar], [0], [stdout])
+AT_CHECK([sed 's/^\(..........\).*/\1/' stdout], [0], [-rw-rw-rw-
+])
+
+AT_DATA([permissions.sps], [PERMISSIONS /FILE='foobar' PERMISSIONS=READONLY.
+])
+AT_CHECK([pspp -O format=csv permissions.sps])
+AT_CHECK([ls -l foobar], [0], [stdout])
+AT_CHECK([sed 's/^\(..........\).*/\1/' stdout], [0], [-r--r--r--
+])
+
+AT_DATA([permissions.sps], [PERMISSIONS /FILE='foobar' PERMISSIONS=WRITEABLE.
+])
+AT_CHECK([pspp -O format=csv permissions.sps])
+AT_CHECK([ls -l foobar], [0], [stdout])
+AT_CHECK([sed 's/^\(..........\).*/\1/' stdout], [0], [-rw-r--r--
+])
+AT_CLEANUP