From d00bce3996ec46b0c4ad1690c1d153b9101d2239 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 24 Mar 2023 11:41:10 +0100 Subject: [PATCH] fprintf-gnu: Add tests. * tests/test-fprintf-gnu.sh: New file, based on tests/test-fprintf-posix.sh. * tests/test-fprintf-gnu.c: New file, based on tests/test-fprintf-posix.c. * modules/fprintf-gnu-tests: New file, based on modules/fprintf-posix-tests. --- ChangeLog | 8 ++++++++ modules/fprintf-gnu-tests | 15 +++++++++++++++ tests/test-fprintf-gnu.c | 36 ++++++++++++++++++++++++++++++++++++ tests/test-fprintf-gnu.sh | 16 ++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 modules/fprintf-gnu-tests create mode 100644 tests/test-fprintf-gnu.c create mode 100755 tests/test-fprintf-gnu.sh diff --git a/ChangeLog b/ChangeLog index 07ef028cff..54de6d019e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2023-03-24 Bruno Haible + fprintf-gnu: Add tests. + * tests/test-fprintf-gnu.sh: New file, based on + tests/test-fprintf-posix.sh. + * tests/test-fprintf-gnu.c: New file, based on + tests/test-fprintf-posix.c. + * modules/fprintf-gnu-tests: New file, based on + modules/fprintf-posix-tests. + fprintf-gnu: New module. * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): New macro, extracted from gl_FUNC_FPRINTF_POSIX. diff --git a/modules/fprintf-gnu-tests b/modules/fprintf-gnu-tests new file mode 100644 index 0000000000..383e5b6426 --- /dev/null +++ b/modules/fprintf-gnu-tests @@ -0,0 +1,15 @@ +Files: +tests/test-fprintf-gnu.sh +tests/test-fprintf-gnu.c +tests/test-fprintf-gnu.h +tests/test-printf-gnu.output +tests/macros.h + +Depends-on: +fprintf-posix-tests + +configure.ac: + +Makefile.am: +TESTS += test-fprintf-gnu.sh +check_PROGRAMS += test-fprintf-gnu diff --git a/tests/test-fprintf-gnu.c b/tests/test-fprintf-gnu.c new file mode 100644 index 0000000000..08def42d82 --- /dev/null +++ b/tests/test-fprintf-gnu.c @@ -0,0 +1,36 @@ +/* Test of POSIX and GNU compatible fprintf() function. + Copyright (C) 2007-2023 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" + +#include "test-fprintf-gnu.h" + +int +main (int argc, char *argv[]) +{ + test_function (fprintf); + return 0; +} diff --git a/tests/test-fprintf-gnu.sh b/tests/test-fprintf-gnu.sh new file mode 100755 index 0000000000..346f13c010 --- /dev/null +++ b/tests/test-fprintf-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-fprintf-gnu.tmp t-fprintf-gnu.out" +${CHECKER} ./test-fprintf-gnu${EXEEXT} > t-fprintf-gnu.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-fprintf-gnu.tmp > t-fprintf-gnu.out || exit 1 + +: "${DIFF=diff}" +${DIFF} "${srcdir}/test-printf-gnu.output" t-fprintf-gnu.out +result=$? + +rm -fr $tmpfiles + +exit $result -- 2.39.5