Skip to content

Commit

Permalink
support baselining tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed May 26, 2016
1 parent b7f5861 commit 6665a46
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
16 changes: 12 additions & 4 deletions fix-tests.sh
@@ -1,10 +1,18 @@
#!/bin/bash
# usage: fix-tests.sh /full/path/to/file/containing/broken/tests.txt
# usage: fix-tests.sh /path/to/file/containing/broken/tests.txt
# should be run from trunk/testsuite
# created by Martin Sjölund

FILE=`realpath $1`
CD=`pwd`
echo Started in directory: $CD
if test -z "$OPENMODELICAHOME"; then
RTEST=`pwd`/rtest
cd `pwd`/testsuite/partest/
else
RTEST=$OPENMODELICAHOME/../testsuite/rtest
cd $OPENMODELICAHOME/../testsuite/partest/
fi
while read line ; do (if test ! -z "$line"; then cd `dirname $line` && $RTEST -b `basename $line`; fi) ; done < $1
echo Switched to directory: $(pwd)
echo Baselining files from $FILE in parallel ...
perl ./runtests.pl -b -file=$FILE
cd $CD

35 changes: 28 additions & 7 deletions partest/runtest.pl
Expand Up @@ -16,6 +16,7 @@
my $no_colour = 0;
my $withxml = 0;
my $rtest_extra_args = "";
my $test_baseline = 0;

for(@ARGV){
if(/--no-colour/) {
Expand All @@ -25,15 +26,19 @@
$withxml = 1;
}
elsif(/-have-dwdiff/) {
$rtest_extra_args = "-c";
$rtest_extra_args = $rtest_extra_args . " -c";
}
elsif(/^--with-omc=(.*)$/) {
$rtest_extra_args = "--with-omc=$1";
$rtest_extra_args = $rtest_extra_args . " --with-omc=$1";
}
elsif(/-b/) {
$rtest_extra_args = $rtest_extra_args . " -b";
$test_baseline = 1;
}
}
if($no_colour) {
$rtest_extra_args = "";
}
#if($no_colour) {
# $rtest_extra_args = "";
#}

# Extract the directory and test name.
(my $test_dir, my $test) = $test_full =~ /(.*)\/([^\/]*)$/;
Expand Down Expand Up @@ -233,11 +238,23 @@ sub needs_sandbox {
$nfailed = $1;
$time = $2;
}
elsif(/== Failed to set baseline.*time: (\d*)/) {
$nfailed = 1;
$time = $2;
}
elsif(/.*time: (\d*)/) {
$nfailed = 0;
$time = $1;
}
}

if (!$no_colour) {
if($nfailed =~ /0/) {
print color 'green';
if ($test_baseline) {
print color 'blue';
} else {
print color 'green';
}
} else {
if($erroneous == 0) {
system("cp $test.test_log $fail_log");
Expand All @@ -250,7 +267,11 @@ sub needs_sandbox {
}
print " ";
}
print "[$test:$time]";
if ($test_baseline) {
print "[Baselining $test:$time]";
} else {
print "[$test:$time]";
}
if ($no_colour) {
if($nfailed =~ /0/) {
print " OK\n";
Expand Down
7 changes: 6 additions & 1 deletion partest/runtests.pl
Expand Up @@ -62,6 +62,7 @@
my $withxmlcmd = 0;
my $withtxt = 0;
my $have_dwdiff = "";
my $rebase_test = "";

{
eval { require File::Which; 1; };
Expand Down Expand Up @@ -97,6 +98,7 @@
print(" -veryfew Run only a very small number of tests to see if runtests.pl is working.\n");
print(" -gitlibs If you have installed omc using GITLIBRARIES=Yes, you can test some of those libraries.\n");
print(" -parmodexp Run the OpenCL ParModelica tests.\n");
print(" -b Rebase tests in parallel. Use in conjuction with -file=/path/to/file.\n");
exit 1;
}
if(/^-f$/) {
Expand Down Expand Up @@ -149,6 +151,9 @@
elsif(/^-parmodexp$/) {
$parmodexp = 1;
}
elsif(/^-b$/) {
$rebase_test = "-b";
}
else {
print("Unknown flag " . $_ . "!\n");
exit 1;
Expand Down Expand Up @@ -257,7 +262,7 @@ sub run_tests {
(my $test_dir, my $test) = $test_full =~ /(.*)\/([^\/]*)$/;

my $t0 = [gettimeofday];
my $cmd = "$testscript $test_full $have_dwdiff $nocolour $withxmlcmd $with_omc";
my $cmd = "$testscript $test_full $have_dwdiff $nocolour $withxmlcmd $with_omc $rebase_test";
my $x = system("$cmd") >> 8;
my $elapsed = tv_interval ( $t0, [gettimeofday]);

Expand Down
11 changes: 8 additions & 3 deletions rtest
Expand Up @@ -88,12 +88,15 @@ sub setbaselineone
my $teardown_command = $info{"teardown_command"};
my $stack_size = $info{"stack_size"};
my $ulimit = ulimit_cmd($stack_size);
my $start_t = time;

$log = "$tmpdir/log-$f";
system "rm -f $log";
if ($setup_command) {
if ( system "$setup_command" ) {
my $end_t = time-$start_t;
print "== Failed to set baseline for $f (system $setup_command failed)";
print " [time: $end_t]\n";
return 1;
}
}
Expand Down Expand Up @@ -145,7 +148,9 @@ sub setbaselineone
close RES;
close LOG;
close SRC;
print "Set baseline for ";print $f;print "\n";

my $end_t = time-$start_t;
print "Set baseline for $f [time: $end_t]\n";

open(SRC,"<$baseline");
open(DST,">$f");
Expand Down Expand Up @@ -248,7 +253,7 @@ sub runone
system "$OPENMODELICAHOME/bin/omc-diff $epsilon $expected $got > $difference";

if ( $? != 0 ) {
print "equation mismatch [time:$end_t]\n";
print "equation mismatch [time: $end_t]\n";
## make a newline
system "echo '' >> $log";
system "echo Equation mismatch: diff says: >> $log";
Expand All @@ -261,7 +266,7 @@ sub runone
return 1;
}

print "ok [time:$end_t]\n";
print "ok [time: $end_t]\n";
return 0;
}

Expand Down

0 comments on commit 6665a46

Please sign in to comment.