This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.28.9000-263-g7597b0c


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  7597b0c7f711a6918d5804e08508817c72916376 (commit)
       via  9771e6cb510230e185a2c9914003b184bab0f21d (commit)
       via  2c03961fce9213904f67376926c8f2ad1617ffba (commit)
      from  6d6ee04622fd77908936250b1f632c2b4388ee78 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7597b0c7f711a6918d5804e08508817c72916376

commit 7597b0c7f711a6918d5804e08508817c72916376
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Tue Aug 7 10:39:47 2018 -0300

    Add tests with floating-point arguments for err* and verr* functions
    
    Similarly to what has been done for argp_error, and argp_failure, as
    well as for warn, warnx, vwarn, and vwarnx, this patch adds new tests
    for the following functions: err, errx, verr, verrx, error, and
    error_at_line.  The new tests check that the conversion of long double
    variables into string works correctly on the default format of the type.
    Future patches will reuse these tests for other formats that long double
    can take.
    
    Tested for powerpc64le.
    
    	* misc/Makefile (tests): Add tst-ldbl-error.
    	* misc/tst-ldbl-error.c: New file.

diff --git a/ChangeLog b/ChangeLog
index 7368be4..d64838b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-11-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
+	* misc/Makefile (tests): Add tst-ldbl-error.
+	* misc/tst-ldbl-error.c: New file.
+
+2018-11-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
 	* misc/Makefile (tests): Add tst-ldbl-warn.
 	* misc/tst-ldbl-warn.c: New file.
 
diff --git a/misc/Makefile b/misc/Makefile
index 201de12..c2c9994 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -85,7 +85,7 @@ tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
 	 tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \
 	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
 	 tst-preadvwritev2 tst-preadvwritev64v2 tst-warn-wide \
