From: Bruno Haible Date: Sun, 30 Jun 2024 15:29:44 +0000 (+0200) Subject: vdzprintf-gnu: Add tests. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5db947823d2e3e2a01fabedc786c3b5ea2cf81c1;p=gnulib.git vdzprintf-gnu: Add tests. * tests/test-fprintf-gnu.h (test_function): Use RETTYPE instead of 'int'. * tests/test-fprintf-gnu.c (RETTYPE): New macro. * tests/test-vdprintf-gnu.c (RETTYPE): New macro. * tests/test-vfprintf-gnu.c (RETTYPE): New macro. * tests/test-vdzprintf-gnu.c: New file, based on tests/test-vdzprintf-posix.c. * tests/test-vdzprintf-gnu.sh: New file, based on tests/test-vdzprintf-posix.sh. * modules/vdzprintf-gnu-tests: New file. --- diff --git a/ChangeLog b/ChangeLog index bae1f68d0e..03746bb590 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2024-06-30 Bruno Haible + vdzprintf-gnu: Add tests. + * tests/test-fprintf-gnu.h (test_function): Use RETTYPE instead of + 'int'. + * tests/test-fprintf-gnu.c (RETTYPE): New macro. + * tests/test-vdprintf-gnu.c (RETTYPE): New macro. + * tests/test-vfprintf-gnu.c (RETTYPE): New macro. + * tests/test-vdzprintf-gnu.c: New file, based on + tests/test-vdzprintf-posix.c. + * tests/test-vdzprintf-gnu.sh: New file, based on + tests/test-vdzprintf-posix.sh. + * modules/vdzprintf-gnu-tests: New file. + vdzprintf-gnu: New module. * modules/vdzprintf-gnu: New file. diff --git a/modules/vdzprintf-gnu-tests b/modules/vdzprintf-gnu-tests new file mode 100644 index 0000000000..a6b4547ccb --- /dev/null +++ b/modules/vdzprintf-gnu-tests @@ -0,0 +1,16 @@ +Files: +tests/test-vdzprintf-gnu.sh +tests/test-vdzprintf-gnu.c +tests/test-fprintf-gnu.h +tests/test-printf-gnu.output +tests/infinity.h +tests/macros.h + +Depends-on: +stdint + +configure.ac: + +Makefile.am: +TESTS += test-vdzprintf-gnu.sh +check_PROGRAMS += test-vdzprintf-gnu diff --git a/tests/test-fprintf-gnu.c b/tests/test-fprintf-gnu.c index 12f1c90763..3c0b59d9b3 100644 --- a/tests/test-fprintf-gnu.c +++ b/tests/test-fprintf-gnu.c @@ -26,6 +26,7 @@ #include "macros.h" +#define RETTYPE int #include "test-fprintf-gnu.h" int diff --git a/tests/test-fprintf-gnu.h b/tests/test-fprintf-gnu.h index f22ed39d02..ce6dc39557 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 vdprintf() functions. +/* Test of POSIX and GNU compatible [v]fprintf() 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 @@ -17,7 +17,7 @@ /* Written by Bruno Haible , 2023. */ static void -test_function (int (*my_fprintf) (FILE *, const char *, ...)) +test_function (RETTYPE (*my_fprintf) (FILE *, const char *, ...)) { /* Here we don't test output that may be platform dependent. The bulk of the tests is done as part of the 'vasnprintf-posix' module. */ diff --git a/tests/test-vdprintf-gnu.c b/tests/test-vdprintf-gnu.c index 5c0f0f3348..4a5f5ffef8 100644 --- a/tests/test-vdprintf-gnu.c +++ b/tests/test-vdprintf-gnu.c @@ -26,6 +26,7 @@ #include "macros.h" +#define RETTYPE int #include "test-fprintf-gnu.h" static int diff --git a/tests/test-vdzprintf-gnu.c b/tests/test-vdzprintf-gnu.c new file mode 100644 index 0000000000..eb92b038bd --- /dev/null +++ b/tests/test-vdzprintf-gnu.c @@ -0,0 +1,50 @@ +/* Test of POSIX and GNU compatible vdzprintf() 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 , 2009. */ + +#include + +#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 = vdzprintf (fileno (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-vdzprintf-gnu.sh b/tests/test-vdzprintf-gnu.sh new file mode 100755 index 0000000000..058fb7d374 --- /dev/null +++ b/tests/test-vdzprintf-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-vdzprintf-gnu.tmp t-vdzprintf-gnu.out" +${CHECKER} ./test-vdzprintf-gnu${EXEEXT} > t-vdzprintf-gnu.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vdzprintf-gnu.tmp > t-vdzprintf-gnu.out || exit 1 + +: "${DIFF=diff}" +${DIFF} "${srcdir}/test-printf-gnu.output" t-vdzprintf-gnu.out +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/tests/test-vfprintf-gnu.c b/tests/test-vfprintf-gnu.c index 813992c93a..e8cc1c4a0b 100644 --- a/tests/test-vfprintf-gnu.c +++ b/tests/test-vfprintf-gnu.c @@ -26,6 +26,7 @@ #include "macros.h" +#define RETTYPE int #include "test-fprintf-gnu.h" static int