This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Write errors to stdout and not stderr in wcsmbs/tst-mbrtowc.c
- From: Arjun Shankar <arjun dot is at lostca dot se>
- To: libc-alpha at sourceware dot org
- Date: Fri, 3 Oct 2014 20:58:33 +0200
- Subject: [PATCH] Write errors to stdout and not stderr in wcsmbs/tst-mbrtowc.c
- Authentication-results: sourceware.org; auth=none
tst-mbrtowc.c uses `assert' for tests, which writes to stderr. This
patch fixes that using dup2, and gets tst-mbrtowc.c and tst-wcrtomb.c
to use the test skeleton - which is just generally nice.
ChangeLog:
2014-10-03 Arjun Shankar <arjun.is@lostca.se>
* wcsmbs/tst-mbrtowc.c: Write errors to stdout, use skeleton.
* wcsmbs/tst-wcrtomb.c: Use skeleton.
---
wcsmbs/tst-mbrtowc.c | 13 ++++++++++---
wcsmbs/tst-wcrtomb.c | 7 +++++--
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/wcsmbs/tst-mbrtowc.c b/wcsmbs/tst-mbrtowc.c
index 3e1eb72..43601cb 100644
--- a/wcsmbs/tst-mbrtowc.c
+++ b/wcsmbs/tst-mbrtowc.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
+#include <unistd.h>
static int check_ascii (const char *locname);
@@ -139,7 +140,7 @@ utf8_test (void)
if (!setlocale (LC_CTYPE, locale))
{
- fprintf (stderr, "locale '%s' not available!\n", locale);
+ printf ("locale '%s' not available!\n", locale);
exit (1);
}
@@ -151,11 +152,14 @@ utf8_test (void)
}
-int
-main (void)
+static int
+do_test (void)
{
int result = 0;
+ /* Failed `assert' messages should go to stdout, not stderr. */
+ dup2 (STDOUT_FILENO, STDERR_FILENO);
+
/* Check mapping of ASCII range for some character sets which have
ASCII as a subset. For those the wide char generated must have
the same value. */
@@ -230,3 +234,6 @@ check_ascii (const char *locname)
return res != 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/wcsmbs/tst-wcrtomb.c b/wcsmbs/tst-wcrtomb.c
index 3f052f3..cad343e 100644
--- a/wcsmbs/tst-wcrtomb.c
+++ b/wcsmbs/tst-wcrtomb.c
@@ -26,8 +26,8 @@
static int check_ascii (const char *locname);
-int
-main (void)
+static int
+do_test (void)
{
int result = 0;
@@ -92,3 +92,6 @@ check_ascii (const char *locname)
return res != 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"