aarch64/fpu: Add vector variants of erf
[glibc.git] / misc / tst-ldbl-error.c
blobd415b99f6d106aa92c5b5ee7a309f134ff6958fa
1 /* Test for the long double conversions in *err* functions.
2 Copyright (C) 2018-2024 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 <https://www.gnu.org/licenses/>. */
19 #include <err.h>
20 #include <errno.h>
21 #include <error.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #include <support/capture_subprocess.h>
26 #include <support/check.h>
28 struct tests
30 void *callback;
31 const char *expected;
34 va_list args;
36 static void
37 callback_err (void *closure)
39 errno = 0;
40 err (0, "%Lf", (long double) -1);
43 static void
44 callback_errx (void *closure)
46 errno = 0;
47 errx (0, "%Lf", (long double) -1);
50 static void
51 callback_verr (void *closure)
53 errno = 0;
54 verr (0, "%Lf", args);
57 static void
58 callback_verrx (void *closure)
60 errno = 0;
61 verrx (0, "%Lf", args);
64 static void
65 callback_error (void *closure)
67 errno = 0;
68 error (0, 0, "%Lf", (long double) -1);
71 static void
72 callback_error_at_line (void *closure)
74 errno = 0;
75 error_at_line (0, 0, "", 0, "%Lf", (long double) -1);
78 static void
79 do_one_test (void *callback, const char *expected, ...)
81 struct support_capture_subprocess result;
83 va_start (args, expected);
85 /* Call 'callback', which fills in the output and error buffers. */
86 result = support_capture_subprocess (callback, NULL);
88 /* Filter out the name of the program (which should always end with
89 -error), so that the test case can be reused by ldbl-opt and
90 ldbl-128ibm-compat. */
91 const char *needle = "-error:";
92 char *message;
93 message = strstr (result.err.buffer, needle);
94 if (message == NULL)
95 FAIL_EXIT1 ("test case error");
96 message += strlen (needle);
98 /* Verify that the output message is as expected. */
99 TEST_COMPARE_STRING (message, expected);
101 va_end (args);
104 static int
105 do_test (void)
107 struct tests tests[] = {
108 { &callback_err, " -1.000000: Success\n" },
109 { &callback_errx, " -1.000000\n" },
110 { &callback_verr, " -1.000000: Success\n" },
111 { &callback_verrx, " -1.000000\n" },
112 { &callback_error, " -1.000000\n" },
113 { &callback_error_at_line, ":0: -1.000000\n" }
116 for (int i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
118 do_one_test (tests[i].callback, tests[i].expected, (long double) -1);
121 return 0;
124 #include <support/test-driver.c>