From nobody Thu Mar 16 12:19:58 2023 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 4PcmYB3TTvz3y3GD; Thu, 16 Mar 2023 12:19:58 +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 4PcmYB2zkHz4KLP; Thu, 16 Mar 2023 12:19:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678969198; 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=NvK84X4PTaykf2W8kvnJbPdPHHSKIU4DOhdLvHtBz9s=; b=easp+YRuaGnnP6nI2k21YL7UPzolX7HeHHCD9wZA4tDHEYSWQ118Ddq7a+MzwNPymphDoo y834ynuorc2Wj+dW0dtL8r7Nc5F8z7lGjXen/6oluwGfBvmQIhuKMYAbcYw4ehKoaSpT7e +5dmGoUfxqTfpqADU21sVEjTQ1oapU9FIXhMZsDGt3sLUbP4PAUe4woA5cLNYXch7/JCW/ GYUX4E2FqVKBOZ1KVD5gV0dCxATirggbGJzrX+u86Fi0wjrJZ3+2lolE//lQiqsxvuAJf/ W6h0NLWt0VM3wd5w9+TveqcwtPdJ86MwDvlqSWOEKuXXEDraj7EGrlleRC3/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678969198; 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=NvK84X4PTaykf2W8kvnJbPdPHHSKIU4DOhdLvHtBz9s=; b=qVycn8LgrsoIACzUV8VaAkBGftia1tv9zVZaWopggFhMHz+lpEdPPrloJZboFezFvo779n jhOpUWalGrHYIAU1nVBR5CdRzi3wFoz3C4RSl+YLub0HkDQpnOeuj2uv+uvxQWxb7tYP32 oHfJw6f29NRgvItWrNwZmWtc8RtXkGcI2bMWTUsiQh6567mF9iBNT1T283ZJQpbdBy97MH zPD8DK5ATiYgFKVWSEIgqP7SgVlrJ2t2aWW5cgslt5QeOT7jNhqD4k7nHrFLWkrfc1b7BW 5Xp9hKMmkcSbx6TK5VjwoMlR3rGEywGfK4DvActdMeLsyyLOUNEnbrdGTYRdvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678969198; a=rsa-sha256; cv=none; b=rkUXLN0u9V2eAy0PYFLhK04XBTBFj9E+xPJtBRvAFHe2fJFj+m02qKKZQEVhpEQbO6TSVH 5EctfaYYEunAB2bHk0uyaT9M/N539V/bDCJj72tFhz4ytGpAlyaTPMIYz/1doE9/aimhi+ lmV3gHfRlwoeEfhLnmtx/BdZ3yFALjArDiy6AQYgJyjooDdEX+NxoJdqVPwzukHyQG9g5m GTGeqgAucsM+2xfkrnHRpl3ztv/gqJGy3+1J6TRQ3fhTeQvKkKMQwDi+n4mz/qKaHzpfcn g1dQ1kNeKgmvLcVswgUpcWW6xW8c703D0giTVA99+a+pyjJdA+0T4HtnsFenAA== 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 4PcmYB225xzhqV; Thu, 16 Mar 2023 12:19:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32GCJwAp079820; Thu, 16 Mar 2023 12:19:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32GCJwHE079819; Thu, 16 Mar 2023 12:19:58 GMT (envelope-from git) Date: Thu, 16 Mar 2023 12:19:58 GMT Message-Id: <202303161219.32GCJwHE079819@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: 6cb78fa479c7 - main - tarfs: Repeat tests using GNU tar if available. 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: 6cb78fa479c7ac8d2b615f903638691a32dc855c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=6cb78fa479c7ac8d2b615f903638691a32dc855c commit 6cb78fa479c7ac8d2b615f903638691a32dc855c Author: Dag-Erling Smørgrav AuthorDate: 2023-03-16 11:31:01 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-03-16 11:31:22 +0000 tarfs: Repeat tests using GNU tar if available. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: ngie, asomers Differential Revision: https://reviews.freebsd.org/D39018 --- tests/sys/fs/tarfs/mktar.c | 11 ++-- tests/sys/fs/tarfs/tarfs_test.sh | 106 +++++++++++++++++++++++++++++++++++---- 2 files changed, 104 insertions(+), 13 deletions(-) diff --git a/tests/sys/fs/tarfs/mktar.c b/tests/sys/fs/tarfs/mktar.c index 9b3d7910a12c..4e7d1acc1c82 100644 --- a/tests/sys/fs/tarfs/mktar.c +++ b/tests/sys/fs/tarfs/mktar.c @@ -48,6 +48,7 @@ #define SHORTLINKNAME "short_link" #define LONGLINKNAME "long_link" +static bool opt_g; static bool opt_v; static void verbose(const char *fmt, ...) @@ -163,7 +164,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s [-v] tarfile\n", PROGNAME); + fprintf(stderr, "usage: %s [-gv] tarfile\n", PROGNAME); exit(EXIT_FAILURE); } @@ -175,8 +176,10 @@ main(int argc, char *argv[]) int opt, wstatus; pid_t pid; - while ((opt = getopt(argc, argv, "v")) != -1) + while ((opt = getopt(argc, argv, "gv")) != -1) switch (opt) { + case 'g': + opt_g = true; case 'v': opt_v = true; break; @@ -220,10 +223,12 @@ main(int argc, char *argv[]) err(1, "fork()"); if (pid == 0) { verbose("creating tarball"); - execlp("tar", "tar", + execlp(opt_g ? "gtar" : "tar", + "tar", "-c", "-f", tarfilename, "-C", dirname, + "--posix", "--zstd", #if 0 "--options", "zstd:frame-per-file", diff --git a/tests/sys/fs/tarfs/tarfs_test.sh b/tests/sys/fs/tarfs/tarfs_test.sh index 32576cbf57b6..6e44a8081cb2 100644 --- a/tests/sys/fs/tarfs/tarfs_test.sh +++ b/tests/sys/fs/tarfs/tarfs_test.sh @@ -26,12 +26,23 @@ # SUCH DAMAGE. # -mktar="$(dirname $(realpath "$0"))"/mktar mnt="$(realpath ${TMPDIR:-/tmp})/mnt" # expected SHA256 checksum of file contained in test tarball sum=4da2143234486307bb44eaa610375301781a577d1172f362b88bb4b1643dee62 +tar() { + if [ -n "${TARFS_USE_GNU_TAR}" ] ; then + gtar --posix --absolute-names "$@" + else + bsdtar "$@" + fi +} + +mktar() { + "$(atf_get_srcdir)"/mktar ${TARFS_USE_GNU_TAR+-g} "$@" +} + atf_test_case tarfs_basic cleanup tarfs_basic_head() { atf_set "descr" "Basic function test" @@ -41,7 +52,7 @@ tarfs_basic_body() { 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}" + mktar "${tarball}" atf_check mount -rt tarfs "${tarball}" "${mnt}" atf_check -o match:"^${tarball} on ${mnt} \(tarfs," mount atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -f%d,%i "${mnt}"/hard_link)" @@ -53,6 +64,20 @@ tarfs_basic_cleanup() { umount "${mnt}" || true } +atf_test_case tarfs_basic_gnu cleanup +tarfs_basic_gnu_head() { + atf_set "descr" "Basic function test using GNU tar" + atf_set "require.user" "root" + atf_set "require.progs" "gtar" +} +tarfs_basic_gnu_body() { + TARFS_USE_GNU_TAR=true + tarfs_basic_body +} +tarfs_basic_gnu_cleanup() { + tarfs_basic_cleanup +} + atf_test_case tarfs_notdir_device cleanup tarfs_notdir_device_head() { atf_set "descr" "Regression test for PR 269519 and 269561" @@ -62,11 +87,11 @@ tarfs_notdir_device_body() { kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" mkdir "${mnt}" atf_check mknod d b 0xdead 0xbeef - tar cf tarfs_notdir.tar d + tar -cf tarfs_notdir.tar d rm d mkdir d echo "boom" >d/f - tar rf tarfs_notdir.tar d/f + tar -rf tarfs_notdir.tar d/f atf_check -s not-exit:0 -e match:"Invalid" \ mount -rt tarfs tarfs_notdir.tar "${mnt}" } @@ -74,6 +99,20 @@ tarfs_notdir_device_cleanup() { umount "${mnt}" || true } +atf_test_case tarfs_notdir_device_gnu cleanup +tarfs_notdir_device_gnu_head() { + atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar" + atf_set "require.user" "root" + atf_set "require.progs" "gtar" +} +tarfs_notdir_device_gnu_body() { + TARFS_USE_GNU_TAR=true + tarfs_notdir_device_body +} +tarfs_notdir_device_gnu_cleanup() { + tarfs_notdir_device_cleanup +} + atf_test_case tarfs_notdir_dot cleanup tarfs_notdir_dot_head() { atf_set "descr" "Regression test for PR 269519 and 269561" @@ -83,11 +122,11 @@ tarfs_notdir_dot_body() { kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" mkdir "${mnt}" echo "hello" >d - tar cf tarfs_notdir.tar d + tar -cf tarfs_notdir.tar d rm d mkdir d echo "world" >d/f - tar rf tarfs_notdir.tar d/./f + tar -rf tarfs_notdir.tar d/./f atf_check -s not-exit:0 -e match:"Invalid" \ mount -rt tarfs tarfs_notdir.tar "${mnt}" } @@ -95,6 +134,20 @@ tarfs_notdir_dot_cleanup() { umount "${mnt}" || true } +atf_test_case tarfs_notdir_dot_gnu cleanup +tarfs_notdir_dot_gnu_head() { + atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar" + atf_set "require.user" "root" + atf_set "require.progs" "gtar" +} +tarfs_notdir_dot_gnu_body() { + TARFS_USE_GNU_TAR=true + tarfs_notdir_dot_body +} +tarfs_notdir_dot_gnu_cleanup() { + tarfs_notdir_dot_cleanup +} + atf_test_case tarfs_notdir_dotdot cleanup tarfs_notdir_dotdot_head() { atf_set "descr" "Regression test for PR 269519 and 269561" @@ -104,11 +157,11 @@ tarfs_notdir_dotdot_body() { kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" mkdir "${mnt}" echo "hello" >d - tar cf tarfs_notdir.tar d + tar -cf tarfs_notdir.tar d rm d mkdir d echo "world" >f - tar rf tarfs_notdir.tar d/../f + tar -rf tarfs_notdir.tar d/../f atf_check -s not-exit:0 -e match:"Invalid" \ mount -rt tarfs tarfs_notdir.tar "${mnt}" } @@ -116,6 +169,20 @@ tarfs_notdir_dotdot_cleanup() { umount "${mnt}" || true } +atf_test_case tarfs_notdir_dotdot_gnu cleanup +tarfs_notdir_dotdot_gnu_head() { + atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar" + atf_set "require.user" "root" + atf_set "require.progs" "gtar" +} +tarfs_notdir_dotdot_gnu_body() { + TARFS_USE_GNU_TAR=true + tarfs_notdir_dotdot_body +} +tarfs_notdir_dotdot_gnu_cleanup() { + tarfs_notdir_dotdot_cleanup +} + atf_test_case tarfs_notdir_file cleanup tarfs_notdir_file_head() { atf_set "descr" "Regression test for PR 269519 and 269561" @@ -125,11 +192,11 @@ tarfs_notdir_file_body() { kldload -n tarfs || atf_skip "This test requires tarfs and could not load it" mkdir "${mnt}" echo "hello" >d - tar cf tarfs_notdir.tar d + tar -cf tarfs_notdir.tar d rm d mkdir d echo "world" >d/f - tar rf tarfs_notdir.tar d/f + tar -rf tarfs_notdir.tar d/f atf_check -s not-exit:0 -e match:"Invalid" \ mount -rt tarfs tarfs_notdir.tar "${mnt}" } @@ -137,10 +204,29 @@ tarfs_notdir_file_cleanup() { umount "${mnt}" || true } +atf_test_case tarfs_notdir_file_gnu cleanup +tarfs_notdir_file_gnu_head() { + atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar" + atf_set "require.user" "root" + atf_set "require.progs" "gtar" +} +tarfs_notdir_file_gnu_body() { + TARFS_USE_GNU_TAR=true + tarfs_notdir_file_body +} +tarfs_notdir_file_gnu_cleanup() { + tarfs_notdir_file_cleanup +} + atf_init_test_cases() { atf_add_test_case tarfs_basic + atf_add_test_case tarfs_basic_gnu atf_add_test_case tarfs_notdir_device + atf_add_test_case tarfs_notdir_device_gnu atf_add_test_case tarfs_notdir_dot + atf_add_test_case tarfs_notdir_dot_gnu atf_add_test_case tarfs_notdir_dotdot + atf_add_test_case tarfs_notdir_dotdot_gnu atf_add_test_case tarfs_notdir_file + atf_add_test_case tarfs_notdir_file_gnu }