From patchwork Tue Oct 17 16:31:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 827121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yGgjP4H38z9t2Q for ; Wed, 18 Oct 2017 03:33:13 +1100 (AEDT) Received: from localhost ([::1]:40451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Unn-0006pC-A8 for incoming@patchwork.ozlabs.org; Tue, 17 Oct 2017 12:33:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Un2-0006ls-HK for qemu-devel@nongnu.org; Tue, 17 Oct 2017 12:32:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Un1-0006HL-Ga for qemu-devel@nongnu.org; Tue, 17 Oct 2017 12:32:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4Umw-00068T-BD; Tue, 17 Oct 2017 12:32:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63836356FC; Tue, 17 Oct 2017 16:32:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 63836356FC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jcody@redhat.com Received: from localhost (ovpn-117-62.phx2.redhat.com [10.3.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A5B761780; Tue, 17 Oct 2017 16:32:15 +0000 (UTC) From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 12:31:48 -0400 Message-Id: <503559b438cd67b865d32d7d0577afc7ee15f32c.1508257445.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 17 Oct 2017 16:32:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 03/10] qemu-iotests: automatically clean up bash protocol servers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jsnow@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For bash tests, this allows 'check' to reap all launch protocol servers / processes, after a test has finished running. Signed-off-by: Jeff Cody Reviewed-by: Eric Blake --- tests/qemu-iotests/check | 13 +++++++ tests/qemu-iotests/common.rc | 93 +++++++++++++++++++++++++++++--------------- 2 files changed, 75 insertions(+), 31 deletions(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 5ae34bf..b4ab646 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -757,6 +757,8 @@ do fi export OUTPUT_DIR=$PWD if $debug; then + # Do this in a sub-shell, so we are operating on the right + # TEST_DIR / QEMU_TEST_DIR ( export TEST_DIR=$TEST_DIR_SEQ cd "$source_iotests"; @@ -766,6 +768,8 @@ do $run_command -d 2>&1 | tee $tmp.out ) else + # Do this in a sub-shell, so we are operating on the right + # TEST_DIR / QEMU_TEST_DIR ( export TEST_DIR=$TEST_DIR_SEQ cd "$source_iotests"; @@ -837,6 +841,15 @@ do fi fi + # Do this in a sub-shell, so we are operating on the right + # TEST_DIR / QEMU_TEST_DIR + ( + export TEST_DIR=$TEST_DIR_SEQ + . "$source_iotests/common.config" + . "$source_iotests/common.rc" + + _cleanup_protocols + ) rm -rf "$TEST_DIR_SEQ" fi diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 0e8a33c..a345ffd 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -101,7 +101,7 @@ _qemu_nbd_wrapper() _qemu_vxhs_wrapper() { ( - echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid" + echo $BASHPID > "${QEMU_TEST_DIR}/qemu-vxhs.pid" exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@" ) } @@ -248,7 +248,7 @@ _make_test_img() # Start QNIO server on image directory for vxhs protocol if [ $IMGPROTO = "vxhs" ]; then - eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &" + eval "$QEMU_VXHS -d $QEMU_TEST_DIR > /dev/null &" sleep 1 # Wait for server to come up. fi } @@ -264,29 +264,64 @@ _rm_test_img() rm -f "$img" } +_cleanup_nbd() +{ + if [ -f "${QEMU_TEST_DIR}/qemu-nbd.pid" ]; then + local QEMU_NBD_PID + read QEMU_NBD_PID < "${QEMU_TEST_DIR}/qemu-nbd.pid" + rm -f "${QEMU_TEST_DIR}/qemu-nbd.pid" + kill ${QEMU_NBD_PID} >/dev/null 2>&1 + fi +} + +_cleanup_vxhs() +{ + if [ -f "${QEMU_TEST_DIR}/qemu-vxhs.pid" ]; then + local QEMU_VXHS_PID + read QEMU_VXHS_PID < "${QEMU_TEST_DIR}/qemu-vxhs.pid" + rm -f "${QEMU_TEST_DIR}/qemu-vxhs.pid" + kill ${QEMU_VXHS_PID} >/dev/null 2>&1 + fi +} + +_cleanup_rbd() +{ + rbd --no-progress rm "$QEMU_TEST_DIR/t.$IMGFMT" > /dev/null +} + +_cleanup_sheepdog() +{ + collie vdi delete "$QEMU_TEST_DIR/t.$IMGFMT" +} + + +_cleanup_protocols() +{ + # Some tests (e.g. 058) start some protocols + # even though the protocol was not specified when running + # check. If the wrappers create pidfiles, go ahead and clean + # up without checking $IMGPROTO. + _cleanup_nbd + _cleanup_vxhs + + case "$IMGPROTO" in + + rbd) + _cleanup_rbd + ;; + + sheepdog) + _cleanup_sheepdog + ;; + + esac +} + _cleanup_test_img() { + _cleanup_protocols + case "$IMGPROTO" in - - nbd) - if [ -f "${QEMU_TEST_DIR}/qemu-nbd.pid" ]; then - local QEMU_NBD_PID - read QEMU_NBD_PID < "${QEMU_TEST_DIR}/qemu-nbd.pid" - kill ${QEMU_NBD_PID} - rm -f "${QEMU_TEST_DIR}/qemu-nbd.pid" - fi - rm -f "$TEST_IMG_FILE" - ;; - vxhs) - if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then - local QEMU_VXHS_PID - read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid" - kill ${QEMU_VXHS_PID} >/dev/null 2>&1 - rm -f "${TEST_DIR}/qemu-vxhs.pid" - fi - rm -f "$TEST_IMG_FILE" - ;; - file) _rm_test_img "$TEST_DIR/t.$IMGFMT" _rm_test_img "$TEST_DIR/t.$IMGFMT.orig" @@ -298,16 +333,12 @@ _cleanup_test_img() TEST_IMG="$ORIG_TEST_IMG" fi ;; - - rbd) - rbd --no-progress rm "$TEST_DIR/t.$IMGFMT" > /dev/null - ;; - - sheepdog) - collie vdi delete "$TEST_DIR/t.$IMGFMT" - ;; - esac + + if [ -n "$TEST_IMG_FILE" ] + then + rm -f "$TEST_IMG_FILE" + fi } _check_test_img()