From 606dd130bdce412935eca78598923720a7e346c4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 3 Oct 2007 23:36:11 +0200 Subject: [PATCH] Test for __fpending function. --- ChangeLog | 6 ++++++ modules/fpending-tests | 10 ++++++++++ tests/test-fpending.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 modules/fpending-tests create mode 100644 tests/test-fpending.c diff --git a/ChangeLog b/ChangeLog index eb7de883b..37d8b80b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-10-03 Bruno Haible + * tests/test-fpending.c: New file, mostly copied + from coreutils/lib/t-fpending.c. + * modules/fpending-tests: New file. + +2007-10-03 Bruno Haible + Port the stdio extensions to QNX (untested). * lib/fseterr.c (fseterr): Add support for QNX. * lib/fbufmode.c (fbufmode): Likewise. diff --git a/modules/fpending-tests b/modules/fpending-tests new file mode 100644 index 000000000..0338987a1 --- /dev/null +++ b/modules/fpending-tests @@ -0,0 +1,10 @@ +Files: +tests/test-fpending.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-fpending +check_PROGRAMS += test-fpending diff --git a/tests/test-fpending.c b/tests/test-fpending.c new file mode 100644 index 000000000..05563f870 --- /dev/null +++ b/tests/test-fpending.c @@ -0,0 +1,50 @@ +/* Ensure that __fpending works. + + Copyright (C) 2004, 2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Written by Jim Meyering. */ + +#include + +#include "fpending.h" + +#include +#include + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) + +int +main () +{ + ASSERT (__fpending (stdout) == 0); + + fputs ("foo", stdout); + ASSERT (__fpending (stdout) == 3); + + fflush (stdout); + ASSERT (__fpending (stdout) == 0); + + exit (0); +} -- 2.11.0