]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/util.sh
2 # SPDX-License-Identifier: LGPL-2.1-or-later
4 # Utility functions for shell tests
13 if [[ $rc -ne 0 ]]; then
14 echo "FAIL: command '$*' failed with exit code $rc" >&2
23 if [[ "${1?}" != "${2?}" ]]; then
24 echo "FAIL: expected: '$2' actual: '$1'" >&2
32 if ! [[ "${2?}" =~
${1?} ]]; then
33 echo "FAIL: '$1' not found in:" >&2
42 if [[ "${2?}" =~
${1?} ]]; then
43 echo "FAIL: '$1' found in:" >&2
57 assert_eq
"$rc" "$exp"
60 get_cgroup_hierarchy
() {
61 case "$(stat -c '%T' -f /sys/fs/cgroup)" in
66 if [[ -d /sys
/fs
/cgroup
/unified
&& "$(stat -c '%T' -f /sys/fs/cgroup/unified)" == cgroup2fs
]]; then
73 echo >&2 "Failed to determine host's cgroup hierarchy"
81 XDG_RUNTIME_DIR
=/run
/user
/"$(id -u "$userid")" setpriv
--reuid="$userid" --init-groups "$@"