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.
}
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() {