tst-error1.c 968 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include <support/xstdio.h>
  8. static int
  9. do_test (int argc, char *argv[])
  10. {
  11. mtrace ();
  12. xfreopen (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. /* We're testing a large format string here and need to generate it
  21. to avoid this source file being ridiculous. So disable the warning
  22. about a generated format string. */
  23. DIAG_PUSH_NEEDS_COMMENT;
  24. DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-security");
  25. error (0, 0, buf);
  26. error (0, 0, buf);
  27. DIAG_POP_NEEDS_COMMENT;
  28. error (0, 0, str);
  29. return 0;
  30. }
  31. #define TEST_FUNCTION do_test (argc, argv)
  32. #include "../test-skeleton.c"