richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
c2dfb7
From 35e9e01b2879854a2adb8d571d0204990cad38d9 Mon Sep 17 00:00:00 2001
c2dfb7
From: Yu Watanabe <watanabe.yu+github@gmail.com>
c2dfb7
Date: Fri, 14 Sep 2018 13:25:02 +0900
c2dfb7
Subject: [PATCH] test: do not use global variable to pass error
c2dfb7
c2dfb7
(cherry picked from commit 0013fac248a15be3acce84c17a65e3ae0377294b)
c2dfb7
c2dfb7
Resolves: #1823767
c2dfb7
---
c2dfb7
 test/TEST-21-SYSUSERS/test.sh | 1 +
c2dfb7
 test/test-functions           | 8 +++++---
c2dfb7
 2 files changed, 6 insertions(+), 3 deletions(-)
c2dfb7
c2dfb7
diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh
c2dfb7
index 73cbe10b69..b1049e720d 100755
c2dfb7
--- a/test/TEST-21-SYSUSERS/test.sh
c2dfb7
+++ b/test/TEST-21-SYSUSERS/test.sh
c2dfb7
@@ -15,6 +15,7 @@ prepare_testdir() {
c2dfb7
         for i in $1.initial-{passwd,group,shadow}; do
c2dfb7
                 test -f $i && cp $i $TESTDIR/etc/${i#*.initial-}
c2dfb7
         done
c2dfb7
+        return 0
c2dfb7
 }
c2dfb7
 
c2dfb7
 preprocess() {
c2dfb7
diff --git a/test/test-functions b/test/test-functions
c2dfb7
index fe25a501da..da83891f46 100644
c2dfb7
--- a/test/test-functions
c2dfb7
+++ b/test/test-functions
c2dfb7
@@ -449,7 +449,7 @@ EOF
c2dfb7
 }
c2dfb7
 
c2dfb7
 check_result_nspawn() {
c2dfb7
-    ret=1
c2dfb7
+    local ret=1
c2dfb7
     [[ -e $TESTDIR/$1/testok ]] && ret=0
c2dfb7
     [[ -f $TESTDIR/$1/failed ]] && cp -a $TESTDIR/$1/failed $TESTDIR
c2dfb7
     cp -a $TESTDIR/$1/var/log/journal $TESTDIR
c2dfb7
@@ -462,7 +462,7 @@ check_result_nspawn() {
c2dfb7
 
c2dfb7
 # can be overridden in specific test
c2dfb7
 check_result_qemu() {
c2dfb7
-    ret=1
c2dfb7
+    local ret=1
c2dfb7
     mkdir -p $TESTDIR/root
c2dfb7
     mount ${LOOPDEV}p1 $TESTDIR/root
c2dfb7
     [[ -e $TESTDIR/root/testok ]] && ret=0
c2dfb7
@@ -1527,7 +1527,9 @@ do_test() {
c2dfb7
         case $1 in
c2dfb7
             --run)
c2dfb7
                 echo "TEST RUN: $TEST_DESCRIPTION"
c2dfb7
-                if test_run; then
c2dfb7
+                test_run
c2dfb7
+                ret=$?
c2dfb7
+                if (( $ret == 0 )); then
c2dfb7
                     echo "TEST RUN: $TEST_DESCRIPTION [OK]"
c2dfb7
                 else
c2dfb7
                     echo "TEST RUN: $TEST_DESCRIPTION [FAILED]"