weston/tests/output-transforms-test.c

152 lines
4.3 KiB
C
Raw Normal View History

tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
/*
* Copyright © 2020 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include "weston-test-client-helper.h"
#include "weston-test-fixture-compositor.h"
#define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x
#define RENDERERS(s, t) \
{ \
.renderer = WESTON_RENDERER_PIXMAN, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "pixman " #s " " #t, \
}, \
{ \
.renderer = WESTON_RENDERER_GL, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "GL " #s " " #t, \
}
tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
struct setup_args {
struct fixture_metadata meta;
enum weston_renderer_type renderer;
tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
int scale;
enum wl_output_transform transform;
const char *transform_name;
};
static const struct setup_args my_setup_args[] = {
RENDERERS(1, NORMAL),
RENDERERS(1, 90),
RENDERERS(1, 180),
RENDERERS(1, 270),
RENDERERS(1, FLIPPED),
RENDERERS(1, FLIPPED_90),
RENDERERS(1, FLIPPED_180),
RENDERERS(1, FLIPPED_270),
RENDERERS(2, NORMAL),
RENDERERS(3, NORMAL),
RENDERERS(2, 90),
RENDERERS(2, 180),
RENDERERS(2, FLIPPED),
RENDERERS(3, FLIPPED_270),
};
static enum test_result_code
fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
{
struct compositor_setup setup;
/* The width and height are chosen to produce 324x240 framebuffer, to
* emulate keeping the video mode constant.
* This resolution is divisible by 2 and 3.
* Headless multiplies the given size by scale.
*/
compositor_setup_defaults(&setup);
setup.renderer = arg->renderer;
setup.width = 324 / arg->scale;
setup.height = 240 / arg->scale;
setup.scale = arg->scale;
setup.transform = arg->transform;
setup.shell = SHELL_TEST_DESKTOP;
return weston_test_harness_execute_as_client(harness, &setup);
}
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
struct buffer_args {
int scale;
enum wl_output_transform transform;
const char *transform_name;
};
static const struct buffer_args my_buffer_args[] = {
{ 1, TRANSFORM(NORMAL) },
{ 2, TRANSFORM(90) },
};
TEST_P(output_transform, my_buffer_args)
{
const struct buffer_args *bargs = data;
const struct setup_args *oargs;
struct client *client;
bool match;
char *refname;
int ret;
oargs = &my_setup_args[get_test_fixture_index()];
ret = asprintf(&refname, "output_%d-%s_buffer_%d-%s",
oargs->scale, oargs->transform_name,
bargs->scale, bargs->transform_name);
assert(ret);
testlog("%s: %s\n", get_test_name(), refname);
/*
* NOTE! The transform set below is a lie.
* Take that into account when analyzing screenshots.
*/
client = create_client();
client->surface = create_test_surface(client);
client->surface->width = 10000; /* used only for damage */
client->surface->height = 10000;
client->surface->buffer = client_buffer_from_image_file(client,
"basic-test-card",
bargs->scale);
wl_surface_set_buffer_scale(client->surface->wl_surface, bargs->scale);
wl_surface_set_buffer_transform(client->surface->wl_surface,
bargs->transform);
move_client(client, 19, 19);
match = verify_screen_content(client, refname, 0, NULL, 0, NULL);
tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
assert(match);
client_destroy(client);
tests: fix refname leaks Reported by ASan. Direct leak of 1468 byte(s) in 48 object(s) allocated from: #0 0x7f20d7ae0330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330) #1 0x7f20d76894b7 in _IO_vasprintf /build/glibc-vjB4T1/glibc-2.28/libio/vasprintf.c:73 #2 0x7f20d7a66827 in __interceptor_vasprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6f827) #3 0x7f20d7a66f76 in asprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6ff76) #4 0x5598e3fbcdfc in buffer_transform ../../git/weston/tests/buffer-transforms-test.c:122 #5 0x5598e3fc9add in run_test ../../git/weston/tests/weston-test-runner.c:162 #6 0x5598e3fca17e in run_case ../../git/weston/tests/weston-test-runner.c:277 #7 0x5598e3fc9f24 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235 #8 0x5598e3fca406 in testsuite_run ../../git/weston/tests/weston-test-runner.c:311 #9 0x7f20d3523b6b in client_thread_routine ../../git/weston/tests/weston-test.c:479 #10 0x7f20d75e8fa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486 #11 0x7f20d770a4ce in clone (/lib/x86_64-linux-gnu/libc.so.6+0xf94ce) Direct leak of 978 byte(s) in 42 object(s) allocated from: #0 0x7f26fed07330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330) #1 0x7f26fe8b04b7 in _IO_vasprintf /build/glibc-vjB4T1/glibc-2.28/libio/vasprintf.c:73 #2 0x7f26fec8d827 in __interceptor_vasprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6f827) #3 0x7f26fec8df76 in asprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6ff76) #4 0x55989ba8c2bc in output_damage ../../git/weston/tests/output-damage-test.c:201 #5 0x55989ba8c0cb in wrapoutput_damage ../../git/weston/tests/output-damage-test.c:176 #6 0x55989ba99131 in run_test ../../git/weston/tests/weston-test-runner.c:162 #7 0x55989ba997d2 in run_case ../../git/weston/tests/weston-test-runner.c:277 #8 0x55989ba99578 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235 #9 0x55989ba99a5a in testsuite_run ../../git/weston/tests/weston-test-runner.c:311 #10 0x7f26fa57ab6b in client_thread_routine ../../git/weston/tests/weston-test.c:479 #11 0x7f26fe80ffa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486 #12 0x7f26fe9314ce in clone (/lib/x86_64-linux-gnu/libc.so.6+0xf94ce) Direct leak of 1696 byte(s) in 56 object(s) allocated from: #0 0x7f077107f330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330) #1 0x7f0770c284b7 in _IO_vasprintf /build/glibc-vjB4T1/glibc-2.28/libio/vasprintf.c:73 #2 0x7f0771005827 in __interceptor_vasprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6f827) #3 0x7f0771005f76 in asprintf (/lib/x86_64-linux-gnu/libasan.so.5+0x6ff76) #4 0x563e6ae36dfc in output_transform ../../git/weston/tests/output-transforms-test.c:122 #5 0x563e6ae43add in run_test ../../git/weston/tests/weston-test-runner.c:162 #6 0x563e6ae4417e in run_case ../../git/weston/tests/weston-test-runner.c:277 #7 0x563e6ae43f24 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235 #8 0x563e6ae44406 in testsuite_run ../../git/weston/tests/weston-test-runner.c:311 #9 0x7f076ca26b6b in client_thread_routine ../../git/weston/tests/weston-test.c:479 #10 0x7f0770b87fa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486 #11 0x7f0770ca94ce in clone (/lib/x86_64-linux-gnu/libc.so.6+0xf94ce) Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-11 16:40:34 +03:00
free(refname);
tests: add output transform tests This goes through all output transforms with two different buffer transforms and verifies the visual output against reference images. This commit introduces a new test input image 'basic-test-card.png'. It is a small image with deliberately odd and indivisible dimensions to provoke bad assumptions about image sizes. It contains red, green and blue areas which are actually text that makes it very obvious if you have e.g. color channels swapped. It has a white thick circle to highlight aspect ratio issues, and an orange cross to show a mixed color. The white border is for contrast and a 1px wide detail. The whole design makes it clear if the image happens to be rotated or flipped in any way. The image has one pixel wide transparent border so that bilinear sampling filter near the edges of the image would produce the same colors with both Pixman- and GL-renderers which handle the out-of-image samples fundamentally differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while GL-renderer clamps sample coordinates to the edge essentially repeating the edge pixels. It would have been "easy" to create a full matrix of every output scale & transform x every buffer scale & transform, but that would have resulted in 2 renderers * 8 output transforms * 3 output scales * 8 buffer transforms * 3 buffer scales = 1152 test cases that would have all ran strictly serially because our test harness has no parallelism inside one test program. That would have been slow to run, and need a lot more reference images too. Instead, I chose to iterate separately through all output scales & transforms (this patch) and all buffer scales & transforms (next patch). This limits the number of test cases in this patch to 56, and allows the two test programs to run in parallel. I did not even pick all possible scale & transform combinations here, but just what I think is a representative sub-set to hopefully exercise all the code paths. https://gitlab.freedesktop.org/wayland/weston/issues/52 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-21 13:00:28 +03:00
}