test: use systemd-journal-remote for journal copying, support $ARTIFACT_DIRECTORY

Using s-j-remote fixes the following issue: when coalescing files from multiple
inputs, simply copying all files with into the the same directory might
potentially mess things up, because a newer system.journal might overwrite an
older journal. This happens because we run multiple tests from the same image,
and need to clean out the directory after each run.

By using systemd-journal-remote, we nicely coalesce all files. This has the
advantage that if there aren't too many logs, we end up with just one journal
file.

ARTIFACT_DIRECTORY is for ubuntuautopackagetests, where the journal files are
copied to a separate directory to preserve after tests have been run. This
functionality can now be recreated by setting
ARTIFACT_DIRECTORY=$AUTOPKGTEST_ARTIFACTS.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-03-30 21:29:52 +02:00
parent 8943daf813
commit f9eb2d51da
1 changed files with 12 additions and 4 deletions

View File

@ -791,13 +791,21 @@ check_asan_reports() {
}
save_journal() {
dest="${TESTDIR}"
if [ -n "${ARTIFACT_DIRECTORY}" ]; then
dest="${ARTIFACT_DIRECTORY}/${testname}.journal"
else
dest="$TESTDIR/system.journal"
fi
cp -a $1 "$dest/"
rm -r $1/*
for j in $1/*; do
/usr/lib/systemd/systemd-journal-remote \
-o $dest \
--getter="journalctl -o export -D $j"
rm -r $j
done
# we want to print this sometime later, so save this in a variable
JOURNAL_LIST="$(ls -l $dest/*/*/*.journal 2>&1)"
JOURNAL_LIST="$(ls -l $dest*)"
}
check_result_nspawn() {