Commit graph

723 commits

Author SHA1 Message Date
Daniel Stone 2ebdf0a7f3 subsurface-shot-test: Don't leak replaced buffer
Destroy the buffer we've overwritten.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:22 +01:00
Daniel Stone 5374d55f6a safe-signal-test: Fix leak
Oops.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone ed97387a4e tests: Use test-desktop-shell for devices-test
It doesn't need to be using desktop-shell; trying to use it is not
sensible as it will try to bind to all the devices we're repeatedly
creating and destroying, sometimes lose the race, and fail the test
because desktop-shell has died too early.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 11:38:36 +00:00
Daniel Stone 9336263d9b Move libweston-desktop into libweston
It's not really useful to have libweston without libweston-desktop. It's
also very little code.

Merging both into the same DSO will allow us to cut out a bunch of
indirection and pain.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-28 10:35:52 +00:00
Daniel Stone c0ff9ed24a test-desktop-shell: Mark weston_curtain views as mapped
Make sure we're there when we need them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-16 12:17:15 +03:00
Daniel Stone 0c69688aa2 libweston: Add weston_surface_map() wrapper
Change all instances of surface->is_mapped = true, to a specialised
function.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-16 12:17:15 +03:00
Pekka Paalanen f212a703cf tests/alpha-blend: use image-iter.h
Simplify the code by using ready-made helpers.

No change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00: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 884c5f80e8 tests/yuv-buffer: use image-iter.h for rgb_image
Make use of the shared code instead of open-coding everywhere. This
should make the code easier to read, and reduce the chance of typos if
changes are needed in the future.

No change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen 94589497a1 tests/client-helper: use image_header_from() more
These are the last places in weston-test-client-helper.c where using
image_header_from() will reduce the code line count and simplify the
code a little.

No change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen 791a6be216 tests: pass image_header to image_check_get_roi()
Make use of the new type to shorten the code.

No change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen 4eb70a602b tests/client-helper: use image-iter.h
Replace private pixel iterator helpers with the shared ones.

No change in behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen 9b82bfae9e tests/color-icc-output: extract image-iter.h
Move the struct image_header and get_image_prop() into a header where we
can share these useful helpers between more test code. While doing that,
drop the unused field 'depth', rename into image_header_from(), and
introduce a helper to get u32 pointer to the beginning of a row. These
helpers should make pixel iterating code easier to read and safer (less
room for mistakes in address computations, and asserts).

Use the shared 'struct image_header' instead of the local one. The
intention is to make the code easier to read by using the same helpers
everywhere.

Width, height and stride use type 'int' because Pixman API uses that
too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-16 08:52:12 +00:00
Pekka Paalanen 4d2ea5dd0b tests: move set_opaque_rect() to client helpers
I will be needing it in a new test, so let's share it.

For convenience, this also adds client back-pointer in struct surface so
that I don't need to pass client explicitly.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-15 12:36:05 +03:00
Pekka Paalanen b878357dfd tests: remove skip() as unused
skip() is a left-over from an old test harness design, the comment even
refers to automake. Calling skip() cannot do anything good anymore,
because it wouldn't print the skips in the TAP report, so it would
probably be considered a failure.

Delete this unused and nowadays incorrect function, so it doesn't
confuse people.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-15 12:36:05 +03:00
Pekka Paalanen 731a2fd45b tests/color-icc-output: move gen_ramp_rgb() in the file
Move gen_ramp_rgb() down in the file where the TEST() specific code
begins. This way we first have a big block of fixture setup code which
creates an ICC profile, and the next big block is the actual test client
code. gen_ramp_rgb() belongs with the latter.

This makes the file structure slightly more logical.

This is a pure code move, no changes at all.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-10 10:49:47 +00:00
Pekka Paalanen cb38c9c84d tests: rename shaper_matrix_and_cLUT to opaque_pixel_conversion
This name describes better what this test does. In the future another
TEST() for alpha blending will be added. Both of them will be using
matrix-shaper and cLUT output profiles.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-10 10:49:47 +00:00
Pekka Paalanen 6393e43357 tests: rename color-shaper-matrix-test.c to color-icc-output-test.c
The new name better matches the contents of the test.

Currently the test creates output ICC profiles with matrix-shaper and
cLUT forms, and tests that basic color conversion from input to output
color space is correct.

The common theme in this test program is to create ICC profiles to be
used as output profiles. In the future this can include more kinds of
testing, e.g. linear blending. OTOH, this test program will always be
limited to SDR because HDR testing probably will not use ICC files.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-10 10:49:47 +00:00
Vitaly Prosyak 0c5860fafb tests/color-shaper-matrix: add creation and usage cLUT profiles
Added cLUT profile creation to validate linearization algorithm
for DToB3 tag (direction dev to PCS). The 3DLUT is
built by using raw matrix conversion from dev to XYZ and reverse
(XYZ to device).

The test uses floating point pipeline, known as unbounded mode of LCMS.
The details are described in ICCSpecRevision_02_11_06_Float.pdf

The purpose of these new test cases is to keep the GL-renderer 3D LUT
path tested even after color-lcms and GL-renderer start using
specialized matrix-shaper paths.

These also exercise build_eotf_from_clut_profile() in color-lcms, but do
not actually verify it. These cases only test that the recovered EOTF
and its inverse produce an identity mapping together.

BT.2020 is not used in these tests, because the RGB-XYZ conversion
matrix does not stay inside [0.0, 1.0] in either direction, which would
be a problem for the 3D LUT element in the multiProcessingElement
pipelines. Handling that would have been possible, but testing with
AdobeRGB color space should suffice while keeping the test code from
being even more complicated.

roundtrip_verification() tests that we succeed in creating cms
pipelines correctly in both directions so that the resulting ICC file is
better behaved. The Weston test itself only cares about the BToD
direction.

Credits to:
Vladimir  Lachine <vladimir.lachine@amd.com>
Graeme Gill <graeme@argyllcms.com>
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 276d1ae024 tests/color-shaper-matrix: add ref image index
This makes it easy to re-use existing reference images for further test
cases.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Vitaly Prosyak 6478859b4f tests/color-shaper-matrix: prepare for cLUT type profiles
We will want to run the same color spaces with different types of ICC
profiles. To help with that:

1. Let struct lcms_pipeline define the test color space and
   transformations and move the tolerance into a new per test case
   structure.

2. Added profile type: PTYPE_MATRIX_SHAPER, PTYPE_CLUT.
   PTYPE_MATRIX_SHAPER is the previously implemented type.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 062b6646ff tests/color-shaper-matrix: fix realpath() leak
Found with ASan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 5921a00b38 tests/lcms_util: add SetTextTags()
This function sets some basic text tags to make an ICC file better
formed.

The code is taken from LittleCMS, https://github.com/mm2/Little-CMS.git
git revision
lcms2.13.1-28-g6ae2e99 (6ae2e99a3535417ca5c95b602eb61fdd29d294d0)
file src/cmsvirt.c.

Suggested-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 44c3079567 tests: add lcms-util with MPE curves
This adds a new test helper library that depends on LittleCMS 2.

For starters, the library implements conversion from enum transfer_fn to
ICC multiProcessingElements compatible LittleCMS curve object.

That conversion allows encoding transfer funtions in ICC files and
LittleCMS pipelines with full float32 precision instead of forcing a
conversion to a 1D LUT which for power-type curves is surprisingly
imprecise.

