Commit Graph

23 Commits

Author SHA1 Message Date
Anita Zhang 61ff7397d0 systemd-oomd: unit testable helper functions
Helpers used by the systemd-oomd daemon to read/fill in various contexts and
make detection and kill decisions.

i.e. a simplified/less configurable version of
https://github.com/facebookincubator/oomd/tree/master/src/oomd.
2020-10-07 17:12:22 -07:00
Zbigniew Jędrzejewski-Szmek 7b43295346 tests: move unit files to units/ subdirectory
We have a bazillion of those unit files, and keeping them all directly in tests/
has become rather unwieldy.
2020-03-19 16:23:27 +01:00
Zbigniew Jędrzejewski-Szmek 64ad9e088d tests: modify enter_cgroup_subroot() to return the new path 2019-11-11 14:55:57 +01:00
Zbigniew Jędrzejewski-Szmek 48e98ba5c3 tests: get rid of test-helper.[ch] completely
I don't think there's any particular reason to keep those functions in a separate
file.
2019-11-11 14:55:57 +01:00
Zbigniew Jędrzejewski-Szmek 5eecb1030f tests: make manager_skip_test() not a macro and move to tests.h
There is nothing magic in it.
2019-11-11 14:55:57 +01:00
Zbigniew Jędrzejewski-Szmek 77abd02985 tests: move memlock helper to shared code 2019-11-10 23:22:15 +01:00
Lennart Poettering a4bc3c1d25 tests: add helper call have_namespaces() to test whether Linux namespaces are available
A slighly sloppy test call for conditionalizing several tests.
2018-10-24 19:40:24 +02:00
Zbigniew Jędrzejewski-Szmek ca7a9afc7e test-sd-hwdb: add a simple test for export sd-hwdb functions 2018-09-30 20:39:02 +02:00
Zbigniew Jędrzejewski-Szmek 730d989acc tests: add a helper function to skip with errno 2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 317bb217d3 tests: add helper to unify skipping a test and exiting 2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 0cf29baac0 tests: centralize check for slow tests 2018-09-13 12:07:27 +02:00
Filipe Brandenburger 49cdae63d1 test: use ${builddir}/systemd-runtest.env for $SYSTEMD_CATALOG_DIR
This makes it so that tests no longer need to know the absolute paths to the
source and build dirs, instead using the systemd-runtest.env file to get these
paths when running from the build tree.

Confirmed that test-catalog works on `ninja test`, when called standalone and
also when the environment file is not present, in which case it will use the
installed location under /usr/lib/systemd/catalog.

The location can now also be overridden for this test by setting the
$SYSTEMD_CATALOG_DIR environment variable.
2018-09-12 09:49:03 -07:00
Filipe Brandenburger 55890a40c3 test: remove support for suffix in get_testdata_dir()
Instead, use path_join() in callers wherever needed.
2018-09-12 09:49:03 -07:00
Yu Watanabe 8cb10a4f4d test: introduce test_is_running_from_builddir() 2018-09-11 09:17:22 +09:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Martin Pitt cc100a5a9b test: drop TEST_DATA_DIR, fold into get_testdata_dir()
Drop the TEST_DATA_DIR macro as this was using alloca() within a
function call which is allegedly unsafe. So add a "suffix" argument to
get_testdata_dir() instead and call that directly.
2017-02-16 21:45:57 +01:00
Martin Pitt c60b6ddafb test: show error message if $SYSTEMD_TEST_DATA does not exist
Rename get_exe_relative_testdata_dir() to get_testdata_dir() and move
the env var check into that, so that everything interesting happens at
the same place.
2017-02-16 21:36:31 +01:00
Martin Pitt f853c6efb5 test: make unit tests relocatable
It is useful to package test-* binaries and run them as root under
autopkgtest or manually on particular machines. They currently have a
built-in hardcoded absolute path to their test data, which does not work
when running the test programs from any other path than the original
build directory.

By default, make the tests look for their data in
<test_exe_directory>/testdata/ so that they can be called from any
directory (provided that the corresponding test data is installed
correctly). As we don't have a fixed static path in the build tree (as
build and source tree are independent), set $TEST_DIR with "make check"
to point to <srcdir>/test/, as we previously did with an automake
variable.
2017-02-13 22:31:13 +01:00
Lennart Poettering d2120590ff tests: override XDG_RUNTIME_DIR where we use the user runtime dir
We don#t really support systems where XDG_RUNTIME_DIR is not supported for
systemd --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that
involve systemd --user, so that we know it is set, and that it doesn't polute
the user's actual runtime dir.
2016-04-12 13:43:33 +02:00