Mercurial > hg > octave-lojdl > gnulib-hg
changeset 11034:c1aeb2f8dd65
Tests for module 'vdprintf-posix'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 18 Jan 2009 02:50:29 +0100 |
parents | 049c445485ee |
children | bf21f4597784 |
files | ChangeLog modules/vdprintf-posix-tests tests/test-vdprintf-posix.c tests/test-vdprintf-posix.sh |
diffstat | 4 files changed, 95 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-01-17 Bruno Haible <bruno@clisp.org> + * modules/vdprintf-posix-tests: New file. + * tests/test-vdprintf-posix.sh: New file. + * tests/test-vdprintf-posix.c: New file. + New modules 'vdprintf', 'vdprintf-posix'. * lib/stdio.in.h (vdprintf): New declaration. * lib/vdprintf.c: New file.
new file mode 100644 --- /dev/null +++ b/modules/vdprintf-posix-tests @@ -0,0 +1,15 @@ +Files: +tests/test-vdprintf-posix.sh +tests/test-vdprintf-posix.c +tests/test-fprintf-posix.h +tests/test-printf-posix.output + +Depends-on: +stdint + +configure.ac: + +Makefile.am: +TESTS += test-vdprintf-posix.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)' +check_PROGRAMS += test-vdprintf-posix
new file mode 100644 --- /dev/null +++ b/tests/test-vdprintf-posix.c @@ -0,0 +1,60 @@ +/* Test of POSIX compatible vdprintf() function. + Copyright (C) 2007-2009 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 <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include <stdio.h> + +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + fflush (stderr); \ + abort (); \ + } \ + } \ + while (0) + +#include "test-fprintf-posix.h" + +static int +my_fprintf (FILE *fp, const char *format, ...) +{ + va_list args; + int ret; + + va_start (args, format); + ret = vdprintf (fileno (fp), format, args); + va_end (args); + return ret; +} + +int +main (int argc, char *argv[]) +{ + test_function (my_fprintf); + return 0; +}
new file mode 100755 --- /dev/null +++ b/tests/test-vdprintf-posix.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-vdprintf-posix.tmp t-vdprintf-posix.out" +./test-vdprintf-posix${EXEEXT} > t-vdprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vdprintf-posix.tmp > t-vdprintf-posix.out || exit 1 + +: ${DIFF=diff} +${DIFF} "${srcdir}/test-printf-posix.output" t-vdprintf-posix.out +result=$? + +rm -fr $tmpfiles + +exit $result