All of lore.kernel.org
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 4/4 v2] fstests: fix cleanup of test btrfs/003
Date: Wed, 23 Dec 2015 04:43:15 +0000	[thread overview]
Message-ID: <1450845795-18729-4-git-send-email-fdmanana@kernel.org> (raw)
In-Reply-To: <1450845795-18729-1-git-send-email-fdmanana@kernel.org>

From: Filipe Manana <fdmanana@suse.com>

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 <fdmanana@suse.com>
---

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
 }
 
-- 
2.1.3


  parent reply	other threads:[~2015-12-24 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-23  4:43 [PATCH 1/4 v2] fstests: fix btrfs test failures after commit 27d077ec0bda fdmanana
2015-12-23  4:43 ` [PATCH 2/4 v2] fstests: cleanup test btrfs/029 fdmanana
2015-12-23  4:43 ` [PATCH 3/4 v2] fstests: cleanup test btrfs/031 fdmanana
2015-12-23  4:43 ` fdmanana [this message]
2016-01-11  3:41 ` [PATCH 1/4 v2] fstests: fix btrfs test failures after commit 27d077ec0bda Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450845795-18729-4-git-send-email-fdmanana@kernel.org \
    --to=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.