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>
dev
Pekka Paalanen 5 years ago committed by Daniel Stone
parent babb3b3bc2
commit 82dd6ce830
  1. 10
      tests/meson.build
  2. 3
      tests/weston-test-client-helper.c
  3. 7
      tests/weston-test-fixture-compositor.c

@ -64,7 +64,6 @@ exe_plugin_test = shared_library(
name_prefix: '',
install: false,
)
config_h.set_quoted('TESTSUITE_PLUGIN_PATH', exe_plugin_test.full_path())
deps_zuc = [ dep_libshared ]
if get_option('test-junit-xml')
@ -250,6 +249,13 @@ env_test_weston = [
'WESTON_DATA_DIR=' + join_paths(meson.current_source_dir(), '..', 'data'),
]
test_config_h = configuration_data()
test_config_h.set_quoted('WESTON_TEST_REFERENCE_PATH', meson.current_source_dir() + '/reference')
test_config_h.set_quoted('WESTON_MODULE_MAP', env_modmap)
test_config_h.set_quoted('WESTON_DATA_DIR', join_paths(meson.current_source_dir(), '..', 'data'))
test_config_h.set_quoted('TESTSUITE_PLUGIN_PATH', exe_plugin_test.full_path())
configure_file(output: 'test-config.h', configuration: test_config_h)
foreach t : tests
t_name = 'test-' + t.get('name')
t_sources = t.get('sources', [t.get('name') + '-test.c'])
@ -271,7 +277,7 @@ foreach t : tests
install: false,
)
test(t.get('name'), t_exe, depends: t.get('test_deps', []), env: env_test_weston)
test(t.get('name'), t_exe, depends: t.get('test_deps', []))
endforeach
# FIXME: the multiple loops is lame. rethink this.

@ -34,6 +34,7 @@
#include <sys/mman.h>
#include <cairo.h>
#include "test-config.h"
#include "shared/os-compatibility.h"
#include "shared/xalloc.h"
#include <libweston/zalloc.h>
@ -1025,7 +1026,7 @@ reference_path(void)
char *path = getenv("WESTON_TEST_REFERENCE_PATH");
if (!path)
return "./tests/reference";
return WESTON_TEST_REFERENCE_PATH;
return path;
}

@ -31,6 +31,7 @@
#include "shared/helpers.h"
#include "weston-test-fixture-compositor.h"
#include "weston.h"
#include "test-config.h"
struct prog_args {
int argc;
@ -180,6 +181,12 @@ execute_compositor(const struct compositor_setup *setup,
const char *ctmp;
int ret;
if (setenv("WESTON_MODULE_MAP", WESTON_MODULE_MAP, 0) < 0 ||
setenv("WESTON_DATA_DIR", WESTON_DATA_DIR, 0) < 0) {
fprintf(stderr, "Error: environment setup failed.\n");
return RESULT_HARD_ERROR;
}
#ifndef BUILD_DRM_COMPOSITOR
if (setup->backend == WESTON_BACKEND_DRM) {
fprintf(stderr, "DRM-backend required but not built, skipping.\n");

Loading…
Cancel
Save