Add libm-test support for per-rounding-mode manually specified results.

This patch continues the libm-test move towards automatic testing of
all test inputs in all rounding modes by adding gen-libm-test.pl
support for tests specifying results in each rounding mode manually.

Previously a TEST_* line could specify arguments and results, or
arguments, results and flags.  Now there is the option of (arguments,
results-rd, flags-rd, results-rn, flags-rn, results-rz, flags-rz,
results-ru, flags-ru).  This is used to replace the separate arrays of
results in each rounding mode for lrint, llrint and rint.  (In the
case of rint, some tests were only in rint_test_data and needed to
have expectations for non-default rounding modes added, which I did
manually.  In various cases there were slight differences in things
such as the ordering of tests in the arrays for each mode.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle results specified for
	each rounding mode separately.
	* math/libm-test.inc (lrint_test_data): Merge in per-rounding-mode
	tests and results from lrint_tonearest_test_data,
	lrint_towardzero_test_data, lrint_downward_test_data and
	lrint_upward_test_data.
	(lrint_test): Use ALL_RM_TEST.
	(lrint_tonearest_test_data): Remove.
	(lrint_test_tonearest): Likewise.
	(lrint_towardzero_test_data): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_downward_test_data): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_upward_test_data): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test_data): Merge in per-rounding-mode tests and results
	from llrint_tonearest_test_data, llrint_towardzero_test_data,
	llrint_downward_test_data and llrint_upward_test_data.
	(llrint_test): Use ALL_RM_TEST.
	(llrint_tonearest_test_data): Remove.
	(llrint_test_tonearest): Likewise.
	(llrint_towardzero_test_data): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_downward_test_data): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_upward_test_data): Likewise.
	(llrint_test_upward): Likewise.
	(rint_test_data): Merge in per-rounding-mode tests and results
	from rint_tonearest_test_data, rint_towardzero_test_data,
	rint_downward_test_data and rint_upward_test_data.  Add
	per-rounding-mode results for tests not in those arrays.
	(rint_test): Use ALL_RM_TEST.
	(rint_tonearest_test_data): Remove.
	(rint_test_tonearest): Likewise.
	(rint_towardzero_test_data): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_downward_test_data): Likewise.
	(rint_test_downward): Likewise.
	(rint_upward_test_data): Likewise.
	(rint_test_upward): Likewise.
	(main): Don't call removed functions.
This commit is contained in:
Joseph Myers 2014-03-17 12:29:26 +00:00
parent 5006148ee5
commit 9962a2d34e
3 changed files with 306 additions and 1288 deletions

View File

@ -1,3 +1,47 @@
2014-03-17 Joseph Myers <joseph@codesourcery.com>
* math/gen-libm-test.pl (parse_args): Handle results specified for
each rounding mode separately.
* math/libm-test.inc (lrint_test_data): Merge in per-rounding-mode
tests and results from lrint_tonearest_test_data,
lrint_towardzero_test_data, lrint_downward_test_data and
lrint_upward_test_data.
(lrint_test): Use ALL_RM_TEST.
(lrint_tonearest_test_data): Remove.
(lrint_test_tonearest): Likewise.
(lrint_towardzero_test_data): Likewise.
(lrint_test_towardzero): Likewise.
(lrint_downward_test_data): Likewise.
(lrint_test_downward): Likewise.
(lrint_upward_test_data): Likewise.
(lrint_test_upward): Likewise.
(llrint_test_data): Merge in per-rounding-mode tests and results
from llrint_tonearest_test_data, llrint_towardzero_test_data,
llrint_downward_test_data and llrint_upward_test_data.
(llrint_test): Use ALL_RM_TEST.
(llrint_tonearest_test_data): Remove.
(llrint_test_tonearest): Likewise.
(llrint_towardzero_test_data): Likewise.
(llrint_test_towardzero): Likewise.
(llrint_downward_test_data): Likewise.
(llrint_test_downward): Likewise.
(llrint_upward_test_data): Likewise.
(llrint_test_upward): Likewise.
(rint_test_data): Merge in per-rounding-mode tests and results
from rint_tonearest_test_data, rint_towardzero_test_data,
rint_downward_test_data and rint_upward_test_data. Add
per-rounding-mode results for tests not in those arrays.
(rint_test): Use ALL_RM_TEST.
(rint_tonearest_test_data): Remove.
(rint_test_tonearest): Likewise.
(rint_towardzero_test_data): Likewise.
(rint_test_towardzero): Likewise.
(rint_downward_test_data): Likewise.
(rint_test_downward): Likewise.
(rint_upward_test_data): Likewise.
(rint_test_upward): Likewise.
(main): Don't call removed functions.
2014-03-14 Roland McGrath <roland@hack.frob.com>
* csu/Makefile ($(objpfx)version-info.h): Remove linux-specific

View File

