tests: redirect the stdout/stderr of journald to a file (under ASan+UBSan)

Sometimes UBSan sends its reports to stderr regardless of what is specified in log_path
Let's try to catch them by redirecting stderr (and stdout just in case) to a file
See https://github.com/systemd/systemd/pull/12524#issuecomment-491108821
This commit is contained in:
Evgeny Vereshchagin 2019-05-10 02:47:03 +02:00
parent abf9b52ccd
commit 6141c6c99b
1 changed files with 7 additions and 1 deletions

View File

@ -380,6 +380,11 @@ JOURNALD_CONF_DIR=/etc/systemd/system/systemd-journald.service.d
mkdir -p "\$JOURNALD_CONF_DIR"
printf "[Service]\nEnvironment=ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd-journald.asan.log UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS:log_path=/systemd-journald.ubsan.log\n" >"\$JOURNALD_CONF_DIR/env.conf"
# Sometimes UBSan sends its reports to stderr regardless of what is specified in log_path
# Let's try to catch them by redirecting stderr (and stdout just in case) to a file
# See https://github.com/systemd/systemd/pull/12524#issuecomment-491108821
printf "[Service]\nStandardOutput=file:/systemd-journald.out\n" >"\$JOURNALD_CONF_DIR/out.conf"
# 90s isn't enough for some services to finish when literally everything is run
# under ASan+UBSan in containers, which, in turn, are run in VMs.
# Let's limit which environments such services should be executed in.
@ -510,7 +515,8 @@ check_asan_reports() {
journald_report=$(find "$root" -name "systemd-journald.*san.log*" -exec cat {} \;)
if [[ ! -z "$journald_report" ]]; then
printf "%s" "$journald_report"
printf "%s\n" "$journald_report"
cat "$root/systemd-journald.out" || true
ret=$(($ret+1))
fi