]> Savannah Git Hosting - gnulib.git/commitdiff
vdprintf-gnu: Add tests.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Mar 2023 11:01:45 +0000 (12:01 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Mar 2023 11:01:45 +0000 (12:01 +0100)
* tests/test-vdprintf-gnu.sh: New file, based on
tests/test-vdprintf-posix.sh.
* tests/test-vdprintf-gnu.c: New file, based on
tests/test-vdprintf-posix.c.
* modules/vdprintf-gnu-tests: New file, based on
modules/vdprintf-posix-tests.

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

index e385339bb5b3c0f5bbed2b97e46ee6c4e30c7176..a65107ca3a7b4393970bce18d5209db7b4d737dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2023-03-24  Bruno Haible  <bruno@clisp.org>
 
+       vdprintf-gnu: Add tests.
+       * tests/test-vdprintf-gnu.sh: New file, based on
+       tests/test-vdprintf-posix.sh.
+       * tests/test-vdprintf-gnu.c: New file, based on
+       tests/test-vdprintf-posix.c.
+       * modules/vdprintf-gnu-tests: New file, based on
+       modules/vdprintf-posix-tests.
+
        vdprintf-gnu: New module.
        * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_IS_POSIX): New macro,
        extracted from gl_FUNC_VDPRINTF_POSIX.
diff --git a/modules/vdprintf-gnu-tests b/modules/vdprintf-gnu-tests
new file mode 100644 (file)
index 0000000..73e57fa
--- /dev/null
@@ -0,0 +1,15 @@
+Files:
+tests/test-vdprintf-gnu.sh
+tests/test-vdprintf-gnu.c
+tests/test-fprintf-gnu.h
+tests/test-printf-gnu.output
+tests/macros.h
+
+Depends-on:
+vdprintf-posix-tests
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vdprintf-gnu.sh
+check_PROGRAMS += test-vdprintf-gnu
diff --git a/tests/test-vdprintf-gnu.c b/tests/test-vdprintf-gnu.c
new file mode 100644 (file)
index 0000000..fa5448d
--- /dev/null
@@ -0,0 +1,48 @@
+/* Test of POSIX and GNU compatible vdprintf() function.
+   Copyright (C) 2007-2023 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 <string.h>
+
+#include "macros.h"
+
+#include "test-fprintf-gnu.h"
+
+static int
+my_fprintf (FILE *fp, const char *format, ...)
+{
+  va_list args;
+  int ret;
+
+  va_start (args, format);
+  ret = vdprintf (fileno (fp), format, args);
+  va_end (args);
+  return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+  test_function (my_fprintf);
+  return 0;
+}
diff --git a/tests/test-vdprintf-gnu.sh b/tests/test-vdprintf-gnu.sh
new file mode 100755 (executable)
index 0000000..496d905
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
+
+tmpfiles="$tmpfiles t-vdprintf-gnu.tmp t-vdprintf-gnu.out"
+${CHECKER} ./test-vdprintf-gnu${EXEEXT} > t-vdprintf-gnu.tmp || exit 1
+LC_ALL=C tr -d '\r' < t-vdprintf-gnu.tmp > t-vdprintf-gnu.out || exit 1
+
+: "${DIFF=diff}"
+${DIFF} "${srcdir}/test-printf-gnu.output" t-vdprintf-gnu.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result