/[pspp]/pspp/tests/command/sort.sh
ViewVC logotype

Diff of /pspp/tests/command/sort.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by jmd, Mon Jan 24 04:29:53 2005 UTC revision 1.8 by blp, Tue Mar 15 06:04:10 2005 UTC
# Line 46  mkdir -p $TEMPDIR Line 46  mkdir -p $TEMPDIR
46    
47  cd $TEMPDIR  cd $TEMPDIR
48    
49    activity="write perl program for generating data"
50  activity="generate stat program"  cat > gen-data.pl <<'EOF'
51  cat > $TESTFILE <<EOF  use strict;
52  title 'Test SORT procedure'.  use warnings;
53    
54  data list file='$here/sort.data' notable /X000 to X126 1-127.  # Generate shuffled data.
55  sort by X000 to x005.  my (@data);
56  print /X000 to X005.  for my $i (0...$ARGV[0] - 1) {
57  execute.      push (@data, $i) foreach 1...$ARGV[1];
58    }
59    fisher_yates_shuffle (\@data);
60    
61    # Output shuffled data.
62    my (@shuffled) = map ([$data[$_], $_], 0...$#data);
63    open (SHUFFLED, ">sort.in");
64    print SHUFFLED "$data[$_] $_\n" foreach 0...$#data;
65    
66    # Output sorted data.
67    my (@sorted) = sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @shuffled;
68    open (SORTED, ">sort.exp");
69    print SORTED "$_->[0] $_->[1]\n" foreach @sorted;
70    
71    # From perlfaq4.
72    sub fisher_yates_shuffle {
73        my $deck = shift;  # $deck is a reference to an array
74        my $i = @$deck;
75        while ($i--) {
76            my $j = int rand ($i+1);
77            @$deck[$i,$j] = @$deck[$j,$i];
78        }
79    }
80  EOF  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  
   
81    
82    for count_repeat_buffers in \
83        "100 5 2" "100 5 3" "100 5 4" "100 5 5" "100 5 10" "100 5 50" "100 5 100" "100 5" \
84        "100 10 2" "100 10 3" "100 10 5" "100 10" \
85        "1000 5 5" "1000 5 50" "1000 5" \
86        "100 100 3" "100 100 5" "100 100" \
87        "10000 5 500" \
88        "50000 1"; do
89      set $count_repeat_buffers
90      count=$1
91      repeat=$2
92      buffers=$3
93    
94      echo -n .
95    
96      activity="generate data for $count_repeat_buffers run"
97      $PERL gen-data.pl $count $repeat > sort.data
98      if [ $? -ne 0 ] ; then no_result ; fi
99      
100      activity="generate test program for $count_repeat_buffers run"
101      {
102          echo "data list list file='sort.in'/x y (f8)."
103          if test "$buffers" != ""; then
104              echo "sort by x/buffers=$buffers."
105          else
106              echo "sort by x."
107          fi
108          echo "print outfile='sort.out'/x y."
109          echo "execute."
110      } > sort.pspp || no_result
111      
112      activity="run program"
113      $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii sort.pspp
114      if [ $? -ne 0 ] ; then no_result ; fi
115    
116      diff -B -w sort.exp sort.out
117      if [ $? -ne 0 ] ; then fail ; fi
118    done
119    echo
120  pass;  pass;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26