From: Ben Pfaff Date: Mon, 11 Oct 2010 04:28:35 +0000 (-0700) Subject: tests: Convert tests for unwritable output dirs to Autotest framework. X-Git-Tag: v0.7.6~51 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=5136fd51c9b4f99c06e5070d85cb057104ef1df5 tests: Convert tests for unwritable output dirs to Autotest framework. --- diff --git a/tests/automake.mk b/tests/automake.mk index 2c335b56..92dc5cdc 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -27,7 +27,6 @@ dist_TESTS = \ tests/formats/wkday-in.sh \ tests/formats/wkday-out.sh \ tests/formats/360.sh \ - tests/bugs/unwritable-dir.sh \ tests/bugs/val-labs.sh \ tests/bugs/val-labs-trailing-slash.sh \ tests/bugs/keep-all.sh \ @@ -371,8 +370,9 @@ TESTSUITE_AT = \ tests/libpspp/stringi-set.at \ tests/libpspp/tower.at \ tests/math/moments.at \ - tests/output/render.at \ tests/output/charts.at \ + tests/output/output.at \ + tests/output/render.at \ tests/ui/terminal/main.at \ tests/perl-module.at diff --git a/tests/bugs/unwritable-dir.sh b/tests/bugs/unwritable-dir.sh deleted file mode 100755 index c7c09f74..00000000 --- a/tests/bugs/unwritable-dir.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -# This program tests for a bug which crashed pspp when output drivers -# tried to create output files in an unwritable directory. - -TEMPDIR=/tmp/pspp-tst-$$ - -# 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 / - chmod u+w $TEMPDIR - 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 test syntax" -cat > test.pspp </dev/null 2>&1 - if [ $? -ne 0 ] ; then fail ; fi -done - -pass; diff --git a/tests/output/output.at b/tests/output/output.at new file mode 100644 index 00000000..919927de --- /dev/null +++ b/tests/output/output.at @@ -0,0 +1,28 @@ +AT_BANNER([output drivers]) + +m4_define([OUTPUT_UNWRITABLE_DIR], + [AT_SETUP([output $1 to unwritable directory]) + mkdir unwritable + chmod u-w unwritable + AT_SKIP_IF([: > unwritable/test]) + AT_DATA([unwritable.sps], [dnl +data list /x 1. +begin data. +1 +2 +3 +end data. +frequencies x/histogram. +]) + dnl PSPP will fail to create the output file. Currently this doesn't cause + dnl PSPP's exit status to be nonzero, although this is arguably incorrect. + dnl At any rate, PSPP should not crash. + AT_CHECK([cd unwritable && pspp -o pspp.$1 ../unwritable.sps], [0], + [ignore], [ignore]) + AT_CLEANUP]) + +OUTPUT_UNWRITABLE_DIR([csv]) +OUTPUT_UNWRITABLE_DIR([html]) +OUTPUT_UNWRITABLE_DIR([odt]) +OUTPUT_UNWRITABLE_DIR([pdf]) +OUTPUT_UNWRITABLE_DIR([txt])