From 5d03891d5016f5090338c51272466ba1dfe7db2a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 30 Jun 2024 21:17:03 +0200 Subject: [PATCH] vfzprintf-posix: Add tests. * tests/test-vfzprintf-posix.c: New file, based on tests/test-vfprintf-posix.c. * tests/test-vfzprintf-posix.sh: New file, based on tests/test-vfprintf-posix.sh. * tests/test-fprintf-posix.h: Update title. * modules/vfzprintf-posix-tests: New file. --- ChangeLog | 8 ++++++ modules/vfzprintf-posix-tests | 16 +++++++++++ tests/test-fprintf-posix.h | 2 +- tests/test-vfzprintf-posix.c | 50 +++++++++++++++++++++++++++++++++++ tests/test-vfzprintf-posix.sh | 16 +++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 modules/vfzprintf-posix-tests create mode 100644 tests/test-vfzprintf-posix.c create mode 100755 tests/test-vfzprintf-posix.sh diff --git a/ChangeLog b/ChangeLog index 981b2734e7..5cc7ae4ac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2024-06-30 Bruno Haible + vfzprintf-posix: Add tests. + * tests/test-vfzprintf-posix.c: New file, based on + tests/test-vfprintf-posix.c. + * tests/test-vfzprintf-posix.sh: New file, based on + tests/test-vfprintf-posix.sh. + * tests/test-fprintf-posix.h: Update title. + * modules/vfzprintf-posix-tests: New file. + vfzprintf-posix: New module. * modules/vfzprintf-posix: New file. diff --git a/modules/vfzprintf-posix-tests b/modules/vfzprintf-posix-tests new file mode 100644 index 0000000000..99902f90fc --- /dev/null +++ b/modules/vfzprintf-posix-tests @@ -0,0 +1,16 @@ +Files: +tests/test-vfzprintf-posix.sh +tests/test-vfzprintf-posix.c +tests/test-fprintf-posix.h +tests/test-printf-posix.output +tests/infinity.h +tests/macros.h + +Depends-on: +stdint + +configure.ac: + +Makefile.am: +TESTS += test-vfzprintf-posix.sh +check_PROGRAMS += test-vfzprintf-posix diff --git a/tests/test-fprintf-posix.h b/tests/test-fprintf-posix.h index eac279ddb8..2242d2af49 100644 --- a/tests/test-fprintf-posix.h +++ b/tests/test-fprintf-posix.h @@ -1,4 +1,4 @@ -/* Test of POSIX compatible [v]fprintf() and vd[z]printf() functions. +/* Test of POSIX 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-posix.c b/tests/test-vfzprintf-posix.c new file mode 100644 index 0000000000..219d0b983b --- /dev/null +++ b/tests/test-vfzprintf-posix.c @@ -0,0 +1,50 @@ +/* Test of POSIX 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 + +#include "macros.h" + +#define RETTYPE off64_t +#include "test-fprintf-posix.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-posix.sh b/tests/test-vfzprintf-posix.sh new file mode 100755 index 0000000000..6d286361e3 --- /dev/null +++ b/tests/test-vfzprintf-posix.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-vfzprintf-posix.tmp t-vfzprintf-posix.out" +${CHECKER} ./test-vfzprintf-posix${EXEEXT} > t-vfzprintf-posix.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-vfzprintf-posix.tmp > t-vfzprintf-posix.out || exit 1 + +: "${DIFF=diff}" +${DIFF} "${srcdir}/test-printf-posix.output" t-vfzprintf-posix.out +result=$? + +rm -fr $tmpfiles + +exit $result -- 2.39.5