You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.0 KiB
51 lines
2.0 KiB
From 3187de29336b4a01e4dcd20f98253e1db913ee7a Mon Sep 17 00:00:00 2001
|
|
From: Yaroslav Halchenko <debian@onerussian.com>
|
|
Date: Sat, 12 Sep 2015 14:15:10 -0400
|
|
Subject: [PATCH] BF(TST): allow exception and False for executeCmd due to
|
|
inconsistent behavior across bash/dash
|
|
|
|
Temporary minimalistic fix to the test
|
|
---
|
|
fail2ban/tests/actiontestcase.py | 23 +++++++++++++++++------
|
|
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/fail2ban/tests/actiontestcase.py b/fail2ban/tests/actiontestcase.py
|
|
index febbc61..73dee12 100644
|
|
--- a/fail2ban/tests/actiontestcase.py
|
|
+++ b/fail2ban/tests/actiontestcase.py
|
|
@@ -222,17 +222,28 @@ def getnastypid():
|
|
return int(f.read())
|
|
|
|
# First test if can kill the bastard
|
|
- self.assertRaises(
|
|
- RuntimeError, CommandAction.executeCmd, 'bash %s' % tmpFilename, timeout=.1)
|
|
+ try:
|
|
+ self.assertFalse(
|
|
+ CommandAction.executeCmd('bash %s' % tmpFilename, timeout=.1))
|
|
+ except RuntimeError:
|
|
+ # this one is expected behavior, see
|
|
+ # https://github.com/fail2ban/fail2ban/issues/1155#issuecomment-139799958
|
|
+ pass
|
|
# Verify that the proccess itself got killed
|
|
self.assertFalse(pid_exists(getnastypid())) # process should have been killed
|
|
self.assertTrue(self._is_logged('timed out'))
|
|
- self.assertTrue(self._is_logged('killed with SIGTERM'))
|
|
+ self.assertTrue(self._is_logged('Terminated'))
|
|
|
|
# A bit evolved case even though, previous test already tests killing children processes
|
|
- self.assertRaises(
|
|
- RuntimeError, CommandAction.executeCmd, 'out=`bash %s`; echo ALRIGHT' % tmpFilename,
|
|
- timeout=.2)
|
|
+ try:
|
|
+ self.assertFalse(
|
|
+ CommandAction.executeCmd('out=`bash %s`; echo ALRIGHT' % tmpFilename,
|
|
+ timeout=.2))
|
|
+ except RuntimeError:
|
|
+ # this one is expected behavior, see
|
|
+ # https://github.com/fail2ban/fail2ban/issues/1155#issuecomment-139799958
|
|
+ pass
|
|
+
|
|
# Verify that the proccess itself got killed
|
|
self.assertFalse(pid_exists(getnastypid()))
|
|
self.assertTrue(self._is_logged('timed out'))
|