From patchwork Fri Apr 11 14:49:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 508 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 91866360060 for ; Fri, 11 Apr 2014 07:49:42 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id 2FE1762920167; Fri, 11 Apr 2014 07:49:41 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id D7D856295623D for ; Fri, 11 Apr 2014 07:49:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=SAILITpavNKvbWipZYTB7WKn+f394MzUu7VnACAU7lePiSOrY5rwX FuLaLX1Yaw2O5gcxpqLmXykSxzXles/SukUFXFUsGjNLMgFZHzKYM61AYIdoTf4X 7ue5oYSChRiqoyF0CvJ/+UvmHrg/kulrJ3bioTX+1hsD4O2TDZm9Is= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=JOCxNLS2hvcPi66kuxvAKrNYg2k=; b=wC8fVOpG1n/W81h5qiK8b37urOqP PWUoeu+uYOwTYJ7jvZdVmVSPBrzrupwb0Mefe7iA/XTuyYIDynMYA6GomtoEF1x6 db4QQ1ANrZepDnSjsMHhzkD5oAUFod24Msm5jOeXXRQe9qqNUhcWzGH3lwhpQh5U lgF0xn2HR+OkyG0= Received: (qmail 5713 invoked by alias); 11 Apr 2014 14:49:40 -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 5704 invoked by uid 89); 11 Apr 2014 14:49:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=Pt1Yv+4iVTO+oOmEwnBhhhdQKDbLbbqGa3KSaU7SH90=; b=KpPxZ7d2ydAOB9nyVk0WFI8+PzBQB27IoO1Gb24FEIvPhUMFMSaEMam5+HD4PUx7Qw y/CruGUJrnTExG/h+YM+tcYk0HCKq/Q68YBBzAWuxI/3Zw+LLvGtvz+gBg+qKnRKUSFz GECaKmwlVNWyj8Bmg+4dihhQmqp2OYrwepAvUIa7u7cJTYF7a8C7nfSylB4zhQ6l6fiG 2YIZgYK5wqzdwvW2a0pMBO4qG43d3LOadnHx60SiQlJyEzWNsTp6fGTKsgYmNkvoAXAf LW2dIsMpDCTpNErrkiigbbWCkLAievctTxB3U+PfDBTXcOCuZSwBZ6cKj2aSlQSi1B5w t/cg== X-Gm-Message-State: ALoCoQnLq89FkpTOtZCLe1LpTM+N7N24NjzcwAqHVPU0omRFV9A0VbPtsU96cxIhPzvs88LV1fuz X-Received: by 10.194.59.43 with SMTP id w11mr2765495wjq.65.1397227774715; Fri, 11 Apr 2014 07:49:34 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] test-skeleton.c: Use stdout for error messages Date: Fri, 11 Apr 2014 15:49:29 +0100 Message-Id: <1397227769-7214-1-git-send-email-will.newton@linaro.org> X-DH-Original-To: glibc@patchwork.siddhesh.in At the moment the test skeleton uses a mixture of stdout and stderr for error message output. Using stdout for all test output keeps all output correctly ordered and properly redirected to the output file. The suggestion to use stdout is also made on the wiki: https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case ChangeLog: 2014-04-11 Will Newton * test-skeleton.c (signal_handler): Use printf and strerror rather than perror. Use printf rather than fprintf to stderr. (main): Likewise. --- test-skeleton.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/test-skeleton.c b/test-skeleton.c index d7d2f75..dd7de8b 100644 --- a/test-skeleton.c +++ b/test-skeleton.c @@ -160,7 +160,7 @@ signal_handler (int sig __attribute__ ((unused))) } if (killed != 0 && killed != pid) { - perror ("Failed to kill test process"); + printf ("Failed to kill test process: %s\n", strerror (errno)); exit (1); } @@ -181,16 +181,16 @@ signal_handler (int sig __attribute__ ((unused))) #endif if (killed == 0 || (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL)) - fputs ("Timed out: killed the child process\n", stderr); + puts ("Timed out: killed the child process\n"); else if (WIFSTOPPED (status)) - fprintf (stderr, "Timed out: the child process was %s\n", - strsignal (WSTOPSIG (status))); + printf ("Timed out: the child process was %s\n", + strsignal (WSTOPSIG (status))); else if (WIFSIGNALED (status)) - fprintf (stderr, "Timed out: the child process got signal %s\n", - strsignal (WTERMSIG (status))); + printf ("Timed out: the child process got signal %s\n", + strsignal (WTERMSIG (status))); else - fprintf (stderr, "Timed out: killed the child process but it exited %d\n", - WEXITSTATUS (status)); + printf ("Timed out: killed the child process but it exited %d\n", + WEXITSTATUS (status)); /* Exit with an error. */ exit (1); @@ -275,7 +275,7 @@ main (int argc, char *argv[]) if (chdir (test_dir) < 0) { - perror ("chdir"); + printf ("chdir: %s\n", strerror (errno)); exit (1); } } @@ -334,10 +334,10 @@ main (int argc, char *argv[]) data_limit.rlim_cur = MIN ((rlim_t) TEST_DATA_LIMIT, data_limit.rlim_max); if (setrlimit (RLIMIT_DATA, &data_limit) < 0) - perror ("setrlimit: RLIMIT_DATA"); + printf ("setrlimit: RLIMIT_DATA: %s\n", strerror (errno)); } else - perror ("getrlimit: RLIMIT_DATA"); + printf ("getrlimit: RLIMIT_DATA: %s\n", strerror (errno)); #endif /* We put the test process in its own pgrp so that if it bogusly @@ -349,7 +349,7 @@ main (int argc, char *argv[]) } else if (pid < 0) { - perror ("Cannot fork test program"); + printf ("Cannot fork test program: %s\n", strerror (errno)); exit (1); } @@ -387,18 +387,16 @@ main (int argc, char *argv[]) if (EXPECTED_SIGNAL != 0) { if (WTERMSIG (status) == 0) - fprintf (stderr, - "Expected signal '%s' from child, got none\n", - strsignal (EXPECTED_SIGNAL)); + printf ("Expected signal '%s' from child, got none\n", + strsignal (EXPECTED_SIGNAL)); else - fprintf (stderr, - "Incorrect signal from child: got `%s', need `%s'\n", - strsignal (WTERMSIG (status)), - strsignal (EXPECTED_SIGNAL)); + printf ("Incorrect signal from child: got `%s', need `%s'\n", + strsignal (WTERMSIG (status)), + strsignal (EXPECTED_SIGNAL)); } else - fprintf (stderr, "Didn't expect signal from child: got `%s'\n", - strsignal (WTERMSIG (status))); + printf ("Didn't expect signal from child: got `%s'\n", + strsignal (WTERMSIG (status))); exit (1); } @@ -408,8 +406,8 @@ main (int argc, char *argv[]) #else if (WEXITSTATUS (status) != EXPECTED_STATUS) { - fprintf (stderr, "Expected status %d, got %d\n", - EXPECTED_STATUS, WEXITSTATUS (status)); + printf ("Expected status %d, got %d\n", + EXPECTED_STATUS, WEXITSTATUS (status)); exit (1); }