about summary refs log tree commit diff
path: root/math/gen-libm-test.pl
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-03-06 14:15:00 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-03-06 14:15:00 +0000
commit215db4029ef909b305c528ca9d36cc88771e3afe (patch)
tree5afa0520f544fcd7f886c79a1a1f52c360fef3c7 /math/gen-libm-test.pl
parent67737b8f07c3664c716f69fd1a531f51a002d1f8 (diff)
downloadglibc-215db4029ef909b305c528ca9d36cc88771e3afe.tar.gz
glibc-215db4029ef909b305c528ca9d36cc88771e3afe.tar.xz
glibc-215db4029ef909b305c528ca9d36cc88771e3afe.zip
Prepare libm-test.inc structures for multi-rounding-mode testing.
At present, libm-test.inc tests are run in multiple rounding modes by
having a separate array for each rounding mode (which might or might
not have the same test inputs as the other such arrays), a separate
function calling a RUN_TEST_LOOP_* macro over that array, and a
separate call to that function in main.  The number of functions
tested in multiple rounding modes has gradually increased as
rounding-mode-specific bugs have been found and fixed in different
functions.

It would be better to be able to use a single macro call, in a single
function, to run tests for a function over all rounding modes, with
this being done for all libm functions except in cases where it's
deferred until some bugs can be fixed because XFAILing all affected
tests would be painful (that's why the full set of pow tests isn't
currently run in all rounding modes).  This patch helps prepare for
that by making the structures storing expected results for tests store
results for all four rounding modes.  After this patch, the results
for all modes are just duplicates, but tests access the appropriate
field in the structure, so helping to pave the way for when the fields
stop being duplicates and multiple rounding modes can be tested from a
single array.  Tests might in future specify a single set of results,
to be used in all rounding modes; separate results for each rounding
mode, specified manually; or use of auto-libm-tests-* to generate
results for each rounding mode.

Tested x86_64.

	* math/libm-test.inc (struct test_f_f_data): Move expected results
	into structure for each rounding mode.
	(struct test_ff_f_data): Likewise.
	(struct test_ff_f_data_nexttoward): Likewise.
	(struct test_fi_f_data): Likewise.
	(struct test_fl_f_data): Likewise.
	(struct test_if_f_data): Likewise.
	(struct test_fff_f_data): Likewise.
	(struct test_c_f_data): Likewise.
	(struct test_f_f1_data): Likewise.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(struct test_c_c_data): Likewise.
	(struct test_cc_c_data): Likewise.
	(struct test_f_i_data): Likewise.
	(struct test_ff_i_data): Likewise.
	(struct test_f_l_data): Likewise.
	(struct test_f_L_data): Likewise.
	(struct test_fFF_11_data): Likewise.
	(RM_): New macro.
	(RM_FE_DOWNWARD): Likewise.
	(RM_FE_TONEAREST): Likewise.
	(RM_FE_TOWARDZERO): Likewise.
	(RM_FE_UPWARD): Likewise.
	(RUN_TEST_LOOP_f_f): Update references to expected results.
	(RUN_TEST_LOOP_2_f): Likewise.
	(RUN_TEST_LOOP_fff_f): Likewise.
	(RUN_TEST_LOOP_c_f): Likewise.
	(RUN_TEST_LOOP_f_f1): Likewise.
	(RUN_TEST_LOOP_fF_f1): Likewise.
	(RUN_TEST_LOOP_fI_f1): Likewise.
	(RUN_TEST_LOOP_ffI_f1): Likewise.
	(RUN_TEST_LOOP_c_c): Likewise.
	(RUN_TEST_LOOP_cc_c): Likewise.
	(RUN_TEST_LOOP_f_i): Likewise.
	(RUN_TEST_LOOP_f_i_tg): Likewise.
	(RUN_TEST_LOOP_ff_i_tg): Likewise.
	(RUN_TEST_LOOP_f_b): Likewise.
	(RUN_TEST_LOOP_f_b_tg): Likewise.
	(RUN_TEST_LOOP_f_l): Likewise.
	(RUN_TEST_LOOP_f_L): Likewise.
	(RUN_TEST_LOOP_fFF_11): Likewise.
	* math/gen-libm-test.pl (parse_args): Output four copies of
	expected results for each test.
Diffstat (limited to 'math/gen-libm-test.pl')
-rwxr-xr-xmath/gen-libm-test.pl19
1 files changed, 11 insertions, 8 deletions
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index a5abda2fb0..097488c17c 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -154,7 +154,7 @@ sub show_exceptions {
 sub parse_args {
   my ($file, $descr, $args) = @_;
   my (@args, $descr_args, $descr_res, @descr);
-  my ($current_arg, $cline, $i);
+  my ($current_arg, $cline, $cline_res, $i);
   my (@special);
   my ($call_args);
   my ($ignore_result_any, $ignore_result_all);
@@ -247,6 +247,7 @@ sub parse_args {
   @descr = split //,$descr_res;
   $ignore_result_any = 0;
   $ignore_result_all = 1;
+  $cline_res = "";
   foreach (@descr) {
     if ($_ =~ /b|f|i|l|L/ ) {
       my ($result) = $args[$current_arg];
@@ -256,7 +257,7 @@ sub parse_args {
       } else {
 	$ignore_result_all = 0;
       }
-      $cline .= ", $result";
+      $cline_res .= ", $result";
       $current_arg++;
     } elsif ($_ eq 'c') {
       my ($result1) = $args[$current_arg];
@@ -273,7 +274,7 @@ sub parse_args {
       } else {
 	$ignore_result_all = 0;
       }
-      $cline .= ", $result1, $result2";
+      $cline_res .= ", $result1, $result2";
       $current_arg += 2;
     } elsif ($_ eq '1') {
       push @special, $args[$current_arg];
@@ -284,10 +285,10 @@ sub parse_args {
     die ("some but not all function results ignored\n");
   }
   # Add exceptions.
-  $cline .= show_exceptions ($ignore_result_any,
-			     ($current_arg <= $#args)
-			     ? $args[$current_arg]
-			     : undef);
+  $cline_res .= show_exceptions ($ignore_result_any,
+				 ($current_arg <= $#args)
+				 ? $args[$current_arg]
+				 : undef);
 
   # special treatment for some functions
   $i = 0;
@@ -298,8 +299,10 @@ sub parse_args {
     if (!$run_extra) {
       $extra_expected = "0";
     }
-    $cline .= ", $run_extra, $extra_expected";
+    $cline_res .= ", $run_extra, $extra_expected";
   }
+  $cline_res =~ s/^, //;
+  $cline .= ", { $cline_res }, { $cline_res }, { $cline_res }, { $cline_res }";
   print $file "    $cline },\n";
 }