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

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

index 0a450fe9db6f95ab40591def8a0ef2f16df8fd5a..d6c8927bcbc9db03f7b5c01b52b73a1ff4d1aa44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2024-06-30  Bruno Haible  <bruno@clisp.org>
 
+       vzprintf-gnu: Add tests.
+       * tests/test-printf-gnu.h (test_function): Use RETTYPE instead of 'int'.
+       * tests/test-printf-gnu.c (RETTYPE): New macro.
+       * tests/test-vprintf-gnu.c (RETTYPE): New macro.
+       * tests/test-vzprintf-gnu.c: New file, based on
+       tests/test-vprintf-gnu.c.
+       * tests/test-vzprintf-gnu.sh: New file, based on
+       tests/test-vprintf-gnu.sh.
+       * modules/vzprintf-gnu-tests: New file.
+
        vzprintf-gnu: New module.
        * modules/vzprintf-gnu: New file.
 
diff --git a/modules/vzprintf-gnu-tests b/modules/vzprintf-gnu-tests
new file mode 100644 (file)
index 0000000..d08e58f
--- /dev/null
@@ -0,0 +1,14 @@
+Files:
+tests/test-vzprintf-gnu.sh
+tests/test-vzprintf-gnu.c
+tests/test-printf-gnu.h
+tests/test-printf-gnu.output
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vzprintf-gnu.sh
+check_PROGRAMS += test-vzprintf-gnu
index ccd4f8bd67b85294d58ae87a362c0618c072b5c6..f229f5fd59aff42cdd68fbe5da04b519c55e820d 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-printf-gnu.h"
 
 int
index 1ee541669a002ee3cbc4c654389a6962189d09c6..b9a9effe049bf418f86e53f417dc208b9f201798 100644 (file)
@@ -1,4 +1,4 @@
-/* Test of POSIX and GNU compatible vprintf() and printf() functions.
+/* Test of POSIX and GNU compatible [v][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_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 1655d261409512bc7456cfe42d09e0c865690389..638ac70a6f7838e8ec58eaadd450dcb88f499855 100644 (file)
@@ -1,4 +1,4 @@
-/* Test of POSIX and GNU compatible vfprintf() function.
+/* Test of POSIX and GNU compatible vprintf() function.
    Copyright (C) 2007-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -26,6 +26,7 @@
 
 #include "macros.h"
 
+#define RETTYPE int
 #include "test-printf-gnu.h"
 
 static int
diff --git a/tests/test-vzprintf-gnu.c b/tests/test-vzprintf-gnu.c
new file mode 100644 (file)
index 0000000..1056f0e
--- /dev/null
@@ -0,0 +1,49 @@
+/* Test of POSIX and GNU 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 <string.h>
+
+#include "macros.h"
+
+#define RETTYPE off64_t
+#include "test-printf-gnu.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-gnu.sh b/tests/test-vzprintf-gnu.sh
new file mode 100755 (executable)
index 0000000..471a4af
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
+
+tmpfiles="$tmpfiles t-vzprintf-gnu.tmp t-vzprintf-gnu.out"
+${CHECKER} ./test-vzprintf-gnu${EXEEXT} > t-vzprintf-gnu.tmp || exit 1
+LC_ALL=C tr -d '\r' < t-vzprintf-gnu.tmp > t-vzprintf-gnu.out || exit 1
+
+: "${DIFF=diff}"
+${DIFF} "${srcdir}/test-printf-gnu.output" t-vzprintf-gnu.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result