summaryrefslogtreecommitdiff
path: root/src/test/test-engine.c
Commit message (Collapse)AuthorAgeFilesLines
* basic: add RuntimeScope enumLennart Poettering2023-03-101-1/+1
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* analyze: extend the dump command to accept patternsFranck Bui2022-10-131-16/+16
| | | | | | | | | | The new function DumpPatterns() can be used to limit (drastically) the size of the data returned by PID1. Hence the optimization of serializing data into a file descriptor should be less relevant than having the possibility to limit the data when communicating with the service manager remotely. NB: when passing patterns, the dump command omits the version of the manager as well as the features and the timestamps.
* core: Return 1 from unit_add_dependency() on successDaan De Meyer2022-05-121-2/+2
| | | | To allow checking if adding dependency was skipped or not.
* Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-291-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/22649/commits/8b3ad3983f5440eef812b34e5ed862ca59fdf7f7#r837345892 The define is generalized and moved to path-lookup.h, where it seems to fit better. This allows a recursive include to be removed and in general makes things simpler.
* various: align vertically for ease of readingZbigniew Jędrzejewski-Szmek2022-03-101-19/+19
|
* core: split $MONITOR_METADATA and return it only if a single unit triggers ↵Luca Boccassi2022-03-101-0/+7
| | | | | | | | | | | OnFailure/OnSuccess Remove the list logic, and simply skip passing metadata if more than one unit triggered an OnFailure/OnSuccess handler. Instead of a single env var to loop over, provide each separate item as its own variable. Fixes https://github.com/systemd/systemd/issues/22370
* core: replace slice dependencies as they get addedAnita Zhang2021-11-101-1/+30
| | | | | | | | Defines a "UNIT_DEPENDENCY_SLICE_PROPERTY" UnitDependencyMask type that is used when adding slices to the dependencies hashmap. This type is used to remove slice dependencies when they get overridden by new ones. Fixes #20182
* systemd-analyze: add --root option for 'verify' verb and allow path parsingMaanya Goenka2021-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------- Example Run: foobar.service created below is a service unit file that has a non-existing key-value pairing (foo = bar) and is thus, syntactically invalid. maanya-goenka@debian:~/systemd (img-support)$ cat <<EOF>img/usr/lib/systemd/system/foobar.service > [Unit] > foo = bar > > [Service] > ExecStart = /opt/script0.sh > EOF The failure to create foobar.service because of the recursive dependency searching and verification has been addressed in a different PR: systemd-analyze: add option to return an error value when unit verification fails #20233 maanya-goenka@debian:~/systemd (img-support)$ sudo build/systemd-analyze verify --root=img/ foobar.service /home/maanya-goenka/systemd/img/usr/lib/systemd/system/foobar.service:2: Unknown key name 'foo' in section 'Unit', ignoring. foobar.service: Failed to create foobar.service/start: Unit sysinit.target not found.
* core: split out core/manager-dump.[ch]Zbigniew Jędrzejewski-Szmek2021-06-021-0/+1
| | | | This is a fairly specialized topic, let's create a separate file for it.
* test-engine: ensure atom bits are properly packedLennart Poettering2021-05-251-0/+17
| | | | Let's make sure all atoms are actually used, and no holes are left.
* test-engine: extend engine testLennart Poettering2021-05-251-2/+90
| | | | | | Let's verify that the dependency type to atom mapping is consistent. Let's also verify that dependency merging works correctly.
* core: split dependency types into atomsLennart Poettering2021-05-251-16/+16
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tests: move unit files to units/ subdirectoryZbigniew Jędrzejewski-Szmek2020-03-191-1/+4
| | | | | We have a bazillion of those unit files, and keeping them all directly in tests/ has become rather unwieldy.
* tests: modify enter_cgroup_subroot() to return the new pathZbigniew Jędrzejewski-Szmek2019-11-111-1/+1
|
* tests: get rid of test-helper.[ch] completelyZbigniew Jędrzejewski-Szmek2019-11-111-1/+0
| | | | | I don't think there's any particular reason to keep those functions in a separate file.
* tests: make manager_skip_test() not a macro and move to tests.hZbigniew Jędrzejewski-Szmek2019-11-111-1/+1
| | | | There is nothing magic in it.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* core: add helper function to check job statusZbigniew Jędrzejewski-Szmek2019-10-011-3/+3
| | | | | Since job.h includes unit.h, and unit.h includes job.h, imports need to be adjusted to make sure unit.h is included first if the helper is used.
* Create src/shared/unit-file.[ch] for unit-file related opsZbigniew Jędrzejewski-Szmek2019-07-191-0/+1
| | | | | So far we put such functinos in install.[ch], but that is tied too closely to enable/disable. Let's start moving things to a place with a better name.
* tests: Check trivial loop between two jobsMichal Koutný2019-06-261-1/+11
| | | | | | job_compare return value is undefined in case the jobs have a loop between them, so better make a test to make sure transaction cycle detection catches it.
* tests: Check job ordering on execution cyclesMichal Koutný2019-06-261-1/+17
| | | | | | | | | | | | | | | | | | | | | The test-engine Test2 tests the cycle detection when units a, b and d all start at once ,-------------------after-----------------, v | a/start ---after---> d/start ---after---> b/start Extend the test with Test11 that adds i.service which causes a and d stop (by unordered Conflicts=) while starting b. Because stops precede starts, we effectively eliminate the job cycle and all transaction jobs should be applicable. ,-------------------after-----------------, v | a/stop <---after--- d/stop <---after--- b/start . . ^ . . | '. . . . . . . . . i/start ---after------'
* core: add new API for enqueing a job with returning the transaction dataLennart Poettering2019-03-271-10/+10
|
* tests: add a helper function to skip with errnoZbigniew Jędrzejewski-Szmek2018-09-141-4/+2
|
* tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-3/+1
| | | | | 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-4/+2
|
* test: remove support for suffix in get_testdata_dir()Filipe Brandenburger2018-09-121-1/+1
| | | | Instead, use path_join() in callers wherever needed.
* tree-wide: pass NULL arguments to manager_startup() directly, avoid ↵Lennart Poettering2018-06-201-3/+1
| | | | declaring unneeded variables
* 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.
* Merge pull request #8575 from keszybz/non-absolute-pathsLennart Poettering2018-04-171-7/+7
|\ | | | | Do not require absolute paths in ExecStart and friends
| * tests: use manager_load_startable_unit_or_warn() to load unitsZbigniew Jędrzejewski-Szmek2018-04-161-7/+7
| | | | | | | | | | | | | | | | Doing manager_load_unit() followed by UNIT_VTABLE(unit)->start(unit) would result in an assertion failure in ->start() if the unit failed to load properly. Something like this is okey-ish is tests, since the test units are not expected to fail to load, but the reason for failure is clearer if we fail immediately.
* | test: add test for prefix unit loadingLennart Poettering2018-04-131-1/+10
| |
* | 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.
* Make MANAGER_TEST_RUN_MINIMAL just allocate data structuresZbigniew Jędrzejewski-Szmek2018-03-111-1/+1
| | | | | | | | | When running tests like test-unit-name, there is not point in setting up the cgroup and signals and interacting with the environment. Similarly when running fuzz testing of the parser. Add new MANAGER_TEST_RUN_BASIC which takes the role of MANAGER_TEST_RUN_MINIMAL, and redefine MANAGER_TEST_RUN_MINIMAL to just create the basic data structures.
* Introduce _cleanup_(manager_freep)Zbigniew Jędrzejewski-Szmek2018-03-111-3/+1
|
* 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.
* core: add internal API to remove dependencies again, based on dependency maskLennart Poettering2017-11-101-0/+27
| | | | | let's make use of the dependency mask, and add internal API to remove dependencies ago, based on bits in the dependency mask.
* tests: skip tests when cg_pid_get_path fails (#7033)Zbigniew Jędrzejewski-Szmek2017-10-101-1/+5
| | | | | v2: - cast the fstype_t type to ull, because it varies between arches. Making it long long should be on the safe side.
* Make test_run into a flags field and disable generators againZbigniew Jędrzejewski-Szmek2017-09-191-1/+1
| | | | | | | | | | Now generators are only run in systemd --test mode, where this makes most sense (how are you going to test what would happen otherwise?). Fixes #6842. v2: - rename test_run to test_run_flags
* tests: when running a manager object in a test, migrate to private cgroup ↵Lennart Poettering2017-08-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | subroot first (#6576) Without this "meson test" will end up running all tests in the same cgroup root, and they all will try to manage it. Which usually isn't too bad, except when they end up clearing up each other's cgroups. This race is hard to trigger but has caused various CI runs to fail spuriously. With this change we simply move every test that runs a manager object into their own private cgroup. Note that we don't clean up the cgroup at the end, we leave that to the cgroup manager around it. This fixes races that become visible by test runs throwing out errors like this: ``` exec-systemcallfilter-failing.service: Passing 0 fds to service exec-systemcallfilter-failing.service: About to execute: /bin/echo 'This should not be seen' exec-systemcallfilter-failing.service: Forked /bin/echo as 5693 exec-systemcallfilter-failing.service: Changed dead -> start exec-systemcallfilter-failing.service: Failed to attach to cgroup /exec-systemcallfilter-failing.service: No such file or directory Received SIGCHLD from PID 5693 ((echo)). Child 5693 ((echo)) died (code=exited, status=219/CGROUP) exec-systemcallfilter-failing.service: Child 5693 belongs to exec-systemcallfilter-failing.service exec-systemcallfilter-failing.service: Main process exited, code=exited, status=219/CGROUP exec-systemcallfilter-failing.service: Changed start -> failed exec-systemcallfilter-failing.service: Unit entered failed state. exec-systemcallfilter-failing.service: Failed with result 'exit-code'. exec-systemcallfilter-failing.service: cgroup is empty Assertion 'service->main_exec_status.status == status_expected' failed at ../src/src/test/test-execute.c:71, function check(). Aborting. ``` BTW, I tracked this race down by using perf: ``` # perf record -e cgroup:cgroup_mkdir,cgroup_rmdir … # perf script ``` Thanks a lot @iaguis, @alban for helping me how to use perf for this. Fixes #5895.
* test: drop TEST_DATA_DIR, fold into get_testdata_dir()Martin Pitt2017-02-161-1/+1
| | | | | | 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: setup test data dir before fake runtime dirMartin Pitt2017-02-161-2/+1
| | | | | | That way, if the test directory does not exist we don't leave behind temporary files (as in that case or on test failure the cleanup actions don't run).
* test: make unit tests relocatableMartin Pitt2017-02-131-1/+1
| | | | | | | | | | | | | | | | 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: get rid of strerrorZbigniew Jędrzejewski-Szmek2016-09-131-1/+1
|
* basic: remove rm_rf_and_free, add rm_rf_physical_and_free, use ↵Evgeny Vereshchagin2016-05-201-1/+1
| | | | | | | | | | | rm_rf_physical_and_freep in tests (#3292) Some distros don't mount /tmp as tmpfs. For example: https://lists.ubuntu.com/archives/ubuntu-cloud/2016-January/001009.html Some tests: * print 'Attempted to remove disk file system, and we can't allow that.' * don't really cleanup /tmp
* tests: override XDG_RUNTIME_DIR where we use the user runtime dirLennart Poettering2016-04-121-0/+5
| | | | | | | 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.
* core: remove ManagerRunningAs enumLennart Poettering2016-04-121-1/+1
| | | | | | | | | | | Previously, we had two enums ManagerRunningAs and UnitFileScope, that were mostly identical and converted from one to the other all the time. The latter had one more value UNIT_FILE_GLOBAL however. Let's simplify things, and remove ManagerRunningAs and replace it by UnitFileScope everywhere, thus making the translation unnecessary. Introduce two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking if we are running in one or the user context.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tests: fix newlines in skip messageZbigniew Jędrzejewski-Szmek2015-12-021-1/+1
|