Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2020 14:55:24 -0700
From:      Enji Cooper <yaneurabeya@gmail.com>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        John-Mark Gurney <jmg@funkthat.com>, freebsd-testing@freebsd.org
Subject:   Re: Querying kernel features
Message-ID:  <0CC36359-9354-4C34-BD65-C01CB15BD5E6@gmail.com>
In-Reply-To: <8B2AC268-7CA2-4FDA-BA58-FAEF7F0715BF@FreeBSD.org>
References:  <6C6C4F2B-CD11-4777-A97C-D249C514DEEA@FreeBSD.org> <20200618231944.GB4213@funkthat.com> <8B2AC268-7CA2-4FDA-BA58-FAEF7F0715BF@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Jun 19, 2020, at 10:47 AM, Kristof Provost <kp@FreeBSD.org> wrote:
>=20
> On 19 Jun 2020, at 1:19, John-Mark Gurney wrote:
>> Kristof Provost wrote this message on Thu, Jun 18, 2020 at 22:57 =
+0200:
>>> Say that I have a test for an optional kernel feature (say ALTQ, or
>>> TMPFS) is there an elegant way of figuring out at runtime if it???s
>>> available?
>>>=20
>>> Doing `sysctl kern.conftxt | grep ALTQ` feels a little inelegant, =
and is
>>> begging for issues with incorrect matches.
>>>=20
>>> I???m tempted to add a sysctl node for ALTQ, but perhaps there???s a
>>> better way. Or perhaps this should be a general feature (so we???d =
have
>>> nodes like kernel.feature.tmpfs=3D1).
>>=20
>> Look at kern.features...  There's a FEATURE macro to add entries to
>> that, but looks like there isn't any man page for it...
>>=20
>> sys/geom/eli/g_eli.c:FEATURE(geom_eli, "GEOM crypto module");
>>=20
> Ah, thanks, that=E2=80=99s pretty much exactly what I was looking for.
>=20
> There is a man page for feature_present(3), which is a C function to =
check for the presence of a given feature. It does the sysctl for you.
> That=E2=80=99s not quite what I need (atf-sh make sysctl the easiest =
interface), but I figured I=E2=80=99d point out at least something is =
documented.

There are some convenience macros in tests/freebsd_test_suite/macros.h . =
I=E2=80=99ll work on adding some atf-sh available functions for the lot =
(seeing as there isn=E2=80=99t really any good documentation for it =
anywhere).
HTH,
-Enji=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0CC36359-9354-4C34-BD65-C01CB15BD5E6>