@@ -35,4 +35,16 @@ CFLAGS-argp-fmtstream.c += -fexceptions
bug-argp1-ARGS = -- --help
bug-argp2-ARGS = -- -d 111 --dstaddr 222 -p 333 --peer 444
+tests-internal += tst-ldbl-argp-error tst-ldbl-argp-failure
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst-ldbl-argp-error.out
+tests-special += $(objpfx)tst-ldbl-argp-failure.out
+endif
+
+$(objpfx)tst-ldbl-argp-%.out: \
+ tst-ldbl-argp-%.sh $(objpfx)tst-ldbl-argp-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
include ../Rules
new file mode 100644
@@ -0,0 +1,3 @@
+#define ARGP_FUNCTION argp_error
+#define ARGP_FUNCTION_PARAMS (state, "%Lf%f%Lf%f", (long double) -1, (double) -2, (long double) -3, (double) -4)
+#include <tst-ldbl-argp-template.c>
new file mode 100644
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Testing of long double conversions in argp_error.
+# 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/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+# Allow argp_error to end with non-zero exit status, run the test
+# program, then restore the exit-on-error behavior
+set +e
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output}
+set -e
+
+cat <<'EOF' |
+test-argp: -1.000000-2.000000-3.000000-4.000000
+Try `test-argp --help' or `test-argp --usage' for more information.
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
new file mode 100644
@@ -0,0 +1,3 @@
+#define ARGP_FUNCTION argp_failure
+#define ARGP_FUNCTION_PARAMS (state, 0, 0, "%Lf%f%Lf%f", (long double) -1, (double) -2, (long double) -3, (double) -4)
+#include <tst-ldbl-argp-template.c>
new file mode 100644
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Testing of long double conversions in argp_failure.
+# 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/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+# Allow argp_failure to end with non-zero exit status, run the test
+# program, then restore the exit-on-error behavior
+set +e
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output}
+set -e
+
+cat <<'EOF' |
+test-argp: -1.000000-2.000000-3.000000-4.000000
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
new file mode 100644
@@ -0,0 +1,69 @@
+/* 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/check.h>
+
+static const struct argp_option
+options[] =
+{
+ { "test", 't', "format", 0, "Run argp 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 't':
+ ARGP_FUNCTION ARGP_FUNCTION_PARAMS;
+ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static struct argp
+argp =
+{
+ options, parser
+};
+
+static int
+do_test (void)
+{
+ int remaining;
+ int argc = 3;
+ char *argv[4] =
+ {
+ (char *) "test-argp",
+ (char *) "--test",
+ (char *) "%Lf - %f - %Lf - %f",
+ NULL
+ };
+
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+ return 0;
+}
+
+#include <support/test-driver.c>