From: Ben Pfaff <blp@cs.stanford.edu> Date: Sun, 3 Oct 2010 22:45:44 +0000 (-0700) Subject: Convert PRINT and WRITE tests to Autotest framework. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=736af120ae00b122994e9e023a29c43ad722a46e;p=pspp Convert PRINT and WRITE tests to Autotest framework. --- diff --git a/tests/automake.mk b/tests/automake.mk index 14b1194cca..28776cf170 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,8 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ - tests/command/print.sh \ - tests/command/print-strings.sh \ tests/command/rank.sh \ tests/command/rename.sh \ tests/command/regression.sh \ @@ -87,7 +85,6 @@ dist_TESTS = \ tests/bugs/unwritable-dir.sh \ tests/bugs/val-labs.sh \ tests/bugs/val-labs-trailing-slash.sh \ - tests/bugs/print-crash.sh \ tests/bugs/keep-all.sh \ tests/data/datasheet-test.sh \ tests/libpspp/sparse-xarray-test.sh \ @@ -363,6 +360,7 @@ TESTSUITE_AT = \ tests/language/data-io/get-data-txt.at \ tests/language/data-io/list.at \ tests/language/data-io/match-files.at \ + tests/language/data-io/print.at \ tests/language/data-io/save.at \ tests/language/data-io/save-translate.at \ tests/language/dictionary/attributes.at \ diff --git a/tests/bugs/print-crash.sh b/tests/bugs/print-crash.sh deleted file mode 100755 index 7995e0421f..0000000000 --- a/tests/bugs/print-crash.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -# This program tests for a bug which crashed when deallocating after a bad -# PRINT command. - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps - -# ensure that top_srcdir and top_builddir are absolute -if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi -if [ -z "$top_builddir" ] ; then top_builddir=. ; fi -top_srcdir=`cd $top_srcdir; pwd` -top_builddir=`cd $top_builddir; pwd` - -PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT - -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 - -cat > $TESTFILE << EOF -DATA LIST LIST /a * b *. -BEGIN DATA. -1 2 -3 4 -END DATA. - -PRINT F8.2 -LIST. -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program" -$SUPERVISOR $PSPP -o pspp.csv -e /dev/null $TESTFILE -if [ $? -ne 1 ] ; then fail ; fi - - -pass; diff --git a/tests/command/print-strings.sh b/tests/command/print-strings.sh deleted file mode 100755 index b6a1ba9b9d..0000000000 --- a/tests/command/print-strings.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -# This program tests that the PRINT command properly outputs string variables. - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps - -# ensure that top_srcdir and top_builddir are absolute -if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi -if [ -z "$top_builddir" ] ; then top_builddir=. ; fi -top_srcdir=`cd $top_srcdir; pwd` -top_builddir=`cd $top_builddir; pwd` -PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT - -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" -cat > $TESTFILE <<EOF -DATA LIST FREE /s8 (a8) s10 (a10) vl255 (a255) vl258 (a258). -BEGIN DATA. -12345678 -AaaaaaaaaZ -AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ -AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ -87654321 -AnnnnnnnnZ -AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ -AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ -END DATA. - -print - outfile='foobar' - /s10 * vl255 * vl258 *. - -EXECUTE. - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - - -diff $TEMPDIR/foobar - <<EOF - AaaaaaaaaZ AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ - AnnnnnnnnZ AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ -EOF -if [ $? -ne 0 ] ; then fail ; fi - - -pass; diff --git a/tests/command/print.sh b/tests/command/print.sh deleted file mode 100755 index 9df49c13aa..0000000000 --- a/tests/command/print.sh +++ /dev/null @@ -1,215 +0,0 @@ -#!/bin/sh - -# This program tests unusual aspects of the PRINT and WRITE -# transformations: -# -# - PRINT puts spaces between variables, unless a format -# is specified explicitly. -# -# - WRITE doesn't put space between variables. -# -# - PRINT to an external file prefixes each line with a space. -# -# - PRINT EJECT to an external file indicates a formfeed by a "1" -# in the first column. -# -# - WRITE writes out spaces for system-missing values, not a period. -# -# - When no output is specified, an empty record is output. - -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 - -LANG=C -export LANG - -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 > $TEMPDIR/print.stat << foobar -data list notable /x y 1-2. -begin data. -12 -34 - 6 -7 -90 -end data. - -print /x y. -print eject /x y 1-2. -print /x '-' y. -print. - -print outfile='print.out' /x y. -print eject outfile='print.out' /x y (f1,f1). -print outfile='print.out' /x '-' y. -print outfile='print.out'. - -write outfile='write.out' /x y. -write outfile='write.out' /x y (2(f1)). -write outfile='write.out' /x '-' y. -write outfile='write.out'. - -execute. -foobar -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program" -$SUPERVISOR $PSPP -o pspp.csv --error-file=$TEMPDIR/errs $TEMPDIR/print.stat -if [ $? -ne 0 ] ; then fail ; fi - -activity="compare print.out" -diff -b $TEMPDIR/print.out - <<EOF - 1 2 -112 - 1 -2 - - 3 4 -134 - 3 -4 - - . 6 -1.6 - . -6 - - 7 . -17. - 7 -. - - 9 0 -190 - 9 -0 - -EOF -if [ $? -ne 0 ] ; then fail ; fi - -activity="compare write.out" -diff -b $TEMPDIR/write.out - <<EOF -12 -12 -1-2 - -34 -34 -3-4 - - 6 - 6 - -6 - -7 -7 -7- - -90 -90 -9-0 - -EOF -if [ $? -ne 0 ] ; then fail ; fi - -activity="compare output" -diff -b $TEMPDIR/pspp.csv - << EOF -1 2 - - - -12 - -1 -2 - - - -3 4 - - - -34 - -3 -4 - - - -. 6 - - - -.6 - -. -6 - - - -7 . - - - -7. - -7 -. - - - -9 0 - - - -90 - -9 -0 - - -EOF -if [ $? -ne 0 ] ; then fail ; fi - -pass; diff --git a/tests/language/data-io/print.at b/tests/language/data-io/print.at new file mode 100644 index 0000000000..f1fae5de67 --- /dev/null +++ b/tests/language/data-io/print.at @@ -0,0 +1,225 @@ +AT_BANNER([PRINT and WRITE]) + +dnl These tests check unusual aspects of the PRINT and WRITE +dnl transformations: +dnl +dnl - PRINT puts spaces between variables, unless a format +dnl is specified explicitly. +dnl +dnl - WRITE doesn't put space between variables. +dnl +dnl - PRINT to an external file prefixes each line with a space. +dnl +dnl - PRINT EJECT to an external file indicates a formfeed by a "1" +dnl in the first column. +dnl +dnl - WRITE writes out spaces for system-missing values, not a period. +dnl +dnl - When no output is specified, an empty record is output. + +AT_SETUP([PRINT numeric variables]) +AT_DATA([print.sps], [dnl +data list notable /x y 1-2. +begin data. +12 +34 + 6 +7 +90 +end data. + +print /x y. +print eject /x y 1-2. +print /x '-' y. +print. + +execute. +]) +AT_CHECK([pspp -O format=csv print.sps], [0], [dnl +1 2 @&t@ + + + +12 + +1 -2 @&t@ + + + +3 4 @&t@ + + + +34 + +3 -4 @&t@ + + + +. 6 @&t@ + + + +.6 + +. -6 @&t@ + + + +7 . @&t@ + + + +7. + +7 -. @&t@ + + + +9 0 @&t@ + + + +90 + +9 -0 @&t@ + + +]) +AT_CLEANUP + +AT_SETUP([PRINT string variables]) +AT_DATA([print.sps], [dnl +DATA LIST FREE /s8 (a8) s10 (a10) vl255 (a255) vl258 (a258). +BEGIN DATA. +12345678 +AaaaaaaaaZ +AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ +AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ +87654321 +AnnnnnnnnZ +AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ +AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ +END DATA. + +print + outfile='print.txt' + /s10 * vl255 * vl258 *. + +EXECUTE. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat print.txt], [0], [dnl + AaaaaaaaaZ AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ @&t@ + AnnnnnnnnZ AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ @&t@ +]) +AT_CLEANUP + +AT_SETUP([PRINT to file]) +AT_DATA([print.sps], [dnl +data list notable /x y 1-2. +begin data. +12 +34 + 6 +7 +90 +end data. + +print outfile='print.out' /x y. +print eject outfile='print.out' /x y (f1,f1). +print outfile='print.out' /x '-' y. +print outfile='print.out'. + +execute. +]) +AT_CHECK([pspp -O format=csv print.sps]) +AT_CHECK([cat print.out], [0], [dnl + 1 2 @&t@ +112 + 1 -2 @&t@ + @&t@ + 3 4 @&t@ +134 + 3 -4 @&t@ + @&t@ + . 6 @&t@ +1.6 + . -6 @&t@ + @&t@ + 7 . @&t@ +17. + 7 -. @&t@ + @&t@ + 9 0 @&t@ +190 + 9 -0 @&t@ + @&t@ +]) +AT_CLEANUP + +dnl Tests for a bug which crashed when deallocating after a bad PRINT +dnl command. +AT_SETUP([PRINT crash bug]) +AT_DATA([print.sps], [dnl +DATA LIST LIST NOTABLE /a * b *. +BEGIN DATA. +1 2 +3 4 +END DATA. + +PRINT F8.2 +LIST. +]) +AT_CHECK([pspp -O format=csv print.sps], [1], [dnl +print.sps:7: error: PRINT: Syntax error at `F8.2': expecting a valid subcommand. + +Table: Data List +a,b +1.00,2.00 +3.00,4.00 +]) +AT_CLEANUP + +AT_SETUP([WRITE to file]) +AT_DATA([write.sps], [dnl +data list notable /x y 1-2. +begin data. +12 +34 + 6 +7 +90 +end data. + +write outfile='write.out' /x y. +write outfile='write.out' /x y (2(f1)). +write outfile='write.out' /x '-' y. +write outfile='write.out'. + +execute. +]) +AT_CHECK([pspp -O format=csv write.sps]) +AT_CHECK([cat write.out], [0], [dnl +12 +12 +1-2 + +34 +34 +3-4 + + 6 + 6 + -6 + +7 @&t@ +7 @&t@ +7- @&t@ + +90 +90 +9-0 + +]) +AT_CLEANUP