valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0355-test-do-not-use-global-variable-to-pass-error.patch

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