]> Savannah Git Hosting - gnulib.git/commitdiff
vdzprintf-posix: Add tests.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 15:21:04 +0000 (17:21 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 15:23:17 +0000 (17:23 +0200)
* tests/test-fprintf-posix.h (test_function): Use RETTYPE instead of
'int'.
* tests/test-fprintf-posix.c (RETTYPE): New macro.
* tests/test-vdprintf-posix.c (RETTYPE): New macro.
* tests/test-vfprintf-posix.c (RETTYPE): New macro.
* tests/test-xfprintf-posix.c (RETTYPE): New macro.
* tests/test-vdzprintf-posix.c: New file, based on
tests/test-vdprintf-posix.c.
* tests/test-vdzprintf-posix.sh: New file, based on
tests/test-vdprintf-posix.sh.
* modules/vdzprintf-posix-tests: New file.

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

index a13e83c6942584608855e1fb9754eb15ccf5ec4a..4b2988dea5e78c4555095b6484d8e533d1ddad0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2024-06-30  Bruno Haible  <bruno@clisp.org>
 
+       vdzprintf-posix: Add tests.
+       * tests/test-fprintf-posix.h (test_function): Use RETTYPE instead of
+       'int'.
+       * tests/test-fprintf-posix.c (RETTYPE): New macro.
+       * tests/test-vdprintf-posix.c (RETTYPE): New macro.
+       * tests/test-vfprintf-posix.c (RETTYPE): New macro.
+       * tests/test-xfprintf-posix.c (RETTYPE): New macro.
+       * tests/test-vdzprintf-posix.c: New file, based on
+       tests/test-vdprintf-posix.c.
+       * tests/test-vdzprintf-posix.sh: New file, based on
+       tests/test-vdprintf-posix.sh.
+       * modules/vdzprintf-posix-tests: New file.
+
        vdzprintf-posix: New module.
        * modules/vdzprintf-posix: New file.
 
diff --git a/modules/vdzprintf-posix-tests b/modules/vdzprintf-posix-tests
new file mode 100644 (file)
index 0000000..8cbf0d6
--- /dev/null
@@ -0,0 +1,16 @@
+Files:
+tests/test-vdzprintf-posix.sh
+tests/test-vdzprintf-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-vdzprintf-posix.sh
+check_PROGRAMS += test-vdzprintf-posix
index f929faeca78cd90617cdc34701fcfa9b575a0a15..019cdcf2bc1f6fbe648659c97dcfdfd44b22146d 100644 (file)
@@ -30,6 +30,7 @@ SIGNATURE_CHECK (fprintf, int, (FILE *, char const *, ...));
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-posix.h"
 
 int
index 8576f58324dea2d2ad6323aafb8911c326e57872..eac279ddb83f0f66feed3d9cd9f90c4eb1633ba7 100644 (file)
@@ -1,4 +1,4 @@
-/* Test of POSIX compatible [v]fprintf() and vdprintf() functions.
+/* Test of POSIX 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
@@ -19,7 +19,7 @@
 #include "infinity.h"
 
 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 0d6b6e39b31c9db0b1512a072387b313b82034fa..eec47b0bc6122ef8baa8f1b7133da6b3958b29d1 100644 (file)
@@ -30,6 +30,7 @@ SIGNATURE_CHECK (vdprintf, int, (int, char const *, va_list));
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-posix.h"
 
 static int
diff --git a/tests/test-vdzprintf-posix.c b/tests/test-vdzprintf-posix.c
new file mode 100644 (file)
index 0000000..f9573fc
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test of POSIX 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-posix.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-posix.sh b/tests/test-vdzprintf-posix.sh
new file mode 100755 (executable)
index 0000000..be2f5d7
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
+
+tmpfiles="$tmpfiles t-vdzprintf-posix.tmp t-vdzprintf-posix.out"
+${CHECKER} ./test-vdzprintf-posix${EXEEXT} > t-vdzprintf-posix.tmp || exit 1
+LC_ALL=C tr -d '\r' < t-vdzprintf-posix.tmp > t-vdzprintf-posix.out || exit 1
+
+: "${DIFF=diff}"
+${DIFF} "${srcdir}/test-printf-posix.output" t-vdzprintf-posix.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
index ae9c8f35bcdd598c39c32e7ad6419504c2ca7778..c64c1d2c4db0a3352fda43306e0c360f9e0afbe5 100644 (file)
@@ -30,6 +30,7 @@ SIGNATURE_CHECK (vfprintf, int, (FILE *, char const *, va_list));
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-posix.h"
 
 static int
index e17f5cbac3f6a7cfbd6babcb6f51bac9d476faa5..372a8fd830519c021ed3fc1d94de1ee57045d057 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-fprintf-posix.h"
 
 int