Commit Graph

35 Commits

Author SHA1 Message Date
Loïc Molinari
343adb2acd tests: Speed up runtime using immediate repaint on capture
The test suite is throttled by the headless backend repaint
timer. This commit uses the headless refresh rate option to speed up
runtime by using the immediate repaint-only-on-capture mode by
default. Tests which don't support that mode yet override the refresh
value to use the highest rate possible.

Fixes #682

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-02-22 14:26:32 +00:00
Leandro Ribeiro
bac9060d54 tests: make use of helpers to create unique filenames
Start to use the helpers introduced in "tests: add helpers to create
unique filenames".

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>

Pekka: Dropped program name from output_filename_for_test_case() calls
as it is already added automatically.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-12 14:10:44 +00:00
Marius Vlad
1e16a5eb2d tests: Add the ability the specify the output name
In preparation of having multiple outputs available we should be able to
specify by its name. We just use the default one if none was set-up at all.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-01-25 17:55:39 +00:00
Philipp Zabel
e3b64b6e76 tests: use enum weston_renderer_type
Now that enum weston_renderer_type is public, there is no need for a
local enum renderer_type in the tests.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-18 14:16:41 +01:00
Pekka Paalanen
67331be0cd tests/internal-screenshot: use image-iter.h
Simplify the code by using ready-made helpers.

This also change the loop to draw the image row by row rather than
column by column. Row by row is more natural as it is linear with the
memory layout. No other change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen
ca59c8e868 tests: fix leaks in internal-screenshot-test
Fixes all the ASan reported leaks in this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Igor Matheus Andrade Torrente
ad41a88535 tests: Add a way to write a Weston.ini inside the test
Currently doesn't exist a standard way to write a weston.ini inside a test.

Here, two new functions `weston_ini_setup` and `cfgln` are introduced to
help the test writer to write a weston.ini file and load it to the test.
And `internal-screenshot-test` is converted to use the new method of write
a weston.ini. This conversion serves as example and initial API test.

The tester needs to call `weston_test_harness_execute_as_client` or
`weston_test_harness_execute_as_plugin` in the same way as before.
The `weston_ini_setup` will fill the setup->config_file with the
correct path to the weston.ini file.

The main design goal is to avoid pre-made or build-made weston.ini(s)
and keep the test as self-contained as possible.

Closes:#410
Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@gmail.com>
2020-09-05 07:14:49 +00:00
Pekka Paalanen
007ab1e5a4 tests: add range argument for fuzzy image matching
The fuzzy range will be used with GL-renderer testing, as it may produce
slightly different images than Pixman-renderer yet still correct results.

Such allowed differences are due to different rounding.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-05 11:13:51 +00:00
Pekka Paalanen
9615ad8b91 tests: migrate internal-screenshot
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen
12a138d51e tests: replace fprintf() with testlog()
When we move on to TAP, stdout will be reserved for TAP and stderr is for free
chatter. Set up an example that tests should use testlog() instead of fprintf
or printf to chat in the right place.

Most statements were already printing to stderr, so this just makes then a
little shorter. There are also some statements that printed to stdout and are
now corrected.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 12:54:10 +02:00
Adam Jackson
3cfd297f2c tests: Fix undefined left shift in internal-screenshot-test
../tests/internal-screenshot-test.c:60:18: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
2019-10-16 16:07:47 -04:00
Alexandros Frantzis
2180858592 tests: Add checks for pointer motion and button event timestamps
Enhance the existing pointer motion and button event tests to
additionally verify the event timestamps. This requires updating the
weston-test protocol to support passing motion and button event
timestamps.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-12-18 11:27:43 +02:00
Jussi Kukkonen
649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Pekka Paalanen
a5bb91dcdc tests: implement visualize_image_difference()
Useful for pointing out where the image comparisons fail.

Internal-screenshot-test is modified to save the visualization if the
test fails.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
365c1296fa tests: make screenshooting return a buffer
Screenshooting does not involve creating a wl_surface, so using struct
surface is superfluous.

