594167
From 60bc6c654dfbcbfeac0120143dd9869ceeb1a56e Mon Sep 17 00:00:00 2001
594167
From: Yu Watanabe <watanabe.yu+github@gmail.com>
594167
Date: Tue, 14 Jun 2022 21:08:04 +0900
594167
Subject: [PATCH] test: use trap RETURN
594167
594167
(cherry picked from commit 6243063824838e027754cc2737bb975472d62de2)
594167
594167
Related: #2087652
594167
---
594167
 test/units/testsuite-35.sh | 10 ++--------
594167
 test/units/testsuite-45.sh | 10 ++--------
594167
 2 files changed, 4 insertions(+), 16 deletions(-)
594167
594167
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
594167
index e369cf8701..05d2a6c4c3 100755
594167
--- a/test/units/testsuite-35.sh
594167
+++ b/test/units/testsuite-35.sh
594167
@@ -91,7 +91,7 @@ test_suspend_on_lid() {
594167
     fi
594167
 
594167
     KILL_PID=
594167
-    trap test_suspend_tear_down EXIT
594167
+    trap test_suspend_tear_down RETURN
594167
 
594167
     # create fake suspend
594167
     mkdir -p /run/systemd/system/systemd-suspend.service.d
594167
@@ -184,9 +184,6 @@ EOF
594167
         echo "logind crashed" >&2
594167
         exit 1
594167
     fi
594167
-
594167
-    test_suspend_tear_down
594167
-    trap - EXIT
594167
 }
594167
 
594167
 test_shutdown() {
594167
@@ -269,7 +266,7 @@ test_session() {
594167
         return
594167
     fi
594167
 
594167
-    trap test_session_tear_down EXIT
594167
+    trap test_session_tear_down RETURN
594167
 
594167
     # add user
594167
     useradd -s /bin/bash logind-test-user
594167
@@ -361,9 +358,6 @@ EOF
594167
         getfacl -p "$dev" >&2
594167
         exit 1
594167
     fi
594167
-
594167
-    test_session_tear_down
594167
-    trap - EXIT
594167
 }
594167
 
594167
 : >/failed
594167
diff --git a/test/units/testsuite-45.sh b/test/units/testsuite-45.sh
594167
index fd8a99076b..322d8086e7 100755
594167
--- a/test/units/testsuite-45.sh
594167
+++ b/test/units/testsuite-45.sh
594167
@@ -23,7 +23,7 @@ test_timezone() {
594167
         mv /etc/timezone /tmp/timezone.bak
594167
     fi
594167
 
594167
-    trap restore_timezone EXIT
594167
+    trap restore_timezone RETURN
594167
 
594167
     if [[ -L /etc/localtime ]]; then
594167
         ORIG_TZ=$(readlink /etc/localtime | sed 's#^.*zoneinfo/##')
594167
@@ -49,9 +49,6 @@ test_timezone() {
594167
             assert_eq "$(cat /etc/timezone)" "$ORIG_TZ"
594167
         fi
594167
     fi
594167
-
594167
-    restore_timezone
594167
-    trap - EXIT
594167
 }
594167
 
594167
 restore_adjtime() {
594167
@@ -75,7 +72,7 @@ test_adjtime() {
594167
         mv /etc/adjtime /etc/adjtime.bak
594167
     fi
594167
 
594167
-    trap restore_adjtime EXIT
594167
+    trap restore_adjtime RETURN
594167
 
594167
     echo 'no adjtime file'
594167
     rm -f /etc/adjtime
594167
@@ -182,9 +179,6 @@ LOCAL"
594167
     assert_eq "$(cat /etc/adjtime)" "0.0 0 0
594167
 0
594167
 LOCAL"
594167
-
594167
-    restore_adjtime
594167
-    trap - EXIT
594167
 }
594167
 
594167
 assert_ntp() {