tst-error1.c 945 B

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