diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-07-15 20:57:45 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-07-15 20:57:45 +0000 |
commit | 00f424512bdd96bb6aa44694b4d20b8c0ced1105 (patch) | |
tree | 4d12f7289745d0060f7a1620c87d4c65a37400a1 | |
parent | e0732fb4a3302da6f4f1b9b5b1f70f25f57bbc2a (diff) |
Patch from Yaakoub for PRs 1480 and 1690. Now have working
code to allow tests to set individual absolute and relative tolerances.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@3808 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r-- | doc/UsersGuide/ThornWriters.tex | 53 | ||||
-rw-r--r-- | lib/sbin/RunTestUtils.pl | 159 |
2 files changed, 168 insertions, 44 deletions
diff --git a/doc/UsersGuide/ThornWriters.tex b/doc/UsersGuide/ThornWriters.tex index e392e2c6..6ca4389a 100644 --- a/doc/UsersGuide/ThornWriters.tex +++ b/doc/UsersGuide/ThornWriters.tex @@ -3351,6 +3351,59 @@ in your thorn. Document carefully any situations or architectures in which your test suite does not give the correct answers. +You can also specify options for running your testsuite by adding an +optional configuration file called {\tt test.ccl} in the {\tt test} +directory. These are simple text files and may contain comments +introduced by the hash `{\tt \#}' character, which indicates that the +rest of the line is a comment. If the last non-blank character of a +line in a config file is a backslash `{\tt $\backslash$}', the +following line is treated as a continuation of the current line. +Options include test specific absolute and relative tolerances, thorn +specific absolute and relative tolerances and file extensions. The +configuration file has the form: + +\begin{alltt} +ABSTOL <\var{thorn_absolute_tolerance}> +RELTOL <\var{thorn_relative_tolerance}> +EXTENSIONS <\var{extension_1} \var{extension_2} \var{extension_3}> + +TEST <\var{test_example}> +\{ + ABSTOL <\var{absolute_tol}> + RELTOL <\var{relative_tol}> +\} +\end{alltt} + +which states that when comparing files of test \verb|test_example|, +\verb|absolute_tol| and \verb|relative_tol| {\space} should be used as +the absolute and relative tolerances. For all other tests in the +thorn, the default value of absolute and relative tolerances are set +to \verb|thorn_absolute_tolerance| and +\verb|thorn_relative_tolerance|. The {\tt EXTENSIONS} option adds +\verb|extension_1|, \verb|extension_2| and \verb|extension_3| to the +list of file extensions that are compared. This list is global over +all tests in a configuration. + +Test specific tolerances have precedence over all tolerances, next +come thorn wide tolerances and then cactus default tolerances. +Absolute and relative tolerances are independent: you can choose to +use test specific absolute tolerance and thorn specific relative +tolerance when running a test. For example, + +\begin{alltt} +TEST \var{test_rad} +\{ + ABSTOL \var{1e-5} +\} + +ABSTOL \var{1e-8} +RELTOL \var{1e-12} +\end{alltt} + +would use an absolute tolerance of 1e-5 and a relative tolerance of +1e-12 when running \verb|test_rad| and an absolute tolerance of 1e-8 +and a relative tolerance of 1e-12 when running all other tests. + For details on running the test suites, see Section~\ref{sec:testing}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/sbin/RunTestUtils.pl b/lib/sbin/RunTestUtils.pl index d0cd5126..d5dd86ad 100644 --- a/lib/sbin/RunTestUtils.pl +++ b/lib/sbin/RunTestUtils.pl @@ -1,3 +1,20 @@ +$top = `pwd` if (! $top); +$config_dir = "$top/config-data" if (! $config_dir); + +# Set up the CCTK home directory +if(! $cctk_home) +{ + $cctk_home = $ENV{'CCTK_HOME'} || "$ENV{HOME}/CCTK"; + $cctk_home =~ s:/$::g; +} + +$sbin_dir = "$cctk_home/lib/sbin"; + +die "Unable to find CCTK sbin directory - tried $sbin_dir\n" + if (! -e "$sbin_dir/parameter_parser.pl"); + +require "$sbin_dir/CSTUtils.pl"; + sub Configure { my($config,$home_dir,$prompt) = @_; @@ -129,57 +146,60 @@ sub ParseParFile sub ParseTestConfigs { my($testdata,$config_data,$runconfig) = @_; + my($line_number, $line); + my($test, $ABSTOL, $RELTOL); foreach $thorn (split(" ",$testdata->{"THORNS"})) { $arrangement = $testdata->{"$thorn ARRANGEMENT"}; + if (-r "$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}test.ccl" && -r "$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}config") + { + print " Thorn $thorn has a test.ccl file and a config file.\n Config files will be deprecated, using test.ccl file.\n"; + @config = &read_file("$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}config"); + } + elsif(-r "$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}test.ccl") + { + @config = &read_file("$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}test.ccl"); + } + elsif(-r "$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}config") + { + @config = &read_file("$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}config"); + } + else + { + next; + } - $config = "$config_data->{\"CCTK_DIR\"}${sep}arrangements${sep}$arrangement${sep}$thorn${sep}test${sep}config"; - if (-e $config) + + if ($config) { $global = 1; - open (CONFIG,"< $config"); - while (<CONFIG>) + for($line_number = 0; $line_number < @config; $line_number++) { - # Skip comment lines - next if (/^\s*(\#.*|\!.*)$/); - - # Remember when we have moved off the global section - if (/(.*):\s*/) - { - $global = 0; - $test = $1; - next; - } + $line = $config[$line_number]; # Parse tokens - if (/^\s*([^\s]*)\s(.*)$/) + if ($line =~ m/^\s*ABSTOL\s*(.*)/i) { - $token = $1; - $value = $2; + $ABSTOL = $runconfig->{"$thorn ABSTOL"}=$1; } - else - { - print " Unrecognised line in config file for thorn $thorn\n"; - } - - if ($token =~ /EXTENSIONS/) + elsif ($line =~ m/^\s*RELTOL\s*(.*)/i) { - $testdata->{"EXTENSIONS"} .= "$value "; + $RELTOL = $runconfig->{"$thorn RELTOL"}=$1; } - elsif ($token =~ /ABSTOL/) + elsif ($line =~ m/^\s*EXTENSIONS\s*(.*)/i) { - $value =~ /^\s*([^\s]*)\s+(.*)$/; - $runconfig->{"$thorn $1 ABSTOL"}=$2; + $testdata->{"EXTENSIONS"} .= $1; } - elsif ($token =~ /RELTOL/) + elsif ($line =~ m/^\s*TEST\s*(.*)/i) { - $value =~ /^\s*([^\s]*)\s+(.*)$/; - $runconfig->{"$thorn $1 RELTOL"}=$2; + ($test, $ABSTOL, $RELTOL, $line_number) = &ParseTestBlock($line_number, \@config); + $runconfig->{"$thorn $test ABSTOL"} = $ABSTOL; + $runconfig->{"$thorn $test RELTOL"} = $RELTOL; } else { - print " Unrecognised token $token in config file for thorn $thorn\n"; + print " Unrecognised token $line in config file for thorn $thorn\n"; } } } @@ -188,6 +208,52 @@ sub ParseTestConfigs return $testdata; } +sub ParseTestBlock +{ + my ($line_number, $data) = @_; + my ($Test, $ABSTOL, $RELTOL); + + $Test = ""; + $ABSTOL = ""; + $RELTOL = ""; + + $data->[$line_number] =~ m/^\s*PROVIDES\s*(.*)/i; + + $Test = $1; + + $line_number++; + + if($data->[$line_number] !~ m/^\s*\{\s*$/) + { + $line_number++ while($data[$line_number] !~ m:\s*\}\s*:); + } + else + { + while($data->[$line_number] !~ m:\s*\}\s*:) + { + $line_number++; + if($data->[$line_number] =~ m/^\s*ABSTOL\s*(.*)$/i) + { + $ABSTOL = $1; + next; + } + elsif($data->[$line_number] =~ m/^\s*RELTOL[^\s]*\s*(.*)$/i) + { + $RELTOL = $1; + next; + } + elsif($data->[$line_number] =~ m:\s*\}\s*:) + { + # do nothing. + } + else + { + print STDERR "Error parsing test config block line '$data->[$line_number]'\n"; + } + } + } + return ($Test, $ABSTOL, $RELTOL, $line_number); +} sub FindTestArchiveFiles { @@ -260,7 +326,7 @@ sub FindTestParameterFiles } else { - # print "Parameter file $filedir in thorn $thorn but no output directory\n"; + print "Parameter file $filedir in thorn $thorn but no output directory\n"; } } } @@ -927,7 +993,6 @@ sub CompareTestFiles next if (($oline =~ /^\s*["\#]/) && ($nline =~ /^\s*["\#]/)); $numlines++; - # Now lets see if they differ. if (!("\U$nline" eq "\U$oline")) { @@ -958,25 +1023,31 @@ sub CompareTestFiles { # They diff. But do they differ strongly? $rundata->{"$thorn $test $file NFAILWEAK"}++; - - if (!$runconfig->{"$thorn $test ABSTOL"}) + if ($runconfig->{"$thorn $test ABSTOL"}) { - $abstol = $runconfig->{"ABSTOL"}; + $abstol = $runconfig->{"$thorn $test ABSTOL"}; } - else + elsif ($runconfig->{"$thorn ABSTOL"}) { - $abstol = $runconfig->{"$thorn $test ABSTOL"}; - print " Using absolute tolerance $abstol for this test\n"; + $abstol = $runconfig->{"$thorn ABSTOL"}; } - - if (!$runconfig->{"$thorn $test RELTOL"}) + else { - $reltol = $runconfig->{"RELTOL"}; + $abstol = $runconfig->{"ABSTOL"}; } - else + + + if ($runconfig->{"$thorn $test RELTOL"}) { $reltol = $runconfig->{"$thorn $test RELTOL"}; - print " Using relative tolerance $reltol for this test\n"; + } + elsif ($runconfig->{"$thorn RELTOL"}) + { + $reltol = $runconfig->{"$thorn RELTOL"}; + } + else + { + $reltol = $runconfig->{"RELTOL"}; } $allunder = 1; |