# [default: anything on the cmd line this script doesn't recognise ]
# the first opt not starting w/ "-" is taken to be an input
# file and (if it exists) is grepped for "what's going on here"
-# comments (^--!!!).
+# comments (^-- !!!).
# * a file to feed to stdin ( -i<file> ) [default: /dev/null ]
# * a "time" command to use (-t <cmd>).
#
#
($Pgm = $0) =~ s|.*/||;
$Verbose = 0;
-$SaveTmpFile = 0;
+$SaveStderr = 0;
+$SaveStdout = 0;
$Status = 0;
@PgmArgs = ();
+$PgmFail=0;
$PgmExitStatus = 0;
$PgmStdinFile = '/dev/null';
if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
last arg; };
/^-v$/ && do { $Verbose = 1; next arg; };
- /^-accept-output$/ && do { $SaveTmpFile = 1; next arg; };
+ /^-accept-output-stderr$/ && do { $SaveStderr = 1; next arg; };
+ /^-accept-output-stdout$/ && do { $SaveStdout = 1; next arg; };
+ /^-accept-output$/ && do { $SaveStdout = 1; $SaveStderr = 1; next arg; };
/^-O(.*)/ && do { push(@PgmArgs, &grab_arg_arg('-O',$1)); next arg; };
/^-i(.*)/ && do { $PgmStdinFile = &grab_arg_arg('-i',$1);
$Status++,
print STDERR "$Pgm: bogus -i input file: $PgmStdinFile\n"
- if ! -f $PgmStdinFile;
+ if $PgmStdinFile !~ /^\/dev\/.*$/ && ! -f $PgmStdinFile;
next arg; };
+ /^-fail/ && do { $PgmFail=1; next arg; };
/^-x(.*)/ && do { $PgmExitStatus = &grab_arg_arg('-x',$1);
$Status++ ,
print STDERR "$Pgm: bogus -x expected exit status: $PgmExitStatus\n"
}
foreach $out_file ( @PgmStdoutFile ) {
- if ( ! -f $out_file ) {
- #$Status++;
- print STDERR "$Pgm: warning: expected-stdout file missing: $out_file\n";
- pop(@PgmStdoutFile);
+ if ( ! -f $out_file && !$SaveStdout ) {
+ print STDERR "$Pgm: warning: expected-stdout file missing: $out_file\n";
+ pop(@PgmStdoutFile);
}
}
foreach $out_file ( @PgmStderrFile ) {
- if ( ! -f $out_file ) {
- #$Status++;
- pop(@PgmStderrFile);
- if ( $SaveTmpFile ) {
- system("touch $out_file");
- } else {
- print STDERR "$Pgm: warning: expected-stderr file missing: $out_file\n";
- }
+ if ( ! -f $out_file && !$SaveStderr ) {
+ print STDERR "$Pgm: warning: expected-stderr file missing: $out_file\n";
+ pop(@PgmStderrFile);
}
}
# tidy up the pgm args:
# (1) look for the "first input file"
-# and grep it for "interesting" comments (--!!! )
+# and grep it for "interesting" comments (-- !!! )
# (2) quote any args w/ whitespace in them.
$grep_done = 0;
foreach $a ( @PgmArgs ) {
if (! $grep_done && $a !~ /^-/ && -f $a) {
- print `egrep "^--!!!" $a`;
+ print `egrep "^--[ ]?!!!" $a`;
$grep_done = 1;
}
if ($a =~ /\s/ || $a =~ /'/) {
# deal with system-specific timing options
$TimingMagic = '';
if ( $SysSpecificTiming =~ /^ghc/ ) {
- $TimingMagic = "+RTS -s$StatsFile -RTS"
+ $TimingMagic = "+RTS -S$StatsFile -RTS"
} elsif ( $SysSpecificTiming eq 'hbc' ) {
$TimingMagic = "-S$StatsFile";
}
$SpixifyLine1
$TimeCmd /bin/sh -c \'$ToRun $TimingMagic @PgmArgs < $PgmStdinFile 1> $TmpPrefix/runtest$$.1 2> $TmpPrefix/runtest$$.2 3> $TmpPrefix/runtest$$.3\'
progexit=\$?
-if [ \$progexit -ne $PgmExitStatus ]; then
+if [ \$progexit -eq 0 ] && [ $PgmFail -ne 0 ]; then
+ echo $ToRun @PgmArgs \\< $PgmStdinFile
+ echo "****" expected a failure, but was successful
+ myexit=1
+fi
+if [ \$progexit -ne $PgmExitStatus ] && [ $PgmFail -eq 0 ]; then
echo $ToRun @PgmArgs \\< $PgmStdinFile
echo "****" expected exit status $PgmExitStatus not seen \\; got \$progexit
myexit=1
if [ \$hit = 'NO' ] ; then
echo $ToRun @PgmArgs \\< $PgmStdinFile
echo expected stdout not matched by reality
- ${CONTEXT_DIFF} $PgmStdoutFile[0] $TmpPrefix/runtest$$.1
- myexit=1
+ orig_file="$PgmStdoutFile[0]";
+ [ ! -f \$orig_file ] && orig_file="/dev/null"
+ ${CONTEXT_DIFF} \$orig_file $TmpPrefix/runtest$$.1
+ myexit=\$?
diffsShown=1
fi
- if [ $SaveTmpFile = 1 ] && [ \$progexit = $PgmExitStatus ] ; then
- rm -f $PgmStdoutFile[0].bak
+ if [ $SaveStdout = 1 ] && [ \$progexit = $PgmExitStatus ] &&
+ [ $PgmStdoutFile[0] != $DefaultStdoutFile ] && [ -s $TmpPrefix/runtest$$.1 ]; then
echo Saving away stdout output in $PgmStdoutFile[0] ...
- cp $PgmStdoutFile[0] $PgmStdoutFile[0].bak
+ if [ -f $PgmStdoutFile[0] ]; then
+ rm -f $PgmStdoutFile[0].bak
+ cp $PgmStdoutFile[0] $PgmStdoutFile[0].bak
+ fi;
cp $TmpPrefix/runtest$$.1 $PgmStdoutFile[0]
fi
fi
if [ \$hit = 'NO' ] ; then
echo $ToRun @PgmArgs \\< $PgmStdinFile
echo expected stderr not matched by reality
- ${CONTEXT_DIFF} $PgmStderrFile[0] $TmpPrefix/runtest$$.2
- myexit=1
+ orig_file="$PgmStderrFile[0]"
+ [ ! -f \$orig_file ] && orig_file="/dev/null"
+ ${CONTEXT_DIFF} \$orig_file $TmpPrefix/runtest$$.2
+ myexit=\$?
diffsShown=1
fi
-if [ $SaveTmpFile = 1 ] && [ \$progexit = $PgmExitStatus ] ; then
- rm -f $PgmStderrFile[0].bak
+if [ $SaveStderr = 1 ] && [ \$progexit = $PgmExitStatus ] &&
+ [ $PgmStderrFile[0] != $DefaultStderrFile ] && [ -s $TmpPrefix/runtest$$.2 ]; then
echo Saving away stderr output in $PgmStderrFile[0] ...
- cp $PgmStderrFile[0] $PgmStderrFile[0].bak
+ if [ -f $PgmStderrFile[0] ]; then
+ rm -f $PgmStderrFile[0].bak
+ cp $PgmStderrFile[0] $PgmStderrFile[0].bak
+ fi;
cp $TmpPrefix/runtest$$.2 $PgmStderrFile[0]
fi
$SpixstatsLine1
# print out what we found
if ( $SpixTiming ne 'yes' ) {
print STDERR "<<$SysSpecificTiming: ",
- "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed)",
+ "$BytesAlloc bytes, $GCs GCs, $AvgResidency/$MaxResidency avg/max bytes residency ($ResidencySamples samples), $GCWork bytes GC work, ${TotMem}M in use, $InitTime INIT ($InitElapsed elapsed), $MutTime MUT ($MutElapsed elapsed), $GcTime GC ($GcElapsed elapsed)",
" :$SysSpecificTiming>>\n";
} else {
print STDERR "<<$SysSpecificTiming: ",
local($tot_samples) = 0;
while (<STATS>) {
- if (! /Minor/ && /^\s*\d+\s+\d+\s+(\d+)\s+\d+\.\d+\%/ ) {
+ if (! /Gen:\s+0/ && /^\s*\d+\s+\d+\s+(\d+)\s+\d+\.\d+/ ) {
$max_live = $1 if $max_live < $1;
$tot_live += $1;
$tot_samples += 1;
}
$BytesAlloc = $1 if /^\s*([0-9,]+) bytes allocated in the heap/;
+ $GCWork = $1 if /^\s*([0-9,]+) bytes copied during GC/;
# if ( /^\s*([0-9,]+) bytes maximum residency .* (\d+) sample/ ) {
# $MaxResidency = $1; $ResidencySamples = $2;
# }
- $GCs = $1 if /^\s*([0-9,]+) garbage collections? performed/;
+ $GCs = $1 if /^\s*([0-9,]+) collections? in generation 0/;
+
+ if ( /^\s+([0-9]+)\s+Mb total memory/ ) {
+ $TotMem = $1;
+ }
if ( /^\s*INIT\s+time\s*(\d+\.\d\d)s\s*\(\s*(\d+\.\d\d)s elapsed\)/ ) {
$InitTime = $1; $InitElapsed = $2;
print STDERR "Warning: MutElapsed not found in stats file\n" unless defined($MutElapsed);
print STDERR "Warning: GcTime inot found in stats file\n" unless defined($GcTime);
print STDERR "Warning: GcElapsed not found in stats file\n" unless defined($GcElapsed);
+ print STDERR "Warning: total memory not found in stats file\n" unless defined($TotMem);
+ print STDERR "Warning: GC work not found in stats file\n" unless defined($GCWork);
# things we didn't necessarily expect to find
$MaxResidency = 0 unless defined($MaxResidency);
# a bit of tidying
$BytesAlloc =~ s/,//g;
+ $GCWork =~ s/,//g;
$MaxResidency =~ s/,//g;
$GCs =~ s/,//g;
$InitTime =~ s/,//g;