summaryrefslogtreecommitdiff
path: root/src/test/test-path.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* tests: always use the right vtable wrapper callsLennart Poettering2018-11-201-9/+9
| | | | Prompted by https://github.com/systemd/systemd/pull/10836#discussion_r234598868
* 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-2/+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-7/+5
|
* test: remove support for suffix in get_testdata_dir()Filipe Brandenburger2018-09-121-1/+4
| | | | Instead, use path_join() in callers wherever needed.
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* 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.
* core: undo the dependency inversion between unit.h and all unit typesFelipe Sateler2018-05-151-0/+1
|
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-04-191-1/+0
| | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* 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.
* | 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.
* test-path: Set umask explicitly (#8616)Filipe Brandenburger2018-04-041-0/+4
| | | | | | | | | | Running `test-path` under an umask such as 027 fails with: Assertion '(s.st_mode & S_IRWXO) == 0004' failed at ../src/test/test-path.c:247, function test_path_makedirectory_directorymode(). Aborting. Looking at directory /tmp/test-path_makedirectory, it was indeed created with mode 0740, applying the umask to the requested 0744. Set an explicit umask for this test, to ensure reproducible results.
* 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.
* 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-path: fix inverted return value (#7050)Zbigniew Jędrzejewski-Szmek2017-10-171-1/+1
| | | | | It must be <0 to indicate failure. Fixes #7050.
* 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-1/+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.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* 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-2/+6
| | | | | | | 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: minor formatting inconsistency cleanupsVito Caputo2016-02-231-1/+1
|
* tests: fix newlines in skip messageZbigniew Jędrzejewski-Szmek2015-12-021-1/+1
|
* tests: turn check if manager cannot be intialized into macroZbigniew Jędrzejewski-Szmek2015-12-021-1/+2
| | | | | | | | | | We need to check the same thing in multiple tests. Use a shared macro to make it easier to update the list of errnos. Change the errno code for "unitialized cgroup fs" for ENOMEDIUM. Exec format error looks like something more serious. This fixes test-execute invocation in mock.
* test-path: move all related test files to a specific directoryRonny Chevalier2015-10-311-1/+1
| | | | To avoid polluting test/
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering2015-10-271-1/+2
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-5/+6
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* tests: Skip tests which need to access /sys/fs/cgroup if that is not availableMartin Pitt2015-09-041-1/+1
| | | | | | | | | | | | | Commit efdb023 ("core: unified cgroup hierarchy support") introduced a new error ENOEXEC in cg_unified() if /sys/fs/cgroup/ is not available. Adjust the "skip" checks in various tests accordingly. Add a corresponding "skip" check to test-bus-creds as well, as sd_bus_creds_new_from_pid() now calls cg_unified() as well. This re-fixes "make check" in build chroots without /sys/fs/cgroup. https://github.com/systemd/systemd/issues/1132
* core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering2015-05-111-1/+1
| | | | | | It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
* test: test-path and test-execute only need units in test/Ronny Chevalier2015-04-211-1/+1
|
* util: rework rm_rf() logicLennart Poettering2015-04-061-3/+9
| | | | | | | | - Move to its own file rm-rf.c - Change parameters into a single flags parameter - Remove "honour sticky" logic, it's unused these days
* fix gcc warnings about uninitialized variablesHarald Hoyer2015-03-271-1/+1
| | | | | | | | | | | | | like: src/shared/install.c: In function ‘unit_file_lookup_state’: src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] return r < 0 ? r : state; ^ src/shared/install.c:1796:13: note: ‘r’ was declared here int r; ^
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-031-2/+2
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* test-path: do not skip tests if we are not rootRonny Chevalier2015-01-151-4/+0
| | | | We can properly run the tests without being root
* tree-wide: spelling fixesVeres Lajos2014-12-301-1/+1
| | | | | | | https://github.com/vlajos/misspell_fixer https://github.com/torstehu/systemd/commit/b6fdeb618cf2f3ce1645b3315f15f482710c7ffa Thanks to Torstein Husebo <torstein@huseboe.net>.
* manager: allow test run to catch SIGCHLD eventsRonny Chevalier2014-11-131-1/+0
| | | | Otherwise we cannot know when a service exited
* tests: add test-pathRonny Chevalier2014-11-081-0/+272
It tests all available directives of Path units: - PathChanged - PathModified - PathExists - PathExisysGlob - DirectoryNotEmpty - MakeDirectory - DirectoryMode - Unit