This also adds CI tests to make sure the conversion matches our
hand-coded transfer functions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 0225453fb1 tests/color_util: add transfer_fn_name()
This helps reporting test results, then you can print the fn by name.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 142d8e5125 tests/color_util: add RGB diff stat
These helpers allow collecting color difference statistics easily.

To be used in color-shaper-matrix-test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen c76e4abb60 tests/color_util: add lcmsMAT3_invert()
Needed to invert device-to-PCS color transformation matrices.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 141cd3021e tests/color_util: add transfer_fn_invert()
When defining a color space with a transfer function, this looks up the
inverse transfer function without needing to store that separately.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen fa477d2407 tests/color_util: add TRANSFER_FN_IDENTITY
This will be useful to make a curve in a color pipeline pass-through
without needing to special-case skipping the curve.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 6fa7ab5d5f tests/color_util: prettify arr_curves
Fix up whitespace and document what this array is for.

For the sake of slightly better readability.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 8adbd3d802 tests/color_util: streamline sRGB_linearize/delinearize
Re-use color_float_apply_curve() instead of open-coding it.

Maybe makes reading the code a little easier.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 53b1268018 tests/color_util: refactor into color_float_apply_matrix()
Make process_pixel_using_pipeline() slightly easier to read by
extracting a meaningful function.

Pure refactoring, no behavioral changes.

Compared to previous, flip the scalar multiplication around, so that it
matches the mathematical order of matrix-vector multiplication.

Also document the layout conventions for lcmsVEC3 and lcmsMAT3. These
follow the convention used in LittleCMS for cmsVEC3 and cmsMAT3, and are
necessary to understand to review the matrix-vector multiplication for
correctness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen c8195289a7 tests/color_util: refactor into color_float_apply_curve()
Make process_pixel_using_pipeline() slightly easier to read by
extracting a meaningful function.

Pure refactoring, no changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 85738af912 tests/color_util: protect header from re-reading
Looks like this was forgotten, and I managed to get compiler errors
about redeclaring all enums.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 7fa9b15348 build: consolidate lcms2 dependencies
It's bad form to set the same variable in multiple places, and not all
of them were even equivalent.

Move lcms2 finding to the root level build file only. It is still an
optional dependency like before, and the if-not-found checks are still
in place where actually needed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen fb7b1a4125 Revert "build: add test-gl-renderer option"
This reverts commit 1618697dc3.

The original commit was a workaround for
https://gitlab.freedesktop.org/mesa/mesa/-/issues/2219 which was fixed
in Mesa:
- c7617d8908a970124321ce731b43d5996c3c5775 released as 20.1.0-rc1
- a0e6341fe4417e41cda0b19e4fa7f8bbe4e1dba1 released as 19.3.5
- f27e5d9df5bc9c85d45c2cb1f2a4997b453365fe released as 20.0.0

This workaround should not be necessary anymore, we don't use it in our
CI, and it was manual to begin with. Therefore remove it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-02 08:37:36 +00:00
Pekka Paalanen 892421a93e tests: add matrix-test for CI
This a new matrix inversion test written from scratch to be suitable for
running in CI: quick to run and automatically detects success/failure.

This all is a result of what I learnt while working on
https://gitlab.freedesktop.org/pq/fourbyfour

Computing the residual error with infinity norm comes straight from
fourbyfour documentation on how to evaluate matrix inversion error.

Most of the hard-coded test matrices have been generated with fourbyfour
project as well, as it contains the generator code. The matrices are
hard-coded here also to make testing faster, but primarily because the
generator code needs BLAS and LAPACK, and having those as Weston
dependencies would be far too much just for this.

Now, if someone wants to modify weston_matrix stuff, we should at least
detect matrix inversion and multiplication bugs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-31 12:26:09 +00:00
Pekka Paalanen 8bbd1a995b libweston: remove UNIT_TEST
This #define was used only by the matrix-test program, which was removed
in the previous commit.

Remove it as unused and fold away MATRIX_TEST_EXPORT.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-31 12:26:09 +00:00
Pekka Paalanen a1e5d46d91 tests: delete the manual matrix-test
This test program was useful a decade ago when weston_matrix_invert()
was being developed. It was a manual test program that ran for a certain
number of seconds and required human interpretation of numbers to see if
results were acceptable or not. Hence it was foundamentally unsuitable
for CI.

The way it generated random matrices for inversion testing was also very
naive, and it used the determinant value to determine invertability
which is completely bogus. This made it also a bad test for correctness.

Much better speed and correctness testing is implemented in

    https://gitlab.freedesktop.org/pq/fourbyfour

with documented testing procedures. It has a copy of the weston_matrix
implementation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-31 12:26:09 +00:00
Pekka Paalanen ccb4c383d7 tests: add color-metadata-errors test
'color_characteristics_config_error' test ensures that all code paths in
parse_color_characteristics() and wet_output_set_color_characteristics()
get exercised.  The return value and logged error messages are checked.

Other cases test the weston_hdr_metadata_type1 validation.

These are for the sake of test coverage, but also an example of how to
test a function from main.c, and how to capture messages from
weston_log().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen e13e64c4e0 tests: add color-metadata-parsing
Check that weston.ini settings to eotf-mode and basic color
characteristics are correctly parsed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Daniel Stone 820f3ae866 gl-renderer: Add support for WL_SHM_FORMAT_YUV444
We support this as an explicit YUV fallback path in gl-renderer's dmabuf
EGLImage import path, so might as well support it in the SHM path, given
it's just YUV420 with no subsampling.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Marius Vlad 0d8e94af61 libweston: Rename weston_surface_destroy() to weston_surface_unref()
Make it obvious that weston_surface has a reference counting happening
and destruction of the weston_surface happens when the last
weston_surface reference has been accounted for.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:31 +03:00
Daniel Stone 577a832f41 test/desktop-shell: Use weston_curtain
Use the helper we have for these, rather than open-coding.

This commit is not believed to result in any functional changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 6cb2526b67 Move shell-utils to its own directory
shell-utils contains a number of helpers which are currently in use by
both desktop-shell and kiosk-shell. In order to extend this use to
fullscreen-shell as well (which can benefit from reusing the
weston_curtain infrastructure to be able to create solid-colour views
which may or may not be opaque, as well as one function within
fullscreen-shell which was copied wholesale to shell-utils), we need to
create a separate Meson dependency object, and avoid the existing
pattern of including the source from shared/ within the source list for
each shell.

This requires creating a new top-level directory for these shared helper
functions which are required by each shell, but are not part of
libweston in and of itself.

shell-utils depends on libweston-desktop; libweston-desktop depends on
libweston; libweston depends on shared.

Thus it is not possible to expose a dependency object from the shared/
directory which declares a dependency on the libweston-desktop
dependency, as Meson processes directories in order and resolves
variable references as they are parsed.

In order to break this deadlock, this commit creates a new top-level
directory called 'shell-utils' containing only this file, which can be
parsed by Meson after libweston-desktop (making the libweston-desktop
Meson dependency variable available to the build file to declare a
dependency on that), but before the shells (making the new Meson
depenendency object available to each shell which wishes to use it).

