From patchwork Thu Nov 27 09:28:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 415415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 9D0D91401F6 for ; Thu, 27 Nov 2014 20:28:48 +1100 (AEDT) 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=WVH0lW1O5IGtu+ALA8wGwJ1QkJlYc z1FEVfl05CGlVHFFKS/osr1Y5nv+jN9C96j5ZtjQP7slkkD0bhH4Ji9J/re1NLvN 5KIM3zuycH9ArRybOpXrTTHmlv1g/silLYjprEyN6Kyu8P+4k/b6QMyyYgF3898z JvGCWHZw8ifT1Q= 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=rQIjT9P/X/NE98r+Vfkg9LeIuyA=; b=CC2 SIV3zkSxazWqzKUO+5A90xP8qhW0NacPnoI2xqDpfITNP+CRQmbzyI1gNuLKXg07 bYPbmxZ2xhBuwK6gAs9RKYrk9s8kLeNXOfJOAHEGRwwGwHUyd00LdTFxatP9SZAJ +DFgTX0lRKysuYqyX68ygpIefw2u/1DY/cDrDAjU= Received: (qmail 7766 invoked by alias); 27 Nov 2014 09:28:41 -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 7755 invoked by uid 89); 27 Nov 2014 09:28:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Thu, 27 Nov 2014 14:58:33 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] tst-ftell-active-handler: Open file with O_TRUNC for w+ mode Message-ID: <20141127092833.GA5527@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) The test case fails to truncate the file when a file is intended to be opened in w+ mode. Add O_TRUNC to fix this. The test still succeeds with this change. OK to commit? Siddhesh * libio/tst-ftell-active-handler.c (do_ftruncate_test): Add O_TRUNC flag for w+ mode. (do_rewind_test): Likewise. (do_ftell_test): Likewise. (do_write_test): Likewise. --- libio/tst-ftell-active-handler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libio/tst-ftell-active-handler.c b/libio/tst-ftell-active-handler.c index 9f23c55..5922bb5 100644 --- a/libio/tst-ftell-active-handler.c +++ b/libio/tst-ftell-active-handler.c @@ -105,7 +105,7 @@ do_ftruncate_test (const char *filename) } test_modes[] = { {"r+", O_RDWR}, {"w", O_WRONLY}, - {"w+", O_RDWR}, + {"w+", O_RDWR | O_TRUNC}, {"a", O_WRONLY}, {"a+", O_RDWR} }; @@ -190,7 +190,7 @@ do_rewind_test (const char *filename) size_t new_off; } test_modes[] = { {"w", O_WRONLY, 0, data_len}, - {"w+", O_RDWR, 0, data_len}, + {"w+", O_RDWR | O_TRUNC, 0, data_len}, {"r+", O_RDWR, 0, data_len}, /* The new offsets for 'a' and 'a+' modes have to factor in the previous writes since they always append to the end of the @@ -295,7 +295,7 @@ do_ftell_test (const char *filename) beginning of the file. After the write, the offset should be updated to data_len. */ {"w", O_WRONLY, 0, data_len}, - {"w+", O_RDWR, 0, data_len}, + {"w+", O_RDWR | O_TRUNC, 0, data_len}, {"r+", O_RDWR, 0, data_len}, /* For the 'a' mode, the initial file position should be the current end of file. After the write, the offset has data_len @@ -376,7 +376,7 @@ do_write_test (const char *filename) int fd_mode; } test_modes[] = { {"w", O_WRONLY}, - {"w+", O_RDWR}, + {"w+", O_RDWR | O_TRUNC}, {"r+", O_RDWR} };