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"
exit 0
fi
if [ ! -c /dev/mdctl ]; then
echo "1..0 # SKIP no /dev/mdctl to create md devices"
exit 0
fi
echo "1..4"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,7 @@ attach_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)"
echo $test_md >> $TEST_MDS_FILE || exit
echo $test_md

View file

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

View file

@ -4,6 +4,11 @@
. `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
ddbs=2048

View file

@ -124,6 +124,7 @@ alloc_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"
echo ${md} >> $MD_DEVS
echo ${md}

View file

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