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 
8 static int
do_test(int argc,char * argv[])9 do_test (int argc, char *argv[])
10 {
11   mtrace ();
12   (void) freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr);
13   /* Orient the stream.  */
14   fwprintf (stderr, 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 (0, 0, 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 (0, 0, buf);
28   error (0, 0, buf);
29 
30   DIAG_POP_NEEDS_COMMENT;
31 
32   error (0, 0, str);
33   return 0;
34 }
35 
36 #define TEST_FUNCTION do_test (argc, argv)
37 #include "../test-skeleton.c"
38