Commit graph

468 commits

Author SHA1 Message Date
Pekka Paalanen 9c267e5b55 tests: move viewport creation into helpers
There will be a new test program using viewports and would like to share this
bit of code.

There are two behavioral changes:
- Compositor wp_viewporter interface version is no longer checked.
- client_create_viewport() does not leak the viewporter object.

test_viewporter_double_create needs to call bind_to_singleton_global() itself
so that the viewporter object still exists when the error event arrives.
Otherwise error verification fails.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-03-11 17:11:03 +02:00
Pekka Paalanen 536873c58e tests: print image difference statistics
When a test fails and it produces a difference image, also compute the min/max
per-channel signed difference statistics. These numbers can be used to adjust
the fuzz needed for fuzzy_match_pixels() to pass. Otherwise one would have to
manually inspect the reference and result images and figure out the values.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-03-10 13:40:00 +00:00
Pekka Paalanen 147e67c425 tests: add buffer transform tests
This patch continues the buffer and output transforms testing by iterating
through a representative selection of buffer transforms and scales.

For more details, see the previous patch "tests: add output transform tests".

https://gitlab.freedesktop.org/wayland/weston/issues/52

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-28 16:02:10 +02:00
Pekka Paalanen 97359ba5c5 tests: add output transform tests
This goes through all output transforms with two different buffer transforms
and verifies the visual output against reference images.

This commit introduces a new test input image 'basic-test-card.png'. It is a
small image with deliberately odd and indivisible dimensions to provoke bad
assumptions about image sizes. It contains red, green and blue areas which are
actually text that makes it very obvious if you have e.g. color channels
swapped. It has a white thick circle to highlight aspect ratio issues, and an
orange cross to show a mixed color. The white border is for contrast and a 1px
wide detail. The whole design makes it clear if the image happens to be rotated
or flipped in any way.

The image has one pixel wide transparent border so that bilinear sampling
filter near the edges of the image would produce the same colors with both
Pixman- and GL-renderers which handle the out-of-image samples fundamentally
differently: Pixman assumes (0, 0, 0, 0) samples outside of the image, while
GL-renderer clamps sample coordinates to the edge essentially repeating the
edge pixels.

It would have been "easy" to create a full matrix of
every output scale & transform x every buffer scale & transform, but that
would have resulted in 2 renderers * 8 output transforms * 3 output scales *
8 buffer transforms * 3 buffer scales = 1152 test cases that would have all
ran strictly serially because our test harness has no parallelism inside one
test program. That would have been slow to run, and need a lot more reference
images too.

Instead, I chose to iterate separately through all output scales & transforms
(this patch) and all buffer scales & transforms (next patch). This limits the
number of test cases in this patch to 56, and allows the two test programs to
run in parallel.

I did not even pick all possible scale & transform combinations here, but just
what I think is a representative sub-set to hopefully exercise all the code
paths.

https://gitlab.freedesktop.org/wayland/weston/issues/52

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-28 15:07:51 +02:00
Pekka Paalanen 20026a55d6 tests: expand allowed pixel fuzz for GL
Running with Mesa 20.1.0-devel (git-c7617d8908) GL renderer:
Radeon RX 550 Series (POLARIS11, DRM 3.27.0, 4.19.0-2-amd64, LLVM 8.0.1)

I found output-tranform test (a future patch) to produce exactly this much more
difference between Pixman and GL rendererers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 080d85b8fb tests: implement client_destroy()
It turns out that if the client is not explicitly destroyed, it will remain
connected until the compositor shuts down because there is no more a client
process that would terminate.

Usually this is not a problem, but if a test file has multiple screenshooting
tests, the windows from earlier tests in the file will remain on screen. That
is not wanted, hence implement client destruction.

To properly destroy a client, we also need a list of outputs. They used to be
simply leaked. This does not fix wl_registry.global_remove for wl_outputs, that
is left for a time when a test will actually need that.

This patch makes only ivi-shell-app test use the new client_destroy() to show
that it actually works. The added log scopes prove it: destroy requests get
sent. Sprinkling client_destroy() around in all other tests is left for a time
when it is actually necessary.

ivi-shell-app is a nicely simple test doing little else, hence I picked it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 444f1a8e22 tests: re-order test naming pattern
The string from get_test_name() can be used for writing screenshot files and
others. Starting the name with the fixture number makes an alphabetized listing
of output files look unorganized.

Let's change the test name to begin with the test (source) name with fixture
and element numbers as suffixes. That makes a file listing easier to look
through, when you have multiple tests each saving multiple screenshot files.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 1eb30468ea tests: add get_test_fixture_index()
A future test wants to access the fixture data array for the currently running
fixture index to log the test description. This patch provides access to the
array index.

Rather than adding more gloabl variables, I changed the type of the existing
one which feels slightly cleaner.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 0ce5a19b7e tests: add scale and transform compositor options
With these, a test can initialize the headless-backend with non-default scale
and transform which allows testing output scales and transforms.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 636fc15f20 tests: allow verify_screen_content() w/o ref image
Allow the reference image to be NULL or missing so that it does not even
attempt to load a reference image or compare it. You cannot just point the
reference image to an arbitrary image because the comparison functions can
abort due to size mismatch. This makes bootstrapping new tests easier when you
do not yet have a reference image.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 7009806b94 tests: rename check_screen() to verify_screen_content() + doc
The old name felt too... short.

The return type is changed to bool; fits better for a success/failure.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 9b682302b8 tests: move check_screen() into client helpers
This will be useful in more tests.

No changes to the code, aside from dropping one 'static'.

Copyright 2017 is taken from git-blame of the moved code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 16:08:42 +02:00
Pekka Paalanen 741fca40b5 tests: run subsurface-shot on GL too
This adds the necessary fuzz to image matching to let GL-renderer pass.
The difference is due to rounding. weston-test-desktop-shell.c uses

weston_surface_set_color(dts->background_surface, 0.16, 0.32, 0.48, 1.);

to set the background color. Pixman-renderer will truncate those to uint8, but
GL-renderer seems to round instead, which causes the +1 in background color
channel values.

	0.16 * 255 = 40.8
	0.32 * 255 = 81.6
	0.48 * 255 = 122.4

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-05 11:13:51 +00:00
Pekka Paalanen 1618697dc3 build: add test-gl-renderer option
This shall be used by CI due to https://gitlab.freedesktop.org/mesa/mesa/issues/2219

It defaults to true, meaning that people by default will be running the
GL-renderer tests. It works fine on hardware drivers, just not llvmpipe.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-05 11:13:51 +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
Guillaume Champagne 7bce28b543 tests: release resources on compositor destruction
Releases touch devices and seat if they were allocated, clean up the
layers and free the weston_test structure.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-02-04 13:30:19 +00:00
Pekka Paalanen 7df5349763 tests: remove tests_weston and WESTON_TEST_CLIENT_PATH
This test category is empty, so it and all the supporting code can go.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen 56b94b5894 tests: migrate xwayland
Move xwayland test to the new harness.

This is the only test that can actually skip. It does it by exit(77) and that
is fine, because there is only one test case in the file so far. To get rid of
the exit() calls we need to return a value from the TEST() function but that is
a big surgery for another time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen dd13498862 tests: migrate linux-explicit-synchronization
Moved to the new test harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen 701676d8c6 tests: migrate client tests
This migrates all the client tests that have nothing special in them to the new
test harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen 3fb67936a9 tests: migrate devices
The devices test was actually using the defaults instead of
weston-test-desktop-shell in meson.build, so this patch keeps it that way.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen af18eb0b5c meson: remove tests_weston_plugin
All plugin tests have been converted to the new harness, so the old definition
can be removed.

The one remaining test surface-screenshot is a manual test, the plugin only
installs a debug key binding. Hence it is open-coded as a normal plugin, not as
a test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen 99c536db91 tests: migrate surface, surface-global
These are normal plugin tests, moved to the new harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +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 431ec067cb tests: migrate ivi-shell-app
Moving to the new test harness.

Carrying the test ini file still just to keep it the same even though I
accidentally noticed the test succeeds also with --no-config.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen ad1a4102fe tests: migrate ivi-layout-internal
Moving to the new harness.

It would be possible to convert every case here into a separate PLUGIN_TEST,
but I did not see the value in that at this time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:35 +00:00
Pekka Paalanen 7f840b721a tests: migrate ivi-layout-test
The ivi-layout-test comprises of two halves: the client and the plugin. This
migrates the test to the new test harness.

In the old harness, the plugin was built as the test in meson.build and it fork
& exec'd the client part. In the new harness client tests start from the client
program which sets up the compositor in-process, so now the client is built as
the test in meson.build and the plugin is just an additional file.

Therefore there is not need for the plugin for fork & exec anything anymore, so
all that code is removed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +00:00
Pekka Paalanen 57a4508ee4 tests: migrate string and vertex-clip
These are the only remaining standalone non-ZUC tests. They do not need any
changes to be built with the new harness - in fact they have already been
running through the new harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +00:00
Pekka Paalanen 82dd6ce830 tests: stop relying on environment in the new harness
Instead of relying on Meson setting up environment so that Weston and tests
find all their files, build those values into the tests. This way one can
execute a test program successfully wihtout Meson, simply by running it.

The old environment variables are still honoured if set. This might change in
the future.

Baking the source or build directory paths into the tests should not regress
reproducible builds, because the binaries where test-config.h values are used
will not be installed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +00:00
Pekka Paalanen babb3b3bc2 tests: thread-based client harness
This replaces the old test harness with a new one.

The old harness relied on fork()'ing each test which makes tests independent,
but makes debugging them harder. The new harness runs client code in a thread
instead of a new process. A side-effect of not fork()'ing anymore is that any
failure will stop running a test series short. Fortunately we do not have any
tests that are expected to crash or fail.

The old harness executed 'weston' from Meson, with lots of setup as both
command line options and environment variables. The new harness executes
wet_main() instead: the test program itself calls the compositor main function
to execute the compositor in-process. Command line arguments are configured in
the test program itself, not in meson.build. Environment variables aside, you
are able to run a test by simply executing the test program, even if it is a
plugin test.

The new harness adds a new type of iteration: fixtures. For now, fixtures are
used to set up the compositor for tests that need a compositor. If necessary, a
fixture setup may include a data array of arbitrary type for executing the test
series for each element in the array. This will be most useful for running
screenshooting tests with both Pixman- and GL-renderers.

The new harness outputs TAP formatted results into stdout. Meson is not
switched to consume TAP yet though, because it would require a Meson version
requirement bump and would not have any benefits at this time. OTOH outputting
TAP is trivial and sets up a clear precedent of random test chatter belonging
to stderr.

This commit migrates only few tests to actually make use of the new features:
roles is a basic client test, subsurface-shot is a client test that
demonstrates the fixture array, and plugin-registry is a plugin test. The rest
of the tests will be migrated later.

Once all tests are migrated, we can remove the test-specific setup from
meson.build, leaving only the actual build instructions in there.

The not migrated tests and stand-alone tests suffer only a minor change: they
no longer fork() for each TEST(), otherwise they keep running as before.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +00:00
Pekka Paalanen 2c8203dcb0 tests: move exit() from run_test()
I will be able to re-use this function if it does not call exit() itself.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-30 10:10:34 +00:00
Pekka Paalanen 1f3615f3cc tests: test-runner needs wayland-client
weston-test-runner.h includes wayland-util.h, therefore it needs
wayland-client. A partial dependency with just compile_args might have been
enough as it does not seem to use functions from wayland-util.c, but safer this
way and no harm.

Fixes: https://lists.freedesktop.org/archives/wayland-devel/2020-January/041149.html

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-01-27 12:15:20 +02:00
Daniel Stone b8c3926445 tests/config-parser: Remove useless duplicate test
test012 and test013 were exact duplicates of each other: asserting that
they could successfully look up a single boolean value.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-28 19:24:13 +00:00
Daniel Stone 51d995ad82 config-parser: Make get_bool be bool
Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.

Make config_parser_get_bool() work on boolean values, and switch all its
users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-28 19:24:13 +00:00
Leandro Ribeiro 442ffcb755 tests: stop using frame_signal 'void *data' argument to get weston_output
Instead of getting weston_output from the frame_signal argument 'void *data',
add weston_output in the private data struct of the users that are listening
to frame_signal. With this change we are able to pass previous_damage as the
data argument.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:47:09 -03:00
Pekka Paalanen b544ac3ab4 tests: drop FAIL_TEST
Nothing is using FAIL_TEST or FAIL_TEST_P and that is good. Remove them to not
encourage using them.

If we need a test that should fail, it always needs to fail in a very specific
way which needs to be checked. For this we have e.g. expect_protocol_error().
We never want a fail-test to pass because it failed in a way we did not expect.
Therefore these macros are useless.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 16:09:41 +02:00
Pekka Paalanen e4f6f8c6de tests/ivi: rename test_section
Use a different section name to make sure that if this plugin is loaded into
the same process as where weston-test-runner.h is used, the two different
sections cannot get mixed up. This is just a precaution, but it removes a bit
of reader confusion as well.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 16:09:20 +02:00
Pekka Paalanen 48d2c15ad6 tests: rename struct weston_test to weston_test_entry
This avoids confusing it with the opaque struct weston_test from
protocol/weston-test.xml.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 12:54:51 +02:00
Pekka Paalanen 54c03dfe51 tests/xwayland: do not call exit(SUCCESS)
Successful tests should just return, not call exit() which breaks the new test
harness when it uses TAP.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 12:54:32 +02: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
Pekka Paalanen dc9d3342a8 tests/subsurface-shot: hardcode reference image names
Using the test name for the reference images will stop working when the new
test harness starts using fixtures. Fixtures allow running the same tests in
varying environments, so the test results file names will include fixture
index. However the reference images will remain the same for all fixtures.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 12:53:29 +02:00
Pekka Paalanen 2c73b673a7 tests: write image to current directory by default
This reverts 50b7b70835.

We didn't make Meson create a logs directory, so writing the images fails
because the directory does not exist. If you run a test without Meson, there is
even less expectation that it would write somewhere else than CWD by default.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-22 12:53:01 +02:00
Pekka Paalanen 6ffbba3ac1 Use weston_compositor_add_destroy_listener_once() in plugins
This introduces a new convention of checking through the compositor destroy
listener if the plugin is already initialized. If the plugin is already
initialized, then the plugin entry function succeeds as a no-op. This makes it
safe to load the same plugin multiple times in a running compositor.

Currently module loading functions return failure if a plugin is already
loaded, but that will change in the future. Therefore we need this other method
of ensuring we do not double-initialize a plugin which would lead to list
corruptions the very least.

All plugins are converted to use the new helper, except:
- those that do not have a destroy listener already, and
- hmi-controller which does the same open-coded as the common code pattern
  did not fit there.

Plugins should always have a compositor destroy listener registered since they
very least allocate a struct to hold their data. Hence omissions are
highlighted in code.

Backends do not need this because weston_compositor_load_backend() already
protects against double-init. GL-renderer does not export a standard module
init function so cannot be initialized the usual way and therefore is not
vulnerable to double-init.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Pekka Paalanen e5e8188aa5 tests: fix test-shell init error path
This was forgetting to remove the compositor destroy listener if init failed,
which would lead to use-after-free on compositor tear-down. Found by
inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Pekka Paalanen f38d4458f7 tests: remove static data from presentation
While get_presentation() will only ever be called once (making the caching of
the return value moot), it is good to stop using the static variable as it
would cause surprising problems if anyone adds more tests here and runs it
under the new test harness.

It was leaked before and continues to be so.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:24:01 +00:00
Pekka Paalanen f8086fb839 tests: remove static data from ivi-layout-test-client
Using static data will mess things up when the test harness no longer fork()'s
each sub-test. Hence it needs to be converted to "normal" data.

Unfortunately here the cached value was actually used, so keeping that
behaviour is a handful. Yes, it was all leaked also before.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:24:01 +00:00
Pekka Paalanen 9551dd7827 tests: remove static data from ivi-shell-app-test
Just one test call this only once, so the cached value will never be useful.

Stop using static data, it sets a bad example. If more tests were added, things
would start failing when forking is removed from the test harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:24:01 +00:00
Pekka Paalanen d19c55c75e tests: remove static data from ivi-layout-test-plugin
I cannot see any reason why this should be static data. But if it is static
data, it will prevent re-entering wet_main() to run tests with this plugin, so
replace it with "normal" data.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:24:01 +00:00
Pekka Paalanen 4058828b54 tests: remove static data from viewporter
This caching is actually never hit. I tested by making the early return abort()
instead and all works just fine.

Remove the caching. The static variable will cause problems when we stop
fork()'ing for each test case.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:24:01 +00:00
Pekka Paalanen 9722ac62f0 tests: surface-screenshot needs libshared
surface-screenshot-test.c uses file_create_dated() provided by libshared, so it
needs to link libshared.

This was not a problem when unresolved symbols during build were allowed and
the symbols was provided by the weston executable which accidentally exported
all libshared symbols. This would become a problem when we disallow unresolved
symbols project-wide, so fix it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:40:51 +03:00