]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: introduce check_asan_reports and use it in check_result_{qemu|nspawn} 11252/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 25 Dec 2018 07:31:50 +0000 (08:31 +0100)
committerEvgeny Vereshchagin <evvers@ya.ru>
Sat, 29 Dec 2018 18:14:35 +0000 (19:14 +0100)
test/test-functions

index dd9cdb7de1c1d4a4e8ffa2e29a64e5a7cfe2c14e..80467b526e8607da2824e27511949381b213bb2a 100644 (file)
@@ -459,35 +459,28 @@ EOF
     fi
 }
 
-check_result_nspawn() {
-    local ret=1
-    local journald_report=""
-    local pids=""
-    [[ -e $TESTDIR/$1/testok ]] && ret=0
-    [[ -f $TESTDIR/$1/failed ]] && cp -a $TESTDIR/$1/failed $TESTDIR
-    cp -a $TESTDIR/$1/var/log/journal $TESTDIR
-    [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
-    ls -l $TESTDIR/journal/*/*.journal
-    test -s $TESTDIR/failed && ret=$(($ret+1))
-    [ -n "$TIMED_OUT" ] && ret=$(($ret+1))
+check_asan_reports() {
+    local ret=0
+    local root="$1"
+
     if [[ "$IS_BUILT_WITH_ASAN" = "yes" ]]; then
-        ls -l "$TESTDIR/$1"
-        if [[ -e "$TESTDIR/$1/systemd.asan.log.1" ]]; then
-            cat "$TESTDIR/$1/systemd.asan.log.1"
+        ls -l "$root"
+        if [[ -e "$root/systemd.asan.log.1" ]]; then
+            cat "$root/systemd.asan.log.1"
             ret=$(($ret+1))
         fi
 
-       journald_report=$(find "$TESTDIR/$1" -name "systemd-journald.asan.log*" -exec cat {} \;)
+       journald_report=$(find "$root" -name "systemd-journald.asan.log*" -exec cat {} \;)
        if [[ ! -z "$journald_report" ]]; then
             printf "%s" "$journald_report"
             ret=$(($ret+1))
        fi
 
-       pids=$("$BUILD_DIR/journalctl" -D "$TESTDIR/$1/var/log/journal" | perl -alne 'print $1 if /\[(\d+)\]:\s*SUMMARY:\s+\w+Sanitizer/')
+       pids=$("$BUILD_DIR/journalctl" -D "$root/var/log/journal" | perl -alne 'print $1 if /\[(\d+)\]:\s*SUMMARY:\s+\w+Sanitizer/')
        if [[ ! -z "$pids" ]]; then
             ret=$(($ret+1))
             for pid in $pids; do
-                "$BUILD_DIR/journalctl" -D "$TESTDIR/$1/var/log/journal" _PID=$pid --no-pager
+                "$BUILD_DIR/journalctl" -D "$root/var/log/journal" _PID=$pid --no-pager
             done
        fi
     fi
@@ -495,6 +488,21 @@ check_result_nspawn() {
     return $ret
 }
 
+check_result_nspawn() {
+    local ret=1
+    local journald_report=""
+    local pids=""
+    [[ -e $TESTDIR/$1/testok ]] && ret=0
+    [[ -f $TESTDIR/$1/failed ]] && cp -a $TESTDIR/$1/failed $TESTDIR
+    cp -a $TESTDIR/$1/var/log/journal $TESTDIR
+    [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
+    ls -l $TESTDIR/journal/*/*.journal
+    test -s $TESTDIR/failed && ret=$(($ret+1))
+    [ -n "$TIMED_OUT" ] && ret=$(($ret+1))
+    check_asan_reports "$TESTDIR/$1" || ret=$(($ret+1))
+    return $ret
+}
+
 # can be overridden in specific test
 check_result_qemu() {
     local ret=1
@@ -503,6 +511,7 @@ check_result_qemu() {
     [[ -e $TESTDIR/root/testok ]] && ret=0
     [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
     cp -a $TESTDIR/root/var/log/journal $TESTDIR
+    check_asan_reports "$TESTDIR/root" || ret=$(($ret+1))
     umount $TESTDIR/root
     [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
     ls -l $TESTDIR/journal/*/*.journal