This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Simplify gen-libm-test.pl handling of tests with extra outputs


This patch simplifies how gen-libm-test.pl handles tests with extra
outputs (through pointers or global variables).  Pointer parameters
are no longer shown in the version of the call appearing in test names
(since there are several other ways in which that call is not a
literal C call, this seems a reasonable simplification to me).  The
test names for the extra output just say "extra output N" rather than
naming the output variable or the expected value.  This means
gen-libm-test.pl no longer cares about the names of output variables
at all and no longer has any special cases for individual such
functions.  Tested x86_64 and x86.  No existing ulps involve any of
the tests whose names this changes.

I think it will be possible to integrate sincos testing with this as
well (using calls to TEST_fFF_11, replacing TEST_extra) so that no
special cases for sincos are needed in gen-libm-test.pl either.  After
that I propose to eliminate expected outputs from test names
completely, so a normal test name is just "function (arguments)" not
"function (arguments) = expected-value" (which will make
libm-test-ulps files significantly smaller), before moving to the only
string in the test arrays being the "arguments" string with the
complete test names being computed at runtime (so allowing an array to
be used for multiple functions).

2013-05-18  Joseph Myers  <joseph@codesourcery.com>

	* math/gen-libm-test.pl (get_variable): Remove function.
	(parse_args): Don't show pointer parameters to call in test
	names.  Use "extra output N" in test names for extra outputs
	rather than naming variables.

diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index c357283..e9f7f9b 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -145,18 +145,6 @@ sub build_complex_beautify {
   return $str1;
 }
 
-# Return name of a variable
-sub get_variable {
-  my ($number) = @_;
-
-  return "x" if ($number == 1);
-  return "y" if ($number == 2);
-  return "z" if ($number == 3);
-  # return x1,x2,...
-  $number =-3;
-  return "x$number";
-}
-
 # Return the text to put in an initializer for a test's exception
 # information.
 sub show_exceptions {
@@ -201,7 +189,7 @@ sub parse_args {
   my (@args, $str, $descr_args, $descr_res, @descr);
   my ($current_arg, $cline, $i);
   my (@special);
-  my ($extra_var, $call);
+  my ($call);
 
   if ($descr eq 'extra') {
     &special_functions ($file, $args);
@@ -215,27 +203,25 @@ sub parse_args {
 
   # Generate first the string that's shown to the user
   $current_arg = 1;
-  $extra_var = 0;
   @descr = split //,$descr_args;
   for ($i = 0; $i <= $#descr; $i++) {
-    if ($i >= 1) {
-      $call .= ', ';
+    my $comma = "";
+    if ($current_arg > 1) {
+      $comma = ', ';
     }
     # FLOAT, int, long int, long long int
     if ($descr[$i] =~ /f|i|l|L/) {
-      $call .= &beautify ($args[$current_arg]);
+      $call .= $comma . &beautify ($args[$current_arg]);
       ++$current_arg;
       next;
     }
-    # &FLOAT, &int - argument is added here
+    # &FLOAT, &int - simplify call by not showing argument.
     if ($descr[$i] =~ /F|I/) {
-      ++$extra_var;
-      $call .= '&' . &get_variable ($extra_var);
       next;
     }
     # complex
     if ($descr[$i] eq 'c') {
-      $call .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+      $call .= $comma . &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
       $current_arg += 2;
       next;
     }
@@ -278,7 +264,6 @@ sub parse_args {
   # Put the C program line together
   # Reset some variables to start again
   $current_arg = 1;
-  $extra_var = 0;
   $cline = "{ \"$str\"";
   @descr = split //,$descr_args;
   for ($i=0; $i <= $#descr; $i++) {
@@ -320,50 +305,17 @@ sub parse_args {
 			     : undef);
 
   # special treatment for some functions
-  if ($args[0] eq 'frexp') {
-    if (defined $special[0]) {
-      my ($extra_expected) = $special[0];
-      my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
-      my ($str) = "$call sets x to $extra_expected";
-      if (!$run_extra) {
-	$str = "";
-	$extra_expected = "0";
-      }
-      $cline .= ", \"$str\", $run_extra, $extra_expected";
-    }
-  } elsif ($args[0] eq 'gamma' || $args[0] eq 'lgamma') {
-    if (defined $special[0]) {
-      my ($extra_expected) = $special[0];
-      my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
-      my ($str) = "$call sets signgam to $extra_expected";
-      if (!$run_extra) {
-	$str = "";
-	$extra_expected = "0";
-      }
-      $cline .= ", \"$str\", $run_extra, $extra_expected";
-    }
-  } elsif ($args[0] eq 'modf') {
-    if (defined $special[0]) {
-      my ($extra_expected) = $special[0];
-      my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
-      my ($str) = "$call sets x to $extra_expected";
-      if (!$run_extra) {
-	$str = "";
-	$extra_expected = "0";
-      }
-      $cline .= ", \"$str\", $run_extra, $extra_expected";
-    }
-  } elsif ($args[0] eq 'remquo') {
-    if (defined $special[0]) {
-      my ($extra_expected) = $special[0];
-      my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
-      my ($str) = "$call sets x to $extra_expected";
-      if (!$run_extra) {
-	$str = "";
-	$extra_expected = "0";
-      }
-      $cline .= ", \"$str\", $run_extra, $extra_expected";
+  $i = 0;
+  foreach (@special) {
+    ++$i;
+    my ($extra_expected) = $_;
+    my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
+    my ($str) = "$call extra output $i";
+    if (!$run_extra) {
+      $str = "";
+      $extra_expected = "0";
     }
+    $cline .= ", \"$str\", $run_extra, $extra_expected";
   }
   print $file "    $cline },\n";
 }

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]