X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Fformats%2Ftime-in.sh;h=ca80f960d3a145bc40dd2481cadcb0d9eda2b5d4;hb=f51ecb48027e6b1eb46840ae25888a25b429f012;hp=da64ff85f7ff9e7fb61b6fe096a36f6651ce607c;hpb=0fa141762183890ebd139ccd9264f08db9011539;p=pspp-builds.git diff --git a/tests/formats/time-in.sh b/tests/formats/time-in.sh index da64ff85..ca80f960 100755 --- a/tests/formats/time-in.sh +++ b/tests/formats/time-in.sh @@ -9,6 +9,7 @@ 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 +: ${PERL:=perl} # ensure that top_srcdir is absolute top_srcdir=`cd $top_srcdir; pwd` @@ -38,6 +39,44 @@ pass() cd $TEMPDIR +activity="write PRNG fragment" +cat > my-rand.pl <<'EOF' +# This random number generator and the test for it below are drawn +# from Park and Miller, "Random Number Generators: Good Ones are Hard +# to Come By", Communications of the ACM 31:10 (October 1988). It is +# documented to function properly on systems with a 46-bit or longer +# real significand, which includes systems that have 64-bit IEEE reals +# (with 53-bit significand). The test should catch any systems for +# which this is not true, in any case. + +our ($seed) = 1; +sub my_rand { + my ($modulo) = @_; + my ($a) = 16807; + my ($m) = 2147483647; + my ($tmp) = $a * $seed; + $seed = $tmp - $m * int ($tmp / $m); + return $seed % $modulo; +} +EOF +if [ $? -ne 0 ] ; then no_result ; fi + +activity="write PRNG test program" +cat > test-my-rand.pl <<'EOF' +#! /usr/bin/perl +use strict; +use warnings; +do 'my-rand.pl'; +my_rand (1) foreach 1...10000; +our $seed; +die $seed if $seed != 1043618065; +EOF +if [ $? -ne 0 ] ; then no_result ; fi + +activity="test PRNG" +$PERL test-my-rand.pl +if [ $? -ne 0 ] ; then no_result ; fi + activity="write program to generate PSPP syntax and data" cat > time-in.pl <<'EOF' #! /usr/bin/perl @@ -45,7 +84,7 @@ cat > time-in.pl <<'EOF' use strict; use warnings; -our $next = 1; +do 'my-rand.pl'; my @formats = (["time", "+H:M", "+H:M:S"], ["dtime", "+D H:M", "+D H:M:S"]); @@ -123,12 +162,6 @@ sub print_time_with_template { sub pick { return $_[int (my_rand ($#_ + 1))]; } - -sub my_rand { - my ($modulo) = @_; - $next = ($next * 1103515245 + 12345) % (2**32); - return int ($next / 65536) % $modulo; -} EOF if [ $? -ne 0 ] ; then no_result ; fi @@ -137,7 +170,7 @@ $PERL time-in.pl if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP --testing-mode time-in.pspp +$SUPERVISOR $PSPP -o pspp.csv time-in.pspp if [ $? -ne 0 ] ; then no_result ; fi activity="compare time.out output" @@ -152,147 +185,147 @@ diff -u time.out - <