This commit contains no functional changes to any observable code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone dc0f73bcac shell: Encapsulate weston_curtain in its own struct
This will allow us to create a solid weston_buffer as well, since we
need to store that separately.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone e81b8d7cc9 shell: Add alpha to weston_curtain_create
Not all solid-colour views want to be opaque: sometimes we use them with
non-opaque alpha values in order to shade views underneath them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone d21563360a shell: Move weston_curtain_create params into the struct
Given that we have a struct for argument params, we might as well use it
rather than have them split between the struct and native params. For
consistency between the implementations, this also includes a shift from
float to int positioning for the base offset within the compositor's
global co-ordinate space.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone 3a298b0b05 shell: Rename weston_solid_color_surface to weston_curtain_params
The name implied that it was a surface in and of itself, rather than
parameters used by a helper to create a surface and view.

Rename it now that we have weston_curtain as a name, and clean up
initialisers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Daniel Stone b77c2374ee shell: Rename solid_color_surface to weston_curtain
create_solid_color_surface actually returns a weston_view that it
creates internally. Since weston_solid_color_view is long and dull,
rename it to weston_curtain.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
Pekka Paalanen b3ba1becba libweston: remove fbdev backend
Fbdev backend was deprecated in the Weston 10.0.0 release with
6338dbd581. Before that, I suggested
already in 2019 to remove it, but it was too soon then. Now it seems the
final voices asking for fbdev to be kept have been satisfied, see the
linked issue.

Fbdev-backend uses a kernel graphics UAPI (fbdev) which is sub-par for a
Wayland compositor: you cannot do GPU accelerated graphics in any
reasonable way, no hotplug support, multi-output support is tedious, and
so on. Most importantly, Linux has deprecated fbdev a long time ago due
to the UAPI fitting modern systems and use cases very poorly, but cannot
get rid of it if any users remain. Let's do here what we can to reduce
fbdev usage.

I am doing color management related additions to libweston which require
adding checks to every backend. One backend less is less churn to write
and review.

Libweston major version has already been bumped to 11, so the next
release will be Weston 11, without fbdev. enum weston_compositor_backend
entries change their numerical values.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/581

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-15 11:32:46 +02:00
Marius Vlad d284ab0322 pipewire,remoting,tests: Replace asprintf w/ str_printf
We have a string helper which wraps asprintf(). Uses that one because it
clears out the destination string, but also it won't return the number
of bytes unlinke asprintf().

Fixes warnings like:
warning: ignoring return value of ‘asprintf’ declared with attribute
‘warn_unused_result’.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-14 15:51:09 +02:00
Pekka Paalanen 3e94836a63 tests: add get_double in config-parser tests
weston_config_section_get_double() was not covered with tests before.

This patch follows the testing style already present in the file.

Cannot use ZUC_ASSERT_EQ() here, because that would convert the values
to integers before comparison. Luckily, simple strict equality
comparison works here, because we are testing conversion to float, not
the results of lossy calculations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-14 08:50:30 +00:00
Pekka Paalanen 5ba7ae2937 tests: preserve ivi runner section
Everywhere else where use this trick, we also have 'used' in the
attributes, except here. Make this consistent.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/517

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-08 14:50:41 +02:00
Pekka Paalanen e2ee2b56f9 tests: make vertex-clip use WESTON_EXPORT_FOR_TESTS
This is probably the simplest case to demonstrate how to use
WESTON_EXPORT_FOR_TESTS.

Previously, vertex-clip test re-built vertex-clipping.c for itself. Now
it directly links in gl-renderer.so instead as that is where
vexter-clipping.c gets built into for actual use. This probably will not
work for any installed program, but luckily tests are never installed,
so Meson makes sure the DSO is found.

Unfortunately we cannot remove the definition of dep_vertex_clipping
yet, because clients/cliptest.c needs it.

This makes vertex-clip test depend on GL-renderer, but that is where the
code is really used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-01 13:32:15 +00:00
Pekka Paalanen 29d4472e13 tests: use color_float rgb[] alias more
Iterate over rgb[] array instead of repeating the code for .r, .g and
.b.

Also in process_pipeline_comparison() f_max_err variable is dropped
since it was not used much.

This should make the code easier to read.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-02-18 15:22:44 +00:00
Pekka Paalanen 4012062228 tests: add rgb[] alias in color_float
Individual struct fields are inconvenient to index into, yet most
operations on a color just repeat the same for each of RGB channel.
Being able to index into RGB avoids repeating the same code for each
channel.

Alpha channel is left as separate, since it is almost never handled the
same as RGB.

The union keeps the old .r, .g and .b addressing working. The static
asserts ensure the aliasing is correct.

For demonstration, two simple functions in color_util.c are converted.

Unfortunately initializers need to be corrected everywhere. Field .a is
not explicitly initialized because it is unused in these cases.

This change should make code easier to read.

This change requires gnu99 or c11 standard. gnu99 is already the default
in top-level meson.build.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-02-18 15:22:44 +00:00
Daniel Stone 2ac6b6b084 tests: Add dependency on screenshooter client protocol
Given that the test-helper code relies on the screenshooter protocol,
make sure it's available for us to build, and the dependency ensures we
build in order.

Fixes: #588

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-18 12:24:01 +00:00
Vitaly Prosyak fe35ca2d68 tests: color shaper-matrix test
1. Use fixture_setup to set the generated by LCMS output profile based on
   given chromaticities and white points. The following  list of well known
   chromaticities:
    - sRGB
    - adobe RGB
    - bt2020
   and white point is D65. Use INTENT_ABSOLUTE_COLORIMETRIC to avoid BPC.
   Input profile is always sRGB and it is used internally by Weston as
   stock profile.

2. Use these hardcoded matrixes as part of pipeline 1DLUT->3x3->1DLUT.
   The diagnostic code to retrieve the transform matrix is availble into
   test in the comments. The conversion matrixes generated for the
   following cases:
    - sRGB to sRGB (unity)
    - sRGB to adobeRGB
    - sRGB to BT2020
3. Compare GPU shaders(gl texture3D) vs manual pipeline calculation
   Use different max tolerable error per transform.
   There are comments how number of points in 3DLUT is related to tolerance.
   Tolerance depends more on the 1D LUT used for the inv EOTF than
   the tested 3D LUT size: 9x9x9, 17x17x17, 33x33x33, 127x127x127.

4. Enable build matrix-shaper test if color-management-lcms is enabled.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-12 23:19:02 -05:00
Vitaly Prosyak 264a18f01a tests: shared color processing functions
Added pixel pipeline processing as following:
tone curve(EOTF) + 3x3 matrix + tone curve(INV_EOTF)

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-12 23:19:02 -05:00
Robert Mader c83f0a1539 tests: Add test for subsurfaces mapping hierachies
Test different scenarios where child subsurfaces of unmapped
subsurfaces would get mapped. This test will fail in various
ways without the commit
"libweston/compositor: Do not map subsurfaces without buffer"

Also try to test potential regressions of that patch.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-07 12:16:16 +00:00
Robert Mader dc3b349325 tests: Add test for synced subsurfaces and buffer damage
Changing `wl_surface_damage()` to `wl_surface_damage_buffer()`
should not have an effect on the existing tests.
The new test will fail without the commit
"libweston/compositor: Cache buffer damage for synced subsurfaces"

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-03 15:44:47 +00:00
Pekka Paalanen e948bd4bc9 tests: give name for the test-shell background
Give a role and a label for the test desktop shell background surface.
This makes it easier reading scenegraph dumps and other surface related
debug messages in tests when you don't have to guess what this
mysterious "PID 0, surface ID 0" surface is.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-01-25 13:10:36 +00:00
Leandro Ribeiro b985c6bf83 tests: fix leak in drm-smoke-test.c
Leak found running drm-smoke-test with ASan.

