This test script is using geom_nop, so reuse the same function (load_gnop) as
in geom/class/nop/nop_test to skip this test if geom_nop is not available.
PR/237051
Details
Should skip if geom_nop or geom_mirror are missing:
kldunload geom_nop
mv /boot/kernel/geom_nop.ko /boot/kernel/geom_nop.ko.bak
kyua test sys/geom/class/mirror/component_selection:run_latest_genid
sys/geom/class/mirror/component_selection:run_latest_genid -> skipped: could not load module for geom nop [0.016s]
Results file id is usr_tests.20190418-155208-306874
Results saved to /root/.kyua/store/results.usr_tests.20190418-155208-306874.db
1/1 passed (0 failed)
mv /boot/kernel/geom_nop.ko.bak /boot/kernel/geom_nop.ko
kldunload geom_mirror
mv /boot/kernel/geom_mirror.ko /boot/kernel/geom_mirror.ko.bak
kyua test sys/geom/class/mirror/component_selection:run_latest_genid
sys/geom/class/mirror/component_selection:run_latest_genid -> skipped: could not load module for geom mirror [0.015s]
Results file id is usr_tests.20190418-155511-102333
Results saved to /root/.kyua/store/results.usr_tests.20190418-155511-102333.db
1/1 passed (0 failed)
mv /boot/kernel/geom_mirror.ko.bak /boot/kernel/geom_mirror.ko
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Warnings Severity Location Code Message Warning tests/sys/geom/class/mirror/component_selection.sh: CHMOD1 Invalid Executable - Unit
No Test Coverage - Build Status
Buildable 23744 Build 22703: arc lint + arc unit
Event Timeline
tests/sys/geom/class/mirror/component_selection.sh | ||
---|---|---|
139 | This should be geom_mirror and geom_nop, not g_mirror and g_nop. |
tests/sys/geom/class/mirror/component_selection.sh | ||
---|---|---|
139 | Are you sure ? # kldload geom_nop # kldstat -q -m g_nop && echo yes || echo no yes # kldstat -q -m geom_nop && echo yes || echo no no # kldload geom_mirror # kldstat -q -m g_mirror && echo yes || echo no yes # kldstat -q -m geom_mirror && echo yes || echo no no # uname -a FreeBSD lame4.bsdrp.net 13.0-CURRENT FreeBSD 13.0-CURRENT r344580 GENERIC-NODEBUG amd64 |
tests/sys/geom/class/mirror/component_selection.sh | ||
---|---|---|
139 | So the mod names are different than the file names? Lame. I guess the diff is ok, then. |
tests/sys/geom/class/mirror/component_selection.sh | ||
---|---|---|
139 | @olivier: your proposed change is correct. Here's some other code that code similar for the TAP format tests: 49 geom_load_class_if_needed() 50 { 51 local class=$1 52 53 # If the geom class isn't already loaded, try loading it. 54 if ! kldstat -q -m g_${class}; then 55 if ! geom ${class} load; then 56 echo "could not load module for geom class=${class}" 57 return 1 58 fi 59 fi 60 return 0 61 } $ grep -r load_class_if_needed tests/sys/geom/class/ tests/sys/geom/class/geom_subr.sh:geom_load_class_if_needed() tests/sys/geom/class/geom_subr.sh: if ! error_message=$(geom_load_class_if_needed $class); then tests/sys/geom/class/geom_subr.sh: if ! error_message=$(geom_load_class_if_needed $class); then tests/sys/geom/class/eli/misc_test.sh: if ! error_message=$(geom_load_class_if_needed nop); then BTW, you can leverage this logic. Just be sure to set ATF_TEST=true above in the test script when doing so, otherwise, it will treat it like a TAP test. Bottom line is this could be condensed to a few lines: # Global variables ATF_TEST=true class=mirror ... # In the test function. geom_atf_test_setup if ! error_message=$(geom_load_class_if_needed nop); then atf_skip "$error_message" fi |
tests/sys/geom/class/mirror/component_selection.sh | ||
---|---|---|
139 | I forgot to add that you'll need to source . $(atf_get_srcdir)/conf.sh in the global space after defining ATF_TEST and class in order to access the geom_atf_test_setup function, etc. |
@olivier: Approved! Please be sure to update the commit message before you commit. Thank you so very much <3!