Blame libio/tst-wfile-sync.c

Packit Service e678c3
/* Test that _IO_wfile_sync does not crash (bug 20568).
Packit Service e678c3
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service e678c3
   This file is part of the GNU C Library.
Packit Service e678c3
Packit Service e678c3
   The GNU C Library is free software; you can redistribute it and/or
Packit Service e678c3
   modify it under the terms of the GNU Lesser General Public
Packit Service e678c3
   License as published by the Free Software Foundation; either
Packit Service e678c3
   version 2.1 of the License, or (at your option) any later version.
Packit Service e678c3
Packit Service e678c3
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service e678c3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service e678c3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service e678c3
   Lesser General Public License for more details.
Packit Service e678c3
Packit Service e678c3
   You should have received a copy of the GNU Lesser General Public
Packit Service e678c3
   License along with the GNU C Library; if not, see
Packit Service e678c3
   <http://www.gnu.org/licenses/>.  */
Packit Service e678c3
Packit Service e678c3
#include <locale.h>
Packit Service e678c3
#include <stdio.h>
Packit Service e678c3
#include <wchar.h>
Packit Service e678c3
#include <support/check.h>
Packit Service e678c3
#include <support/xunistd.h>
Packit Service e678c3
Packit Service e678c3
static int
Packit Service e678c3
do_test (void)
Packit Service e678c3
{
Packit Service e678c3
  TEST_VERIFY_EXIT (setlocale (LC_ALL, "de_DE.UTF-8") != NULL);
Packit Service e678c3
  /* Fill the stdio buffer and advance the read pointer.  */
Packit Service e678c3
  TEST_VERIFY_EXIT (fgetwc (stdin) != WEOF);
Packit Service e678c3
  /* This calls _IO_wfile_sync, it should not crash.  */
Packit Service e678c3
  TEST_VERIFY_EXIT (setvbuf (stdin, NULL, _IONBF, 0) == 0);
Packit Service e678c3
  /* Verify that the external file offset has been synchronized.  */
Packit Service e678c3
  TEST_COMPARE (xlseek (0, 0, SEEK_CUR), 1);
Packit Service e678c3
Packit Service e678c3
  return 0;
Packit Service e678c3
}
Packit Service e678c3
Packit Service e678c3
#include <support/test-driver.c>