+2019-03-01 Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
+
+ * misc/tst-ldbl-error.c (do_one_test): Adapt for reuse by nldbl
+ tests.
+ (do_test): Likewise.
+ * misc/tst-ldbl-warn.c (do_one_test): Likewise.
+ (do_test_call_varg): Likewise.
+ (do_test_call_rarg): Likewise.
+ * sysdeps/ieee754/ldbl-opt/Makefile
+ [subdir == misc] (tests-internal): Add tst-nldbl-warn,
+ tst-nldbl-error.
+ ($(objpfx)tst-nldbl-warn.c): New rule.
+ ($(objpfx)tst-nldbl-error.c): Likewise.
+ (CFLAGS-tst-nldbl-warn.c, CFLAGS-tst-nldbl-error.c):
+ New variables.
+
2019-03-01 Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
[BZ #23984]
/* 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:";
+ /* Filter out the name of the program (which should always end with
+ -error), so that the test case can be reused by ldbl-opt and
+ ldbl-128ibm-compat. */
+ const char *needle = "-error:";
char *message;
message = strstr (result.err.buffer, needle);
+ if (message == NULL)
+ FAIL_EXIT1 ("test case error");
+ message += strlen (needle);
/* Verify that the output message is as expected. */
TEST_COMPARE_STRING (message, expected);
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" }
+ { &callback_err, " -1.000000: Success\n" },
+ { &callback_errx, " -1.000000\n" },
+ { &callback_verr, " -1.000000: Success\n" },
+ { &callback_verrx, " -1.000000\n" },
+ { &callback_error, " -1.000000\n" },
+ { &callback_error_at_line, ":0: -1.000000\n" }
};
for (int i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
stderr = old_stderr;
- /* Close the in-memory stream and check the output buffer. */
+ /* Close the in-memory stream. */
xfclose_memstream (&stream);
- TEST_COMPARE_STRING (stream.buffer, expected);
+
+ /* Filter out the name of the program (which should always end with
+ warn), so that the test case can be reused by ldbl-opt and
+ ldbl-128ibm-compat. */
+ const char *needle = "warn: ";
+ char *message;
+ message = strstr (stream.buffer, needle);
+ if (message == NULL)
+ FAIL_EXIT1 ("test case error");
+ message += strlen (needle);
+
+ /* Check that the rest of the output is as expected. */
+ TEST_COMPARE_STRING (message, expected);
if (stream.buffer != NULL)
free (stream.buffer);
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);
}
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");
}
CFLAGS-tst-nldbl-argp.c += -mlong-double-64
endif
+
+# Tests for err.h and error.h functions (reusing the relevant tests from
+# misc/).
+ifeq ($(subdir), misc)
+tests-internal += tst-nldbl-warn
+tests-internal += tst-nldbl-error
+
+$(objpfx)tst-nldbl-warn.c: tst-ldbl-warn.c
+ cp $< $@
+
+$(objpfx)tst-nldbl-error.c: tst-ldbl-error.c
+ cp $< $@
+
+CFLAGS-tst-nldbl-warn.c += -mlong-double-64
+CFLAGS-tst-nldbl-error.c += -mlong-double-64
+endif