Do not forget to destroy the SHM buffer by the end of the test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Leandro Ribeiro 5911d2a762 tests: fix leak when we won't run DRM-backend tests
This fixes a leak found running drm-smoke-test with ASan. Do not forget
to call prog_args_fini() when:

- skipping DRM-backend tests because we don't have
  WESTON_TEST_SUITE_DRM_DEVICE set.

- we fail to acquire the lock needed to run DRM-backend tests.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Derek Foreman 3759ad1538 tests: Fix use after free on exit
We need to unlink this before freeing it since it's being called from
weston_signal_emit_mutable.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-19 10:55:04 -06:00
Marius Vlad ee5716798a tests/safe-signal-output-removal: Add test for output removal
This simulates an output removal which should trigger a crash when
the compositor is shutdown abruptly by having a view with a listener installed
on its output_destroy signal.

This patch assumes that weston_compositor_remove_output() has already
been amended to use the more safer version for triggering signal
emission.

As both shells use this construct it should catch any potential signal
corruption.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Marius Vlad 990173050c test/safe-signal: Add a basic test for weston_signal_emit_mutable
Basic test to verify that weston_signal_emit_mutable() would not
corrupt the signal list.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Daniel Stone 23f7e26978 tests/xwayland: Remove manual timeout implementation
One of the best things about a real test framework is that they handle
timeouts for you.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Simon Ser <contact@emersion.fr>
2021-12-14 14:57:40 +00:00
Daniel Stone 533950cc31 tests: Serialise drm-smoke-test against everything else
drm-smoke-test can't run at the same time as anything else which touches
DRM devices. This includes any test which would use the GL renderer or
GL/GBM on the client side, since they will open DRM devices to probe
them at init time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-30 15:56:42 +00:00
Leandro Ribeiro 60c7fee48d drm-formats: add weston_drm_format_array_count_pairs()
It simply returns the number of format/modifier pairs in the array. This
will be useful for the next commits, in which we add support for dma-buf
feedback.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 10:47:45 -03:00
Vitaly Prosyak 15d7546b2d tests: refactoring alpha-blending
No functional change. Moved color processing
functions into shared files which can be used
between different tests.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2021-11-13 00:17:03 +00:00
Pekka Paalanen 645df9556d ci: bump test timeouts
This is prompted by the spurious CI failure
https://gitlab.freedesktop.org/wayland/weston/-/jobs/13891809
saying:

31/36 output-damage                          TIMEOUT        122.52s   8 subtests passed
32/36 output-transforms                      TIMEOUT        122.52s   16 subtests passed
33/36 subsurface                             TIMEOUT        122.52s
34/36 xwayland                               TIMEOUT        122.51s
35/36 ivi-shell-app                          TIMEOUT        122.51s
ERROR: Job failed: execution took longer than 5m0s seconds

That is hitting both kinds of timeouts at the same time: the per-test
timeouts, and the CI job total timeout.

That run seems to have had a particularly ill fortune, as a simple retry
finished the same job in 2 minutes, and the longest running test took
only 24 seconds.

Nevertheless, by Daniel Stone's suggestion let's bump both timeouts:

- the per-test timeout to 120 seconds, which with the multiplier in CI
  goes up to 8 minutes

- the job timeout for all build related jobs to 15 minutes

The timeout for tests_standalone is not bumped as we are not adding
significant amounts of new tests there.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-09-22 16:29:05 +03:00
Leandro Ribeiro 0750ceae6c drm-formats: remove create() and destroy() from the API
Since commit "drm-formats: save result of intersection in the first
array", every block of code where weston_drm_format_array_create() and
destroy() are being called could use init() and fini() instead.

Remove these two functions from the API to make it leaner. This patch
also modifies the code that depends on these functions to use init() and
fini().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-09-06 12:52:37 +00:00
Leandro Ribeiro c51d4ad9c8 drm-formats: save result of intersection in the first array
In the current API, we have some set operations: join, intersect and
subtract. Both join and subtract receives two DRM format arrays and save
the result in the first one.

For the intersection we have a slightly different approach, what makes
the API weird. We don't save the result in the arguments, instead we
return a new array with the result.

Modify weston_drm_format_array_intersect() in order to make it similar
to the other two set operations.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-09-06 12:52:37 +00:00
Daniel Stone ccb64f301c tests: Bump alignment for test structures to 64 bytes
Our core test structure is 36 bytes wide. Declaring it with a 32-bit
alignment should thus stripe it to 64 bytes. For some reason, clang+lld
lays them out with a 96-byte stride within the section (does it want an
entire 32-bit word when building with ASan?), getting the code wildly
confused when it tries to step through the structures.

So we could fix all our tests to avoid the fragile section dance, or we
could just waste another 4 bytes per test definition by bumping the
alignment up to 64 bytes, which seems to do enough to magically accord
with what clang+lld+ASan expect.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-08-03 18:42:25 +01:00
Emmanuel Gil Peyrot eff793ab46 Fix indentation all through the project
Fixes a “regression” from 04918f3b0b, but
also other missed pieces.
2021-07-31 15:28:20 +00:00
Simon Ser b46d0e3304 tests/roles: switch to xdg-shell
Stop using wl_shell for the roles tests, since it'll get disabled
and removed eventually.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-07-23 17:26:02 +01:00
Pekka Paalanen 591fa3b95b tests: fix all leaks in devices-test
This fixes all ASan reported leaks in this test.

This test program has several tests named *_multiple that just run
another test function 30 times. Previously without cleanup all the
created clients would be left lingering, but now they are torn down. Ths
might cause a change in test behaviour, although that was never the
intention:

> It is intentional to run it so many times, but it is not intentional
> to run a hundred clients at a time.  The problem is that currently we
> have no destroy function for client.  However, the clients do not run
> simultaneously but serially, so the effect should be the same as if
> we'd destroy them (after the client finishes its body, it just 'is'
> and does nothing until the process exits)

- the original review discussion in
https://lists.freedesktop.org/archives/wayland-devel/2015-March/020957.html

The intention for the repeat testing is that as the Weston instance
remains from test to another, each test needs to undo its changes to the
devices. Failing to correcntly undo would accumulate devices.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:43 +03:00
Pekka Paalanen f6acdc5db0 tests: free pixman image in yuv-buffer-test
Fixes all ASan reported leaks in this test when using AMD Mesa driver.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen a01299a5b8 tests: fix all leaks in touch-test
Fixes all ASan reported leaks.

The manual touch release is slightly awkward as we need to open-code a
part of input_destroy() to avoid double-freeing pointer->wl_touch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen 56a8d69b0e tests: fix all leaks in text-test
Fix all ASan reported leaks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen 54ea691b99 tests: fix all leaks in surface-global-test
Fix all ASan reported leaks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen b982676213 tests: fix all leaks in surface-test
Fixes all ASan reported leaks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen 4f515a1da7 tests: fix all leaks in linux-explicit-synchronization-test
Fix all ASan reported leaks in this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen 9cf9121b73 tests: fix some leaks in subsurface-shot-test
Fix all ASan reported leaks in this test when running on AMD Mesa
driver.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:20:27 +03:00
Pekka Paalanen c021e2f9eb tests: reduce subsurface-test verbosity
Not printing these will drop 7980 lines or roughly 350 kB from the test
logs. Now I don't have scroll through them all, and I don't have to
watch them if I run this test manually.

