pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] Changes to pspp/tests/command/sort.sh


From: Ben Pfaff
Subject: [Pspp-cvs] Changes to pspp/tests/command/sort.sh
Date: Tue, 15 Mar 2005 01:04:14 -0500

Index: pspp/tests/command/sort.sh
diff -u pspp/tests/command/sort.sh:1.7 pspp/tests/command/sort.sh:1.8
--- pspp/tests/command/sort.sh:1.7      Mon Jan 24 04:29:53 2005
+++ pspp/tests/command/sort.sh  Tue Mar 15 06:04:10 2005
@@ -46,38 +46,75 @@
 
 cd $TEMPDIR
 
-
-activity="generate stat program"
-cat > $TESTFILE <<EOF
-title 'Test SORT procedure'.
-
-data list file='$here/sort.data' notable /X000 to X126 1-127.
-sort by X000 to x005.
-print /X000 to X005.
-execute.
+activity="write perl program for generating data"
+cat > gen-data.pl <<'EOF'
+use strict;
+use warnings;
+
+# Generate shuffled data.
+my (@data);
+for my $i (0...$ARGV[0] - 1) {
+    push (@data, $i) foreach 1...$ARGV[1];
+}
+fisher_yates_shuffle (address@hidden);
+
+# Output shuffled data.
+my (@shuffled) = map ([$data[$_], $_], 0...$#data);
+open (SHUFFLED, ">sort.in");
+print SHUFFLED "$data[$_] $_\n" foreach 0...$#data;
+
+# Output sorted data.
+my (@sorted) = sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @shuffled;
+open (SORTED, ">sort.exp");
+print SORTED "$_->[0] $_->[1]\n" foreach @sorted;
+
+# From perlfaq4.
+sub fisher_yates_shuffle {
+    my $deck = shift;  # $deck is a reference to an array
+    my $i = @$deck;
+    while ($i--) {
+       my $j = int rand ($i+1);
+       @$deck[$i,$j] = @$deck[$j,$i];
+    }
+}
 EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program"
-$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-# Now there should be some sorted data in $TEMPDIR/pspp.list
-# We have to do some checks on it.
-
-# 1. Is it sorted ?
-
-activity="check sorted"
-sort $TEMPDIR/pspp.list  > $TEMPDIR/sortsort
-if [ $? -ne 0 ] ; then no_result ; fi
-
-diff -B -b $TEMPDIR/sortsort $TEMPDIR/pspp.list
-if [ $? -ne 0 ] ; then fail ; fi
-
-# 2. It should be six elements wide
-activity="check data width"
-awk '!/^\ *$/{if (NF!=6) exit 1}' $TEMPDIR/pspp.list 
-if [ $? -ne 0 ] ; then fail ; fi
-
 
+for count_repeat_buffers in \
+    "100 5 2" "100 5 3" "100 5 4" "100 5 5" "100 5 10" "100 5 50" "100 5 100" 
"100 5" \
+    "100 10 2" "100 10 3" "100 10 5" "100 10" \
+    "1000 5 5" "1000 5 50" "1000 5" \
+    "100 100 3" "100 100 5" "100 100" \
+    "10000 5 500" \
+    "50000 1"; do
+  set $count_repeat_buffers
+  count=$1
+  repeat=$2
+  buffers=$3
+
+  echo -n .
+
+  activity="generate data for $count_repeat_buffers run"
+  $PERL gen-data.pl $count $repeat > sort.data
+  if [ $? -ne 0 ] ; then no_result ; fi
+  
+  activity="generate test program for $count_repeat_buffers run"
+  {
+      echo "data list list file='sort.in'/x y (f8)."
+      if test "$buffers" != ""; then
+         echo "sort by x/buffers=$buffers."
+      else
+         echo "sort by x."
+      fi
+      echo "print outfile='sort.out'/x y."
+      echo "execute."
+  } > sort.pspp || no_result
+  
+  activity="run program"
+  $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii sort.pspp
+  if [ $? -ne 0 ] ; then no_result ; fi
+ 
+  diff -B -w sort.exp sort.out
+  if [ $? -ne 0 ] ; then fail ; fi
+done
+echo
 pass;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]