From patchwork Wed Dec 23 04:43:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 7917501 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73AE0BEEED for ; Thu, 24 Dec 2015 12:14:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A837D205F1 for ; Thu, 24 Dec 2015 12:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE087204B0 for ; Thu, 24 Dec 2015 12:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754734AbbLXMOL (ORCPT ); Thu, 24 Dec 2015 07:14:11 -0500 Received: from mail.kernel.org ([198.145.29.136]:45374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754721AbbLXMOI (ORCPT ); Thu, 24 Dec 2015 07:14:08 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 892C1205FF; Thu, 24 Dec 2015 12:14:07 +0000 (UTC) Received: from debian3.lan (bl8-199-62.dsl.telepac.pt [85.241.199.62]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1E071204A7; Thu, 24 Dec 2015 12:14:05 +0000 (UTC) From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 4/4 v2] fstests: fix cleanup of test btrfs/003 Date: Wed, 23 Dec 2015 04:43:15 +0000 Message-Id: <1450845795-18729-4-git-send-email-fdmanana@kernel.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1450845795-18729-1-git-send-email-fdmanana@kernel.org> References: <1450845795-18729-1-git-send-email-fdmanana@kernel.org> X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana If the test fails after removing a device and before adding it back, it attempts to add back the device in its _cleanup() function. However this is broken because the device identifier is stored in a variable local to the function _test_replace() and not in a global variable. So make the variable global instead of local. Signed-off-by: Filipe Manana --- V2: No changes from v1. Only added to V2 of the corresponding patchset. tests/btrfs/003 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/btrfs/003 b/tests/btrfs/003 index 353cb48..ae7e377 100755 --- a/tests/btrfs/003 +++ b/tests/btrfs/003 @@ -29,6 +29,7 @@ here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! dev_removed=0 +removed_dev_htl="" trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() @@ -37,7 +38,7 @@ _cleanup() rm -f $tmp.* if [ $dev_removed == 1 ]; then _scratch_unmount - _devmgt_add "${DEVHTL}" + _devmgt_add "${removed_dev_htl}" fi } @@ -125,7 +126,6 @@ _test_replace() local n=${#devs[@]} local ds local d - local DEVHTL="" # exclude the first and the last disk in the disk pool n=$(($n-1)) @@ -142,10 +142,10 @@ _test_replace() # retrive the HTL for this scsi disk d=`echo $ds|cut -d"/" -f3` - DEVHTL=`ls -l /sys/class/block/${d} | rev | cut -d "/" -f 3 | rev` + removed_dev_htl=`ls -l /sys/class/block/${d} | rev | cut -d "/" -f 3 | rev` #fail disk - _devmgt_remove ${DEVHTL} $ds + _devmgt_remove ${removed_dev_htl} $ds dev_removed=1 $BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV | grep "Some devices missing" >> $seqres.full || _fail \ @@ -162,7 +162,7 @@ _test_replace() # cleaup. add the removed disk _scratch_unmount - _devmgt_add "${DEVHTL}" + _devmgt_add "${removed_dev_htl}" dev_removed=0 }