mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 18:55:40 +03:00
test: unify checking for user xattrs support in cgroupfs
Also, run the coredump forwarding test only if user xattrs are supported.
This commit is contained in:
parent
725e646854
commit
a2dd592002
@ -173,6 +173,7 @@ BASICTOOLS=(
|
||||
getconf
|
||||
getent
|
||||
getfacl
|
||||
getfattr
|
||||
grep
|
||||
gunzip
|
||||
gzip
|
||||
|
@ -3,6 +3,9 @@
|
||||
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:?}"
|
||||
@ -27,20 +30,7 @@ run_service_and_fetch_logs() {
|
||||
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") ]]
|
||||
|
@ -3,6 +3,9 @@
|
||||
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
|
||||
@ -149,7 +152,7 @@ if systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.ser
|
||||
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/
|
||||
|
@ -3,6 +3,9 @@
|
||||
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"
|
||||
@ -89,15 +92,17 @@ ExecStart=systemd-nspawn --quiet --link-journal=try-guest --keep-unit --machine=
|
||||
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
|
||||
|
@ -171,3 +171,14 @@ systemctl_final() {
|
||||
|
||||
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 ]]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user