summaryrefslogtreecommitdiffstats
path: root/src/test/test-cgroup-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ASSERT_STREQ for simple casesIvan Kruglov2024-04-151-11/+11
|
* ASSERT_NULL/ASSERT_NOT_NULLIvan Kruglov2024-04-101-2/+2
|
* I made more unit test to use the test macroUsman Akinyemi2024-04-081-4/+4
|
* test-cgroup-util: reduce scope of iterator variablesZbigniew Jędrzejewski-Szmek2024-03-201-7/+8
|
* test: Skip various tests when /sys is not mountedDaan De Meyer2023-12-191-2/+2
| | | | | When running tests in a container, /sys might not be mounted, so let's make sure we skip tests that depend on /sys in this case.
* test: port tests over to new /proc/ enumeration APILennart Poettering2023-10-181-19/+17
|
* process-util: add pidref_is_kernel_thread()Lennart Poettering2023-10-181-1/+1
|
* tree-wide: drop unnecessary inclusion of version.hYu Watanabe2023-07-291-1/+0
|
* cgroup: rework how we validate/escape cgroupsLennart Poettering2023-04-271-5/+10
| | | | | | Let's clean up validation/escaping of cgroup names. i.e. split out code that tests if name needs escaping. Return proper error codes, and extend test a bit.
* core: add cg_path_get_unit_path()Quentin Deslandes2023-02-081-0/+27
| | | | | | | | | | From a given cgroup path, cg_path_get_unit() allows to retrieve the unit's name. Although, this removes the path to the unit's cgroup, preventing the result to be used to fetch xattrs. Introduce cg_path_get_unit_path() which provides the path to the unit's cgroup. This function behave similarly to cg_path_get_unit() (checking the validity and escaping the unit's name).
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* cgroup-util: Move macros to macros and tests to testsMichal Koutný2022-01-101-0/+9
| | | | | Friends to friends to be consistent with the other macros and make tests separate from main code.
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* test: Convert to TEST/TEST_RET macrosJan Janssen2021-11-281-44/+19
| | | | | Note that test-cgroup-mask, test-cgroup-unit-default and test-unit-name will now report being skipped instead of reporting success if not run under systemd.
* test: use assert_se() instead of assert()Yu Watanabe2021-10-121-2/+2
|
* meson: simplify the BUILD_MODE conditionalZbigniew Jędrzejewski-Szmek2021-04-141-1/+1
| | | | | | | Using a enum is all nice and generic, but at this point it seems unlikely that we'll add further build modes. But having an enum means that we need to include the header file with the enumeration whenerever the conditional is used. I want to use the conditional in log.h, which makes it hard to avoid circular imports.
* test: skip tests if cgroup isn't mountedDan Streetman2021-02-251-1/+1
| | | | | | Debian builds in a chroot without cgroup mounted, so tests expecting to access cgroup will fail with ENOMEDIUM, so skip the tests in that situation.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* test-cgroup-util: Handle result=NULL as empty stringGaurav Singh2020-07-291-3/+3
| | | | Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
* test: fix potential use-after-freeFrantisek Sumsal2020-05-041-1/+1
| | | | CID#1428676.
* basic/cgroup-util: introduce cg_get_keyed_attribute_full()Michal Sekletár2020-04-291-0/+20
| | | | | | Callers of cg_get_keyed_attribute_full() can now specify via the flag whether the missing keyes in cgroup attribute file are OK or not. Also the wrappers for both strict and graceful version are provided.
* tests: various small fixes for strict systemsTopi Miettinen2020-04-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | Don't assume that 4MB can be allocated from stack since there could be smaller DefaultLimitSTACK= in force, so let's use malloc(). NUL terminate the huge strings by hand, also ensure termination in test_lz4_decompress_partial() and optimize the memset() for the string. Some items in /proc and /etc may not be accessible to poor unprivileged users due to e.g. SELinux, BOFH or both, so check for EACCES and EPERM. /var/tmp may be a symlink to /tmp and then path_compare() will always fail, so let's stick to /tmp like elsewhere. /tmp may be mounted with noexec option and then trying to execute scripts from there would fail. Detect and warn if seccomp is already in use, which could make seccomp test fail if the syscalls are already blocked. Unset $TMPDIR so it will not break specifier tests where %T is assumed to be /tmp and %V /var/tmp.
* 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.
* util-lib: move some functions from basic/cgroup-util to shared/cgroup-setupZbigniew Jędrzejewski-Szmek2019-09-161-52/+0
| | | | | | | | | This way less stuff needs to be in basic. Initially, I wanted to move all the parts of cgroup-utils.[ch] that depend on efivars.[ch] to shared, because efivars.[ch] is in shared/. Later on, I decide to split efivars.[ch], so the move done in this patch is not necessary anymore. Nevertheless, it is still valid on its own. If at some point we want to expose libbasic, it is better to to not have stuff that belong in libshared there.
* basic/cgroup-util: let cgroup_unified_flush() return the detected hierarchyZbigniew Jędrzejewski-Szmek2019-09-161-2/+2
| | | | | | | This avoid the use of the global variable. Also rename cgroup_unified_update() to cgroup_unified_cached() and cgroup_unified_flush() to cgroup_unified() to better reflect their new roles.
* basic/build.h: fix typoZbigniew Jędrzejewski-Szmek2019-08-201-1/+1
|
* cgroup: Imply systemd.unified_cgroup_hierarchy=1 on cgroup_no_v1=allChris Down2018-12-211-0/+11
| | | | | | | | | | | | | | | | cgroup_no_v1=all doesn't make a whole lot of sense with legacy hierarchy (where we use v1 hierarchy for everything), or hybrid hierarchy (where we still use v1 hierarchy for resource control). Right now we have to tell people to add both cgroup_no_v1=all and systemd.unified_cgroup_hierarchy=1 to get the desired behaviour, however in reality it's hard to imagine any situation where someone passes cgroup_no_v1=all but *doesn't* want to use the unified cgroup hierarchy. Make it so that cgroup_no_v1=all produces intuitive behaviour in systemd by default, although it can still be disabled by passing systemd.unified_cgroup_hierarchy=0 explicitly.
* Merge pull request #10059 from yuwata/env-exec-directoryLennart Poettering2018-09-251-1/+1
|\ | | | | core: introduce $RUNTIME_DIRECTORY= or friends
| * test: replace swear words by 'hoge'Yu Watanabe2018-09-131-1/+1
| |
* | tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-3/+2
|/ | | | | The advantages are that we save a few lines, and that we can override logging using environment variables in more test executables.
* Drop my copyright headersZbigniew Jędrzejewski-Szmek2018-06-141-3/+0
| | | | | | | perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
* 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.
* tests: add some tests for unit_name_is_valid() and related functionsZbigniew Jędrzejewski-Szmek2018-04-241-2/+16
| | | | | I was surprised to see that foo@bar@bar.service is a valid unit name. Apparently it is according to current code and docs.
* 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-cgroup-util: bail out when running under mock (#8365)Zbigniew Jędrzejewski-Szmek2018-03-071-2/+8
| | | | | | The builds were failing in Fedora koji, where something strange is mounted on /sys/fs/cgroup. Also closes https://github.com/systemd/systemd/issues/8383.
* basic/cgroup-util: simplify cg_get_keyed_attribute(), add testZbigniew Jędrzejewski-Szmek2018-03-011-0/+41
| | | | | I didn't like the nested loop where we'd count what we have acquired already, since we should always know that.
* tree-wide: use SPECIAL_ROOT_SLICEZbigniew Jędrzejewski-Szmek2017-12-151-8/+9
|
* 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-cgroup-util: skip cg hierarchy tests when necessary (#7371)Zbigniew Jędrzejewski-Szmek2017-11-171-2/+7
|
* test-cgroup-util: add basic test for ↵Zbigniew Jędrzejewski-Szmek2017-11-151-0/+27
| | | | cg_all_unified/cg_hybrid_unified/cg_unified_controller
* tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold2017-10-021-2/+1
| | | | | | The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
* test-cgroup-util: add a "test" to print out cg_is_*_wanted() valuesZbigniew Jędrzejewski-Szmek2017-02-231-0/+47
| | | | | This isn't terribly useful because /sys/fs/cgroup will usually be mounted. But it at least allows checking if the values make sense in this case.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* nspawn: cleanup and chown the synced cgroup hierarchy (#4223)Evgeny Vereshchagin2016-10-131-0/+25
| | | Fixes: #4181
* 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.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering2015-10-271-0/+1
|
* util-lib: introduce dirent-util.[ch] for directory entry callsLennart Poettering2015-10-271-0/+1
| | | | Also, move a couple of more path-related functions to path-util.c.
* util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering2015-10-271-0/+1
|