These prints were useful when developing the test, but we don't need
them printed in CI all the time. Printing the final count should be
enough.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-23 15:20:25 +03:00
Pekka Paalanen ecbf1dba43 tests: fix all leaks in subsurface-test
Fix all ASan reported leaks in this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-23 15:20:25 +03:00
Pekka Paalanen fc26bdb2fb tests: clean up in roles-test
This fixes all ASan reported leaks in this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-23 15:20:25 +03:00
Pekka Paalanen 35cae567d6 tests/alpha-blending: add sRGB linear light case
Now that GL-renderer and color manager implement linear light blending
for sRGB EOTF, add a test case to verify the result is expected.

As noted in test comments, this new tests is quite powerful in ensuring
the whole linear light pipeline is working correctly with 1D LUTs in
GL-renderer. This test will even catch smashing source_lut.scale = 1.0f
and source_lut.offset = 0.0f which would result in wrong texture sample
positions for LUT data.

As the assumption is that by default content and outputs are in sRGB
color space, this test should not need fix-ups or become stale when more
color management features are implemented.

The sRGB EOTF can be found in:
http://www.color.org/sRGB.pdf (beware, typos)
https://www.w3.org/Graphics/Color/srgb
https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#TRANSFER_SRGB

Note on AMD Polaris 11 error threshold: this is quite likely due to
using fp16 format shadow framebuffer and GCN fp32 to fp16 conversion
instruction rounding mode. When using fp32 shadow framebuffer, the error
glitch is not present and the threshold could be significantly lower.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen e70aa1fde2 tests/alpha-blending: reference blending
Instead of checking just the monotonicity of the blending results, this
changes the alpha-blending test to compute the reference blend result
itself and then comparing to the compositor result. This way we can be
sure that the compositor implements the exact correct formula and not
something that just looks nice, as verifying the reference images are
actually correct is hard.

The reference image is renamed to follow the fact that this is not
primarily a monotonicity test anymore. The reference image is also
redundant, but I think it has documentary value.

The #if 0'd block of code was very useful in figuring out blending
errors in a future test case, so it is included here. I have a feeling
we are going to need it again.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 129bef50db tests/alpha-blending: refactor into get_middle_row()
Refactor the alpha-blending test to allow using all three images
foreground, background, and screenshot in a future new verification
function.

This is a pure refactoring, no change in behavior.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-21 14:36:33 +00:00
Pekka Paalanen 1600431e80 tests: fix leaks in presentation-test
Fixes all leaks found by ASan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen ee1c1778bf tests: fix leak in surface_commit_color() in pointer-shot
Found by ASan, several leaks like:

Direct leak of 48 byte(s) in 2 object(s) allocated from:
    #0 0x7f35fdc9c518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x55a77d6a4c6a in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x55a77d6a748e in create_shm_buffer ../../git/weston/tests/weston-test-client-helper.c:459
    #3 0x55a77d6a78cd in create_shm_buffer_a8r8g8b8 ../../git/weston/tests/weston-test-client-helper.c:499
    #4 0x55a77d6a4145 in surface_commit_color ../../git/weston/tests/pointer-shot-test.c:89
    #5 0x55a77d6a4542 in pointer_cursor_retains_committed_buffer_after_reenter ../../git/weston/tests/pointer-shot-test.c:135
    #6 0x55a77d6a4207 in wrappointer_cursor_retains_committed_buffer_after_reenter ../../git/weston/tests/pointer-shot-test.c:98
    #7 0x55a77d6b15c2 in run_test ../../git/weston/tests/weston-test-runner.c:162
    #8 0x55a77d6b1c63 in run_case ../../git/weston/tests/weston-test-runner.c:277
    #9 0x55a77d6b1a09 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235
    #10 0x55a77d6b1eeb in testsuite_run ../../git/weston/tests/weston-test-runner.c:311
    #11 0x7f35f9510b6b in client_thread_routine ../../git/weston/tests/weston-test.c:479
    #12 0x7f35fd7a4fa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486
    #13 0x7f35fd8c64ce in clone (/lib/x86_64-linux-gnu/libc.so.6+0xf94ce)

Now this test has no more leaks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen 689e8b3c0a tests: destroy client in pointer-test
Fixes all the leaks reported by ASan in this test.

The manual pointer release in
pointer_timestamps_stop_after_client_releases_wl_pointer is slightly
awkward as we need to open-code a part of input_destroy() to avoid
double-freeing pointer->wl_pointer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen ef8d652023 tests: destroy client in keyboard-test
Fixes all the leaks reported by ASan in this test.

The manual keyboard release in
keyboard_timestamps_stop_after_client_releases_wl_keyboard is slightly
awkward as we need to open-code a part of input_destroy() to avoid
double-freeing keyboard->wl_keyboard.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen b64d411448 tests: fix leak in ivi-shell-app-test
Found by ASan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen 2dcc79f58e tests: add destroy listener in ivi-layout test plugin
Fixes ASan reported leak:

Direct leak of 136 byte(s) in 1 object(s) allocated from:
    #0 0x7ff60173c518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7ff5fcfed3fa in zalloc ../../git/weston/include/libweston/zalloc.h:38
    #2 0x7ff5fcfed8bf in wet_module_init ../../git/weston/tests/ivi-layout-test-plugin.c:196
    #3 0x7ff60161bd81 in wet_load_module ../../git/weston/compositor/main.c:941
    #4 0x7ff60161c165 in load_modules ../../git/weston/compositor/main.c:1012
    #5 0x7ff60162ced9 in wet_main ../../git/weston/compositor/main.c:3441
    #6 0x559a98fd7d4c in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
    #7 0x559a98fdb780 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
    #8 0x559a98fcbc48 in fixture_setup ../../git/weston/tests/ivi-layout-test-client.c:48
    #9 0x559a98fcbcca in fixture_setup_run_ ../../git/weston/tests/ivi-layout-test-client.c:50
    #10 0x559a98fdbd35 in main ../../git/weston/tests/weston-test-runner.c:661
    #11 0x7ff60129109a in __libc_start_main ../csu/libc-start.c:308
    #12 0x559a98fcb769 in _start (/home/pq/build/weston-meson/tests/test-ivi-layout-client+0xd769)

This also plugs the leak on wl_global_create() error path, though it
cannot really be tested.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +00:00
Pekka Paalanen fda3696ecf tests: fix leaks in ivi-layout-test-client
Everything here was systematically leaking client and iviapp.

Discovered by ASan on ./tests/test-ivi-layout-client

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-16 14:41:08 +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
Pekka Paalanen d3acfd3b6b tests: fix leak in events
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
Leandro Ribeiro 7c547e492c tests: fix leaks in drm-formats-test
Leak found running drm-formats-test with ASan:

