tests: Convert no_case_size.sh test to Autotest framework.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 2 Oct 2010 21:29:37 +0000 (14:29 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 2 Oct 2010 21:29:37 +0000 (14:29 -0700)
tests/automake.mk
tests/command/no_case_size.sh [deleted file]
tests/data/sys-file.at [new file with mode: 0644]
tests/no_case_size.sav [deleted file]

index 9170f9d325000fa6c2e75247682aa1976cebef70..e02e090b8a6cf0aed9671f9f0f447c7c22ae6bcf 100644 (file)
@@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C
 TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
 
 dist_TESTS = \
-       tests/command/no_case_size.sh \
        tests/command/n_of_cases.sh \
        tests/command/npar-binomial.sh \
        tests/command/npar-chisquare.sh \
@@ -300,7 +299,6 @@ tests_output_render_test_LDADD = \
 EXTRA_DIST += \
        $(dist_TESTS) \
        tests/weighting.data \
-       tests/no_case_size.sav \
        tests/coverage.sh tests/test_template \
        tests/v13.sav tests/v14.sav \
        tests/expressions/randist/beta.out \
@@ -357,6 +355,7 @@ EXTRA_DIST += \
 TESTSUITE_AT = \
        tests/data/calendar.at \
        tests/data/data-in.at \
+       tests/data/sys-file.at \
        tests/language/command.at \
        tests/language/control/do-if.at \
        tests/language/control/do-repeat.at \
diff --git a/tests/command/no_case_size.sh b/tests/command/no_case_size.sh
deleted file mode 100755 (executable)
index a03c617..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-# This program tests that system files can be read properly, even when the 
-# case_size header value is -1 (Some 3rd party products do this)
-
-
-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 program"
-cat <<EOF > $TESTFILE
-GET FILE='$top_srcdir/tests/no_case_size.sav'.
-DISPLAY DICTIONARY.
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output"
-diff -c pspp.csv - <<EOF
-Variable,Description,,Position
-cont,continents of the world,,1
-,Format: A32,,
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-size,sq km,,2
-,Format: F8.2,,
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-pop,population,,3
-,Format: F8.2,,
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-count,number of countries,,4
-,Format: F8.2,,
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-
-Table: Data List
-cont,size,pop,count
-Asia                            ,44579000,3.7E+009,44.00
-Africa                          ,30065000,7.8E+008,53.00
-North America                   ,24256000,4.8E+008,23.00
-South America                   ,17819000,3.4E+008,12.00
-Antarctica                      ,13209000,.00,.00
-Europe                          ,9938000,7.3E+008,46.00
-Australia/Oceania               ,7687000,31000000,14.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-pass;
diff --git a/tests/data/sys-file.at b/tests/data/sys-file.at
new file mode 100644 (file)
index 0000000..f8f07a0
--- /dev/null
@@ -0,0 +1,60 @@
+AT_BANNER([system files])
+
+# Test that system files can be read properly, even when the case_size
+# header value is -1 (Some 3rd party products do this).
+AT_SETUP([system files with -1 case_size])
+AT_DATA([save.sps], [dnl
+DATA LIST LIST NOTABLE /cont (A32) size pop count.
+VAR LABEL
+    cont 'continents of the world'
+    size 'sq km'
+    pop 'population'
+    count 'number of countries'.
+SAVE OUTFILE='cont.sav'.
+BEGIN DATA.
+Asia, 44579000, 3.7E+009, 44.00
+Africa, 30065000, 7.8E+008, 53.00
+"North America", 24256000, 4.8E+008, 23.00
+"South America", 17819000, 3.4E+008, 12.00
+Antarctica, 13209000, .00, .00
+Europe, 9938000, 7.3E+008, 46.00
+Australia/Oceania, 7687000, 31000000, 14.00
+END DATA.
+])
+AT_CHECK([pspp -O format=csv save.sps])
+AT_CHECK([test -f cont.sav])
+
+dnl case_size is a 4-byte field at offset 68.
+dnl Make a new copy with its value changed to -1.
+AT_CHECK(
+  [(dd if=cont.sav bs=1 count=68;
+    printf '\377\377\377\377';
+    dd if=cont.sav bs=1 skip=72) > cont2.sav], [0], [], [ignore])
+AT_CHECK([cmp cont.sav cont2.sav], [1],
+  [cont.sav cont2.sav differ: char 69, line 1
+])
+
+AT_DATA([get.sps], [dnl
+GET FILE='cont2.sav'.
+DISPLAY LABELS.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv get.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Variable,Label,,Position
+cont,continents of the world,,1
+size,sq km,,2
+pop,population,,3
+count,number of countries,,4
+
+Table: Data List
+cont,size,pop,count
+Asia                            ,44579000,3.7E+009,44.00
+Africa                          ,30065000,7.8E+008,53.00
+North America                   ,24256000,4.8E+008,23.00
+South America                   ,17819000,3.4E+008,12.00
+Antarctica                      ,13209000,.00,.00
+Europe                          ,9938000,7.3E+008,46.00
+Australia/Oceania               ,7687000,31000000,14.00
+])
+AT_CLEANUP
diff --git a/tests/no_case_size.sav b/tests/no_case_size.sav
deleted file mode 100644 (file)
index d338212..0000000
Binary files a/tests/no_case_size.sav and /dev/null differ