Math error-reporting test scripts useful in glibc?

Agner Fog agner@agner.org
Tue Aug 26 06:10:00 GMT 2008


Looks great!
Do the math functions have different versions for microprocessors with 
and without SSE2 and later instruction sets?  If so, is there a 
testability feature built into the CPU dispatching mechanism - in other 
words: is there a way of testing the old non-SSE2 version on a computer 
with SSE2? Are the non-SSE2 math functions normally inlined? If they are 
inlined, I guess they would not set errno?

Michael Kerrisk wrote in libc-alpha:
> A few weeks back I wrote some scripts to test error reporting by
> nearly all math functions in glibc.  (Some details below.)  These
> scripts are available here:
> http://linux-man-pages.blogspot.com/2008/08/help-request-testing-of-math-function.html.
>
> The main points about these scripts are that:
>
> a) They automate generation of test programs for math functions, so
> that together two scripts generate tests for about 70 math functions
> (in any of the three type flavors, float, double, and long double).
>
> b) They produce C programs that can be driven from the command-line to
> perform almost any test of the math function.  Thus, as well as
> accepting numeric vales for the function arguments, one can use words
> such as "+inf", "-inf", "nan", "max" (the largest value of the
> function's type), "subnormal:N" (a subnormal power-of-two number with
> N leading zeroes in the significand), etc.  The resulting programs can
> be useful for working with glibc bug reports for math functions where
> no test program is supplied, or the test program is very limited in
> its operation.
>
> c) The generated test programs produce output that can easily be
> script processed -- each program produces a summary line containing
> the errno setting, the exception raised (if any), and the (class of
> the) result value.  For example, the log(3) test program produces the
> following output when given a command-line argument of 0:
> ERANGE FE_DIVBYZERO -inf
> And an argument of 10 produces the output:
> 0 0 normal
> (where normal is indicates that the result is a normalized floating
> point number; it is also possible to use the programs to test that the
> result matches a specific value, if merely knowing that the value is
> "normal" is insufficient).
>
> d) They can be extended fairly easily to cover other math functions
> (though in fact I think I've covered most math functions already,
> including all of those in POSIX.1-2001, and most of the glibc
> extensions -- however, note that these scripts don't deal with the
> complex math functions).
>
> My question is: would / could these tests be usefully integrated into
> glibc?  If necessary, I may have some time to do some reworking to
> make them more suited to glibc requirements.
>
> Cheers,
>
> Michael
>
> PS The scripts check things such as:
>
> * Are errors reported via errno, via exceptions, or both?  For cases
> where errors are reported using only one of these mechanisms, or
> reported the wrong errors (see next point) or where errors are not
> reported at all, I logged bugs  --
> http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13583/focus=13594 .
>  The results of my tests are here:
> http://linux-man-pages.blogspot.com/2008/08/math-functions-and-error-reporting.html
> .)
>
> * Do the functions report errors for the appropriate cases (e.g.,
> underflow overflow, domain error, pole error), and (more difficult to
> determine, so not complete) are there cases where errors are being
> reported when they shouldn't be?
>
> * Are errors reported correctly?  (i.e., is errno set to the right
> value, or is the correct exception raised)?
>
>   



More information about the Libc-help mailing list