1/* Test for the long double variants of *syslog* functions.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <stdarg.h>
20#include <stddef.h>
21#include <syslog.h>
22
23#include <support/capture_subprocess.h>
24#include <support/check.h>
25
26static void
27do_test_one_call (void *last, ...)
28{
29 long double ld = -1;
30 va_list ap;
31
32 /* Make syslog functions write to stderr with LOG_PERROR, so that it
33 can be captured by support_capture_subprocess and verified. */
34 openlog (ident: "test-syslog", LOG_PERROR, LOG_USER);
35
36 /* Call syslog functions that take a format string. */
37 SYSLOG_FUNCTION SYSLOG_FUNCTION_PARAMS;
38 va_start (ap, last);
39 VSYSLOG_FUNCTION VSYSLOG_FUNCTION_PARAMS;
40 va_end (ap);
41}
42
43static void
44do_test_call (void)
45{
46 long double ld = -1;
47 do_test_one_call (NULL, ld);
48}
49
50static int
51do_test (void)
52{
53 struct support_capture_subprocess result;
54 result = support_capture_subprocess (callback: (void *) &do_test_call, NULL);
55
56 do_test_call ();
57
58 /* Compare against the expected output. */
59 const char *expected =
60 "test-syslog: -1.000000\n"
61 "test-syslog: -1.000000\n";
62 TEST_COMPARE_STRING (expected, result.err.buffer);
63
64 return 0;
65}
66
67#include <support/test-driver.c>
68

source code of glibc/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c