==59454==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5302ff2459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f5302e75e3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7f5302e75e4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x7f5302e76e33 in weston_drm_format_array_intersect ../libweston/drm-formats.c:340
    #4 0x559dc2d3c69f in intersect_arrays_same_content ../tests/drm-formats-test.c:391
    #5 0x559dc2d3c317 in wrapintersect_arrays_same_content ../tests/drm-formats-test.c:376
    #6 0x559dc2d409ec in run_test ../tests/weston-test-runner.c:162
    #7 0x559dc2d410f2 in run_case ../tests/weston-test-runner.c:277
    #8 0x559dc2d40e8b in for_each_test_case ../tests/weston-test-runner.c:235
    #9 0x559dc2d4139b in testsuite_run ../tests/weston-test-runner.c:311
    #10 0x559dc2d423c4 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #11 0x559dc2d423f4 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #12 0x559dc2d42887 in main ../tests/weston-test-runner.c:661
    #13 0x7f5302c5eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #14 0x559dc2d3642d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5302ff2459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f5302e75e3a in zalloc ../include/libweston/zalloc.h:38
    #2 0x7f5302e75e4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
    #3 0x559dc2d3bc7b in intersect_arrays ../tests/drm-formats-test.c:352
    #4 0x559dc2d3b678 in wrapintersect_arrays ../tests/drm-formats-test.c:339
    #5 0x559dc2d409ec in run_test ../tests/weston-test-runner.c:162
    #6 0x559dc2d410f2 in run_case ../tests/weston-test-runner.c:277
    #7 0x559dc2d40e8b in for_each_test_case ../tests/weston-test-runner.c:235
    #8 0x559dc2d4139b in testsuite_run ../tests/weston-test-runner.c:311
    #9 0x559dc2d423c4 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
    #10 0x559dc2d423f4 in fixture_setup_run_ ../tests/weston-test-runner.c:610
    #11 0x559dc2d42887 in main ../tests/weston-test-runner.c:661
    #12 0x7f5302c5eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #13 0x559dc2d3642d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-06-16 13:36:43 +00:00
Pekka Paalanen 819054ceac tests: fix leaks in bad-buffer
Fixes all ASan reported leaks for this test.

If frame_callback_wait_nofail() returns before the callback is handled,
the callback is not destroyed automatically. This happens on a protocol
error. This test intentionally triggers a protocol error.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-15 07:43:00 +00:00
Pekka Paalanen b0eb059818 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-15 07:43:00 +00:00
Pekka Paalanen 478123b967 Revert "compositor: add weston.ini option use-renderer-shadow"
This reverts commit 81ef6d0ab3.

This also removes a bit from "tests: ensure color-lcms plugin loads".

Use of the shadow buffer is determined automatically based on
color transformations by the previous commit
"gl-renderer: use shadow framebuffer automatically".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen d2cfbff186 gl-renderer: use shadow framebuffer automatically
This creates the FP16 shadow framebuffer automatically if the color
transformation from blending space to output space is not identity and
the backend does not claim to implement it on the renderer's behalf.

That makes the weston_output_set_renderer_shadow_buffer() API and
use-renderer-shadow weston.ini option obsolete.

To still cater for the one test that needs to enable the shadow
framebuffer in spite of not needing it for color correct blending, the
quirk it uses now also forces the shadow.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 16:04:43 +03:00
Pekka Paalanen 21b8ad5a16 tests: ensure color-lcms plugin loads
This is a trivial smoke test to ensure that the color-lcms plugin is
loadable.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-14 12:53:41 +00:00
Alexandros Frantzis 6ee80ecc9d tests: Add shot test for pointer cursor behavior
Add a regression test to verify that the cursor image is correctly
updated when setting a cursor surface with an already committed buffer
from a previous pointer entry, without recommitting a cursor buffer for
the current entry.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-06-10 17:20:30 +03:00
Alexandros Frantzis 4ea9be5193 tests: Store the pointer event serial
Store the pointer serial for events that provide one, so that it can be
used by tests to send requests that require it (e.g., setting the cursor
surface).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-06-10 17:20:30 +03:00
Pekka Paalanen ef4d5c4086 tests: clean up after viewporter-test
Clean up after each test to avoid ASan reporting leaks.

At few points client_roundtrip() is replaced with client_destroy()
because the latter does a final roundtrip anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen ed6df8ed1c tests: allow client_destroy() after expect_protocol_error()
expect_protocol_error() ensures that the connection has failed in the
expected way. To satisfy ASan leak detection, we still need to tear down
everything, including call client_destroy().

client_destroy() needs to check that tear-down does not cause protocol
errors, so it does one last roundtrip that checks that is succeeds. But
if the connection is already down in an expected way, this roundtrip
cannot succeed and must be skipped.

Also moves the roundtrip under 'if (wl_display)', assuming the 'if' is
there for a reason - but obviously that reason was never used as it
would have crashed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 7514bf7e45 tests: proper weston_test_surface_create()
struct weston_test_surface in the test harness' compositor plugin had no
tear down code, which lead to ASan report on alpha-blending test:

Direct leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x7f8931f10330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
    #1 0x7f892d934425 in move_surface ../../git/weston/tests/weston-test.c:181
    #2 0x7f893159d8ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)

While at it, let's do this properly for once:
- put the creation in a new function
- hook up to the weston_surface destroy signal so this actually gets
  freed (fixes the leak)
- check that we don't overwrite another surface role
- check that committed_private actually is ours
- set the surface label func so it gets properly listed in debugs and
  traces
- use the proper surface role setup call, so no-one stomps on anyones
  toes if a test makes a mistake by using a wrong wl_surface

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Pekka Paalanen 33b29bbb11 tests: destroy screenshooter
Fixes a leak found by ASan in alpha-blending-test.

Direct leak of 160 byte(s) in 2 object(s) allocated from:
    #0 0x7f511fe11518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f511fc76373 in zalloc ../../git/wayland/src/wayland-private.h:232
    #2 0x7f511fc76373 in proxy_create ../../git/wayland/src/wayland-client.c:422
    #3 0x7f511fc79dcc in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
    #4 0x7f511fc79dcc in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
    #5 0x7f511fc7b17b in wl_proxy_marshal_constructor_versioned ../../git/wayland/src/wayland-client.c:873
    #6 0x5583e5348f43 in wl_registry_bind /home/pq/local/include/wayland-client-protocol.h:1165
    #7 0x5583e534cfbe in handle_global ../../git/weston/tests/weston-test-client-helper.c:800
    #8 0x7f511f34b8ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Pekka Paalanen 681db3416d tests: destroy subcompositor in alpha-blending
Fixed a leak found by ASan:

Direct leak of 160 byte(s) in 2 object(s) allocated from:
    #0 0x7f511fe11518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7f511fc76373 in zalloc ../../git/wayland/src/wayland-private.h:232
    #2 0x7f511fc76373 in proxy_create ../../git/wayland/src/wayland-client.c:422
    #3 0x7f511fc79dcc in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
    #4 0x7f511fc79dcc in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
    #5 0x7f511fc7b17b in wl_proxy_marshal_constructor_versioned ../../git/wayland/src/wayland-client.c:873
    #6 0x5583e5348f43 in wl_registry_bind /home/pq/local/include/wayland-client-protocol.h:1165
    #7 0x5583e535140b in bind_to_singleton_global ../../git/weston/tests/weston-test-client-helper.c:1863
    #8 0x5583e5348752 in alpha_blend_monotonic ../../git/weston/tests/alpha-blending-test.c:219
    #9 0x5583e5348571 in wrapalpha_blend_monotonic ../../git/weston/tests/alpha-blending-test.c:200
    #10 0x5583e53554cc in run_test ../../git/weston/tests/weston-test-runner.c:162
    #11 0x5583e5355b6d in run_case ../../git/weston/tests/weston-test-runner.c:277
    #12 0x5583e5355913 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235
    #13 0x5583e5355df5 in testsuite_run ../../git/weston/tests/weston-test-runner.c:311
    #14 0x7f511aaaf752 in client_thread_routine ../../git/weston/tests/weston-test.c:404
    #15 0x7f511f88cfa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Pekka Paalanen 6a0a3a014f tests: call weston_layer_fini()
