Bug 191675

Summary: [tests] tools/regression/lib/libc/stdio/test-printfloat.t failures with i386 with assumptions about LDBL_MANT_DIG == 53?
Product: Base System Reporter: Enji Cooper <ngie>
Component: testsAssignee: freebsd-testing mailing list <testing>
Status: New ---    
Severity: Affects Some People CC: das, kargl
Priority: ---    
Version: CURRENT   
Hardware: i386   
OS: Any   

Description Enji Cooper freebsd_committer 2014-07-07 00:38:47 UTC
A check was added to test-printfloat.c to deal with i386 some years ago, most likely because of the issues noted in this mailing list thread: http://lists.freebsd.org/pipermail/freebsd-standards/2007-October/001452.html .

The code is always hitting the #else case, which fails with i386, using both clang and gcc. If I remove the !defined(__i386__) (for two spots in the testcases), the tests pass on i386.

Is this expected?

5a0431f63 (das      2004-01-19 05:59:07 +0000 259) #if (LDBL_MANT_DIG == 64) && !defined(__i386__)
61773c1de (das      2008-04-12 03:11:56 +0000 260)      testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L);
61773c1de (das      2008-04-12 03:11:56 +0000 261)      testfmt("0x1p-16445", "%La", 0x1p-16445L);
61773c1de (das      2008-04-12 03:11:56 +0000 262)      testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L);
...
5a0431f63 (das      2004-01-19 05:59:07 +0000 268) #else
1f0071c6f (das      2012-01-14 21:09:54 +0000 269)      testfmt("0x1.921fb54442d18p+1", "%La", 0x3.243f6a8885a31p0L);
1f0071c6f (das      2012-01-14 21:09:54 +0000 270)      testfmt("0x1p-1074", "%La", 0x1p-1074L);
1f0071c6f (das      2012-01-14 21:09:54 +0000 271)      testfmt("0x1.30ecap-1021", "%La", 0x9.8765p-1024L);

commit 1f0071c6f6eac4b1e00802e089059cbb55254ba9
Author: das <das@FreeBSD.org>
Date:   Sat Jan 14 21:09:54 2012 +0000

    Update the tests for arm and other ports where long double is the same
    as double, similar to r178141.

Notes:
    svn path=/head/; revision=230114

...

commit 5a0431f630ef41b4c8dfbf0aa35c96e9104ea4c3
Author: das <das@FreeBSD.org>
Date:   Mon Jan 19 05:59:07 2004 +0000

    Add regression tests for printf's %a/%A formats.
    
    While here, disable some of the long double tests on i386, since
    FreeBSD/i386 is the only port that doesn't evaluate long doubles in
    their full precision (due to constant folding bugs in gcc).

Notes:
    svn path=/head/; revision=124708


% make CC=gcc47 test-printfloat LDFLAGS+="-Wl,-rpath=/usr/local/lib/gcc47/ -L/usr/local/lib/gcc47/"
gcc47 -O2 -pipe   -lm -Wl,-rpath=/usr/local/lib/gcc47/ -L/usr/local/lib/gcc47/ test-printfloat.c  -o test-printfloat
% ./test-printfloat
1..11
ok 1 - printfloat
ok 2 - printfloat
ok 3 - printfloat
ok 4 - printfloat
ok 5 - printfloat
ok 6 - printfloat
ok 7 - printfloat
ok 8 - printfloat
ok 9 - printfloat
269: printf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d1846ap+1], expected [0x1.921fb54442d18p+1]
Abort trap (core dumped)
% prove -v test-printfloat.t 
test-printfloat.t .. 
1..11
ok 1 - printfloat
ok 2 - printfloat
ok 3 - printfloat
ok 4 - printfloat
ok 5 - printfloat
ok 6 - printfloat
ok 7 - printfloat
ok 8 - printfloat
ok 9 - printfloat
269: printf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d188p+1], expected [0x1.921fb54442d18p+1]
Failed 2/11 subtests 

Test Summary Report
-------------------
test-printfloat.t (Wstat: 134 Tests: 9 Failed: 0)
  Non-zero wait status: 134
  Parse errors: Bad plan.  You planned 11 tests but ran 9.
Files=1, Tests=9,  1 wallclock secs ( 0.01 usr  0.02 sys +  0.07 cusr  0.22 csys =  0.32 CPU)
Result: FAIL
% git checkout isilon-atf
% cd -
% git diff HEAD^..
diff --git a/lib/libc/tests/legacy/stdio/test-printfloat.c b/lib/libc/tests/legacy/stdio/test-printfloat.c
index 806a85e..d4a189c 100644
--- a/lib/libc/tests/legacy/stdio/test-printfloat.c
+++ b/lib/libc/tests/legacy/stdio/test-printfloat.c
@@ -75,7 +75,7 @@ main(int argc, char *argv[])
        testfmt("1234567.800000", "%Lf", 1234567.8L);
        testfmt("1.23457E+06", "%LG", 1234567.8L);
 
-#if (LDBL_MANT_DIG > DBL_MANT_DIG) && !defined(__i386__)
+#if (LDBL_MANT_DIG > DBL_MANT_DIG)
        testfmt("123456789.864210", "%Lf", 123456789.8642097531L);
        testfmt("-1.23457E+08", "%LG", -123456789.8642097531L);
        testfmt("123456789.8642097531", "%.10Lf", 123456789.8642097531L);
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
        testfmt("0x1p-1074", "%a", 0x1p-1074);
        testfmt("0x1.2345p-1024", "%a", 0x1.2345p-1024);
 
-#if (LDBL_MANT_DIG == 64) && !defined(__i386__)
+#if (LDBL_MANT_DIG == 64)
        testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L);
        testfmt("0x1p-16445", "%La", 0x1p-16445L);
        testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L);
% make all install
...
% pwd; ./test-printfloat 
/usr/tests/lib/libc/legacy/stdio
1..11
ok 1 - printfloat
ok 2 - printfloat
ok 3 - printfloat
ok 4 - printfloat
ok 5 - printfloat
ok 6 - printfloat
ok 7 - printfloat
ok 8 - printfloat
ok 9 - printfloat
ok 10 - printfloat
ok 11 - printfloat