Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
apitest2.pl 4.62 KiB
#!/usr/bin/env perl
use strict;
use rob_misc;
use Time::HiRes qw(gettimeofday tv_interval);
use 5.16.0;
use POSIX;

#
# Script to test the binary_c API by running many identical systems in parallel
# and compares the results from them to make sure they are truly identical.
#

$|=1;
my @blockn;
my $thissystem;
my $eps=2.0*DBL_EPSILON;
my $abs_eps=10.0*DBL_MIN;
my $neg_abs_eps=-$abs_eps;


#tests();# floating point tests

while(1)
{
    # run the test program
    open(APITEST,"-|","nice -n +19 ./apitest2.sh $$")||die("cannot open apitest2.sh for reading pipe");
    my @blocks;
    my $prevt;
    my $error=0;
    
    while(<APITEST>)
    {
	# remove ANSI colouring 
	$_=remove_ANSI($_);

	# clean up pointers (they will always differ!)
	s/0x[a-f0-9]+/pointer/g;

	if(/Evolve system \d+ from t=(\S+) to \S+/)
	{
	    $prevt=$1 if(!defined($prevt));
	    if($prevt != $1)
	    {
		$error=check_blocks($prevt,\@blocks); 
		$prevt=$1; # set prevt
	    }
	}
	elsif(s/^\# APITEST//)
	{
	    $thissystem=$_;
	    print "Testing system : ".$$.': '.$_;
	}
	elsif(s/^\(star (\d+)\) //)
	{
	    $blocks[$1].=$_;

	    $blockn[$1]++;
	    
	    if($1==0)
	    {
		output(sprintf "Time $prevt Block % 3d linecount % 7d            \x0d",$1,$blockn[$1]);
	    }
	    else
	    {
		output(sprintf "Time $prevt Block % 3d linecount % 7d (% 5.2f%%) \x0d",$1,$blockn[$1],
		       $blockn[$1]/MAX(1,$blockn[0])*100.0);
	    }
	}

	close APITEST if($error);