This ensures the layers are torn down properly.

See commit: libweston: add weston_layer_fini()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Leandro Ribeiro b4cf450ce1 shared/helpers: use ARRAY_COPY where possible
In "backend-drm: simplify compile time array copy", ARRAY_COPY was
introduced to be used by the DRM-backend.

In this patch we expand its usage to other code where hardcoded arrays
are being copied.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-28 12:17:24 -03:00
Leandro Ribeiro 859e3f220d tests: add unit tests for struct weston_drm_format
In commit "libweston: add struct weston_drm_format" we've added an API
to store and manage DRM formats and modifiers. As it has a couple of set
operations that are not so obvious, this adds unit tests to ensure
correctness. In the future we may expand this API and also improve
performance, so it is important to have this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Pekka Paalanen ee38ed80d8 tests: add build option to force skips as failures
This will be useful in CI, where we do not want to see any skips. If
something starts to skip, that's a mistake somewhere, and want to catch
it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen e88de3ef37 tests: define ENABLE_JUNIT_XML to 1 or 0
Code is using the form
  #if ENABLE_JUNIT_XML
which is fine until we start using -Wundef. I think the existing code
would fail or at least warn if you disabled test-junit-xml with -Wundef.

Make sure ENABLE_JUNIT_XML is always defined so that -Wundef can be
added to build flags.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen f1fb48ed28 tests: let output damage skip without color ops
If the compositor does not have the shadow buffer capability (implied by
the color ops capability bit), then trying to run the shadow buffer test
is useless, it would just fail. Let it skip instead.

Fixes: b1e56143c5

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen 19d31dd4c3 libweston: add required_capabilities test suite quirk
This allows tests to skip when required capabilities are not present.
The output damage test for the shadow buffer case needs this.

required_capabilities is added to struct weston_testsuite_quirks which
is libweston public API just because there is no better place currently.
This is a little weird because the code to check it is in compositor,
not libweston.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen f6a8aa15f5 tests: add XYUV8888 to yuv-test
This will hit the XYUV shader variant in GL-renderer that was not
covered in the test suite before.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen 4b301fe7f2 Add weston-drm-fourcc.h
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.

Share these fallback definitions in one place instead of copying them
all over.

All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen b1e56143c5 tests: extend output-damage to GL shadow framebuffer
Extend the existing output-damage test to test
blit_shadow_to_output() specifically. This function had problems
originally, so make sure they can't reappear.

The added quirk is explained in the test.

An additional check of the quirk in gl_renderer_output_create() ensures
that the shadow framebuffer is really used. The test could false-pass if
the shadow is not used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:27:33 +02:00
Harish Krupo 7ef26886f5 gl-renderer: implement intermediate framebuffer (shadow)
Proper color management will need blending done with linear light pixel
values, that is, EOTF applied before blending, and then inverse-EOTF
applied for scanout after blending. The simplest way to set that up is
to use an intemediate framebuffer a.k.a shadow buffer containing the
composited image in linear light values, then blit from that to the
actual framebuffer.

This patch implements the shadow buffer, but the linear light
blending is left for another patch. This allows GL-renderer to turn
WESTON_CAP_COLOR_OPS on.

Half-float is chosen as the buffer format because linear light values
require more bits to encode with sufficient precision than the usual
non-linear pixel values.

v2: Use /* */ instead of // (Pekka)
    Rename fbo and tex to shadow_{fbo,tex} (Pekka)
    Check for OpenGLES capabilities before creating
    shadow_{tex,fbo} (Pekka)

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v3: Rebased.
    Simplified GL version checks (Sebastian)
    Apply changes from "libweston: add color ops cap and bool renderer
    shadow buffer"
    Renamed supports_half_float_texture to has_gl_half_float to
    follow the existing naming pattern.
    Introduce gl_renderer_create_shadow_16f().
    Undo moving of glViewport() call.
    Replace half_float_texture_enabled with shadow_exists().
    Introduce struct gl_output_state_shadow.
    Assert no resizing with shadow.
    Fix triangle fan debug.
    Rename repaint_from_texture() to blit_shadow_to_output().
    Rewrite commit message because linear light blending is not
    implemented in this patch.
    Fix blit_shadow_to_output() for scaled/transformed outputs and
    remove redundant code.
    Fix has_gl_half_float determination.

v4: Disable blending in blit_shadow. (Daniel)
    Port to gl_renderer_get_program().
    Make a generic fbo-texture struct with parameterized format. (Daniel)
    Change has_gl_half_float into gl_half_float_type.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen fbd4160474 tests: add output damage test
This test ensures that client submitted damage goes to the screen
correctly, regardless of output scale or transform.

The added quirk is explained in the test that uses it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 12:54:17 +02:00
Pekka Paalanen 0f7da612eb tests: add drm_screenshot_no_damage
I am working on adding a test to ensure Weston repaints damage
correctly, where I rely on Weston repainting exactly and only the damage
submitted by a client. That means I have to stop screenshooting from
damaging everything automatically. Doing that, I noticed that
screenshots on DRM-backend could theoretically get stuck if I do that.
So test for it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 12:47:07 +02:00
Maxime Roussin-Bélanger 4e8ea1f9d5 tests: fix typos
Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
2021-02-24 10:00:21 -05:00
Pekka Paalanen 946b933f9e tests: clarify --help
Use consistent terminology with the code: index starts from zero,
numbering starts from one. Fixture 0 runs all fixtures.

Suggested-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Pekka Paalanen 3ee1f27278 tests: --list lists individual fixture setups
When there is a fixture setup array, list all fixture setups with their
numbers and names. This should help people picking a single fixture to
run and makes the --list output more interesting.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Pekka Paalanen d91e63dea0 tests: use fixture names in reports
Instead of "fixture %d", use the proper fixture name if it exists or
nothing. Some places still show the fixture index because it is used on
the command line.

This makes the reports more readable.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Pekka Paalanen 345d7da606 tests: refactor into fixture_setup_array_get_arg()
Make it more explicit that the return value is NULL when there is no
arrray.

This patch makes the following patch smaller.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Pekka Paalanen ef81388466 tests: introduce struct fixture_metadata
This allows tests to give a meaningful name for their fixture setups
when they use more than one of them.

If a test uses DECLARE_FIXTURE_SETUP_WITH_ARG(), it must now pass a
third argument naming the field which is struct fixture_metadata. This
also means that the fixture setup data must now be a struct, it cannot
be a plain type anymore. A compiler error is generated if the field type
is not the expected one.

All tests using DECLARE_FIXTURE_SETUP_WITH_ARG() and converted to the
new form and given names for their fixture setups.

