public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: snitzer@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/test test-utils.sh Date: Tue, 20 Apr 2010 18:19:00 -0000 [thread overview] Message-ID: <20100420181859.1573.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-04-20 18:18:59 Modified files: test : test-utils.sh Log message: Re-enable t-topology-support.sh Reintroduce split teardown (teardown() calls teardown_devs()) because t-topology-support.sh only needs the teardown_devs() subset of the full teardown() between each iteration of the topology tests -- in particular the $TESTDIR must not get removed between each topology test iteration. prepare_loop() must return if prepare_scsi_debug_dev() already established $LOOP. Also fix (and simplify) the unsafe scsi-debug device discovery in prepare_scsi_debug_dev(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.37&r2=1.38 --- LVM2/test/test-utils.sh 2010/04/14 12:04:23 1.37 +++ LVM2/test/test-utils.sh 2010/04/20 18:18:59 1.38 @@ -92,16 +92,7 @@ done } -teardown() { - echo $LOOP - echo $PREFIX - - test -n "$LOCAL_CLVMD" && { - kill "$LOCAL_CLVMD" - sleep .1 - kill -9 "$LOCAL_CLVMD" || true - } - +teardown_devs() { test -n "$PREFIX" && { rm -rf $TESTDIR/dev/$PREFIX* @@ -124,6 +115,19 @@ test -n "$LOOPFILE" && rm -f $LOOPFILE fi unset devs # devs is set in prepare_devs() +} + +teardown() { + echo $LOOP + echo $PREFIX + + test -n "$LOCAL_CLVMD" && { + kill "$LOCAL_CLVMD" + sleep .1 + kill -9 "$LOCAL_CLVMD" || true + } + + teardown_devs test -n "$TESTDIR" && { cd $OLDPWD @@ -145,6 +149,11 @@ size=$1 test -n "$size" || size=32 + # skip if prepare_scsi_debug_dev() was used + if [ -n "$SCSI_DEBUG_DEV" -a -n "$LOOP" ]; then + return 0 + fi + test -z "$LOOP" test -n "$DM_DEV_DIR" @@ -183,71 +192,50 @@ exit 1 # should not happen } -get_sd_devs_() -{ - # prepare_scsi_debug_dev() requires the ability to lookup - # the scsi_debug created SCSI device in /dev/ - local _devs=$(lvmdiskscan --config 'devices { filter = [ "a|/dev/sd.*|", "r|.*|" ] scan = "/dev/" }' | grep /dev/sd | awk '{ print $1 }') - echo $_devs -} - # A drop-in replacement for prepare_loop() that uses scsi_debug to create # a ramdisk-based SCSI device upon which all LVM devices will be created # - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer prepare_scsi_debug_dev() { - # FIXME this is extremely fragile and can cause data loss if an unrelated - # SCSI device appears at a wrong time... we need the code to reliably - # identify the scsi_debug device it has created before we can re-include - # this in the testsuite - exit 200 - local DEV_SIZE="$1" shift local SCSI_DEBUG_PARAMS="$@" test -n "$SCSI_DEBUG_DEV" && return 0 + test -z "$LOOP" + test -n "$DM_DEV_DIR" + trap_teardown # Skip test if awk isn't available (required for get_sd_devs_) which awk || exit 200 # Skip test if scsi_debug module is unavailable or is already in use - modinfo scsi_debug || exit 200 + modprobe --dry-run scsi_debug || exit 200 lsmod | grep -q scsi_debug && exit 200 # Create the scsi_debug device and determine the new scsi device's name - local devs_before=`get_sd_devs_` # NOTE: it will _never_ make sense to pass num_tgts param; # last param wins.. so num_tgts=1 is imposed modprobe scsi_debug dev_size_mb=$DEV_SIZE $SCSI_DEBUG_PARAMS num_tgts=1 || exit 200 sleep 2 # allow for async Linux SCSI device registration - local devs_after=`get_sd_devs_` - for dev1 in $devs_after; do - FOUND=0 - for dev2 in $devs_before; do - if [ "$dev1" = "$dev2" ]; then - FOUND=1 - break - fi - done - if [ $FOUND -eq 0 ]; then - # Create symlink to scsi_debug device in $DM_DEV_DIR - SCSI_DEBUG_DEV=$DM_DEV_DIR/$(basename $dev1) - # Setting $LOOP provides means for prepare_devs() override - LOOP=$SCSI_DEBUG_DEV - ln -snf $dev1 $SCSI_DEBUG_DEV - return 0 - fi - done - exit 1 # should not happen + local DEBUG_DEV=/dev/$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /) + [ -b $DEBUG_DEV ] || exit 1 # should not happen + + # Create symlink to scsi_debug device in $DM_DEV_DIR + SCSI_DEBUG_DEV=$DM_DEV_DIR/$(basename $DEBUG_DEV) + # Setting $LOOP provides means for prepare_devs() override + LOOP=$SCSI_DEBUG_DEV + ln -snf $DEBUG_DEV $SCSI_DEBUG_DEV + return 0 } cleanup_scsi_debug_dev() { - aux teardown + aux teardown_devs unset SCSI_DEBUG_DEV + unset LOOP } prepare_devs() {
next reply other threads:[~2010-04-20 18:19 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-04-20 18:19 snitzer [this message] -- strict thread matches above, loose matches on Subject: below -- 2010-12-09 11:19 mbroz 2010-10-26 1:25 snitzer 2010-10-12 16:13 mornfall 2010-08-27 8:52 mbroz 2010-08-27 7:59 mbroz 2010-08-02 13:18 zkabelac 2010-05-24 17:19 mbroz 2010-05-24 17:18 mbroz 2010-05-12 11:58 mornfall 2010-04-14 12:04 mornfall 2010-04-13 8:01 mornfall 2010-04-13 7:02 mornfall 2010-04-13 6:24 mornfall 2010-04-07 21:38 mornfall 2010-04-07 21:19 mornfall 2010-04-07 16:04 mornfall 2010-04-06 14:25 agk 2010-03-28 15:52 mornfall 2010-03-18 9:27 mornfall 2010-02-01 19:43 wysochanski 2009-05-13 19:18 wysochanski 2009-04-24 8:00 mornfall 2008-12-10 16:16 zkabelac 2008-12-05 5:03 wysochanski 2008-11-10 12:36 mornfall 2008-11-04 14:38 mornfall 2008-10-14 19:48 mornfall
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=20100420181859.1573.qmail@sourceware.org \ --to=snitzer@sourceware.org \ --cc=lvm-devel@redhat.com \ --cc=lvm2-cvs@sourceware.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).