hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame libio/tst-wfile-sync.c

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