-	 tst-ldbl-warn
+	 tst-ldbl-warn tst-ldbl-error
 
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
diff --git a/misc/tst-ldbl-error.c b/misc/tst-ldbl-error.c
new file mode 100644
index 0000000..a02cb27
--- /dev/null
+++ b/misc/tst-ldbl-error.c
@@ -0,0 +1,130 @@
+/* Test for the long double conversions in *err* functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <err.h>
+#include <errno.h>
+#include <error.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+struct tests
+{
+  void *callback;
+  const char *expected;
+};
+
+va_list args;
+
+static void
+callback_err (void *closure)
+{
+  errno = 0;
+  err (0, "%Lf", (long double) -1);
+}
+
+static void
+callback_errx (void *closure)
+{
+  errno = 0;
+  errx (0, "%Lf", (long double) -1);
+}
+
+static void
+callback_verr (void *closure)
+{
+  errno = 0;
+  verr (0, "%Lf", args);
+}
+
+static void
+callback_verrx (void *closure)
+{
+  errno = 0;
+  verrx (0, "%Lf", args);
+}
+
+static void
+callback_error (void *closure)
+{
+  errno = 0;
+  error (0, 0, "%Lf", (long double) -1);
+}
+
+static void
+callback_error_at_line (void *closure)
+{
+  errno = 0;
+  error_at_line (0, 0, "", 0, "%Lf", (long double) -1);
+}
+
+static void
+do_one_test (void *callback, const char *expected, ...)
+{
+  struct support_capture_subprocess result;
+
+  va_start (args, expected);
+
+  /* Call 'callback', which fills in the output and error buffers.  */
+  result = support_capture_subprocess (callback, NULL);
+
+  /* The functions err, errx, verr, and verrx print just the program
+     name followed by a colon, whereas error and error_at_line print the
+     whole path to the program.  Since the whole path depends on the
+     working directory used to build and test glibc, remove it from the
+     comparison against the expected result.  */
+  const char *needle = "tst-ldbl-error:";
+  char *message;
+  message = strstr (result.err.buffer, needle);
+
+  /* Verify that the output message is as expected.  */
+  if (strcmp (message, expected) != 0)
+    {
+      support_record_failure ();
+      printf ("error:\n"
+	      "    expected: '%s'\n"
+	      "      actual: '%s'\n",
+	      expected, message);
+    }
+
+  va_end (args);
+}
+
+static int
+do_test (void)
+{
+  struct tests tests[] = {
+    { &callback_err, "tst-ldbl-error: -1.000000: Success\n" },
+    { &callback_errx, "tst-ldbl-error: -1.000000\n" },
+    { &callback_verr, "tst-ldbl-error: -1.000000: Success\n" },
+    { &callback_verrx, "tst-ldbl-error: -1.000000\n" },
+    { &callback_error, "tst-ldbl-error: -1.000000\n" },
+    { &callback_error_at_line, "tst-ldbl-error::0: -1.000000\n" }
+  };
+
+  for (int i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
+    {
+      do_one_test (tests[i].callback, tests[i].expected, (long double) -1);
+    }
+
+  return 0;
+}
+
+#include <support/test-driver.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9771e6cb510230e185a2c9914003b184bab0f21d

commit 9771e6cb510230e185a2c9914003b184bab0f21d
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Mon Aug 6 12:06:03 2018 -0300

    Add test for warn, warnx, vwarn, and vwarnx with floating-point parameters
    
    Similarly to what has been done for argp_error and argp_failure, this
    patch patch adds new tests for the warn, warnx, vwarn, and vwarnx
    functions.  The new tests use the format string to request the
    conversion of long double parameters into string.  Currently, these
    tests only check that the default format of the long double type works.
    Future patches will extend the test for platforms that can have an
    optional format for long double.
    
    Tested for powerpc64le.
    
    	* misc/Makefile (tests): Add tst-ldbl-warn.
    	* misc/tst-ldbl-warn.c: New file.

diff --git a/ChangeLog b/ChangeLog
index f61a292..7368be4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-11-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
+	* misc/Makefile (tests): Add tst-ldbl-warn.
+	* misc/tst-ldbl-warn.c: New file.
+
+2018-11-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
 	* argp/Makefile (tests): Add tst-ldbl-argp.
 	* argp/tst-ldbl-argp.c: New file.
 
diff --git a/misc/Makefile b/misc/Makefile
index 30e0673..201de12 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -84,7 +84,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
 	 tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
 	 tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \
 	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
-	 tst-preadvwritev2 tst-preadvwritev64v2 tst-warn-wide
+	 tst-preadvwritev2 tst-preadvwritev64v2 tst-warn-wide \
+	 tst-ldbl-warn
 
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
diff --git a/misc/tst-ldbl-warn.c b/misc/tst-ldbl-warn.c
new file mode 100644
index 0000000..3ac0e4c
--- /dev/null
+++ b/misc/tst-ldbl-warn.c
@@ -0,0 +1,120 @@
+/* Test for the long double conversions in *warn* functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <err.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <support/check.h>
+#include <support/xmemstream.h>
+
+enum {WARN, WARNX, VWARN, VWARNX};
+
+static void
+do_one_test (int select, const char *format, va_list args,
+	     long double arg1, double arg2, long double arg3,
+	     double arg4, const char *expected)
+{
+  /* Prepare in-memory buffer to hold the output.  */
+  struct xmemstream stream;
+  xopen_memstream (&stream);
+  FILE *old_stderr = stderr;
+  stderr = stream.out;
+
+  /* Write to the buffer using one of the *warn* functions.  */
+  errno = 0;
+  switch (select)
+    {
+      case WARN:
+	warn (format, arg1, arg2, arg3, arg4);
+	break;
+      case WARNX:
+	warnx (format, arg1, arg2, arg3, arg4);
+	break;
+      case VWARN:
+	vwarn (format, args);
+	break;
+      case VWARNX:
+	vwarnx (format, args);
+	break;
+    }
+
+  stderr = old_stderr;
+
+  /* Close the in-memory stream and check the output buffer.  */
+  xfclose_memstream (&stream);
+  if (strcmp (stream.buffer, expected) != 0)
+    FAIL_EXIT1 ("error:\n"
+		"    expected: '%s'\n"
+		"      actual: '%s'\n",
+		expected, stream.buffer);
+
+  if (stream.buffer != NULL)
+    free (stream.buffer);
+}
+
+static void
+do_test_call_varg (const char *format, ...)
+{
+  va_list args;
+
+  va_start (args, format);
+  do_one_test (VWARN, format, args, 0, 0, 0, 0,
+	       "tst-ldbl-warn: "
+	       "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n");
+  va_end (args);
+
+  va_start (args, format);
+  do_one_test (VWARNX, format, args, 0, 0, 0, 0,
+	       "tst-ldbl-warn: "
+	       "-1.000000 - -2.000000 - -3.000000 - -4.000000\n");
+  va_end (args);
+}
+
+static void
+do_test_call_rarg (const char *format, long double arg1, double arg2,
+		   long double arg3, double arg4)
+{
+  va_list args;
+  memset (&args, 0, sizeof (args));
+  do_one_test (WARN, format, args, arg1, arg2, arg3, arg4,
+	       "tst-ldbl-warn: "
+	       "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n");
+  do_one_test (WARNX, format, args, arg1, arg2, arg3, arg4,
+	       "tst-ldbl-warn: "
+	       "-1.000000 - -2.000000 - -3.000000 - -4.000000\n");
+}
+
+static int
+do_test (void)
+{
+  long double arg1 = -1;
+  long double arg3 = -3;
+  double arg2 = -2;
+  double arg4 = -4;
+
+  do_test_call_rarg ("%Lf - %f - %Lf - %f", arg1, arg2, arg3, arg4);
+  do_test_call_varg ("%Lf - %f - %Lf - %f", arg1, arg2, arg3, arg4);
+
+  return 0;
+}
+
+#include <support/test-driver.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2c03961fce9213904f67376926c8f2ad1617ffba

