From bc51900253384a031401ef7a68674e350dc8225f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 6 Jan 2005 12:55:44 +0000 Subject: [PATCH] Added a signal handler for SIGFPE (Re)Fixed an assertion in sort.c Added a test for sorting with ENORMOUS input files. Added a test to ensure that fatal errors are reported properly. Tidied up a few other tests. --- po/en_GB.po | 22 +++++++- po/pspp.pot | 22 +++++++- src/ChangeLog | 6 +++ src/main.c | 14 +++++- src/sort.c | 4 +- tests/Makefile.am | 2 + tests/bugs/big-input-2.sh | 103 ++++++++++++++++++++++++++++++++++++++ tests/bugs/big-input.sh | 15 +++--- tests/bugs/data-crash.sh | 3 +- tests/bugs/t-test.sh | 2 + tests/bugs/terminate.sh | 75 +++++++++++++++++++++++++++ tests/bugs/val-labs.sh | 2 + 12 files changed, 258 insertions(+), 12 deletions(-) create mode 100755 tests/bugs/big-input-2.sh create mode 100755 tests/bugs/terminate.sh diff --git a/po/en_GB.po b/po/en_GB.po index 4e60da85..defa8859 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.3.1\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-01-05 08:20+0800\n" +"POT-Creation-Date: 2005-01-05 22:50+0800\n" "PO-Revision-Date: 2004-01-23 13:04+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -2714,6 +2714,26 @@ msgstr "" msgid "Error opening page on %s device of %s class." msgstr "" +#: src/percentiles.c:38 +msgid "HAverage" +msgstr "" + +#: src/percentiles.c:39 +msgid "Weighted Average" +msgstr "" + +#: src/percentiles.c:40 +msgid "Rounded" +msgstr "" + +#: src/percentiles.c:41 +msgid "Empirical" +msgstr "" + +#: src/percentiles.c:42 +msgid "Empirical with averaging" +msgstr "" + #: src/permissions.c:75 #, c-format msgid "Expecting %s or %s." diff --git a/po/pspp.pot b/po/pspp.pot index 170e85d7..7cf0a1d6 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-01-05 08:20+0800\n" +"POT-Creation-Date: 2005-01-05 22:50+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2714,6 +2714,26 @@ msgstr "" msgid "Error opening page on %s device of %s class." msgstr "" +#: src/percentiles.c:38 +msgid "HAverage" +msgstr "" + +#: src/percentiles.c:39 +msgid "Weighted Average" +msgstr "" + +#: src/percentiles.c:40 +msgid "Rounded" +msgstr "" + +#: src/percentiles.c:41 +msgid "Empirical" +msgstr "" + +#: src/percentiles.c:42 +msgid "Empirical with averaging" +msgstr "" + #: src/permissions.c:75 #, c-format msgid "Expecting %s or %s." diff --git a/src/ChangeLog b/src/ChangeLog index 2e1ecee5..3f3e65bc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 6 18:48:58 WST 2005 John Darrington + + * main.c Added a signal handler for SIGFPE + + * sort.c Somewhat more robust fix to the previous entry. + Wed Jan 5 21:23:31 2005 Ben Pfaff * sort.c: (merge) Fix assertion for proper Huffman merge pattern: diff --git a/src/main.c b/src/main.c index b4aa2435..b09a200a 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,7 @@ int main (int argc, char **argv) { signal (SIGSEGV, bug_handler); + signal (SIGFPE, bug_handler); gsl_set_error_handler_off(); @@ -185,5 +186,16 @@ handle_error (int code) void bug_handler(int sig UNUSED) { - request_bug_report_and_abort("Segmentation Violation"); + switch (sig) + { + case SIGFPE: + request_bug_report_and_abort("Floating Point Exception"); + break; + case SIGSEGV: + request_bug_report_and_abort("Segmentation Violation"); + break; + default: + request_bug_report_and_abort(""); + break; + } } diff --git a/src/sort.c b/src/sort.c index 5a6cf6a1..2aa800e0 100644 --- a/src/sort.c +++ b/src/sort.c @@ -752,7 +752,9 @@ merge (struct external_sort *xsrt) make_heap (xsrt->initial_runs, xsrt->run_cnt, sizeof *xsrt->initial_runs, compare_initial_runs, NULL); dummy_run_cnt = mod (1 - (int) xsrt->run_cnt, max_order - 1); - assert (max_order == 2 + + assert( max_order > 0 ); + assert (max_order <= 2 || (xsrt->run_cnt + dummy_run_cnt) % (max_order - 1) == 1); while (xsrt->run_cnt > 1) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 9b2946ee..66faad06 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -43,6 +43,7 @@ TESTS = \ command/weight.sh \ bugs/alpha-freq.sh \ bugs/big-input.sh \ + bugs/big-input-2.sh \ bugs/comment-at-eof.sh \ bugs/compute-fmt.sh \ bugs/crosstabs.sh \ @@ -57,6 +58,7 @@ TESTS = \ bugs/t-test.sh \ bugs/t-test-alpha.sh \ bugs/t-test-alpha2.sh \ + bugs/terminate.sh \ bugs/temporary.sh \ bugs/val-labs.sh \ bugs/val-labs-trailing-slash.sh \ diff --git a/tests/bugs/big-input-2.sh b/tests/bugs/big-input-2.sh new file mode 100755 index 00000000..ee29226b --- /dev/null +++ b/tests/bugs/big-input-2.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +# This program tests for a bug which caused a crash when +# very large files are presented. + + +TEMPDIR=/tmp/pspp-tst-$$ + +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="delete data" +rm -f $TEMPDIR/large.dat +if [ $? -ne 0 ] ; then no_result ; fi + +printf "Creating input data. Please wait" +activity="create data" +i=0 +while [ $i -lt 100000 ] ; do + echo AB12 >> $TEMPDIR/large.dat; + i=$[$i + 1]; +done; +printf '.' +i=0 +while [ $i -lt 100000 ] ; do + echo AB04 >> $TEMPDIR/large.dat; + i=$[$i + 1]; +done; +if [ $? -ne 0 ] ; then no_result ; fi +printf "\n"; + +activity="create program" +cat > $TEMPDIR/large.sps < /dev/null +if [ $? -ne 0 ] ; then fail ; fi + + +activity="appending to data" +# Put another 100,000 cases into large.dat +i=0 +while [ $i -lt 50000 ] ; do + echo AB04 >> $TEMPDIR/large.dat; + echo AB12 >> $TEMPDIR/large.dat; + i=$[$i + 1]; +done; +if [ $? -ne 0 ] ; then no_result ; fi + +activity="run program" +$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/large.sps > /dev/null +if [ $? -ne 0 ] ; then fail ; fi + + + +pass; diff --git a/tests/bugs/big-input.sh b/tests/bugs/big-input.sh index 84f7abef..d15cde4e 100755 --- a/tests/bugs/big-input.sh +++ b/tests/bugs/big-input.sh @@ -50,20 +50,21 @@ cd $TEMPDIR activity="create program" cat > $TEMPDIR/foo.sps < /dev/null -if [ $? -ne 1 ] ; then fail ; fi +if [ $? -ne 0 ] ; then fail ; fi pass; diff --git a/tests/bugs/data-crash.sh b/tests/bugs/data-crash.sh index b1d453a8..d005680d 100755 --- a/tests/bugs/data-crash.sh +++ b/tests/bugs/data-crash.sh @@ -54,7 +54,8 @@ EXECUTE. EOF if [ $? -ne 0 ] ; then no_result ; fi - +#This must fail +activity="run program" $SUPERVISOR $here/../src/pspp $TEMPDIR/ct.stat > /dev/null if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/t-test.sh b/tests/bugs/t-test.sh index 7896b771..6ce101f0 100755 --- a/tests/bugs/t-test.sh +++ b/tests/bugs/t-test.sh @@ -64,6 +64,8 @@ T-TEST /groups=id(3) . EOF if [ $? -ne 0 ] ; then no_result ; fi +#The syntax was invalid. Therefore pspp must return non zero. +activity="run program" $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/rnd.sps > /dev/null if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/terminate.sh b/tests/bugs/terminate.sh new file mode 100755 index 00000000..6e1168b6 --- /dev/null +++ b/tests/bugs/terminate.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +# This tests checks that when a fatal error occurs, +# and appropriate notice is printed and the program exits with a +# non zero status + + +TEMPDIR=/tmp/pspp-tst-$$ + +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="delete file" +rm -f $TEMPDIR/bar.dat +if [ $? -ne 0 ] ; then no_result ; fi + +activity="create program" +cat > $TEMPDIR/foo.sps < /dev/null 2> $TEMPDIR/stderr +if [ $? -eq 0 ] ; then fail ; fi + +activity="compare stderr" +diff $TEMPDIR/stderr - << EOF +pspp: Terminating NOW due to a fatal error! +EOF +if [ $? -ne 0 ] ; then fail ; fi + +pass; diff --git a/tests/bugs/val-labs.sh b/tests/bugs/val-labs.sh index fc052b7b..9fcf39ed 100755 --- a/tests/bugs/val-labs.sh +++ b/tests/bugs/val-labs.sh @@ -64,6 +64,8 @@ VALUE LABELS /var=a 'label for a'. EOF if [ $? -ne 0 ] ; then no_result ; fi +#Invalid syntax --- return value is non zero. +activity="run program" $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/rnd.sps > /dev/null if [ $? -ne 1 ] ; then fail ; fi -- 2.30.2