tests: Skip all tests that require mdconfig when /dev/mdctl missing

When run in a jail, /dev/mdctl is missing. So skip any tests that use
mdconfig or mdmfs with md in this case: they can't possibly work. This
is in line with other tests that test for presence of required features
and skip if they aren't present. I did this instead of checking for
jails so they can still run in jails that allow creation of md devices.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2023-09-02 13:12:31 -06:00
parent 32988c1499
commit ea82362219
11 changed files with 30 additions and 0 deletions

View File

@ -43,6 +43,10 @@ if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP you must be root" echo "1..0 # SKIP you must be root"
exit 0 exit 0
fi fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..4" echo "1..4"

View File

@ -45,6 +45,10 @@ if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP you must be root" echo "1..0 # SKIP you must be root"
exit 0 exit 0
fi fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..4" echo "1..4"

View File

@ -43,6 +43,10 @@ if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP you must be root" echo "1..0 # SKIP you must be root"
exit 0 exit 0
fi fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..4" echo "1..4"

View File

@ -40,6 +40,10 @@ if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP you must be root" echo "1..0 # SKIP you must be root"
exit 0 exit 0
fi fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..5" echo "1..5"

View File

@ -37,6 +37,10 @@ if [ $(id -u) -ne 0 ]; then
echo "1..0 # SKIP you must be root" echo "1..0 # SKIP you must be root"
exit 0 exit 0
fi fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..3" echo "1..3"

View File

@ -280,6 +280,7 @@ cache_010_neg_body()
. $(atf_get_srcdir)/cache.kshlib . $(atf_get_srcdir)/cache.kshlib
. $(atf_get_srcdir)/cache.cfg . $(atf_get_srcdir)/cache.cfg
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
verify_disk_count "$DISKS" 1 verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/cache_010_neg.ksh || atf_fail "Testcase failed" ksh93 $(atf_get_srcdir)/cache_010_neg.ksh || atf_fail "Testcase failed"

View File

@ -8,6 +8,7 @@ attach_md()
{ {
local test_md local test_md
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)" test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)"
echo $test_md >> $TEST_MDS_FILE || exit echo $test_md >> $TEST_MDS_FILE || exit
echo $test_md echo $test_md

View File

@ -16,6 +16,7 @@ attach_md()
{ {
local test_md local test_md
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
test_md=$(mdconfig -a "$@") || exit test_md=$(mdconfig -a "$@") || exit
echo $test_md >> $TEST_MDS_FILE || exit echo $test_md >> $TEST_MDS_FILE || exit
echo $test_md echo $test_md

View File

@ -4,6 +4,11 @@
. `dirname $0`/conf.sh . `dirname $0`/conf.sh
if ! [ -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo 1..1 echo 1..1
ddbs=2048 ddbs=2048

View File

@ -124,6 +124,7 @@ alloc_md()
{ {
local md local md
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
md=$(mdconfig -a -t swap -s 256M) || atf_fail "mdconfig -a failed" md=$(mdconfig -a -t swap -s 256M) || atf_fail "mdconfig -a failed"
echo ${md} >> $MD_DEVS echo ${md} >> $MD_DEVS
echo ${md} echo ${md}

View File

@ -27,6 +27,7 @@ setup()
{ {
check_ko check_ko
mkdir mnt mkdir mnt
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
mdmfs -s 25m md mnt \ mdmfs -s 25m md mnt \
|| atf_fail "failed to mount md device" || atf_fail "failed to mount md device"
chmod a+rwx mnt chmod a+rwx mnt