From nobody Sat Apr 4 08:59:34 2026 X-Original-To: dev-commits-src-branches@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 4fnqKM0bZpz6YGmX for ; Sat, 04 Apr 2026 08:59: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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fnqKL6QXQz3L55 for ; Sat, 04 Apr 2026 08:59:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775293174; 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=RAobMeUd0+QaEPDmLKXegxaXWqHqSBDmvMGH9s8Jc/U=; b=eQSCMrB9oLp34CC9wmdzXOxA7wtBxcfi3rK2LWB/yi7apAmm5uuZVx3hGVhuUEjAfIqCs6 AAB4ZjYo5rvq5L3UMUdRLVdJEggkkaHOQGWdInf5Ds+RkK9TVgKUJCZ2E4zQ6iQ1UzeNum lT4/3svLA2QXZAvtW1efh8viTb4qxwBF6RzfWvjf7eUjIFe3ZSjY07dsGhQvoppYDIfRjH kPtT4C19m5QJlOXLuoGdUWj5/H3QUbkw3IU2l0qDCgdNCx2tDKFmCtHQAasaQWFYKoOKgb OHkj1tI51Pe4kfx+yXILCToY6Jcf/n4WDF8zcnBBPEEtWVm0VH5Lio0FyX97EA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1775293174; a=rsa-sha256; cv=none; b=nEdWgBogc1sySE6yTYQXFy3ZK9YfBTwFC3ghqL2j3J4BnHjCX+cf95aclgqPsRh8gffHGx 2Z5APsVk64+GFAL3l5ZCpn1mCIu+6QU0vjaz5i7gjgjlEAvz6c0DIVxTEnCi8ci+qM8qOS ig6nVzcVS7+nTVVBHan6fklTKmtnLBT/QcXUNvkAkRKAXNUjyELpuPdeP6cvL9eEbnu4js Ngp4+uRS+acfcnLZqsbEBc7N9CpAz4hDwlFHGVAf1Y7i2F8FyraUj9oAFWb2oxc92jADvA wh4B0IBbaAJMq88uTgKDqpDA+pGibO0M/tDPkW6MP+Cfw1n0RuYll9R3KyJgww== 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=1775293174; 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=RAobMeUd0+QaEPDmLKXegxaXWqHqSBDmvMGH9s8Jc/U=; b=KeFlGOs5/gCxmkBwZhST94WjYNVuo+TuPyI/6ZGqc9fodFa9NybbSyoCsI980bfPzH/ByY ikQRzYV1sadvE2HUPf222RpNWdZVm1PqdNfEqlglTwgcuwGzslEWs4dTse7hu4IGRY6Gjx 8Yvkrp1yhnCdteteV/83gzXRC2pelpQdjXGJTIeAHbP+w6lCcpXKgRhyatpdxcFD1H6gRe OkS5O0a26hA9Qyaow3rLWNGTa4jO8h0rzD5AXyiLFyxsVtZzDfmlleCRz4JSuZCfZC2fjZ zV6drsz1HCWavlkWXK7sa3nu6gwv4hhMmUMpBE7pIDYqwfTfAfhS62E0EngNnA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fnqKL61S2z1QR9 for ; Sat, 04 Apr 2026 08:59:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3454c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 04 Apr 2026 08:59:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: b78e2b69893c - stable/14 - tunefs: Add tests List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: b78e2b69893ca536b738850dff556808905d07a8 Auto-Submitted: auto-generated Date: Sat, 04 Apr 2026 08:59:34 +0000 Message-Id: <69d0d2f6.3454c.3d49acc0@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b78e2b69893ca536b738850dff556808905d07a8 commit b78e2b69893ca536b738850dff556808905d07a8 Author: Dag-Erling Smørgrav AuthorDate: 2026-04-02 11:22:05 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-04-04 08:59:26 +0000 tunefs: Add tests MFC after: 1 week Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D56034 (cherry picked from commit 6630c3a73688ae3c33df892f6802bea5b8460e17) --- etc/mtree/BSD.tests.dist | 2 + sbin/tunefs/Makefile | 4 + sbin/tunefs/tests/Makefile | 4 + sbin/tunefs/tests/tunefs_test.sh | 189 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 199 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index f5d683630c92..574a41378a90 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -487,6 +487,8 @@ .. sysctl .. + tunefs + .. .. secure lib diff --git a/sbin/tunefs/Makefile b/sbin/tunefs/Makefile index de9529386071..67a160827e26 100644 --- a/sbin/tunefs/Makefile +++ b/sbin/tunefs/Makefile @@ -1,4 +1,5 @@ # @(#)Makefile 8.1 (Berkeley) 6/5/93 +.include PACKAGE=ufs PROG= tunefs @@ -10,4 +11,7 @@ MOUNT= ${SRCTOP}/sbin/mount CFLAGS+= -I${MOUNT} .PATH: ${MOUNT} +HAS_TESTS= +SUBDIR.${MK_TESTS}= tests + .include diff --git a/sbin/tunefs/tests/Makefile b/sbin/tunefs/tests/Makefile new file mode 100644 index 000000000000..3a5245633dea --- /dev/null +++ b/sbin/tunefs/tests/Makefile @@ -0,0 +1,4 @@ +PACKAGE= tests +ATF_TESTS_SH= tunefs_test + +.include diff --git a/sbin/tunefs/tests/tunefs_test.sh b/sbin/tunefs/tests/tunefs_test.sh new file mode 100755 index 000000000000..5df8dca1137e --- /dev/null +++ b/sbin/tunefs/tests/tunefs_test.sh @@ -0,0 +1,189 @@ +# +# Copyright (c) 2026 Dag-Erling Smørgrav +# +# SPDX-License-Identifier: BSD-2-Clause +# + +# Create a small file system to experiment on +tunefs_setup() +{ + atf_check -o save:dev mdconfig -t malloc -s 16M + tunefs_dev=/dev/$(cat dev) + atf_check -o ignore newfs "$@" $tunefs_dev +} + +# Verify that the changes we ask tunefs to perform are applied to the +# test file system +tunefs_test() +{ + local opt=$1 # tunefs option + local name=$2 # what tunefs(8) calls it + local descr=${3:-$name} # what file(1) calls it, if different + + # Verify that the optin is not enabled + atf_check -o not-match:"$name" \ + file -s $tunefs_dev + + # Enable the option and verify that it is enabled + atf_check -e match:"$name set" -o ignore \ + tunefs $opt enable $tunefs_dev + atf_check -o match:"$descr" \ + file -s $tunefs_dev + + # Enable it again and verify that it is still enabled + atf_check -e match:"$name remains unchanged as enabled" \ + tunefs $opt enable $tunefs_dev + atf_check -o match:"$descr" \ + file -s $tunefs_dev + + # Disable the option and verify that it is disabled + atf_check -e match:"$name cleared" -o ignore \ + tunefs $opt disable $tunefs_dev + atf_check -o not-match:"$descr" \ + file -s $tunefs_dev + + # Disable it again and verify that it is still disabled + atf_check -e match:"$name remains unchanged as disabled" \ + tunefs $opt disable $tunefs_dev + atf_check -o not-match:"$descr" \ + file -s $tunefs_dev +} + +# Clean up after ourselves +tunefs_cleanup() +{ + # Destroy the test file system + if [ -f dev ]; then + mdconfig -d -u $(cat dev) || true + fi +} + +# POSIX.1e ACLs +atf_test_case posixacl cleanup +posixacl_head() +{ + atf_set descr "Turn POSIX.1e ACLs on and off" + atf_set require.user "root" +} +posixacl_body() +{ + tunefs_setup + tunefs_test -a "POSIX.1e ACLs" +} +posixacl_cleanup() +{ + tunefs_cleanup +} + +# NFSv4 ACLs +atf_test_case nfs4acl cleanup +nfs4acl_head() +{ + atf_set descr "Turn NFSv4 ACLs on and off" + atf_set require.user "root" +} +nfs4acl_body() +{ + tunefs_setup + tunefs_test -N "NFSv4 ACLs" +} +nfs4acl_cleanup() +{ + tunefs_cleanup +} + +# Soft Updates (no journaling) +atf_test_case sunoj cleanup +sunoj_head() +{ + atf_set descr "Turn Soft Updates on and off" + atf_set require.user "root" +} +sunoj_body() +{ + tunefs_setup -u + tunefs_test -n "soft updates" +} +sunoj_cleanup() +{ + tunefs_cleanup +} + +# Soft Updates journaling +atf_test_case suj cleanup +suj_head() +{ + atf_set descr "Turn Soft Updates journaling on and off" + atf_set require.user "root" +} +suj_body() +{ + tunefs_setup + tunefs_test -j "soft updates journaling" +} +suj_cleanup() +{ + tunefs_cleanup +} + +# GEOM journaling +atf_test_case gjournal cleanup +gjournal_head() +{ + atf_set descr "Turn GEOM journaling on and off" + atf_set require.user "root" +} +gjournal_body() +{ + tunefs_setup -u + tunefs_test -J "gjournal" "GEOM journaling" +} +gjournal_cleanup() +{ + tunefs_cleanup +} + +# Try combining Soft Updates with GEOM journaling +atf_test_case conflict cleanup +conflict_head() +{ + atf_set descr "Soft Updates and GEOM journaling are mutually exclusive" + atf_set require.user "root" +} +conflict_body() +{ + tunefs_setup -U + + # Verify that SU is enabled + atf_check -o match:"soft updates" \ + file -s $tunefs_dev + # Verify that enabling gjournal fails + atf_check -e match:"cannot be enabled" \ + tunefs -J enable $tunefs_dev + # Now turn SU off + atf_check -e match:"soft updates cleared" \ + tunefs -n disable $tunefs_dev + # Enable gjournal + atf_check -e match:"gjournal set" \ + tunefs -J enable $tunefs_dev + # Verify that enabling SU+J fails + atf_check -e match:"cannot be enabled" \ + tunefs -j enable $tunefs_dev + # Verify that enabling SU alone fails + atf_check -e match:"cannot be enabled" \ + tunefs -n enable $tunefs_dev +} +conflict_cleanup() +{ + tunefs_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case posixacl + atf_add_test_case nfs4acl + atf_add_test_case sunoj + atf_add_test_case suj + atf_add_test_case gjournal + atf_add_test_case conflict +}