From f9eb2d51dadc730b5de97e4c7780450ec91c0d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 30 Mar 2020 21:29:52 +0200 Subject: [PATCH] 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. --- test/test-functions | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/test-functions b/test/test-functions index b1b69add05..bf21c6312f 100644 --- a/test/test-functions +++ b/test/test-functions @@ -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() {