summaryrefslogtreecommitdiff
path: root/src/shared/tests.c
Commit message (Collapse)AuthorAgeFilesLines
* util-lib: split out env file parsing code into env-file.cLennart Poettering2018-12-021-1/+1
| | | | | | It's quite complex, let's split this out. No code changes, just some file rearranging.
* tree-wide: rename path_join_many() to path_join()Zbigniew Jędrzejewski-Szmek2018-11-301-1/+1
| | | | | | $ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g' The two test functions are merged into one.
* tree-wide: replace path_join with path_join_manyZbigniew Jędrzejewski-Szmek2018-11-301-1/+1
|
* fileio: drop "newline" parameter for env file parsersLennart Poettering2018-11-141-1/+1
| | | | | | | Now that we don't (mis-)use the env file parser to parse kernel command lines there's no need anymore to override the used newline character set. Let's hence drop the argument and just "\n\r" always. This nicely simplifies our code.
* tests: add helper call have_namespaces() to test whether Linux namespaces ↵Lennart Poettering2018-10-241-0/+37
| | | | | | are available A slighly sloppy test call for conditionalizing several tests.
* tests: as per CODING_STYLE undefine basename() right after including libgen.hLennart Poettering2018-10-241-1/+6
|
* tests: alloc-util.h and fs-util.h are our own headersLennart Poettering2018-10-241-2/+1
| | | | | Hence include them with "" rather than <>. Also including them twices is a pretty bad idea too.
* tests: add a helper function to skip with errnoZbigniew Jędrzejewski-Szmek2018-09-141-0/+6
|
* tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-0/+6
| | | | | The advantages are that we save a few lines, and that we can override logging using environment variables in more test executables.
* tests: add helper to unify skipping a test and exitingZbigniew Jędrzejewski-Szmek2018-09-141-0/+7
|
* tests: centralize check for slow testsZbigniew Jędrzejewski-Szmek2018-09-131-0/+13
|
* test: use ${builddir}/systemd-runtest.env for $SYSTEMD_CATALOG_DIRFilipe Brandenburger2018-09-121-6/+16
| | | | | | | | | | | | | 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.
* test: use ${builddir}/systemd-runtest.env to set $SYSTEMD_TEST_DATAFilipe Brandenburger2018-09-121-35/+32
| | | | | | | | | | | | | | | | | | | | | 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.
* test: remove support for suffix in get_testdata_dir()Filipe Brandenburger2018-09-121-3/+1
| | | | Instead, use path_join() in callers wherever needed.
* test: introduce test_is_running_from_builddir()Yu Watanabe2018-09-111-3/+20
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | 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.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | 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.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we canLennart Poettering2017-12-251-2/+2
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* test: drop TEST_DATA_DIR, fold into get_testdata_dir()Martin Pitt2017-02-161-20/+25
| | | | | | 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.
* test: show error message if $SYSTEMD_TEST_DATA does not existMartin Pitt2017-02-161-1/+12
| | | | | | 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.
* tests: look for tests relative to source dir when running from build dirZbigniew Jędrzejewski-Szmek2017-02-161-5/+12
| | | | | | | | | | | | | | | | automake helpfully sets a few variables for during build. When our executable is in a directory underneath $(abs_top_builddir), we know that we're in the build environment $(abs_top_srcdir) contains the sources, and test data is under $(abs_top_srcdir)/test. This remains true no matter where the build directory is relative to the source directory. It also works if the test executable is invoked as ./test-whatever or .libs/test-whatever, since the relative path is not used at all. When running from outside of the build directory, we should be running from the installed location and we can look for ../testdata relative to the location of the exe file. Of course, $SYSTEMD_TEST_DATA always overrides this logic.
* Rename $TEST_DIR to $SYSTEMD_TEST_DATA, document itZbigniew Jędrzejewski-Szmek2017-02-161-1/+1
| | | | | TEST_DIR is rather generic, and we prefix all variables used by installed executables with "SYSTEMD_".
* test: clarify error message if test data directory does not existMartin Pitt2017-02-161-0/+4
| | | | | | When trying to directly run a test executable in the build tree without setting $TEST_DIR, some tests fail with a non-obvious error message. Print an useful one instead.
* test: make unit tests relocatableMartin Pitt2017-02-131-0/+13
| | | | | | | | | | | | | | | | 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.
* tests: override XDG_RUNTIME_DIR where we use the user runtime dirLennart Poettering2016-04-121-0/+33
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.