]> Savannah Git Hosting - gnulib.git/commitdiff
vzprintf-posix: Add tests.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 20:12:41 +0000 (22:12 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2024 20:33:41 +0000 (22:33 +0200)
* tests/test-printf-posix.h (test_function): Use RETTYPE instead of
'int'.
* tests/test-printf-posix.c (RETTYPE): New macro.
* tests/test-vprintf-posix.c (RETTYPE): New macro.
* tests/test-xprintf-posix.c (RETTYPE): New macro.
* tests/test-vzprintf-posix.c: New file, based on
tests/test-vprintf-posix.c.
* tests/test-vzprintf-posix.sh: New file, based on
tests/test-vprintf-posix.sh.
* modules/vzprintf-posix-tests: New file.

ChangeLog
modules/vzprintf-posix-tests [new file with mode: 0644]
tests/test-printf-posix.c
tests/test-printf-posix.h
tests/test-vprintf-posix.c
tests/test-vzprintf-posix.c [new file with mode: 0644]
tests/test-vzprintf-posix.sh [new file with mode: 0755]
tests/test-xprintf-posix.c

index 4962f24cf278b5895e5d778cc25c19f944d9a859..4d4489279ab869a2d88f4f88121d399eed856eb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2024-06-30  Bruno Haible  <bruno@clisp.org>
 
+       vzprintf-posix: Add tests.
+       * tests/test-printf-posix.h (test_function): Use RETTYPE instead of
+       'int'.
+       * tests/test-printf-posix.c (RETTYPE): New macro.
+       * tests/test-vprintf-posix.c (RETTYPE): New macro.
+       * tests/test-xprintf-posix.c (RETTYPE): New macro.
+       * tests/test-vzprintf-posix.c: New file, based on
+       tests/test-vprintf-posix.c.
+       * tests/test-vzprintf-posix.sh: New file, based on
+       tests/test-vprintf-posix.sh.
+       * modules/vzprintf-posix-tests: New file.
+
        vzprintf-posix: New module.
        * modules/vzprintf-posix: New file.
 
diff --git a/modules/vzprintf-posix-tests b/modules/vzprintf-posix-tests
new file mode 100644 (file)
index 0000000..c6e4b8e
--- /dev/null
@@ -0,0 +1,16 @@
+Files:
+tests/test-vzprintf-posix.sh
+tests/test-vzprintf-posix.c
+tests/test-printf-posix.h
+tests/test-printf-posix.output
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+stdint
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vzprintf-posix.sh
+check_PROGRAMS += test-vzprintf-posix
index f24a0297ef54a8e0aa04b9a3349f4529ba9b2de0..8e7667740ec714e8e3c13e9bf36908ebb93af38b 100644 (file)
@@ -29,6 +29,7 @@ SIGNATURE_CHECK (printf, int, (char const *, ...));
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-printf-posix.h"
 
 int
index 68e8edb17586d4b4738126a252aa14f7a1ee59d1..60b6cf9c84023d482e8da63ede4380e6e95f0f69 100644 (file)
@@ -1,4 +1,4 @@
-/* Test of POSIX compatible vprintf() and printf() functions.
+/* Test of POSIX compatible v[z]printf() and 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_printf) (const char *, ...))
+test_function (RETTYPE (*my_printf) (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 795b09366befb82ef7a941131a39d86c89b66be9..b25274ab9dc75c8ea86598394a4c67e516c44d43 100644 (file)
@@ -30,6 +30,7 @@ SIGNATURE_CHECK (vprintf, int, (char const *, va_list));
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-printf-posix.h"
 
 static int
diff --git a/tests/test-vzprintf-posix.c b/tests/test-vzprintf-posix.c
new file mode 100644 (file)
index 0000000..daf6e97
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test of POSIX compatible vzprintf() 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>, 2007.  */
+
+#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-printf-posix.h"
+
+static off64_t
+my_zprintf (const char *format, ...)
+{
+  va_list args;
+  off64_t ret;
+
+  va_start (args, format);
+  ret = vzprintf (format, args);
+  va_end (args);
+  return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+  test_function (my_zprintf);
+  return test_exit_status;
+}
diff --git a/tests/test-vzprintf-posix.sh b/tests/test-vzprintf-posix.sh
new file mode 100755 (executable)
index 0000000..fc55247
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
+
+tmpfiles="$tmpfiles t-vzprintf-posix.tmp t-vzprintf-posix.out"
+${CHECKER} ./test-vzprintf-posix${EXEEXT} > t-vzprintf-posix.tmp || exit 1
+LC_ALL=C tr -d '\r' < t-vzprintf-posix.tmp > t-vzprintf-posix.out || exit 1
+
+: "${DIFF=diff}"
+${DIFF} "${srcdir}/test-printf-posix.output" t-vzprintf-posix.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
index 29758ef42c0f881f988b95b681fa1e94d54f7d7c..c9e79c0e267554f4d9dda8db5edb17d483f4e3c3 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-printf-posix.h"
 
 int