Bug 236841 - Check geom_nop.ko module for sys/geom/class/nop/nop_test
Summary: Check geom_nop.ko module for sys/geom/class/nop/nop_test
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Enji Cooper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-27 23:30 UTC by Olivier Cochard
Modified: 2019-04-05 17:53 UTC (History)
3 users (show)

See Also:


Attachments
patch to skip sys/geom/class/nop/nop_test if geom_nop.ko not installed (348 bytes, patch)
2019-03-27 23:30 UTC, Olivier Cochard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Cochard freebsd_committer freebsd_triage 2019-03-27 23:30:14 UTC
Created attachment 203200 [details]
patch to skip sys/geom/class/nop/nop_test if geom_nop.ko not installed

On my nanobsd system I didn't have geom_nop.ko module installed, so this test failed.
Here is a patch to check for /boot/kernel/geom_nop.ko.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2019-03-28 00:21:27 UTC
Comment on attachment 203200 [details]
patch to skip sys/geom/class/nop/nop_test if geom_nop.ko not installed

This patch isn't right.  The "load_gnop" function should already skip the test if it can't load the g_nop module.  That function must not be working correctly.  What error do you get?
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2019-03-28 01:01:21 UTC
This is the error:

$ geom nop load
geom: Invalid class name.
$
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2019-03-28 01:52:54 UTC
Ok, this partly boils down to a change introduced in r274631...

$ git diff 2cfe78eed8ed3^..2cfe78eed8ed3
diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c
index 8c15c2143e1e..5d23d933ec94 100644
--- a/sbin/geom/core/geom.c
+++ b/sbin/geom/core/geom.c
@@ -640,6 +640,11 @@ get_class(int *argc, char ***argv)
 #endif /* !STATIC_GEOM_CLASSES */
 
        set_class_name();
+
+       /* If we can't load or list, it's not a class. */
+       if (!std_available("load") && !std_available("list"))
+               errx(EXIT_FAILURE, "Invalid class name.");
+
        if (*argc < 1)
                usage();
 }

... and this code:

1318         if (sysctlbyname("kern.module_path", paths, &len, NULL, 0) < 0)
1319                 err(EXIT_FAILURE, "sysctl(kern.module_path)");
1320         for (p = strtok(paths, ";"); p != NULL; p = strtok(NULL, ";")) {
1321                 snprintf(name, sizeof(name), "%s/geom_%s.ko", p, class_name);
1322                 /*
1323                  * If geom_<name>.ko file exists, "load" command is available.
1324                  */
1325                 if (stat(name, &sb) == 0)
1326                         return (1);
1327         }
1328         return (0);

If the module doesn't exist, it will fail with `EXIT_FAILURE`.

Why doesn't the test get skipped though?

It looks like all of the load_gnop calls are kosher:

$ grep -c load_gnop tests/sys/geom/class/nop/nop_test.sh
8
$ grep -c atf_add_test_case tests/sys/geom/class/nop/nop_test.sh
7
$
Comment 4 Enji Cooper freebsd_committer freebsd_triage 2019-03-28 01:55:13 UTC
The code looks ok... getting the actual failure would definitely help for resolving this issue.
Comment 5 Olivier Cochard freebsd_committer freebsd_triage 2019-04-05 15:20:52 UTC
So I can close this PR because it's a "normal" (real regression) ?
Comment 6 Enji Cooper freebsd_committer freebsd_triage 2019-04-05 16:30:45 UTC
(In reply to Olivier Cochard from comment #5)

I don't think we've resolved the bug quite yet.

First off, the message I pointed out in comment # 4 is misleading: it's not that the class name is invalid; it's just not available.

Second off, I'd really like to get a log of the output from your test run: both the summary from `kyua test` and the in-depth output from `kyua debug`.
Comment 7 Olivier Cochard freebsd_committer freebsd_triage 2019-04-05 16:51:26 UTC
Ouch: I was digging into my Jenkins archives to retrieve the kyua's verbose output, and I didn't found any failed test regarding geom/class/nop :-(
It's look like by digging this nop message, I've incorrectly works on the wrong tests cases (nop) but the culprit test was geom/class/mirror.
(There is another PR about geom/class/mirror).
Comment 8 Enji Cooper freebsd_committer freebsd_triage 2019-04-05 17:53:40 UTC
(In reply to Olivier Cochard from comment #7)

Ah, that's good to hear (and you're tackling that in bug 237051!).

I will close this bug, based on the summary/comment #0, but be sure to commit a change to geom to clarity what is actually going on when a class doesn't exist.