From c2f28b1ce0383e6366846a5993f59a7a4c3ccc11 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Wed, 13 Jul 2022 11:29:20 +0200
Subject: [PATCH] test: ensure cleanup functions return success
Otherwise the return value of the last command is propagated, which may
cause spurious test failures. E.g., pkill returns 1 if no process
matched, which may be a problem in cleanup session:
cleanup_session() {
...
pkill -u "$(id -u logind-test-user)"
sleep 1
pkill -KILL -u "$(id -u logind-test-user)"
}
If there are no remaining processes when the final pkill runs, it will
return 1 and therefore cleanup_session will return 1 as well.
(cherry picked from commit bd681a7eb04fd6d1fb9631e277bef93ceb06b321)
Related: #2100464
---
test/units/testsuite-35.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
index 9c37fc36d0..ad14d8a73c 100755
--- a/test/units/testsuite-35.sh
+++ b/test/units/testsuite-35.sh
@@ -13,6 +13,8 @@ cleanup_test_user() (
sleep 1
pkill -KILL -u "$(id -u logind-test-user)"
userdel -r logind-test-user
+
+ return 0
)
setup_test_user() {
@@ -83,6 +85,8 @@ teardown_suspend() (
rm -f /run/udev/rules.d/70-logindtest-lid.rules
udevadm control --reload
+
+ return 0
)
test_suspend_on_lid() {
@@ -224,6 +228,8 @@ cleanup_session() (
pkill -u "$(id -u logind-test-user)"
sleep 1
pkill -KILL -u "$(id -u logind-test-user)"
+
+ return 0
)
teardown_session() (
@@ -234,6 +240,8 @@ teardown_session() (
rm -f /run/udev/rules.d/70-logindtest-scsi_debug-user.rules
udevadm control --reload
rmmod scsi_debug
+
+ return 0
)
check_session() (