Return a struct buffer instead. It could have been just a
pixman_image_t, but setting up proper destruction would be a bit more
work. Should not hurt to keep the wl_buffer around until the user is
ready to free the image.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
fd10ef0f63 tests: convert image saver to pixman
This rewrites write_surface_as_png() into write_image_as_png(), which
operates on a pixman_image_t instead of a struct surface.

This is part of the migration to use pixman_image_t everywhere without
superfluous parameters/members.

Now the image saving handles more than just ARGB32 format, presumably.
At least it does not assume everything is always ARGB32.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
289fdeb019 tests: convert reference image loader to pixman
This rewrites load_surface_from_png() to load_image_from_png(), to
return a pixman_image_t instead of a struct surface.

A loaded image has no need for wl_buffer or wl_surface or any of the
associated attributes. This is part of unifying to make everything use
pixman_image_t.

cairo_surface_flush() is added, because Cairo documentation for
cairo_image_surface_get_data() says you have to flush after drawing,
before using the data. It is unclear if loading a PNG counts as drawing,
so stay on the safe side.

load_image_from_png() now pays attention to the pixel format returned by
Cairo, which seems to come out as CAIRO_FORMAT_RGB24 in
internal-screenshot-test, not as CAIRO_FORMAT_ARGB32 as expected. I do
not know if Cairo actually guarantees the x8/a8 channel to be 0xff for
RGB24, but better to not trust it. Therefore the image is explicitly
converted to a8r8g8b8 as needed. This also adds support for loading A8
and RGB16_565 images, provided that Cairo delivers them.

The cairo surface is now wrapped directly into a pixman_image_t. If the
pixel format conversion is not needed, this eliminates a copy of the
image data. The Cairo surface will get automatically destroyed with the
Pixman image.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
47d68dae59 tests: rewrite check_surfaces_*() API
check_surfaces_geometry() is removed as it was not used by anything, and
unlikely would be.

check_surfaces_equal() is merged into check_surfaces_match_in_clip(),
passing a NULL clip means to compare whole images.

check_surfaces_match_in_clip() is converted to work on pixman_image_t
instead of struct surface. The function is only concerned about
comparing images in memory, and does not care about a wl_buffer or a
wl_surface.

The verbosity of image comparisons is greatly reduced. An image mismatch
no longer prints a flood of raw pixel values. This will be replaced
later with a function writing out an error image instead.

Degenerate comparisons are no longer accepted, be that clip outside
images or zero area. Those are an indication of a programmer error.

The pixel format assumptions are made more visible in the code.

A new internal helper image_check_get_roi() computes and verifies the
area to be compared. Image iterator helper makes it simpler to write
manual pixel-poking loops.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
95e2872e9c tests: internal-screenshot-test to use create_shm_buffer_a8r8g8b8()
This removes the uses of create_shm_buffer() from this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:41:31 +03:00
Pekka Paalanen
924cd948ee tests: introduce struct buffer for client-helper
We are growing more tests that need to handle buffers, both just images
and wl_buffers. Particularly the screenshooting facility needs these.
Currently everything is in struct surface, which contains more than we
need. It is a bit messy.

Create a new struct buffer to encapsulate the image representation, the
wl_buffer, and enough information to tear it all down (munmap) so we
don't have to leak everything. Some tests might start doing things in
loops, and leaking would accumulate.

Instead of inventing our own image representation, use pixman_image_t.
It is a well-tested library worth using, and we already rely on it in
other places.

This makes the tests depend on Pixman, which requires the fix for
building buffer-count, which would otherwise not find pixman.h.

The new create_shm_buffer_a8r8g8b8() creates an image with an explicit
format, and pixman_image_t keeps track of it. And stride and size and
data. This implementation is still a little hacky due to calling
create_shm_buffer().

