diff options
author | Filipe Brandenburger <filbranden@google.com> | 2018-09-11 23:55:02 -0700 |
---|---|---|
committer | Filipe Brandenburger <filbranden@google.com> | 2018-09-12 09:49:03 -0700 |
commit | e2d413707fc68ed033a83e10a055ca638a1e1e18 (patch) | |
tree | a58e24cbbe43ea9e22c4dce0835b179f763f617b /meson.build | |
parent | 55890a40c3ec0c061c04d1395a38c26313132d12 (diff) | |
download | systemd-e2d413707fc68ed033a83e10a055ca638a1e1e18.tar.gz systemd-e2d413707fc68ed033a83e10a055ca638a1e1e18.tar.bz2 systemd-e2d413707fc68ed033a83e10a055ca638a1e1e18.zip |
test: use ${builddir}/systemd-runtest.env to set $SYSTEMD_TEST_DATA
This simplifies get_testdata_dir() to simply checking for an environment
variable, with an additional function to locate a systemd-runtest.env file in
the same directory as the test binary and reading environment variable
assignments from that file if it exists.
This makes it possible to:
- Run `ninja test` from the build dir and have it use ${srcdir}/test for
test unit definitions.
- Run a test directly, such as `build/test-execute` and have it locate
them correctly.
- Run installed tests (from systemd-tests package) and locate the test
units in the installed location (/usr/lib/systemd/tests/testdata), in
which case the absence of the systemd-runtest.env file will have
get_testdata_dir() use the installed location hardcoded into the
binaries.
Explicit setting of $SYSTEMD_TEST_DATA still overrides the contents of
systemd-runtest.env.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/meson.build b/meson.build index d4d6f01377..ed91d1a4db 100644 --- a/meson.build +++ b/meson.build @@ -206,6 +206,7 @@ conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir) conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir) conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map')) conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map')) +conf.set_quoted('SYSTEMD_TEST_DATA', join_paths(testsdir, 'testdata')) conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir) conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent')) conf.set_quoted('LIBDIR', libdir) @@ -222,7 +223,6 @@ conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_ conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no') conf.set_quoted('ABS_BUILD_DIR', meson.build_root()) -conf.set_quoted('ABS_SRC_DIR', meson.source_root()) substs.set('prefix', prefixdir) substs.set('exec_prefix', prefixdir) @@ -2607,6 +2607,14 @@ executable('systemd-sulogin-shell', ############################################################ +custom_target( + 'systemd-runtest.env', + output : 'systemd-runtest.env', + command : ['sh', '-c', '{ ' + + 'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(meson.current_source_dir(), 'test')) + + '} >@OUTPUT@'], + build_by_default : true) + foreach tuple : tests sources = tuple[0] link_with = tuple[1].length() > 0 ? tuple[1] : [libshared] |