1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 03:25:31 +03:00

Merge pull request #28140 from mrc0mmand/more-coverage

test: test transactions with cycles
This commit is contained in:
Luca Boccassi 2023-06-23 19:56:28 +01:00 committed by GitHub
commit 51d64d8869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 9 deletions

View File

@ -914,7 +914,7 @@ EOF
}
create_asan_wrapper() {
local asan_wrapper default_asan_options default_ubsan_options default_environment
local asan_wrapper default_asan_options default_ubsan_options default_environment manager_environment
[[ -z "$ASAN_RT_PATH" ]] && dfatal "ASAN_RT_PATH is empty, but it shouldn't be"
@ -948,12 +948,17 @@ EOF
"UBSAN_OPTIONS='$default_ubsan_options'"
"ASAN_RT_PATH='$ASAN_RT_PATH'"
)
manager_environment=(
"ASAN_OPTIONS='$default_asan_options:log_path=/systemd-pid1.asan.log:log_to_syslog=1'"
"UBSAN_OPTIONS='$default_ubsan_options:log_path=/systemd-pid1.ubsan.log:log_to_syslog=1'"
"ASAN_RT_PATH='$ASAN_RT_PATH'"
)
mkdir -p "${initdir:?}/etc/systemd/system.conf.d/"
cat >"${initdir:?}/etc/systemd/system.conf.d/asan.conf" <<EOF
[Manager]
DefaultEnvironment=${default_environment[*]}
ManagerEnvironment=${default_environment[*]}
ManagerEnvironment=${manager_environment[*]}
DefaultTimeoutStartSec=180s
DefaultStandardOutput=journal+console
EOF
@ -1002,7 +1007,7 @@ EOF
set -eux
export PATH="/sbin:/bin:/usr/sbin:/usr/bin"
export ${default_environment[@]}
export ${manager_environment[@]}
[[ -n "\$ASAN_OPTIONS" && -n "\$UBSAN_OPTIONS" ]]
exec "$ROOTLIBDIR/systemd" "\$@"
@ -1534,6 +1539,7 @@ create_empty_image_rootdir() {
check_asan_reports() {
local ret=0
local root="${1:?}"
local log report
if get_bool "$IS_BUILT_WITH_ASAN"; then
ls -l "$root"
@ -1542,12 +1548,15 @@ check_asan_reports() {
ret=$((ret+1))
fi
journald_report="$(find "$root" -name "systemd-journald.*san.log*" -exec cat {} \;)"
if [[ -n "$journald_report" ]]; then
printf "%s\n" "$journald_report"
cat "$root/systemd-journald.out" || :
ret=$((ret+1))
fi
for log in pid1 journald; do
report="$(find "$root" -name "systemd-$log.*san.log*" -exec cat {} \;)"
if [[ -n "$report" ]]; then
printf "%s\n" "$report"
# shellcheck disable=SC2015
[[ "$log" == journald ]] && cat "$root/systemd-journald.out" || :
ret=$((ret+1))
fi
done
# May 08 13:23:31 H testleak[2907148]: SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
pids="$(

View File

@ -110,4 +110,21 @@ ELAPSED=$((END_SEC-START_SEC))
[[ "$ELAPSED" -ge 3 ]] && [[ "$ELAPSED" -le 5 ]] || exit 1
[[ "$RESULT" -ne 0 ]] || exit 1
# Test transactions with cycles
# Provides coverage for issues like https://github.com/systemd/systemd/issues/26872
for i in {0..19}; do
cat >"/run/systemd/system/transaction-cycle$i.service" <<EOF
[Unit]
After=transaction-cycle$(((i + 1) % 20)).service
Requires=transaction-cycle$(((i + 1) % 20)).service
[Service]
ExecStart=true
EOF
done
systemctl daemon-reload
for i in {0..19}; do
systemctl start "transaction-cycle$i.service"
done
touch /testok