Added some test files, which I'd forgotten about.
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 13 Apr 2005 14:50:05 +0000 (14:50 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 13 Apr 2005 14:50:05 +0000 (14:50 +0000)
tests/command/longvars.sh [new file with mode: 0755]
tests/command/rename.sh [new file with mode: 0755]
tests/command/sysfiles-old.sh [new file with mode: 0755]
tests/command/sysfiles.sh [new file with mode: 0755]

diff --git a/tests/command/longvars.sh b/tests/command/longvars.sh
new file mode 100755 (executable)
index 0000000..d0fe2e8
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# This program tests that both long and short variable names are parsed OK.
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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
+
+# Use crosstabs, since its TABLES subcommand exercises the array var set 
+# feature.
+activity="create program"
+cat > $TESTFILE <<EOF
+DATA LIST LIST /AlphaBetaGamma * B * X * Yabbadabbadoo * .
+BEGIN DATA.
+2 3 4 5
+END DATA.
+
+LIST.
+
+CROSSTABS 
+       VARIABLES X (1,7) Yabbadabbadoo (1,7) 
+       /TABLES X BY Yabbadabbadoo.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST.  Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|ALPHABET|F8.0  |
+|B       |F8.0  |
+|X       |F8.0  |
+|YABBADAB|F8.0  |
++--------+------+
+
+ALPHABET        B        X YABBADAB
+-------- -------- -------- --------
+    2.00     3.00     4.00     5.00 
+
+2.1 CROSSTABS.  Summary.
+#===============#=====================================================#
+#               #                        Cases                        #
+#               #-----------------+-----------------+-----------------#
+#               #      Valid      |     Missing     |      Total      #
+#               #--------+--------+--------+--------+--------+--------#
+#               #       N| Percent|       N| Percent|       N| Percent#
+#---------------#--------+--------+--------+--------+--------+--------#
+#X * YABBADAB   #       1|  100.0%|       0|    0.0%|       1|  100.0%#
+#===============#========#========#========#========#========#========#
+
+2.2 CROSSTABS.  X by YABBADAB [count].
+#===============#==============================================================#========#
+#               #                           YABBADAB                           |        #
+#               #--------+--------+--------+--------+--------+--------+--------+        #
+#              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
+#---------------#--------+--------+--------+--------+--------+--------+--------+--------#
+#           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
+#           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
+#Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
+#===============#========#========#========#========#========#========#========#========#
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass
diff --git a/tests/command/rename.sh b/tests/command/rename.sh
new file mode 100755 (executable)
index 0000000..bb63003
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# This program tests that the rename command works properly
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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 program"
+cat > $TESTFILE <<EOF
+DATA LIST LIST /brakeFluid * y * .
+BEGIN DATA.
+1 3
+2 3
+3 3
+4 3
+END DATA.
+
+LIST.
+
+RENAME VARIABLES (brakeFluid=applecarts).
+
+LIST.
+
+SAVE /OUTFILE='$TEMPDIR/rename.sav'.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="check sysfile"
+grep -i Brake $TEMPDIR/rename.sav
+if [ $? -eq 0 ] ; then fail ; fi
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST.  Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|BRAKEFLU|F8.0  |
+|Y       |F8.0  |
++--------+------+
+
+BRAKEFLU        Y
+-------- --------
+    1.00     3.00 
+    2.00     3.00 
+    3.00     3.00 
+    4.00     3.00 
+
+APPLECAR        Y
+-------- --------
+    1.00     3.00 
+    2.00     3.00 
+    3.00     3.00 
+    4.00     3.00 
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass
diff --git a/tests/command/sysfiles-old.sh b/tests/command/sysfiles-old.sh
new file mode 100755 (executable)
index 0000000..246fc09
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# This program tests that system files can be read and written 
+# without the long name tables.
+
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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 program"
+cat > $TESTFILE <<EOF
+DATA LIST LIST NOTABLE / X * variable001 * variable002 * variable003 * .
+BEGIN DATA.
+    1.00     1.00    1.0     2.00
+    1.00     1.00    2.0    30.00
+    1.00     2.00    1.0     8.00
+    1.00     2.00    2.0    20.00
+    2.00     1.00    1.0     2.00
+    2.00     1.00    2.0    22.00
+    2.00     2.00    1.0     1.00
+    2.00     2.00    2.0     3.00
+END DATA.
+
+SAVE /OUTFILE='$TEMPDIR/foo.sav'
+     /VERSION=3x
+     .
+
+GET /FILE='$TEMPDIR/foo.sav'.
+
+LIST.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="check file exists"
+ls -l $TEMPDIR/foo.sav > /dev/null
+if [ $? -ne 0 ] ; then no_result ; fi
+
+# Ensure that the written file has no long name table
+activity="check sysfile type"
+grep  'X=X' $TEMPDIR/foo.sav
+if [ $? -eq 0 ] ; then fail ; fi
+
+activity="compare output"
+diff -b -B -w $TEMPDIR/pspp.list - << EOF
+       X VARIABLE VARIAB_A VARIAB_B
+-------- -------- -------- --------
+    1.00     1.00     1.00     2.00 
+    1.00     1.00     2.00    30.00 
+    1.00     2.00     1.00     8.00 
+    1.00     2.00     2.00    20.00 
+    2.00     1.00     1.00     2.00 
+    2.00     1.00     2.00    22.00 
+    2.00     2.00     1.00     1.00 
+    2.00     2.00     2.00     3.00 
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;
diff --git a/tests/command/sysfiles.sh b/tests/command/sysfiles.sh
new file mode 100755 (executable)
index 0000000..e16d161
--- /dev/null
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+# This program tests that system files can be read and written 
+# including the long variable names.
+
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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 program"
+cat > $TESTFILE <<EOF
+DATA LIST LIST NOTABLE / variable001 * variable002 * variable003 * variable004 * .
+BEGIN DATA.
+    1.00     1.00    1.0     2.00
+    1.00     1.00    2.0    30.00
+    1.00     2.00    1.0     8.00
+    1.00     2.00    2.0    20.00
+    2.00     1.00    1.0     2.00
+    2.00     1.00    2.0    22.00
+    2.00     2.00    1.0     1.00
+    2.00     2.00    2.0     3.00
+END DATA.
+
+SAVE /OUTFILE='$TEMPDIR/foo.sav'.
+
+GET /FILE='$TEMPDIR/foo.sav'.
+
+LIST.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare output"
+diff -b -B -w $TEMPDIR/pspp.list - << EOF
+VARIABLE VARIAB_A VARIAB_B VARIAB_C
+-------- -------- -------- --------
+    1.00     1.00     1.00     2.00 
+    1.00     1.00     2.00    30.00 
+    1.00     2.00     1.00     8.00 
+    1.00     2.00     2.00    20.00 
+    2.00     1.00     1.00     2.00 
+    2.00     1.00     2.00    22.00 
+    2.00     2.00     1.00     1.00 
+    2.00     2.00     2.00     3.00 
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;