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: 28281 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 265172100C for ; Fri, 11 Apr 2014 14:49:50 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id e16sf15694072qcx.10 for ; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=Pt1Yv+4iVTO+oOmEwnBhhhdQKDbLbbqGa3KSaU7SH90=; b=iOYnLLyMvNaNWp2o/qvv8DDcxurR2aQM+kwbyvOXymLvOrZzKQwxaZVaekJbqUcO9/ kVLH1mKwUOgWAUCYGj3kopzJ/I6qW+NWfydEq/NLCYknJHiJu2n8NHcl50hKIRQxfAVi PI1GcJjBtfc7qfhlidHI6AIWWftrfBRbI7qtPJZbGoONIhGi8IgawjuWwhg3vBR3Kjmu K5IX07X9BWCHJasnk0Dbx8vBUCifeQvQLFS8ZKm4vDbU3rMSzEtd1dmlZ9kE8Slb5tlR tFc7CH5+tgPSEyfEubUU3RsKtz+sBaMtt0KfxTH7787U1nzl9d2cO7Z2NNEk7JKNagXj Xs5w== X-Gm-Message-State: ALoCoQl5+z596A+BFdZYGdSiA6vgrnoDIc0ETaWJxiE/xOZqA18Wus/PWRg+/mYLOf9Oxedv+NiS X-Received: by 10.236.134.98 with SMTP id r62mr9426361yhi.14.1397227789849; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls1658165qgf.84.gmail; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) X-Received: by 10.52.241.106 with SMTP id wh10mr17013133vdc.16.1397227789733; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) Received: from mail-ve0-x232.google.com (mail-ve0-x232.google.com [2607:f8b0:400c:c01::232]) by mx.google.com with ESMTPS id ud8si841458vdc.177.2014.04.11.07.49.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 07:49:49 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::232; Received: by mail-ve0-f178.google.com with SMTP id jw12so4798833veb.23 for ; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) X-Received: by 10.220.162.6 with SMTP id t6mr20568935vcx.12.1397227789644; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp62349vcb; Fri, 11 Apr 2014 07:49:49 -0700 (PDT) X-Received: by 10.68.240.68 with SMTP id vy4mr27516433pbc.127.1397227788893; Fri, 11 Apr 2014 07:49:48 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id hw8si4405607pbc.34.2014.04.11.07.49.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Apr 2014 07:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-48973-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 5713 invoked by alias); 11 Apr 2014 14:49:40 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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-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-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 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); }