From 8943daf813221345580abe8ebaddcf10e2752287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 30 Mar 2020 16:39:31 +0200 Subject: [PATCH] test: use a helper function to move the journal files --- test/TEST-02-CRYPTSETUP/test.sh | 5 ++--- test/TEST-24-UNIT-TESTS/test.sh | 6 ++---- test/test-functions | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 157a70021b..27b42223d1 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -13,13 +13,12 @@ check_result_qemu() { [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile mount /dev/mapper/varcrypt $initdir/var - cp -a $initdir/var/log/journal $TESTDIR - rm -r $initdir/var/log/journal/* + save_journal $initdir/var/log/journal _umount_dir $initdir/var _umount_dir $initdir cryptsetup luksClose /dev/mapper/varcrypt [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - ls -l $TESTDIR/journal/*/*.journal + echo $JOURNAL_LIST test -s $TESTDIR/failed && ret=$(($ret+1)) return $ret } diff --git a/test/TEST-24-UNIT-TESTS/test.sh b/test/TEST-24-UNIT-TESTS/test.sh index a3a911c1b2..e5553b0fb5 100755 --- a/test/TEST-24-UNIT-TESTS/test.sh +++ b/test/TEST-24-UNIT-TESTS/test.sh @@ -30,8 +30,7 @@ check_result_nspawn() { cat $1/testok fi fi - cp -a $1/var/log/journal $TESTDIR - rm -r $1/var/log/journal/* + save_journal $1/var/log/journal _umount_dir $initdir [[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) return $_ret @@ -55,8 +54,7 @@ check_result_qemu() { cat $initdir/testok fi fi - cp -a $initdir/var/log/journal $TESTDIR - rm -r $initdir/var/log/journal/* + save_journal $initdir/var/log/journal _umount_dir $initdir [[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1)) return $_ret diff --git a/test/test-functions b/test/test-functions index ee2dca64f8..b1b69add05 100644 --- a/test/test-functions +++ b/test/test-functions @@ -790,16 +790,25 @@ check_asan_reports() { return $ret } +save_journal() { + dest="${TESTDIR}" + + cp -a $1 "$dest/" + rm -r $1/* + + # we want to print this sometime later, so save this in a variable + JOURNAL_LIST="$(ls -l $dest/*/*/*.journal 2>&1)" +} + check_result_nspawn() { local ret=1 local journald_report="" local pids="" [[ -e $1/testok ]] && ret=0 [[ -f $1/failed ]] && cp -a $1/failed $TESTDIR - cp -a $1/var/log/journal $TESTDIR - rm -r $1/var/log/journal/* + save_journal $1/var/log/journal [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - ls -l $TESTDIR/journal/*/*.journal + echo $JOURNAL_LIST test -s $TESTDIR/failed && ret=$(($ret+1)) [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) check_asan_reports "$1" || ret=$(($ret+1)) @@ -813,12 +822,11 @@ check_result_qemu() { mount_initdir [[ -e $initdir/testok ]] && ret=0 [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR - cp -a $initdir/var/log/journal $TESTDIR - rm -r $initdir/var/log/journal/* + save_journal $initdir/var/log/journal check_asan_reports "$initdir" || ret=$(($ret+1)) _umount_dir $initdir [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - ls -l $TESTDIR/journal/*/*.journal + echo $JOURNAL_LIST test -s $TESTDIR/failed && ret=$(($ret+1)) [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) return $ret