3 # This program tests the sort command
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
13 export STAT_CONFIG_PATH=$top_srcdir/config
49 activity="write perl program for generating data"
50 cat > gen-data.pl <<'EOF'
54 # Generate shuffled data.
56 for my $i (0...$ARGV[0] - 1) {
57 push (@data, $i) foreach 1...$ARGV[1];
59 fisher_yates_shuffle (\@data);
61 # Output shuffled data.
62 my (@shuffled) = map ([$data[$_], $_], 0...$#data);
63 open (SHUFFLED, ">sort.in");
64 print SHUFFLED "$data[$_] $_\n" foreach 0...$#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;
72 sub fisher_yates_shuffle {
73 my $deck = shift; # $deck is a reference to an array
76 my $j = int rand ($i+1);
77 @$deck[$i,$j] = @$deck[$j,$i];
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" \
89 set $count_repeat_buffers
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
100 activity="generate test program for $count_repeat_buffers run"
102 echo "data list list file='sort.in'/x y (f8)."
103 if test "$buffers" != ""; then
104 echo "sort by x/buffers=$buffers."
108 echo "print outfile='sort.out'/x y."
110 } > sort.pspp || no_result
112 activity="run program"
113 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii sort.pspp
114 if [ $? -ne 0 ] ; then no_result ; fi
116 diff -B -w sort.exp sort.out
117 if [ $? -ne 0 ] ; then fail ; fi