Page MenuHomeFreeBSD

Skip test component_selection:run_latest_genid if gmirror/gnop GEOM classes aren't available
ClosedPublic

Authored by olivier on Apr 18 2019, 3:56 PM.
Tags
None
Referenced Files
F103598051: D19958.diff
Tue, Nov 26, 11:20 PM
Unknown Object (File)
Sep 24 2024, 8:55 AM
Unknown Object (File)
Sep 24 2024, 3:48 AM
Unknown Object (File)
Sep 23 2024, 2:22 PM
Unknown Object (File)
Sep 22 2024, 12:56 AM
Unknown Object (File)
Sep 21 2024, 3:53 PM
Unknown Object (File)
Sep 20 2024, 4:34 PM
Unknown Object (File)
Sep 17 2024, 8:23 PM
Subscribers

Details

Summary

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

Test Plan

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

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

asomers requested changes to this revision.Apr 18 2019, 4:04 PM
asomers added inline comments.
tests/sys/geom/class/mirror/component_selection.sh
139

This should be geom_mirror and geom_nop, not g_mirror and g_nop.

This revision now requires changes to proceed.Apr 18 2019, 4:04 PM
tests/sys/geom/class/mirror/component_selection.sh
139

Are you sure ?
Because:

# 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
asomers added inline comments.
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.

This revision is now accepted and ready to land.Apr 23 2019, 2:46 PM
ngie requested changes to this revision.Apr 23 2019, 2:47 PM
ngie added inline comments.
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
This revision now requires changes to proceed.Apr 23 2019, 2:47 PM
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 retitled this revision from Skip test component_selection:run_latest_genid if gmirror/gnop GEOM classes aren't available to Skip test component_selection:run_latest_genid if gmirror/gnop GEOMclasses aren't available.

Applying ngie's comments

ngie retitled this revision from Skip test component_selection:run_latest_genid if gmirror/gnop GEOMclasses aren't available to Skip test component_selection:run_latest_genid if gmirror/gnop GEOM classes aren't available.

@olivier: Approved! Please be sure to update the commit message before you commit. Thank you so very much <3!

This revision is now accepted and ready to land.Apr 23 2019, 7:59 PM
This revision was automatically updated to reflect the committed changes.