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>
dev
Pekka Paalanen 5 years ago committed by Daniel Stone
parent 57a4508ee4
commit 7f840b721a
  1. 17
      tests/ivi-layout-test-client.c
  2. 76
      tests/ivi-layout-test-plugin.c
  3. 33
      tests/meson.build

@ -34,6 +34,20 @@
#include "weston-test-client-helper.h"
#include "ivi-application-client-protocol.h"
#include "ivi-test.h"
#include "weston-test-fixture-compositor.h"
static enum test_result_code
fixture_setup(struct weston_test_harness *harness)
{
struct compositor_setup setup;
compositor_setup_defaults(&setup);
setup.shell = SHELL_IVI;
setup.extra_module = "test-ivi-layout.so";
return weston_test_harness_execute_as_client(harness, &setup);
}
DECLARE_FIXTURE_SETUP(fixture_setup);
struct runner {
struct client *client;
@ -171,9 +185,6 @@ ivi_window_destroy(struct ivi_window *wnd)
/******************************** tests ********************************/
/*
* This is a test program, launched by ivi-layout-test-plugin.c. Each TEST()
* is forked and exec'd as usual with the weston-test-runner framework.
*
* These tests make use of weston_test_runner global interface exposed by
* ivi-layout-test-plugin.c. This allows these tests to trigger compositor-side
* checks.

@ -91,8 +91,6 @@ struct test_context {
struct test_launcher {
struct weston_compositor *compositor;
struct test_context context;
char exe[2048];
struct weston_process process;
const struct ivi_layout_interface *layout_interface;
};
@ -181,56 +179,10 @@ bind_runner(struct wl_client *client, void *data,
}
}
static void
test_client_sigchld(struct weston_process *process, int status)
{
struct test_launcher *launcher =
container_of(process, struct test_launcher, process);
struct weston_compositor *c = launcher->compositor;
/* Chain up from weston-test-runner's exit code so that ninja
* knows the exit status and can report e.g. skipped tests. */
if (WIFEXITED(status))
weston_compositor_exit_with_code(c, WEXITSTATUS(status));
else
weston_compositor_exit_with_code(c, EXIT_FAILURE);
}
static void
idle_launch_client(void *data)
{
struct test_launcher *launcher = data;
pid_t pid;
sigset_t allsigs;
pid = fork();
if (pid == -1) {
weston_log("fatal: failed to fork '%s': %s\n", launcher->exe,
strerror(errno));
weston_compositor_exit_with_code(launcher->compositor,
EXIT_FAILURE);
return;
}
if (pid == 0) {
sigfillset(&allsigs);
sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
execl(launcher->exe, launcher->exe, NULL);
weston_log("compositor: executing '%s' failed: %s\n",
launcher->exe, strerror(errno));
_exit(EXIT_FAILURE);
}
launcher->process.pid = pid;
launcher->process.cleanup = test_client_sigchld;
weston_watch_process(&launcher->process);
}
WL_EXPORT int
wet_module_init(struct weston_compositor *compositor,
int *argc, char *argv[])
{
struct wl_event_loop *loop;
struct test_launcher *launcher;
const struct ivi_layout_interface *iface;
@ -245,13 +197,6 @@ wet_module_init(struct weston_compositor *compositor,
if (!launcher)
return -1;
if (weston_module_path_from_env("ivi-layout-test-client.ivi",
launcher->exe,
sizeof launcher->exe) == 0) {
weston_log("test setup failure: WESTON_MODULE_MAP not set\n");
return -1;
}
launcher->compositor = compositor;
launcher->layout_interface = iface;
@ -260,9 +205,6 @@ wet_module_init(struct weston_compositor *compositor,
launcher, bind_runner) == NULL)
return -1;
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, idle_launch_client, launcher);
return 0;
}
@ -301,18 +243,15 @@ runner_assert_fail(const char *cond, const char *file, int line,
/*************************** tests **********************************/
/*
* This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
* This is a IVI controller module requiring ivi-shell.so.
* This module is specially written to execute tests that target the
* ivi_layout API.
*
* This module is listed in meson.build which handles
* this module specially by loading it in ivi-shell.
*
* Once Weston init completes, this module launches one test program:
* ivi-layout-test-client.ivi (ivi-layout-test-client.c).
* That program uses the weston-test-runner
* framework to fork and exec each TEST() in ivi-layout-test-client.c with a fresh
* connection to the single compositor instance.
* The test program containing the fixture setup and initiating the tests is
* test-ivi-layout-client (ivi-layout-test-client.c).
* That program uses the weston-test-runner framework to execute each TEST()
* in ivi-layout-test-client.c with a fresh connection to the single
* compositor instance.
*
* Each TEST() in ivi-layout-test-client.c will bind to weston_test_runner global
* interface. A TEST() will set up the client state, and issue
@ -324,8 +263,7 @@ runner_assert_fail(const char *cond, const char *file, int line,
*
* A RUNNER_TEST() function simply returns when it succeeds. If it fails,
* a fatal protocol error is sent to the client from runner_assert() or
* runner_assert_or_return(). This module catches the test program exit
* code and passes it out of Weston to the test harness.
* runner_assert_or_return().
*
* A single TEST() in ivi-layout-test-client.c may use multiple RUNNER_TEST()s to
* achieve multiple test points over a client action sequence.

@ -220,30 +220,33 @@ if get_option('shell-ivi')
]
tests_weston_plugin += [
['ivi-layout-internal'],
[
'ivi-layout',
]
ivi_layout_test_plugin = shared_library(
'test-ivi-layout',
[
'ivi-layout-test-plugin.c',
weston_test_server_protocol_h,
weston_test_protocol_c,
],
[ dep_libexec_weston ]
],
]
include_directories: common_inc,
dependencies: [ dep_libweston_private, dep_libexec_weston ],
name_prefix: '',
install: false,
)
env_modmap += 'test-ivi-layout.so=' + ivi_layout_test_plugin.full_path() + ';'
exe_ivi_layout_client = executable(
'ivi-layout-test-client',
tests += [
{
'name': 'ivi-layout-client',
'sources': [
'ivi-layout-test-client.c',
weston_test_client_protocol_h,
weston_test_protocol_c,
ivi_application_client_protocol_h,
ivi_application_protocol_c,
include_directories: common_inc,
dependencies: dep_test_client,
install: false
)
env_modmap += 'ivi-layout-test-client.ivi=@0@;'.format(exe_ivi_layout_client.full_path())
],
'test_deps': [ ivi_layout_test_plugin ],
},
]
endif
env_test_weston = [

Loading…
Cancel
Save