commit 2c03961fce9213904f67376926c8f2ad1617ffba
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Tue Jun 12 22:27:21 2018 -0300

    Add tests for argp_error and argp_failure with floating-point parameters
    
    The functions argp_error and argp_failure, from argp.h, have a format
    string as parameter, which can possibly request the printing of
    floating-point values.  These values could be of long double type, which
    can have different formats, depending on the architecture and on
    compilation parameters (for instance, on powerpc, long double values can
    have double format (-mlong-double-64) or IBM Extended Precision format
    (-mlong-double-128)).
    
    This patch adds tests for argp_error and argp_failure that contain a
    format string with double and long double conversion specifiers ('%f'
    and '%Lf').  These tests automatically check that the default format of
    the long double type works.  A future patch will extend the test for
    platforms that can have an optional format for long double.
    
    Tested for powerpc64le.
    
    	* argp/Makefile (tests): Add tst-ldbl-argp.
    	* argp/tst-ldbl-argp.c: New file.

diff --git a/ChangeLog b/ChangeLog
index d7ee676..f61a292 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+	* argp/Makefile (tests): Add tst-ldbl-argp.
+	* argp/tst-ldbl-argp.c: New file.
+
 2018-11-05  Arjun Shankar  <arjun@redhat.com>
 
 	* iconv/gconv_conf.c (__gconv_read_conf): Remove NULL check for
diff --git a/argp/Makefile b/argp/Makefile
index 6e4799c..2ea7118 100644
--- a/argp/Makefile
+++ b/argp/Makefile
@@ -26,7 +26,8 @@ headers		= argp.h
 routines	= $(addprefix argp-, ba fmtstream fs-xinl help parse pv \
 				     pvh xinl eexst)
 
-tests		= argp-test tst-argp1 bug-argp1 tst-argp2 bug-argp2
+tests		= argp-test tst-argp1 bug-argp1 tst-argp2 bug-argp2 \
+		  tst-ldbl-argp
 
 CFLAGS-argp-help.c += $(uses-callbacks) -fexceptions
 CFLAGS-argp-parse.c += $(uses-callbacks)
diff --git a/argp/tst-ldbl-argp.c b/argp/tst-ldbl-argp.c
new file mode 100644
index 0000000..4465f81
--- /dev/null
+++ b/argp/tst-ldbl-argp.c
@@ -0,0 +1,109 @@
+/* Testing of long double conversions in argp.h functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <argp.h>
+#include <string.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static const struct argp_option
+options[] =
+{
+  { "error", 'e', "format", OPTION_ARG_OPTIONAL,
+    "Run argp_error function with a format string", 0 },
+  { "failure", 'f', "format", OPTION_ARG_OPTIONAL,
+    "Run argp_failure function with a format string", 0 },
+  { NULL, 0, NULL, 0, NULL }
+};
+
+static error_t
+parser (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+      case 'e':
+	argp_error (state, "%Lf%f%Lf%f", (long double) -1, (double) -2,
+		    (long double) -3, (double) -4);
+	break;
+      case 'f':
+	argp_failure (state, 0, 0, "%Lf%f%Lf%f", (long double) -1,
+		      (double) -2, (long double) -3, (double) -4);
+	break;
+      default:
+	return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+static struct argp
+argp =
+{
+  options, parser
+};
+
+int argc = 2;
+char *argv[3] = { (char *) "test-argp", NULL, NULL };
+
+static void
+do_test_call (void)
+{
+  int remaining;
+  argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+}
+
+static int
+do_one_test (const char *expected)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  if (strcmp (result.err.buffer, expected) != 0)
+    {
+      support_record_failure ();
+      printf ("error:\n"
+	      "    expected: '%s'\n"
+	      "      actual: '%s'\n",
+	      expected, result.err.buffer);
+    }
+
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  const char *param_error = "--error";
+  const char *expected_error =
+    "test-argp: -1.000000-2.000000-3.000000-4.000000\n"
+    "Try `test-argp --help' or `test-argp --usage' for more information.\n";
+
+  const char *param_failure = "--failure";
+  const char *expected_failure =
+    "test-argp: -1.000000-2.000000-3.000000-4.000000\n";
+
+  argv[1] = (char *) param_error;
+  do_one_test (expected_error);
+
+  argv[1] = (char *) param_failure;
+  do_one_test (expected_failure);
+
+  return 0;
+}
+
+#include <support/test-driver.c>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   15 ++++++
 argp/Makefile         |    3 +-
 argp/tst-ldbl-argp.c  |  109 +++++++++++++++++++++++++++++++++++++++++
 misc/Makefile         |    3 +-
 misc/tst-ldbl-error.c |  130 +++++++++++++++++++++++++++++++++++++++++++++++++
 misc/tst-ldbl-warn.c  |  120 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 378 insertions(+), 2 deletions(-)
 create mode 100644 argp/tst-ldbl-argp.c
 create mode 100644 misc/tst-ldbl-error.c
 create mode 100644 misc/tst-ldbl-warn.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]