From nobody Wed Mar 06 16:24:34 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tqd770N7Mz5Csl9; Wed, 6 Mar 2024 16:24:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tqd765GX8z4ffj; Wed, 6 Mar 2024 16:24:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709742274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OVJqexMRmqW65B5E9tHdnJexQMu5AuNQbjVMQOib7J0=; b=i/EtTRBHmD4mCFnmM2lSWov4CT3yyo4ZEcavtYZYNgPBvm8NRePpO2aXWlygmiHv16wU0j 7XWW/+MWzwJctvib5eKm99owM2j1VOfjCdIXDwblZNubpcXx5PApHP6CwnpAE6AQtxYjd5 DGQ/ii9eyHjYtURcE0odOSYqpRUBL+gBk675CqZ2VLCBdtBK+v5ltj18bCMfYm23l1uleJ EZhMQaDLuVlIiFLMFv9OctAXYrSwICVKQRctE2CGeDY2kdYrYveIURORRCpEPYLvWyM6QT f3hUUpVKqTB7luDNBsgtd6oIHGEiGc5X7GBmvXWeUIF+FCYBIkZIWZwOdbKi3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709742274; a=rsa-sha256; cv=none; b=dTayFlo6F0Yb9MpIYozXA6WXxm+D4xsVgwM3LQ8ZqL52l2ajIzCt1xLaminUJ0/bV+Iwx9 I05BTvMzzcHy8cQQLLsE96TTa9BBfpxxBHobzAYDmPX0cxms15eEbquaSfhp6Y5gY2E2l2 3x8POGwi6NVsTwdhaNDAfpJB3hfsdNdddYN8I8YJVrEWIxHZyAe7K4e87GNPGK3FcmPlAB eUKpxyDwvJf0T8W5U17RfXzX801/sJ1he9JkcRJ2nzk+AUgzIxh/nL9rWUmFgiywUx+IyQ skW14X0aZtjTrlIEgXLvIqfPEn7uggxzkZjoKyw1Po+D3LhETW+BTIvgnnLfdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709742274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OVJqexMRmqW65B5E9tHdnJexQMu5AuNQbjVMQOib7J0=; b=LrdI3XcV5tEE/FuYFyWvsdXQXApJCAs+7Xc16/nnLa3fuNHGevfQrMGgOxPZNK2AiT96HD /OHNjd+Dez6SpDMGHC9l36Ywjd1Kgq18KHUIZAJUNzD8qoAa35HrITSSwaJ7aLBbCyN4Mj Zu/yxXD9wzx3Bxc3Nscz5hF1kIGm/kNxDN4fDlwG//xZH71InVSEhslnCq8D+YRCoz3DWx AfA7KucS5ujsFCTl1kHDiTqiajyxKO/9pwvcX28AShnMLgFtMqcpkbN/KD79zCyNUXABDB nROOXug+jpRl1nwrbl8xgH3wroMI6hBsjZiyrFw0T+/GhyiH0vX6vgw1bmqnAA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tqd764m8hzxbG; Wed, 6 Mar 2024 16:24:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 426GOYds025262; Wed, 6 Mar 2024 16:24:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 426GOYOC025259; Wed, 6 Mar 2024 16:24:34 GMT (envelope-from git) Date: Wed, 6 Mar 2024 16:24:34 GMT Message-Id: <202403061624.426GOYOC025259@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 32b8aac6f9b7 - main - tarfs: Factor out common test code. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 32b8aac6f9b77a1c4326083472d634e5de427547 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=32b8aac6f9b77a1c4326083472d634e5de427547 commit 32b8aac6f9b77a1c4326083472d634e5de427547 Author: Dag-Erling Smørgrav AuthorDate: 2024-03-06 16:14:05 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-03-06 16:14:05 +0000 tarfs: Factor out common test code. MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44227 --- tests/sys/fs/tarfs/tarfs_test.sh | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/sys/fs/tarfs/tarfs_test.sh b/tests/sys/fs/tarfs/tarfs_test.sh index 46aefd832d5d..2a5dfc434201 100644 --- a/tests/sys/fs/tarfs/tarfs_test.sh +++ b/tests/sys/fs/tarfs/tarfs_test.sh @@ -47,15 +47,23 @@ tarsum() { "$(atf_get_srcdir)"/tarsum } +tarfs_setup() { + kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" + mkdir "${mnt}" +} + +tarfs_cleanup() { + umount -f "${mnt}" 2>/dev/null || true +} + atf_test_case tarfs_basic cleanup tarfs_basic_head() { atf_set "descr" "Basic function test" atf_set "require.user" "root" } tarfs_basic_body() { + tarfs_setup local tarball="${PWD}/tarfs_test.tar.zst" - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" mktar "${tarball}" atf_check mount -rt tarfs "${tarball}" "${mnt}" atf_check -o match:"^${tarball} on ${mnt} \(tarfs," mount @@ -72,7 +80,7 @@ tarfs_basic_body() { atf_check -o inline:"3,40755\n" stat -f%l,%p "${mnt}" } tarfs_basic_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_basic_gnu cleanup @@ -95,8 +103,7 @@ tarfs_notdir_device_head() { atf_set "require.user" "root" } tarfs_notdir_device_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup atf_check mknod d b 0xdead 0xbeef tar -cf tarfs_notdir.tar d rm d @@ -107,7 +114,7 @@ tarfs_notdir_device_body() { mount -rt tarfs tarfs_notdir.tar "${mnt}" } tarfs_notdir_device_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_notdir_device_gnu cleanup @@ -130,8 +137,7 @@ tarfs_notdir_dot_head() { atf_set "require.user" "root" } tarfs_notdir_dot_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup echo "hello" >d tar -cf tarfs_notdir.tar d rm d @@ -142,7 +148,7 @@ tarfs_notdir_dot_body() { mount -rt tarfs tarfs_notdir.tar "${mnt}" } tarfs_notdir_dot_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_notdir_dot_gnu cleanup @@ -165,8 +171,7 @@ tarfs_notdir_dotdot_head() { atf_set "require.user" "root" } tarfs_notdir_dotdot_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup echo "hello" >d tar -cf tarfs_notdir.tar d rm d @@ -177,7 +182,7 @@ tarfs_notdir_dotdot_body() { mount -rt tarfs tarfs_notdir.tar "${mnt}" } tarfs_notdir_dotdot_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_notdir_dotdot_gnu cleanup @@ -200,8 +205,7 @@ tarfs_notdir_file_head() { atf_set "require.user" "root" } tarfs_notdir_file_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup echo "hello" >d tar -cf tarfs_notdir.tar d rm d @@ -212,7 +216,7 @@ tarfs_notdir_file_body() { mount -rt tarfs tarfs_notdir.tar "${mnt}" } tarfs_notdir_file_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_notdir_file_gnu cleanup @@ -235,8 +239,7 @@ tarfs_emptylink_head() { atf_set "require.user" "root" } tarfs_emptylink_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup touch z ln -f z hard ln -fs z soft @@ -246,7 +249,7 @@ tarfs_emptylink_body() { mount -rt tarfs tarfs_emptylink.tar "${mnt}" } tarfs_emptylink_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_linktodir cleanup @@ -255,8 +258,7 @@ tarfs_linktodir_head() { atf_set "require.user" "root" } tarfs_linktodir_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup mkdir d tar -cf - d | dd bs=512 count=1 > tarfs_linktodir.tar rmdir d @@ -267,7 +269,7 @@ tarfs_linktodir_body() { mount -rt tarfs tarfs_linktodir.tar "${mnt}" } tarfs_linktodir_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_test_case tarfs_linktononexistent cleanup @@ -276,8 +278,7 @@ tarfs_linktononexistent_head() { atf_set "require.user" "root" } tarfs_linktononexistent_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup touch f ln -f f link tar -cf - f link | dd bs=512 skip=1 >> tarfs_linktononexistent.tar @@ -294,8 +295,7 @@ tarfs_checksum_head() { atf_set "require.user" "root" } tarfs_checksum_body() { - kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" - mkdir "${mnt}" + tarfs_setup touch f tar -cf tarfs_checksum.tar f truncate -s 500 tarfs_checksum.tar @@ -306,7 +306,7 @@ tarfs_checksum_body() { mount -rt tarfs tarfs_checksum.tar "${mnt}" } tarfs_checksum_cleanup() { - umount "${mnt}" || true + tarfs_cleanup } atf_init_test_cases() {