A very new thing is buffer_destroy(). Previously we didn't really free
any buffers. It is not a problem when the process will exit soon anyway,
but it may become a problem if tests start iterating things.

Manual memset() on a image is converted to a pixman action, just to show
how to do it properly with pixman.

Stride and pixel format assumptions still linger all around, but those
are for another patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 12:39:30 +03:00
Pekka Paalanen
e651bb021e tests: fix the cursor race in internal-screenshot
This fix also depends on "compositor-headless: do not create a seat".

If we lose the race against weston-desktop-shell setting cursors, which
is very rare, we get a cursor image in the screenshot, causing the test
to fail. This is now fixed by moving the (remaining) cursor out of the
way.

Arguably we should have better solutions for this, but that is another
story. This is a stop-gap measure we can copy also in new
screenshooting tests.

v2: Remove the example code for how to trigger the race, and rewrite the
big comment.

Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2016-06-23 18:04:19 +03:00
Bryce Harrington
892122ed64 tests: Migrate screenshot code from internal test to client helpers
These routines provide test cases an ability to capture screen images
for rendering verification.

This commit is a no-change refactoring, except for making the routines
non-static.  Makefile rules are also updated; most notably, this links
test clients against the cairo libraries now.

v2: Fix pointer code styling, suggested in review

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-09-25 11:23:08 -07:00
Seedo Eldho Paul
43af680abf tests: Convert 'xalloc's to 'zalloc's
xalloc terminates the program abruptly if the requested amount of
memory couldn't be allocated. To insure that the errors are handled
cleanly, use zalloc instead.

Signed-off-by: Seedo Eldho Paul <seedoeldhopaul@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-09-22 18:23:44 -07:00
Dawid Gajownik
74a635b1ec Coding style fixes
- opening braces are on the same line as the if statement
- opening braces are not on the same line as the function name
- space between for/while/if and opening parenthesis

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-08-07 12:01:22 -07:00
Bryce Harrington
2cc9297aca tests: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:19 -07:00
Derek Foreman
97b9b17668 internal-screenshot-test: Fix endian problem
Use bit-shifts to properly generate pixel data.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-04 17:13:22 -07:00
Bryce Harrington
a291fcb949 tests: Drop redundant debug output
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-05-26 18:03:34 -07:00
Derek Foreman
35b7f25ae3 tests/internal-screenshot: Fix test so it doesn't expect shell surfaces
We no longer have a race with shell startup because we create our own
colored surface and check that it's properly drawn.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-05-26 11:26:06 +03:00
Bryce Harrington
0ccf8e2238 tests: cleanup whitespace 2015-05-21 15:26:06 -07:00
Bryce Harrington
c919883d26 tests: Check that the PNG file's stride matches our internal assumption
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:10:37 -07:00
Bryce Harrington
111e022e91 tests: Add capture_screenshot_of_output()
Provides a convenience function for JFDI grabbing of a single
screenshot.  Tests that are doing multiple screenshots or other
fanciness probably will bypass this routine and do things more manually,
but this'll provide a reference implementation.  And hopefully there'll
be enough simple cases that this actually is useful.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:06:43 -07:00
Bryce Harrington
198f941ec8 tests: Add load_surface_from_png()
Loads an image from disk via cairo, and copies data into a weston test
surface for internal use.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:06:31 -07:00
Bryce Harrington
2eaf7d78ba tests: Add create_screenshot_surface()
Refactor out the screenshot shm buffer creation code.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:06:26 -07:00
Bryce Harrington
85e65f5fe5 tests: Add write_surface_as_png() helper
And use the helper routine for generating the output filename.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:06:15 -07:00
Bryce Harrington
fb9089d4f5 tests: Add internal test for the weston test screenshot capability
This also serves as a proof of concept of the screen capture
functionality and as a demo for snapshot-based rendering verification.
Implements screenshot saving clientside in the test itself.

This also demonstrates use of test-specific configuration files, in this
case to disable fadein animations and background images.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-05-21 15:06:11 -07:00