| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_atan.c,v 1.3 2012/02/28 08:58:39 pgoyette Exp $ */ | | 1 | /* $NetBSD: t_atan.c,v 1.4 2012/03/10 20:11:01 jruoho Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jukka Ruohonen. | | 8 | * by Jukka Ruohonen. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,29 @@ | | | @@ -20,27 +20,29 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <atf-c.h> | | 32 | #include <atf-c.h> |
| | | 33 | #include <atf-c/config.h> |
33 | #include <math.h> | | 34 | #include <math.h> |
| | | 35 | #include <string.h> |
34 | | | 36 | |
35 | /* | | 37 | /* |
36 | * atan(3) | | 38 | * atan(3) |
37 | */ | | 39 | */ |
38 | ATF_TC(atan_nan); | | 40 | ATF_TC(atan_nan); |
39 | ATF_TC_HEAD(atan_nan, tc) | | 41 | ATF_TC_HEAD(atan_nan, tc) |
40 | { | | 42 | { |
41 | atf_tc_set_md_var(tc, "descr", "Test atan(NaN) == NaN"); | | 43 | atf_tc_set_md_var(tc, "descr", "Test atan(NaN) == NaN"); |
42 | } | | 44 | } |
43 | | | 45 | |
44 | ATF_TC_BODY(atan_nan, tc) | | 46 | ATF_TC_BODY(atan_nan, tc) |
45 | { | | 47 | { |
46 | #ifndef __vax__ | | 48 | #ifndef __vax__ |
| @@ -53,62 +55,71 @@ ATF_TC_BODY(atan_nan, tc) | | | @@ -53,62 +55,71 @@ ATF_TC_BODY(atan_nan, tc) |
53 | | | 55 | |
54 | ATF_TC(atan_inf_neg); | | 56 | ATF_TC(atan_inf_neg); |
55 | ATF_TC_HEAD(atan_inf_neg, tc) | | 57 | ATF_TC_HEAD(atan_inf_neg, tc) |
56 | { | | 58 | { |
57 | atf_tc_set_md_var(tc, "descr", "Test atan(-Inf) == -pi/2"); | | 59 | atf_tc_set_md_var(tc, "descr", "Test atan(-Inf) == -pi/2"); |
58 | } | | 60 | } |
59 | | | 61 | |
60 | ATF_TC_BODY(atan_inf_neg, tc) | | 62 | ATF_TC_BODY(atan_inf_neg, tc) |
61 | { | | 63 | { |
62 | #ifndef __vax__ | | 64 | #ifndef __vax__ |
63 | const double x = -1.0L / 0.0L; | | 65 | const double x = -1.0L / 0.0L; |
64 | const double eps = 1.0e-40; | | 66 | const double eps = 1.0e-40; |
65 | | | 67 | |
| | | 68 | if (strcmp(atf_config_get("atf_arch"), "i386") == 0) |
| | | 69 | atf_tc_expect_fail("PR port-i386/46108"); |
| | | 70 | |
66 | if (fabs(atan(x) + M_PI_2) > eps) | | 71 | if (fabs(atan(x) + M_PI_2) > eps) |
67 | atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); | | 72 | atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); |
68 | #endif | | 73 | #endif |
69 | } | | 74 | } |
70 | | | 75 | |
71 | ATF_TC(atan_inf_pos); | | 76 | ATF_TC(atan_inf_pos); |
72 | ATF_TC_HEAD(atan_inf_pos, tc) | | 77 | ATF_TC_HEAD(atan_inf_pos, tc) |
73 | { | | 78 | { |
74 | atf_tc_set_md_var(tc, "descr", "Test atan(+Inf) == pi/2"); | | 79 | atf_tc_set_md_var(tc, "descr", "Test atan(+Inf) == pi/2"); |
75 | } | | 80 | } |
76 | | | 81 | |
77 | ATF_TC_BODY(atan_inf_pos, tc) | | 82 | ATF_TC_BODY(atan_inf_pos, tc) |
78 | { | | 83 | { |
79 | #ifndef __vax__ | | 84 | #ifndef __vax__ |
80 | const double x = +1.0L / 0.0L; | | 85 | const double x = +1.0L / 0.0L; |
81 | const double eps = 1.0e-40; | | 86 | const double eps = 1.0e-40; |
82 | | | 87 | |
| | | 88 | if (strcmp(atf_config_get("atf_arch"), "i386") == 0) |
| | | 89 | atf_tc_expect_fail("PR port-i386/46108"); |
| | | 90 | |
83 | if (fabs(atan(x) - M_PI_2) > eps) | | 91 | if (fabs(atan(x) - M_PI_2) > eps) |
84 | atf_tc_fail_nonfatal("atan(+Inf) != pi/2"); | | 92 | atf_tc_fail_nonfatal("atan(+Inf) != pi/2"); |
85 | #endif | | 93 | #endif |
86 | } | | 94 | } |
87 | | | 95 | |
88 | ATF_TC(atan_tan); | | 96 | ATF_TC(atan_tan); |
89 | ATF_TC_HEAD(atan_tan, tc) | | 97 | ATF_TC_HEAD(atan_tan, tc) |
90 | { | | 98 | { |
91 | atf_tc_set_md_var(tc, "descr", "Test atan(tan(x)) == x"); | | 99 | atf_tc_set_md_var(tc, "descr", "Test atan(tan(x)) == x"); |
92 | } | | 100 | } |
93 | | | 101 | |
94 | ATF_TC_BODY(atan_tan, tc) | | 102 | ATF_TC_BODY(atan_tan, tc) |
95 | { | | 103 | { |
96 | #ifndef __vax__ | | 104 | #ifndef __vax__ |
97 | const double x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; | | 105 | const double x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; |
98 | const double eps = 1.0e-40; | | 106 | const double eps = 1.0e-40; |
99 | double y; | | 107 | double y; |
100 | size_t i; | | 108 | size_t i; |
101 | | | 109 | |
| | | 110 | if (strcmp(atf_config_get("atf_arch"), "i386") == 0) |
| | | 111 | atf_tc_expect_fail("PR port-i386/46108"); |
| | | 112 | |
102 | for (i = 0; i < __arraycount(x); i++) { | | 113 | for (i = 0; i < __arraycount(x); i++) { |
103 | | | 114 | |
104 | y = atan(tan(x[i])); | | 115 | y = atan(tan(x[i])); |
105 | | | 116 | |
106 | if (fabs(y - x[i]) > eps) | | 117 | if (fabs(y - x[i]) > eps) |
107 | atf_tc_fail_nonfatal("atan(tan(%0.03f)) != %0.03f", | | 118 | atf_tc_fail_nonfatal("atan(tan(%0.03f)) != %0.03f", |
108 | x[i], x[i]); | | 119 | x[i], x[i]); |
109 | } | | 120 | } |
110 | #endif | | 121 | #endif |
111 | } | | 122 | } |
112 | | | 123 | |
113 | ATF_TC(atan_zero_neg); | | 124 | ATF_TC(atan_zero_neg); |
114 | ATF_TC_HEAD(atan_zero_neg, tc) | | 125 | ATF_TC_HEAD(atan_zero_neg, tc) |