Blame misc/tst-error1.c

Packit 6c4009
#include <error.h>
Packit 6c4009
#include <mcheck.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
#include <wchar.h>
Packit 6c4009
#include <libc-diag.h>
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (int argc, char *argv[])
Packit 6c4009
{
Packit 6c4009
  mtrace ();
Packit 6c4009
  (void) freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr);
Packit 6c4009
  /* Orient the stream.  */
Packit 6c4009
  fwprintf (stderr, L"hello world\n");
Packit 6c4009
  char buf[20000];
Packit 6c4009
  static const char str[] = "hello world! ";
Packit 6c4009
  for (int i = 0; i < 1000; ++i)
Packit 6c4009
    memcpy (&buf[i * (sizeof (str) - 1)], str, sizeof (str));
Packit 6c4009
  error (0, 0, str);
Packit 6c4009
Packit 6c4009
  /* We're testing a large format string here and need to generate it
Packit 6c4009
     to avoid this source file being ridiculous.  So disable the warning
Packit 6c4009
     about a generated format string.  */
Packit 6c4009
  DIAG_PUSH_NEEDS_COMMENT;
Packit 6c4009
  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-security");
Packit 6c4009
Packit 6c4009
  error (0, 0, buf);
Packit 6c4009
  error (0, 0, buf);
Packit 6c4009
Packit 6c4009
  DIAG_POP_NEEDS_COMMENT;
Packit 6c4009
Packit 6c4009
  error (0, 0, str);
Packit 6c4009
  return 0;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test (argc, argv)
Packit 6c4009
#include "../test-skeleton.c"