test: use a helper function to move the journal files

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-03-30 16:39:31 +02:00
parent 3597bf7550
commit 8943daf813
3 changed files with 18 additions and 13 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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