[igt-dev] [PATCH 1/2] tests/fbdev: Store framebuffer pointer at function scope
Daniel Vetter
daniel.vetter at ffwll.ch
Tue Nov 3 12:01:14 UTC 2020
On Tue, Nov 3, 2020 at 11:48 AM Thomas Zimmermann <tzimmermann at suse.de> wrote:
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
Quick intro to igt subtests: They can be enumerated without running
them (--list-subtest), which skips everything in these blocks, and
they can be run individually (with --run-subtest).
This means if you extract setup code into common code, you have to
pull it all out into igt_fixtures. But that also complicates the test
flow if e.g. another test would be trying to unload the fbdev driver,
so generally only a good idea if you need a given pieces of setup for
all tests (or a set of tests in an igt_subtest_group) and the code is
expensive enough to warrant the extraction.
I'd just extract this into an fbdev mmap helper here that you can call
from test functions as needed. That's simpler.
-Daniel
> ---
> tests/fbdev.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tests/fbdev.c b/tests/fbdev.c
> index e5efeb93..11df954d 100644
> --- a/tests/fbdev.c
> +++ b/tests/fbdev.c
> @@ -42,6 +42,7 @@ igt_main
> struct fb_var_screeninfo var_info;
> struct fb_fix_screeninfo fix_info;
> int fd = -1;
> + void *map = NULL;
>
> /*
> * Should this test focus on the fbdev independent of any drm driver,
> @@ -71,7 +72,6 @@ igt_main
> }
>
> igt_subtest("mmap") {
> - void *map;
>
> igt_require(fix_info.smem_len);
>
> @@ -80,10 +80,11 @@ igt_main
> igt_assert(map != MAP_FAILED);
>
> memset(map, 0, fix_info.smem_len);
> - munmap(map, fix_info.smem_len);
> }
>
> igt_fixture {
> + if (map && map != MAP_FAILED)
> + munmap(map, fix_info.smem_len);
> close(fd);
> }
> }
> --
> 2.29.0
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the igt-dev
mailing list