From 7ef85f40fd55d9d22f797fa8d14b10855b29766f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 30 Jun 2024 23:10:41 +0200 Subject: [PATCH] zprintf-gnu: Add tests. * tests/test-zprintf-gnu.c: New file, based on tests/test-printf-gnu.c. * tests/test-zprintf-gnu.sh: New file, based on tests/test-printf-gnu.sh. * modules/zprintf-gnu-tests: New file. --- ChangeLog | 6 ++++++ modules/zprintf-gnu-tests | 14 ++++++++++++++ tests/test-zprintf-gnu.c | 36 ++++++++++++++++++++++++++++++++++++ tests/test-zprintf-gnu.sh | 16 ++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 modules/zprintf-gnu-tests create mode 100644 tests/test-zprintf-gnu.c create mode 100755 tests/test-zprintf-gnu.sh diff --git a/ChangeLog b/ChangeLog index 2ade395fa4..6a1e5d92a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2024-06-30 Bruno Haible + zprintf-gnu: Add tests. + * tests/test-zprintf-gnu.c: New file, based on tests/test-printf-gnu.c. + * tests/test-zprintf-gnu.sh: New file, based on + tests/test-printf-gnu.sh. + * modules/zprintf-gnu-tests: New file. + zprintf-gnu: New module. * modules/zprintf-gnu: New file. diff --git a/modules/zprintf-gnu-tests b/modules/zprintf-gnu-tests new file mode 100644 index 0000000000..72edbfe514 --- /dev/null +++ b/modules/zprintf-gnu-tests @@ -0,0 +1,14 @@ +Files: +tests/test-zprintf-gnu.sh +tests/test-zprintf-gnu.c +tests/test-printf-gnu.h +tests/test-printf-gnu.output +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-zprintf-gnu.sh +check_PROGRAMS += test-zprintf-gnu diff --git a/tests/test-zprintf-gnu.c b/tests/test-zprintf-gnu.c new file mode 100644 index 0000000000..4bdd5028c7 --- /dev/null +++ b/tests/test-zprintf-gnu.c @@ -0,0 +1,36 @@ +/* Test of POSIX and GNU compatible zprintf() 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 "macros.h" + +#define RETTYPE off64_t +#include "test-printf-gnu.h" + +int +main (int argc, char *argv[]) +{ + test_function (zprintf); + return test_exit_status; +} diff --git a/tests/test-zprintf-gnu.sh b/tests/test-zprintf-gnu.sh new file mode 100755 index 0000000000..c5902178a5 --- /dev/null +++ b/tests/test-zprintf-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-zprintf-gnu.tmp t-zprintf-gnu.out" +${CHECKER} ./test-zprintf-gnu${EXEEXT} > t-zprintf-gnu.tmp || exit 1 +LC_ALL=C tr -d '\r' < t-zprintf-gnu.tmp > t-zprintf-gnu.out || exit 1 + +: "${DIFF=diff}" +${DIFF} "${srcdir}/test-printf-gnu.output" t-zprintf-gnu.out +result=$? + +rm -fr $tmpfiles + +exit $result -- 2.39.5