Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n7rI2-0006JG-Ki for mharc-grub-devel@gnu.org; Wed, 12 Jan 2022 23:00:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7rHy-0006G6-0E for grub-devel@gnu.org; Wed, 12 Jan 2022 23:00:38 -0500 Received: from [2607:f8b0:4864:20::f36] (port=45051 helo=mail-qv1-xf36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7rHu-0001iH-Nj for grub-devel@gnu.org; Wed, 12 Jan 2022 23:00:37 -0500 Received: by mail-qv1-xf36.google.com with SMTP id jr5so5335556qvb.11 for ; Wed, 12 Jan 2022 20:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WYr9hVlRIkj223UuG7Wj2gvDqvLbqY2QFcJmhPAYBNI=; b=6iEyJSZ5YoKoQkPSnGG7a91Y+GAQq3rQO3qOxLSCf/kTopchjNO6+J+lAzeltuDgAm eWf/b+OYLMYOMhwMMOfBXgCS0sFKjIqGvmTgbolTihA0u9ocxbuV959jBpaXyrQww5vF R5vTifJuCgO0hapmixrK1EDZy8qiT/4XEmgD8ZyIrF1nJ0tfbFIGkOC7VVKRHvI9k1KN GUKgY2txBs8XDUeXNbyAjTSuR9fwCS++L/3U2BMKlLBhPnpdMMJ90TJ9zp13fnomHS3n 479J5RRd1wqk3IJjxId6LcfePVvSFS2/80kmmOtOOVkxn0UIIvhAwEdS2Dit0TfEXySP LyQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WYr9hVlRIkj223UuG7Wj2gvDqvLbqY2QFcJmhPAYBNI=; b=wsfP+vHz4J2XjhQED2Lf8Z2KWy5uYD8K6VYh/JRzHCiaPx+GtLssAEd43sBFSmkAA1 d7r0fdk6EhI+3XTZpfmlJjk8y2KcYi6YN4TwMibVF7zmQXMmdqAVsBwL9fEK1VsPGOK2 68u2m/m4EVuyzz+aOr/nhpGx3L27eOKH7WA+cF0AaUm1TwJ0fNhIGp9vrZv9yYZ7TBjg 0AlsM5qogcqXW8jMGr3Q304x4OgWZk1DQeVj/EpCxZRp8Nx2xFBDWxzRhIrvbZBnfPD0 Dlm67fCyl+M4IbBOSZfL98GnSVaoqtbiSJ/HvNKUmDDdDa9nHq1R2dgJqeyB+Lnp6Sh6 xy9g== X-Gm-Message-State: AOAM531kc0tsvcyxqLfZyGUqIhCP2M9+i9a5Dqwc/BfiKGLUDIrhZVy1 LeDS/fGSB48xrbq82DJbdp/yhw== X-Google-Smtp-Source: ABdhPJyXdstQoM1gh6nDFme6wCqjUXjionBC/EIsiT+KAR+JtqFV6kKk6jWgfwE3UxNkQNEuc4KWdA== X-Received: by 2002:ad4:5baf:: with SMTP id 15mr2496363qvq.21.1642046428083; Wed, 12 Jan 2022 20:00:28 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id 94sm1100138qtf.87.2022.01.12.20.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 20:00:27 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Glenn Washburn Subject: [PATCH 5/5] tests: Ensure that loopback devices and zfs devices are cleaned up Date: Wed, 12 Jan 2022 21:59:43 -0600 Message-Id: <61bd6959bf68861069e3798f3b6a0c916acea542.1642046227.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f36 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=development@efficientek.com; helo=mail-qv1-xf36.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2022 04:00:38 -0000 ZFS file systems are not unmounted using umount, but instead by exporting them. So export the ZFS file system that has the same label as the one that was created during the test, if such one exists. This is required to delete the loopback device that uses the ZFS image file. Otherwise the added code to delete all loopback devices setup during the test run will never be able to finish because the loopback device can not be deleted while in use. Signed-off-by: Glenn Washburn --- tests/util/grub-fs-tester.in | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index b39831f27..5c23c41a1 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -14,15 +14,32 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || XORRISOFS_CHARSET="-input-charset UTF-8 -output-charset UTF-8" MOUNTS= -umount_all() { +LODEVICES= +cleanup() { + if [ -n "$fs" -a -z "${fs##*zfs*}" -a -n "$FSLABEL" ]; then + zpool list "$FSLABEL" 2>/dev/null && + while ! zpool export "$FSLABEL" ; do + sleep 1; + done + fi + for MOUNT in $MOUNTS; do umount "$MOUNT" && MOUNTS="$(echo ${MOUNTS} | sed "s|$MOUNT||g;")" done + + for lodev in $LODEVICES; do + local i=600 + while losetup -l -O NAME | grep -q "^$lodev\$"; do + losetup -d "$lodev" || sleep 1 + [ "$((i--))" = "0" ] && break + done + done + return 0 } -trap umount_all EXIT INT +trap cleanup EXIT INT # This is for bash, dash and ash do not recognize ERR -trap umount_all ERR || : +trap cleanup ERR || : # This wrapper is to ease insertion of valgrind or time statistics run_it () { -- 2.27.0