@ -158,6 +158,7 @@ sub parse_args {
my (@special);
my ($call_args);
my ($ignore_result_any, $ignore_result_all);
my ($num_res, @args_res, $start_rm, $this_start_rm);
($descr_args, $descr_res) = split /_/,$descr, 2;
@ -194,32 +195,39 @@ sub parse_args {
}
# Result
@args_res = @args[$current_arg .. $#args];
$num_res = 0;
@descr = split //,$descr_res;
foreach (@descr) {
if ($_ =~ /f|i|l|L/) {
++$current_arg;
++$num_res;
} elsif ($_ eq 'c') {
$current_arg += 2;
$num_res += 2;
} elsif ($_ eq 'b') {
# boolean
++$current_arg;
++$num_res;
} elsif ($_ eq '1') {
++$current_arg;
++$num_res;
} else {
die ("$_ is unknown");
}
}
# consistency check
if ($current_arg == $#args) {
if ($#args_res == $num_res - 1) {
# One set of results for all rounding modes, no flags.
$start_rm = [ 0, 0, 0, 0 ];
} elsif ($#args_res == $num_res) {
# One set of results for all rounding modes, with flags.
die ("wrong number of arguments")
unless ($args[$current_arg] =~ /EXCEPTION|ERRNO|IGNORE_ZERO_INF_SIGN|TEST_NAN_SIGN|NO_TEST_INLINE|XFAIL_TEST/);
} elsif ($current_arg < $#args) {
die ("wrong number of arguments");
} elsif ($current_arg > ($#args+1)) {
unless ($args_res[$#args_res] =~ /EXCEPTION|ERRNO|IGNORE_ZERO_INF_SIGN|TEST_NAN_SIGN|NO_TEST_INLINE|XFAIL_TEST/);
$start_rm = [ 0, 0, 0, 0 ];
} elsif ($#args_res == 4 * $num_res + 3) {
# One set of results per rounding mode, with flags.
$start_rm = [ 0, $num_res + 1, 2 * $num_res + 2, 3 * $num_res + 3 ];
} else {
die ("wrong number of arguments");
}
# Put the C program line together
# Reset some variables to start again
$current_arg = 1;
@ -245,64 +253,68 @@ 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];
if ($result eq "IGNORE") {
$ignore_result_any = 1;
$result = "0";
} else {
$ignore_result_all = 0;
foreach $this_start_rm (@$start_rm) {
$current_arg = $this_start_rm;
$ignore_result_any = 0;
$ignore_result_all = 1;
$cline_res = "";
@special = ();
foreach (@descr) {
if ($_ =~ /b|f|i|l|L/ ) {
my ($result) = $args_res[$current_arg];
if ($result eq "IGNORE") {
$ignore_result_any = 1;
$result = "0";
} else {
$ignore_result_all = 0;
}
$cline_res .= ", $result";
$current_arg++;
} elsif ($_ eq 'c') {
my ($result1) = $args_res[$current_arg];
if ($result1 eq "IGNORE") {
$ignore_result_any = 1;
$result1 = "0";
} else {
$ignore_result_all = 0;
}
my ($result2) = $args_res[$current_arg + 1];
if ($result2 eq "IGNORE") {
$ignore_result_any = 1;
$result2 = "0";
} else {
$ignore_result_all = 0;
}
$cline_res .= ", $result1, $result2";
$current_arg += 2;
} elsif ($_ eq '1') {
push @special, $args_res[$current_arg];
++$current_arg;
}
$cline_res .= ", $result";
$current_arg++;
} elsif ($_ eq 'c') {
my ($result1) = $args[$current_arg];
if ($result1 eq "IGNORE") {
$ignore_result_any = 1;
$result1 = "0";
} else {
$ignore_result_all = 0;
}
my ($result2) = $args[$current_arg + 1];
if ($result2 eq "IGNORE") {
$ignore_result_any = 1;
$result2 = "0";
} else {
$ignore_result_all = 0;
}
$cline_res .= ", $result1, $result2";
$current_arg += 2;
} elsif ($_ eq '1') {
push @special, $args[$current_arg];
++$current_arg;
}
}
if ($ignore_result_any && !$ignore_result_all) {
die ("some but not all function results ignored\n");
}
# Add exceptions.
$cline_res .= show_exceptions ($ignore_result_any,
($current_arg <= $#args)
? $args[$current_arg]
: undef);
if ($ignore_result_any && !$ignore_result_all) {
die ("some but not all function results ignored\n");
}
# Add exceptions.
$cline_res .= show_exceptions ($ignore_result_any,
($current_arg <= $#args_res)
? $args_res[$current_arg]
: undef);
# special treatment for some functions
$i = 0;
foreach (@special) {
++$i;
my ($extra_expected) = $_;
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
if (!$run_extra) {
$extra_expected = "0";
# special treatment for some functions
$i = 0;
foreach (@special) {
++$i;
my ($extra_expected) = $_;
my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
if (!$run_extra) {
$extra_expected = "0";
}
$cline_res .= ", $run_extra, $extra_expected";
}
$cline_res .= ", $run_extra, $extra_expected";
$cline_res =~ s/^, //;
$cline .= ", { $cline_res }";
}
$cline_res =~ s/^, //;
$cline .= ", { $cline_res }, { $cline_res }, { $cline_res }, { $cline_res }";
print $file " $cline },\n";
}

File diff suppressed because it is too large Load Diff