From patchwork Mon Mar 10 12:16:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 21 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id DC82A36005B for ; Mon, 10 Mar 2014 05:16:33 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id 828C5406A3F3E; Mon, 10 Mar 2014 05:16:33 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.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-mx20.g.dreamhost.com (Postfix) with ESMTPS id 5F8EA406B2F66 for ; Mon, 10 Mar 2014 05:16:33 -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:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=AdfOaZYNrckNOufDpCsP2G9wCBjxn xMzMCWy7oVDHCdTvgGg7I+0df13ahVqjkz59UX/MyGEXxb6npvJXQ/pvYygv+hQQ JqBOOYaqK2+mvf9kLMc2KjnmcuseH5Z9acGYOpw3R2eNrgjImOjeoHUVPkbPPXna mry2j3JY52bMdY= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=3HbGER9AQ8kiANe1Pze9SpyVCg0=; b=sjM 4Xs/v+WRyVZamhPiv6hKqV+FF644QLEe35MBtcY7NCHV4DV7lpJzXkTdRl7sC4vm m+k93wPDvxs1IqoRVVC0I7lmU/8s2GDT19wmgkCzbkFNDBvKxzHV/cyecx9KuBw3 IvJAcjWcuv60AJs6XXD+O/qyeWb2mrrE0wLWZ1iM= Received: (qmail 7262 invoked by alias); 10 Mar 2014 12:16:30 -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 7227 invoked by uid 89); 10 Mar 2014 12:16:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Mon, 10 Mar 2014 17:46:58 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] Fix up return codes for tests in tst-ftell-active-handler Message-ID: <20140310121657.GE1656@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) X-DH-Original-To: glibc@patchwork.siddhesh.in Hi, The test functions used a variable ret to store failure codes for individual tests, but the variable was incorrectly used to record other failure codes too, resulting in overwriting of the tests status. This is now fixed by making sure that the ret variable is used only for recording test failures. Siddhesh * libio/tst-ftell-active-handler.c (do_ftell_test): Don't mix up test status with function return status. (do_write_test): Likewise. (do_append_test): Likewise. --- libio/tst-ftell-active-handler.c | 49 +++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/libio/tst-ftell-active-handler.c b/libio/tst-ftell-active-handler.c index 54bfe63..5d5fc26 100644 --- a/libio/tst-ftell-active-handler.c +++ b/libio/tst-ftell-active-handler.c @@ -119,17 +119,20 @@ do_ftell_test (const char *filename) { FILE *fp; int fd; + int fileret; + printf ("\tftell: %s (file, \"%s\"): ", j == 0 ? "fdopen" : "fopen", test_modes[i].mode); if (j == 0) - ret = get_handles_fdopen (filename, fd, fp, test_modes[i].fd_mode, - test_modes[i].mode); + fileret = get_handles_fdopen (filename, fd, fp, + test_modes[i].fd_mode, + test_modes[i].mode); else - ret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); + fileret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); - if (ret != 0) - return ret; + if (fileret != 0) + return fileret; long off = ftell (fp); if (off != test_modes[i].old_off) @@ -143,7 +146,12 @@ do_ftell_test (const char *filename) /* The effect of this write on the offset should be seen in the ftell call that follows it. */ - int ret = write (fd, data, data_len); + int write_ret = write (fd, data, data_len); + if (write_ret != data_len) + { + printf ("write failed (%m)\n"); + ret |= 1; + } off = ftell (fp); if (off != test_modes[i].new_off) @@ -184,21 +192,23 @@ do_write_test (const char *filename) { for (int i = 0; i < sizeof (test_modes) / sizeof (struct test); i++) { + int fileret; printf ("\twrite: %s (file, \"%s\"): ", j == 0 ? "fopen" : "fdopen", test_modes[i].mode); if (j == 0) - ret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); + fileret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); else - ret = get_handles_fdopen (filename, fd, fp, test_modes[i].fd_mode, - test_modes[i].mode); + fileret = get_handles_fdopen (filename, fd, fp, + test_modes[i].fd_mode, + test_modes[i].mode); - if (ret != 0) - return ret; + if (fileret != 0) + return fileret; /* Move offset to just before the end of the file. */ - off_t ret = lseek (fd, file_len - 1, SEEK_SET); - if (ret == -1) + off_t seek_ret = lseek (fd, file_len - 1, SEEK_SET); + if (seek_ret == -1) { printf ("lseek failed: %m\n"); ret |= 1; @@ -258,17 +268,20 @@ do_append_test (const char *filename) { for (int i = 0; i < sizeof (test_modes) / sizeof (struct test); i++) { + int fileret; + printf ("\tappend: %s (file, \"%s\"): ", j == 0 ? "fopen" : "fdopen", test_modes[i].mode); if (j == 0) - ret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); + fileret = get_handles_fopen (filename, fd, fp, test_modes[i].mode); else - ret = get_handles_fdopen (filename, fd, fp, test_modes[i].fd_mode, - test_modes[i].mode); + fileret = get_handles_fdopen (filename, fd, fp, + test_modes[i].fd_mode, + test_modes[i].mode); - if (ret != 0) - return ret; + if (fileret != 0) + return fileret; /* Write some data. */ size_t written = fputs_func (data, fp);