Update copyright dates with scripts/update-copyrights.
[glibc.git] / math / test-fenv-return.c
blobfac3c750c2fbf43739b3dcac8cd430c29f129059
1 /* Test return value when setting FE_NOMASK_ENV (BZ16918, BZ17009).
2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <fenv.h>
20 #include <stdio.h>
21 #include <math-tests.h>
23 static int count_errors;
25 static void
26 test_feenableexcept (void)
28 #if defined FE_ALL_EXCEPT
29 int res;
31 fedisableexcept (FE_ALL_EXCEPT);
33 res = feenableexcept (FE_ALL_EXCEPT);
35 if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT) && (res == -1))
37 puts ("feenableexcept (FE_ALL_EXCEPT) not supported, cannot test.");
38 return;
40 else if (res != 0)
42 puts ("feenableexcept (FE_ALL_EXCEPT) failed");
43 count_errors++;
46 if (fegetexcept () != FE_ALL_EXCEPT)
48 puts ("feenableexcept did not set all exceptions");
49 count_errors++;
51 #endif
54 static void
55 test_fesetenv (void)
57 #if defined FE_NOMASK_ENV && defined FE_ALL_EXCEPT
58 int res;
60 fedisableexcept (FE_ALL_EXCEPT);
62 res = fesetenv (FE_NOMASK_ENV);
64 if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT) && (res != 0))
66 puts ("fesetenv (FE_NOMASK_ENV) not supported, cannot test.");
67 return;
69 else if (res != 0)
71 puts ("fesetenv (FE_NOMASK_ENV) failed");
72 count_errors++;
75 if (fegetexcept () != FE_ALL_EXCEPT)
77 puts ("fesetenv did not set all exceptions");
78 count_errors++;
80 #endif
83 static void
84 test_feupdateenv (void)
86 #if defined FE_NOMASK_ENV && defined FE_ALL_EXCEPT
87 int res;
89 fedisableexcept (FE_ALL_EXCEPT);
91 res = feupdateenv (FE_NOMASK_ENV);
93 if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT) && (res != 0))
95 puts ("feupdateenv (FE_NOMASK_ENV)) not supported, cannot test.");
96 return;
98 else if (res != 0)
100 puts ("feupdateenv (FE_NOMASK_ENV) failed");
101 count_errors++;
104 if (fegetexcept () != FE_ALL_EXCEPT)
106 puts ("feupdateenv did not set all exceptions");
107 count_errors++;
109 #endif
112 static int
113 do_test (void)
115 test_feenableexcept ();
116 test_fesetenv ();
117 test_feupdateenv ();
119 return count_errors != 0 ? 1 : 0;
122 #define TEST_FUNCTION do_test ()
123 #include "../test-skeleton.c"