[igt-dev] [PATCH v3 2/8] tests/fbdev: Map framebuffer in igt_fixture
Petri Latvala
petri.latvala at intel.com
Wed Nov 11 09:49:30 UTC 2020
On Tue, Nov 10, 2020 at 08:50:56AM +0100, Thomas Zimmermann wrote:
> The mapping of the framebuffer memory will be useful for read/write
> tests. Move it into an igt_fixture block.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
> tests/fbdev.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/tests/fbdev.c b/tests/fbdev.c
> index 46641fea..fc66210a 100644
> --- a/tests/fbdev.c
> +++ b/tests/fbdev.c
> @@ -63,15 +63,10 @@ static void mode_tests(int fd)
> static void framebuffer_tests(int fd)
> {
> struct fb_fix_screeninfo fix_info;
> + void *map;
After this patch, map is assigned to in an igt_fixture and read in a
subtest. As igt_fixture uses longjmp(), the value of map when read
depends on whether this is compiled with or without optimizations.
The options for such variables are:
1) move it to global scope
2) make it volatile
3) make a struct data_d with the map (and in a later patch, buf as
well) variable and assign its members instead.
I think we prefer 3 generally.
--
Petri Latvala
>
> igt_fixture {
> igt_require(ioctl(fd, FBIOGET_FSCREENINFO, &fix_info) == 0);
> - }
> -
> - igt_describe("Check mmap operations on framebuffer memory");
> - igt_subtest("mmap") {
> - void *map;
> -
> igt_require(fix_info.smem_len);
>
> map = mmap(NULL, fix_info.smem_len,
> @@ -79,6 +74,9 @@ static void framebuffer_tests(int fd)
> igt_assert(map != MAP_FAILED);
>
> memset(map, 0, fix_info.smem_len);
> + }
> +
> + igt_fixture {
> munmap(map, fix_info.smem_len);
> }
> }
> --
> 2.29.2
>
More information about the igt-dev
mailing list