getconf
getent
getfacl
+ getfattr
grep
gunzip
gzip
set -eux
set -o pipefail
+# shellcheck source=test/units/util.sh
+ . "$(dirname "$0")"/util.sh
+
add_logs_filtering_override() {
local unit="${1:?}"
local override_name="${2:?}"
systemctl stop "$unit"
}
-is_xattr_supported() {
- local start end
-
- start="$(date '+%Y-%m-%d %T.%6N')"
- systemd-run --unit text_xattr --property LogFilterPatterns=log sh -c "sleep .5"
- sleep .5
- journalctl --sync
- end="$(date '+%Y-%m-%d %T.%6N')"
- systemctl stop text_xattr
-
- ! journalctl -q -u "text_xattr" -S "$start" -U "$end" --grep "Failed to set 'user.journald_log_filter_patterns' xattr.*not supported$"
-}
-
-if is_xattr_supported; then
+if cgroupfs_supports_user_xattrs; then
# Accept all log messages
add_logs_filtering_override "logs-filtering.service" "00-reset" ""
[[ -n $(run_service_and_fetch_logs "logs-filtering.service") ]]
set -eux
set -o pipefail
+# shellcheck source=test/units/util.sh
+ . "$(dirname "$0")"/util.sh
+
systemd-analyze log-level debug
# Ensure that the init.scope.d drop-in is applied on boot
if ! systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service; then exit 24; fi
# only run this portion of the test if we can set xattrs
-if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
+if cgroupfs_supports_user_xattrs; then
sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
mkdir -p /run/systemd/system/testsuite-55-testbloat.service.d/
set -eux
set -o pipefail
+# shellcheck source=test/units/util.sh
+ . "$(dirname "$0")"/util.sh
+
# Make sure the binary name fits into 15 characters
CORE_TEST_BIN="/tmp/test-dump"
CORE_TEST_UNPRIV_BIN="/tmp/test-usr-dump"
EOF
systemctl daemon-reload
-machinectl start "$CONTAINER"
-timeout 60 bash -xec "until systemd-run -M '$CONTAINER' -q --wait --pipe true; do sleep .5; done"
+if cgroupfs_supports_user_xattrs; then
+ machinectl start "$CONTAINER"
+ timeout 60 bash -xec "until systemd-run -M '$CONTAINER' -q --wait --pipe true; do sleep .5; done"
-[[ "$(systemd-run -M "$CONTAINER" -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l)" -eq 0 ]]
-machinectl copy-to "$CONTAINER" "$MAKE_DUMP_SCRIPT"
-systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGABRT"
-systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGTRAP"
-# Wait a bit for the coredumps to get processed
-timeout 30 bash -c "while [[ \$(systemd-run -M $CONTAINER -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l) -lt 2 ]]; do sleep 1; done"
+ [[ "$(systemd-run -M "$CONTAINER" -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l)" -eq 0 ]]
+ machinectl copy-to "$CONTAINER" "$MAKE_DUMP_SCRIPT"
+ systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGABRT"
+ systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGTRAP"
+ # Wait a bit for the coredumps to get processed
+ timeout 30 bash -c "while [[ \$(systemd-run -M $CONTAINER -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l) -lt 2 ]]; do sleep 1; done"
+fi
coredumpctl
SYSTEMD_LOG_LEVEL=debug coredumpctl
systemctl "$@"
}
+
+cgroupfs_supports_user_xattrs() {
+ local xattr
+
+ xattr="user.supported_$RANDOM"
+ # shellcheck disable=SC2064
+ trap "setfattr --remove=$xattr /sys/fs/cgroup || :" RETURN
+
+ setfattr --name="$xattr" --value=254 /sys/fs/cgroup
+ [[ "$(getfattr --name="$xattr" --absolute-names --only-values /sys/fs/cgroup)" -eq 254 ]]
+}