The fixture setup names not actually used yet, that will be another
patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Pekka Paalanen 5580cb13c9 tests: switch to TAP
This makes sub-tests visible in the junit output, making Gitlab test
reports more detailed.

This does not apply to zuc tests, which look like they could produce
junit XML directly. And maybe TAP? Left for another time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-15 11:17:17 +02:00
Pekka Paalanen ae12b9596d tests: add yuv-buffer test
This adds a test to ensure that the wl_shm formats YUV420, NV12 and YUYV
are decoded and converted to RGB correctly in GL-renderer.

The test deliberately uses a 256 x 256 test image so that effects from
width vs. pitch vs. stride cannot be observed, and row padding is zero.
Also padding between planes is zero. Attempting to use a test image with
less "round" dimensions lead to stride mismatch in GL-renderer, likely
due to GL_UNPACK_ALIGNMENT being left at value 4. It is unclear if YUV
wl_shm buffers' row stride needs to be aligned to 4 bytes or not, so I
did not pursue fixing it. GL-renderer seems to be confusing width, pitch
and stride even further, and not e.g. allow padding with ARGB buffers.
See also: https://gitlab.freedesktop.org/wayland/weston/-/issues/354

Furthermore, the test arranges so that each 2x2 pixel block has the same
color. This avoids having to consider chroma siting when sub-sampling.
This way all the test cases can use the same reference image.

The source image chocolate-cake.png is taken and copyright by Pekka
Paalanen, hereby licensed as
http://creativecommons.org/licenses/by-sa/4.0/ .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-17 09:34:09 +00:00
Pekka Paalanen 26258817fc tests: add alpha-blending test
In anticipation of invasive future work on color management, add an
alpha blending test to make sure we don't break alpha blending.

The idea for doing a monotonicity test came from glennk on #dri-devel in
Freenode IRC.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-09 14:06:43 +02:00
Pekka Paalanen f8d170c4e7 tests: factor out verify_image()
This refactors a new function verify_image() out of
verify_screen_content().

verify_image() will be useful with a test that verifies a screenshot
against a reference image but also wants to do additional testing on the
screenshot.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-09 14:06:43 +02:00
Pekka Paalanen ee60752ebd tests: constify fill_image_with_color()
Const has documentary value saying the code will not modify the
parameter contents. Everything that can be const, should be const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-09 14:06:43 +02:00
Pekka Paalanen a3bfa1b27d tests: re-order drm-smoke in test list
To keep the list in alphabetical order so it's easy to search.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-09 14:06:43 +02:00
Pekka Paalanen 94bf0a6463 tests: do not save PNG on success
Do not write out PNG files for successful screenshot tests. It clutters
the build directory, but the biggest reason is to keep the CI artifacts
smaller.

internal-screenshot test still writes a PNG, it's good to keep one PNG
written so that we exercise the PNG writing code always.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-11-18 16:14:33 +02:00
Leandro Ribeiro 79491b41f5 tests: drop test suite screenshooter implementation and protocol extension
This is a follow-up of commit "tests: start to use Weston's
default screenshooter in the test suite".

As we've started to use Weston's default screenshooter
implementation and protocol extension in the test suite,
we don't need what we've created specifically for the test
suite anymore.

Drop test suite screenshooter implementation and protocol
extension.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro 9e90760ab0 tests: start to use Weston's default screenshooter in the test suite
Until now we had two different protocol extensions: one for the
test suite screenshooter and other for the screenshooter client.
As they are identical and this won't change, make the test suite
use the same protocol that the screenshooter client uses.

Besides the cleanup, this change will also allow us to use the
DRM writeback screenshooter in the test suite, as the test suite
implementation is hardcoded to use a renderer based screenshooter.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro 6c7dc70d86 tests: change type of int buffer_copy_done to bool
The 'struct test' has a field 'int buffer_copy_done', but it
is in a fact a boolean. Change it to 'bool buffer_copy_done'.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro 6b4d48736f tests: remove has_wl_drm from struct client
The wl_drm protocol is not being used by the test client. So
remove 'bool has_wl_drm' from 'struct client' and also the
branch that initializes this variable in handle_global().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro a7e0e717a9 tests: remove destroy_listener when destroying test-desktop-shell
When destroying the shell we need to remove the listeners
as well. The test-desktop-shell was forgetting to do this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 12:19:39 +00:00
Leandro Ribeiro 32a5acde5b tests: add mechanism to change Weston's behavior when running certain tests
There are some specific cases in which we need Weston to
behave differently when running in the test suite. This
adds a new API to allow the tests to select these behaviors.

For instance, in the DRM backend we plan to add a writeback
connector screenshooter. In case it fails for some
reason, it should fallback to the renderer screenshooter
that all other backends use. But if we add a test to
ensure the correctness of the writeback screenshooter,
we don't want it to fallback to the renderer one, we
want it to fail. With this new API we can choose to
disable the fallback behavior specifically for this test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 11:21:55 +00:00
Igor Matheus Andrade Torrente d8e09afc9f tests: Convert ivi-shell-app-test.c to use weston_ini_setup
Convert ivi-shell-app-test.c to use `weston_ini_setup`. It also removes
the pre-made weston.ini and all the related code in the meson files.

Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@gmail.com>
2020-09-30 09:41:34 -03:00
Denys Dmytriyenko b10c0e843d tests: include fcntl.h for open(), O_RDWR, O_CLOEXEC and O_CREAT
musl libc (unlike glibc) requires explicitly incuding fcntl.h to define open(),
O_RDWR, O_CLOEXEC and O_CREAT. Otherwise the build fails with the errors:

| ../weston-9.0.0/tests/weston-test-fixture-compositor.c: In function 'wait_for_lock':
| ../weston-9.0.0/tests/weston-test-fixture-compositor.c:135:7: warning: implicit declaration of function 'open'; did you mean 'popen'? [-Wimplicit-function-declaration]
|   135 |  fd = open(lock_path, O_RDWR | O_CLOEXEC | O_CREAT, 00700);
|       |       ^~~~
|       |       popen
| ../weston-9.0.0/tests/weston-test-fixture-compositor.c:135:23: error: 'O_RDWR' undeclared (first use in this function)
|   135 |  fd = open(lock_path, O_RDWR | O_CLOEXEC | O_CREAT, 00700);
|       |                       ^~~~~~
| ../weston-9.0.0/tests/weston-test-fixture-compositor.c:135:23: note: each undeclared identifier is reported only once for each function it appears in
| ../weston-9.0.0/tests/weston-test-fixture-compositor.c:135:32: error: 'O_CLOEXEC' undeclared (first use in this function)
|   135 |  fd = open(lock_path, O_RDWR | O_CLOEXEC | O_CREAT, 00700);
|       |                                ^~~~~~~~~
| ../weston-9.0.0/tests/weston-test-fixture-compositor.c:135:44: error: 'O_CREAT' undeclared (first use in this function)
|   135 |  fd = open(lock_path, O_RDWR | O_CLOEXEC | O_CREAT, 00700);
|       |                                            ^~~~~~~

Signed-off-by: Denys Dmytriyenko <denys@ti.com>
2020-09-08 22:10:06 -04: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
Leandro Ribeiro b1c529e9d7 tests: add drm-backend smoke test
This adds the first DRM-backend test. It is very simple
and was made in order to make easier to add more complex
DRM-backend tests in the future.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-06-02 13:47:15 +00:00