[project @ 1999-07-15 09:56:04 by simonmar]
[ghc-hetmet.git] / glafp-utils / runstdtest / runstdtest.prl
index 882dbf9..906f503 100644 (file)
@@ -45,6 +45,7 @@ $SaveStderr = 0;
 $SaveStdout = 0;
 $Status = 0;
 @PgmArgs = ();
+$PgmFail=0;
 $PgmExitStatus = 0;
 $PgmStdinFile  = '/dev/null';
 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
@@ -86,8 +87,9 @@ arg: while ($_ = $ARGV[0]) {
     /^-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"
@@ -156,7 +158,7 @@ foreach $a ( @PgmArgs ) {
 # 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";
 }
@@ -219,7 +221,12 @@ $PreScriptLines
 $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
@@ -311,7 +318,7 @@ if ( $SysSpecificTiming eq '' ) {
 # 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: ",
@@ -381,6 +388,7 @@ sub process_stats_file {
            }
 
            $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;
@@ -388,6 +396,10 @@ sub process_stats_file {
 
            $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;
            } elsif ( /^\s*MUT\s+time\s*(\d+\.\d\d)s\s*\(\s*(\d+\.\d\d)s elapsed\)/ ) {
@@ -436,6 +448,8 @@ sub process_stats_file {
     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);
@@ -444,6 +458,7 @@ sub process_stats_file {
 
     # a bit of tidying
     $BytesAlloc =~ s/,//g;
+    $GCWork =~ s/,//g;
     $MaxResidency =~ s/,//g;
     $GCs =~ s/,//g;
     $InitTime =~ s/,//g;