]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use a helper function to move the journal files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 30 Mar 2020 14:39:31 +0000 (16:39 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Mar 2020 10:31:10 +0000 (12:31 +0200)
test/TEST-02-CRYPTSETUP/test.sh
test/TEST-24-UNIT-TESTS/test.sh
test/test-functions

index 157a70021b486966f80efe0c06c16ea6da28dbac..27b42223d1725d6bf5b6d499a0e13800b501ce1c 100755 (executable)
@@ -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
 }
index a3a911c1b2e3c1981bc50eee8bc9566f0b471d2d..e5553b0fb541f4502fef2d3556eac8b336597c5c 100755 (executable)
@@ -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
index ee2dca64f8ed4d38b99a2dcbd8eef0ddc4605c81..b1b69add05807a72526791c79f6534de5fad775b 100644 (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