git: e78dc78e517a - main - testing: skip tarfs tests if module is not loadable.

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Wed, 01 Mar 2023 21:23:59 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=e78dc78e517ae36143973dd2675da8ec93c4951e

commit e78dc78e517ae36143973dd2675da8ec93c4951e
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2023-03-01 20:26:54 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2023-03-01 21:23:07 +0000

    testing: skip tarfs tests if module is not loadable.
    
    Approved by:    asomers
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D38828
---
 tests/sys/fs/tarfs/tarfs_test.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/sys/fs/tarfs/tarfs_test.sh b/tests/sys/fs/tarfs/tarfs_test.sh
index 15319e249034..388a78efa476 100644
--- a/tests/sys/fs/tarfs/tarfs_test.sh
+++ b/tests/sys/fs/tarfs/tarfs_test.sh
@@ -38,6 +38,7 @@ tarfs_basic_head() {
 	atf_set "require.user" "root"
 }
 tarfs_basic_body() {
+	kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
 	mkdir "${mnt}"
 	"${mktar}" tarfs_test.tar.zst
 	atf_check mount -rt tarfs tarfs_test.tar.zst "${mnt}"
@@ -47,7 +48,7 @@ tarfs_basic_body() {
 	atf_check_equal "$(sha256 -q "${mnt}"/sparse_file)" ${sum}
 }
 tarfs_basic_cleanup() {
-	umount "${mnt}"
+	umount "${mnt}" || true
 }
 
 atf_test_case tarfs_notdir_device cleanup
@@ -56,6 +57,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}"
 	atf_check mknod d b 0xdead 0xbeef
 	tar cf tarfs_notdir.tar d
@@ -76,6 +78,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}"
 	echo "hello" >d
 	tar cf tarfs_notdir.tar d
@@ -96,6 +99,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}"
 	echo "hello" >d
 	tar cf tarfs_notdir.tar d
@@ -116,6 +120,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}"
 	echo "hello" >d
 	tar cf tarfs_notdir.tar d