From: Bruno Haible Date: Sun, 30 Jun 2024 20:42:20 +0000 (+0200) Subject: vfzprintf-gnu: Add tests. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=88f544ba9f2d7ecf534d2265c6dc8f7c57119b7d;p=gnulib.git vfzprintf-gnu: Add tests. * tests/test-vfzprintf-gnu.c: New file, based on tests/test-vfprintf-gnu.c. * tests/test-vfzprintf-gnu.sh: New file, based on tests/test-vfprintf-gnu.sh. * tests/test-fprintf-gnu.h: Update title. * modules/vfzprintf-gnu-tests: New file. --- diff --git a/ChangeLog b/ChangeLog index 4e374a5913..345716dcb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2024-06-30 Bruno Haible + vfzprintf-gnu: Add tests. + * tests/test-vfzprintf-gnu.c: New file, based on + tests/test-vfprintf-gnu.c. + * tests/test-vfzprintf-gnu.sh: New file, based on + tests/test-vfprintf-gnu.sh. + * tests/test-fprintf-gnu.h: Update title. + * modules/vfzprintf-gnu-tests: New file. + vfzprintf-gnu: New module. * modules/vfzprintf-gnu: New file. diff --git a/modules/vfzprintf-gnu-tests b/modules/vfzprintf-gnu-tests new file mode 100644 index 0000000000..64d217bb38 --- /dev/null +++ b/modules/vfzprintf-gnu-tests @@ -0,0 +1,14 @@ +Files: +tests/test-vfzprintf-gnu.sh +tests/test-vfzprintf-gnu.c +tests/test-fprintf-gnu.h +tests/test-printf-gnu.output +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-vfzprintf-gnu.sh +check_PROGRAMS += test-vfzprintf-gnu diff --git a/tests/test-fprintf-gnu.h b/tests/test-fprintf-gnu.h index ce6dc39557..6c8c3b9f01 100644 --- a/tests/test-fprintf-gnu.h +++ b/tests/test-fprintf-gnu.h @@ -1,4 +1,4 @@ -/* Test of POSIX and GNU compatible [v]fprintf() and vd[z]printf() functions. +/* Test of POSIX and GNU compatible [v]f[z]printf() and vd[z]printf() functions. Copyright (C) 2007-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/tests/test-vfzprintf-gnu.c b/tests/test-vfzprintf-gnu.c new file mode 100644 index 0000000000..b2ede1f584 --- /dev/null +++ b/tests/test-vfzprintf-gnu.c @@ -0,0 +1,49 @@ +/* Test of POSIX and GNU compatible vfzprintf() function. + Copyright (C) 2007-2024 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 Bruno Haible , 2007. */ + +#include + +#include + +#include +#include +#include + +#include "macros.h" + +#define RETTYPE off64_t +#include "test-fprintf-gnu.h" + +static off64_t +my_fzprintf (FILE *fp, const char *format, ...) +{ + va_list args; + off64_t ret; + + va_start (args, format); + ret = vfzprintf (fp, format, args); + va_end (args); + return ret; +} + +int +main (int argc, char *argv[]) +{ + test_function (my_fzprintf); + return test_exit_status; +} diff --git a/tests/test-vfzprintf-gnu.sh b/tests/test-vfzprintf-gnu.sh new file mode 100755 index 0000000000..5c60192b98 --- /dev/null +++ b/tests/test-vfzprintf-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-vfzprintf-gnu.tmp t-vfzprintf-gnu.out" +${CHECKER} ./test-vfzprintf-gnu${EXEEXT} > t-vfzprintf-gnu.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vfzprintf-gnu.tmp > t-vfzprintf-gnu.out || exit 1 + +: "${DIFF=diff}" +${DIFF} "${srcdir}/test-printf-gnu.output" t-vfzprintf-gnu.out +result=$? + +rm -fr $tmpfiles + +exit $result