1#include <error.h>
2#include <mcheck.h>
3#include <stdio.h>
4#include <string.h>
5#include <wchar.h>
6#include <libc-diag.h>
7
8static int
9do_test (int argc, char *argv[])
10{
11 mtrace ();
12 (void) freopen (filename: argc == 1 ? "/dev/stdout" : argv[1], modes: "a", stderr);
13 /* Orient the stream. */
14 fwprintf (stderr, format: L"hello world\n");
15 char buf[20000];
16 static const char str[] = "hello world! ";
17 for (int i = 0; i < 1000; ++i)
18 memcpy (&buf[i * (sizeof (str) - 1)], str, sizeof (str));
19 error (status: 0, errnum: 0, format: str);
20
21 /* We're testing a large format string here and need to generate it
22 to avoid this source file being ridiculous. So disable the warning
23 about a generated format string. */
24 DIAG_PUSH_NEEDS_COMMENT;
25 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-security");
26
27 error (status: 0, errnum: 0, format: buf);
28 error (status: 0, errnum: 0, format: buf);
29
30 DIAG_POP_NEEDS_COMMENT;
31
32 error (status: 0, errnum: 0, format: str);
33 return 0;
34}
35
36#define TEST_FUNCTION do_test (argc, argv)
37#include "../test-skeleton.c"
38

source code of glibc/misc/tst-error1.c