3 TEMPDIR=/tmp/pspp-tst-$$
5 trap 'cd /; rm -rf $TEMPDIR' 0
7 # ensure that top_builddir are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
41 activity="write program to generate PSPP syntax and data"
42 cat > time-in.pl <<'EOF'
50 my @formats = (["time", "+H:M", "+H:M:S"],
51 ["dtime", "+D H:M", "+D H:M:S"]);
53 my @times = (# D HH MM SS
75 open (SYNTAX, '>', 'time-in.pspp') or die "time-in.pspp: create: $!\n";
76 for my $format (@formats) {
77 my ($name) = @$format;
78 print SYNTAX "DATA LIST file='$name.data'/$name 1-40 ($name).\n";
79 print SYNTAX "PRINT OUTFILE='$name.out'/$name (F16.2).\n";
80 print SYNTAX "EXECUTE.\n";
84 for my $format (@formats) {
85 my ($fmt_name, @templates) = @$format;
86 my ($fn) = "$fmt_name.data";
87 open (DATA, '>', $fn) or die "$fn: create: $!\n";
89 for my $template (@templates) {
90 for my $time (@times) {
91 print_time_with_template ($time, $template) for 1...10;
97 sub print_time_with_template {
98 my ($time, $template) = @_;
99 my ($day, $hour, $minute, $second) = @$time;
100 for my $c (split ('', $template)) {
102 print +pick ('', '-', '+');
103 } elsif ($c eq 'D') {
104 printf (+pick ('%d', '%02d'), $day);
106 } elsif ($c eq 'H') {
107 printf (+pick ('%d', '%02d'), $hour + 24 * $day);
108 } elsif ($c eq 'M') {
109 printf (+pick ('%d', '%02d'), $minute);
110 } elsif ($c eq 'S') {
111 printf (+pick ('%.0f', '%02.0f', '%.1f', '%.2f'), $second);
112 } elsif ($c eq ':') {
113 print +pick (' ', ':');
114 } elsif ($c eq ' ') {
124 return $_[int (my_rand ($#_ + 1))];
129 $next = ($next * 1103515245 + 12345) % (2**32);
130 return int ($next / 65536) % $modulo;
133 if [ $? -ne 0 ] ; then no_result ; fi
135 activity="generate PSPP syntax and data"
137 if [ $? -ne 0 ] ; then no_result ; fi
139 activity="run program"
140 $SUPERVISOR $PSPP --testing-mode time-in.pspp
141 if [ $? -ne 0 ] ; then no_result ; fi
143 activity="compare time.out output"
144 diff -u time.out - <<EOF
546 if [ $? -ne 0 ] ; then fail ; fi
548 activity="compare dtime.out output"
549 diff -u dtime.out - <<EOF
951 if [ $? -ne 0 ] ; then fail ; fi