From patchwork Fri Oct 3 18:58:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 3097 Received: (qmail 21532 invoked by alias); 3 Oct 2014 18:57:00 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 21520 invoked by uid 89); 3 Oct 2014 18:56:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: arati.lostca.se Date: Fri, 3 Oct 2014 20:58:33 +0200 From: Arjun Shankar To: libc-alpha@sourceware.org Subject: [PATCH] Write errors to stdout and not stderr in wcsmbs/tst-mbrtowc.c Message-ID: <20141003205833.6deb3569@zion> Mime-Version: 1.0 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 * 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 #include #include +#include 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"