Blame libio/tst-wfile-sync.c

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