]> Savannah Git Hosting - gnulib.git/commitdiff
vdzprintf-gnu: Add tests.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 15:29:44 +0000 (17:29 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 15:30:53 +0000 (17:30 +0200)
* 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.

ChangeLog
modules/vdzprintf-gnu-tests [new file with mode: 0644]
tests/test-fprintf-gnu.c
tests/test-fprintf-gnu.h
tests/test-vdprintf-gnu.c
tests/test-vdzprintf-gnu.c [new file with mode: 0644]
tests/test-vdzprintf-gnu.sh [new file with mode: 0755]
tests/test-vfprintf-gnu.c

index bae1f68d0ef2b6aca799b440617844440c1f37ca..03746bb5908aa47d3af25e91dff8c4453358a8e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2024-06-30  Bruno Haible  <bruno@clisp.org>
 
+       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 (file)
index 0000000..a6b4547
--- /dev/null
@@ -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
index 12f1c90763a08eb4905d6847cb593e15d75a9747..3c0b59d9b304391e9aa35ebd8d09443366a636f4 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-gnu.h"
 
 int
index f22ed39d027129c3d4705c3597fe5136d13fe7b7..ce6dc395571682a922c272dc23101b964297152e 100644 (file)
@@ -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 <bruno@clisp.org>, 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.  */
index 5c0f0f33482f4587ea7fac7d1940386e89e3cdac..4a5f5ffef89c4450cc6a6abb39ddd99ad4e209a4 100644 (file)
@@ -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 (file)
index 0000000..eb92b03
--- /dev/null
@@ -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 <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2009.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#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 (executable)
index 0000000..058fb7d
--- /dev/null
@@ -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
index 813992c93a1b936e400fcacb182577fd83fd2c48..e8cc1c4a0b648a35bdfa040b21e0fa5607593c7a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-gnu.h"
 
 static int