[igt-dev] [PATCH v3 3/3] core_getversion: Test for desired device

Rob Clark robdclark at gmail.com
Wed Sep 27 17:46:30 UTC 2023


On Wed, Sep 27, 2023 at 9:42 AM Kamil Konieczny
<kamil.konieczny at linux.intel.com> wrote:
>
> Hi Rob,
>
> On 2023-09-26 at 11:47:47 -0700, Rob Clark wrote:
> > From: Rob Clark <robdclark at chromium.org>
> >
> > We discovered in drm/ci that if the drm device fails to probe, all the
> > tests come back as "Skip" and the job is considered successful. Fix
> > the getversion test to fail if there is no drm device or if the drm
> > device does not match the expected device as specified by the optional
> > IGT_REQUIRED_DRIVER environment variable.
> >
> > Signed-off-by: Rob Clark <robdclark at chromium.org>
> > Acked-by: Helen Koike <helen.koike at collabora.com>
> > ---
> >  tests/core_getversion.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/tests/core_getversion.c b/tests/core_getversion.c
> > index 32cb976e4923..b298a6890ef9 100644
> > --- a/tests/core_getversion.c
> > +++ b/tests/core_getversion.c
> > @@ -48,14 +48,25 @@ igt_simple_main
> >  {
> >       int fd;
> >       drmVersionPtr v;
> > +     const char *name = getenv("IGT_REQUIRED_DRIVER");
> > +     int chipset = DRIVER_ANY;
> >
> > -     fd = drm_open_driver(DRIVER_ANY);
> > +     if (name)
> > +             chipset = drm_find_chipset(name);
>
> This will not work as you want, it will load your driver
> instead of DRIVER_ANY, imho leave this line as is:

That is fine for the intended use-case.

>
>         fd = drm_open_driver(DRIVER_ANY);
>
> and drop taking chipset.
>
> > +
> > +     fd = __drm_open_driver(chipset);
> > +     igt_assert_fd(fd);
>
> I tested this on machine with i915 driver and when running:
>
> build/tests# IGT_REQUIRED_DRIVER=v3d ./core_getversion
>
> it failed on following assert:
>
> (core_getversion:577767) igt_kmod-DEBUG: Unknown symbol in module v3d or unknown parameter
> (core_getversion:577767) CRITICAL: Failed assertion: fd >= 0
>
> After my changes:
> (core_getversion:577941) CRITICAL: Expected driver "v3d" but got "i915"

That makes the error msg a bit more clear, but as Daniel Stone pointed
out earlier, DRIVER_ANY won't do the right thing if you have multiple
GPUs from different vendors.  (OTOH I guess most of igt will also not
dtrt in that scenario.)

BR,
-R

>
> Regards,
> Kamil
>
> >       v = drmGetVersion(fd);
> >       igt_assert_neq(strlen(v->name), 0);
> >       igt_assert_neq(strlen(v->date), 0);
> >       igt_assert_neq(strlen(v->desc), 0);
> >       if (is_i915_device(fd))
> >               igt_assert_lte(1, v->version_major);
> > +     if (name) {
> > +             igt_assert_f(!strcmp(name, v->name),
> > +                          "Expected driver \"%s\" but got \"%s\"\n",
> > +                          name, v->name);
> > +     }
> >
> >       drmFree(v);
> >       drm_close_driver(fd);
> > --
> > 2.41.0
> >


More information about the igt-dev mailing list