summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2015-12-29 17:40:37 +0100
committersebres <serg.brester@sebres.de>2015-12-29 19:00:51 +0100
commit134c33cc6d11249c5f1532f098345681e1875eec (patch)
treee4c15150056fca1f846279360f88b9a1ec2a6216
parent8eca2ecd84182242973aed9fba5760bd32947dc9 (diff)
downloadfail2ban-134c33cc6d11249c5f1532f098345681e1875eec.tar.gz
fail2ban-testcases: added option "--ignore": negate [regexps] filter, to ignore tests matched specified regexps
-rwxr-xr-xbin/fail2ban-testcases3
-rw-r--r--fail2ban/tests/utils.py4
2 files changed, 6 insertions, 1 deletions
diff --git a/bin/fail2ban-testcases b/bin/fail2ban-testcases
index 22a44a8b..606b0b06 100755
--- a/bin/fail2ban-testcases
+++ b/bin/fail2ban-testcases
@@ -67,6 +67,9 @@ def get_opt_parser():
Option('-f', "--fast", action="store_true",
dest="fast",
help="Try to increase speed of the tests, decreasing of wait intervals, memory database"),
+ Option('-i', "--ignore", action="store_true",
+ dest="negate_re",
+ help="negate [regexps] filter to ignore tests matched specified regexps"),
Option("-t", "--log-traceback", action='store_true',
help="Enrich log-messages with compressed tracebacks"),
Option("--full-traceback", action='store_true',
diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py
index 0cac9df5..ce6d638a 100644
--- a/fail2ban/tests/utils.py
+++ b/fail2ban/tests/utils.py
@@ -55,6 +55,7 @@ class F2B(optparse.Values):
def __init__(self, opts={}):
self.__dict__ = opts.__dict__ if opts else {
'fast': False, 'memory_db':False, 'no_gamin': False, 'no_network': False,
+ "negate_re": False,
}
if self.fast:
self.memory_db = True
@@ -157,7 +158,8 @@ def gatherTests(regexps=None, opts=None):
for test in suite:
s = str(test)
for r in self._regexps:
- if r.search(s):
+ m = r.search(s)
+ if (m if not opts.negate_re else not m):
matched.append(test)
break
for test in matched: