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>
2019-11-01 15:02:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Collabora, Ltd.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WESTON_TESTSUITE_DATA_H
|
|
|
|
#define WESTON_TESTSUITE_DATA_H
|
|
|
|
|
|
|
|
/** Standard return codes
|
|
|
|
*
|
|
|
|
* Both Autotools and Meson use these codes as test program exit codes
|
|
|
|
* to denote the test result for the whole process.
|
|
|
|
*
|
|
|
|
* \ingroup testharness
|
|
|
|
*/
|
|
|
|
enum test_result_code {
|
|
|
|
RESULT_OK = 0,
|
|
|
|
RESULT_SKIP = 77,
|
|
|
|
RESULT_FAIL = 1,
|
|
|
|
RESULT_HARD_ERROR = 99,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_test;
|
|
|
|
struct weston_compositor;
|
|
|
|
|
|
|
|
/** Weston test types
|
|
|
|
*
|
|
|
|
* \sa weston_test_harness_execute_standalone
|
|
|
|
* weston_test_harness_execute_as_plugin
|
|
|
|
* weston_test_harness_execute_as_client
|
|
|
|
*
|
|
|
|
* \ingroup testharness_private
|
|
|
|
*/
|
|
|
|
enum test_type {
|
|
|
|
TEST_TYPE_STANDALONE,
|
|
|
|
TEST_TYPE_PLUGIN,
|
|
|
|
TEST_TYPE_CLIENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Test harness specific data for running tests
|
|
|
|
*
|
|
|
|
* \ingroup testharness_private
|
|
|
|
*/
|
|
|
|
struct wet_testsuite_data {
|
|
|
|
void (*run)(struct wet_testsuite_data *);
|
|
|
|
|
|
|
|
/* test definitions */
|
|
|
|
const struct weston_test_entry *tests;
|
|
|
|
unsigned tests_count;
|
|
|
|
int case_index;
|
|
|
|
enum test_type type;
|
|
|
|
struct weston_compositor *compositor;
|
|
|
|
|
|
|
|
/* client thread control */
|
|
|
|
int thread_event_pipe;
|
|
|
|
|
|
|
|
/* informational run state */
|
|
|
|
int fixture_iteration;
|
2021-02-15 15:43:14 +03:00
|
|
|
const char *fixture_name;
|
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>
2019-11-01 15:02:15 +03:00
|
|
|
|
|
|
|
/* test counts */
|
|
|
|
unsigned counter;
|
|
|
|
unsigned passed;
|
|
|
|
unsigned skipped;
|
|
|
|
unsigned failed;
|
|
|
|
unsigned total;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* WESTON_TESTSUITE_DATA_H */
|