diff options
author | tobiasu <> | 2014-06-07 01:47:02 +0000 |
---|---|---|
committer | tobiasu <> | 2014-06-07 01:47:02 +0000 |
commit | cdcb57035b4584fe754a6f9a8a18b47cc2b8fc27 (patch) | |
tree | 4160a1be059f6e1497e93fcbe814d7f46260d904 /src | |
parent | 93ba46972d1208b467cbbdcfb9ae5873587eb6ba (diff) | |
download | openbsd-cdcb57035b4584fe754a6f9a8a18b47cc2b8fc27.tar.gz openbsd-cdcb57035b4584fe754a6f9a8a18b47cc2b8fc27.tar.bz2 openbsd-cdcb57035b4584fe754a6f9a8a18b47cc2b8fc27.zip |
Add basic regression test for modf() issue.
encouraged by deraadt and miod
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libc/Makefile | 4 | ||||
-rw-r--r-- | src/regress/lib/libc/modf/Makefile | 3 | ||||
-rw-r--r-- | src/regress/lib/libc/modf/modf_test.c | 35 |
3 files changed, 40 insertions, 2 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile index 3109c0c1fd..f138f16ffd 100644 --- a/src/regress/lib/libc/Makefile +++ b/src/regress/lib/libc/Makefile | |||
@@ -1,8 +1,8 @@ | |||
1 | # $OpenBSD: Makefile,v 1.38 2013/12/29 01:39:44 martynas Exp $ | 1 | # $OpenBSD: Makefile,v 1.39 2014/06/07 01:46:40 tobiasu Exp $ |
2 | 2 | ||
3 | SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env | 3 | SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env |
4 | SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob | 4 | SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob |
5 | SUBDIR+= hsearch longjmp locale malloc mkstemp netdb open_memstream | 5 | SUBDIR+= hsearch longjmp locale malloc mkstemp modf netdb open_memstream |
6 | SUBDIR+= orientation popen printf | 6 | SUBDIR+= orientation popen printf |
7 | SUBDIR+= regex setjmp setjmp-signal sigreturn sigsetjmp sprintf | 7 | SUBDIR+= regex setjmp setjmp-signal sigreturn sigsetjmp sprintf |
8 | SUBDIR+= stdio_threading stpncpy strerror strtod strtol strtonum | 8 | SUBDIR+= stdio_threading stpncpy strerror strtod strtol strtonum |
diff --git a/src/regress/lib/libc/modf/Makefile b/src/regress/lib/libc/modf/Makefile new file mode 100644 index 0000000000..587c595f12 --- /dev/null +++ b/src/regress/lib/libc/modf/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | PROG=modf_test | ||
2 | |||
3 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/modf/modf_test.c b/src/regress/lib/libc/modf/modf_test.c new file mode 100644 index 0000000000..f732533635 --- /dev/null +++ b/src/regress/lib/libc/modf/modf_test.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* Public domain, 2014, Tobias Ulmer <tobiasu@tmux.org> */ | ||
2 | |||
3 | /* Test for bug introduced in 4.4BSD modf() on sparc */ | ||
4 | |||
5 | #include <math.h> | ||
6 | |||
7 | #define BIGFLOAT (5e15) /* Number large enough to trigger the "big" case */ | ||
8 | |||
9 | int | ||
10 | main(void) | ||
11 | { | ||
12 | double f, i; | ||
13 | |||
14 | f = modf(BIGFLOAT, &i); | ||
15 | if (i != BIGFLOAT) | ||
16 | return 1; | ||
17 | if (f != 0.0) | ||
18 | return 1; | ||
19 | |||
20 | /* Repeat, maybe we were lucky */ | ||
21 | f = modf(BIGFLOAT, &i); | ||
22 | if (i != BIGFLOAT) | ||
23 | return 1; | ||
24 | if (f != 0.0) | ||
25 | return 1; | ||
26 | |||
27 | /* With negative number, for good measure */ | ||
28 | f = modf(-BIGFLOAT, &i); | ||
29 | if (i != -BIGFLOAT) | ||
30 | return 1; | ||
31 | if (f != 0.0) | ||
32 | return 1; | ||
33 | |||
34 | return 0; | ||
35 | } | ||