diff options
| author | Haixiao Yan <haixiao.yan.cn@windriver.com> | 2025-10-21 13:43:22 +0800 |
|---|---|---|
| committer | Scott Murray <scott.murray@konsulko.com> | 2025-11-12 14:17:55 -0500 |
| commit | 98c7c1c9a5c54028705c7f34af8144498141d324 (patch) | |
| tree | 081bc3342013c6d93375d45a2bc50099ce6a2ce4 | |
| parent | 3045ef984a8cf996ebe2cf246cbb2a354f84ae34 (diff) | |
| download | meta-security-98c7c1c9a5c54028705c7f34af8144498141d324.tar.gz | |
fail2ban: Adapt test output to Automake format for ptest compatibility
Convert fail2ban-testcases output to follow Automake-compatible format
(PASS:/FAIL:) so that ptest-runner can correctly parse and
report test results.
root@intel-x86-64:~# ptest-runner python3-fail2ban -t 300
START: ptest-runner
2025-09-22T07:57
BEGIN: /usr/lib64/python3-fail2ban/ptest
Fail2ban 1.1.1.dev1 test suite. Python 3.12.11 (main, Jun 3 2025, 15:41:47) [GCC 13.4.0]. Please wait...
I: Skipping smtp tests: No module named 'smtpd'
I: Skipping SSL smtp tests: No module named 'aiosmtpd'
PASS: fail2ban.tests.servertestcase.Transmitter.testAction
PASS: fail2ban.tests.servertestcase.Transmitter.testAddJail
PASS: fail2ban.tests.servertestcase.Transmitter.testDatabase
PASS: fail2ban.tests.servertestcase.Transmitter.testDatePattern
PASS: fail2ban.tests.servertestcase.Transmitter.testGetNOK
PASS: fail2ban.tests.servertestcase.Transmitter.testJailAttemptIP
PASS: fail2ban.tests.servertestcase.Transmitter.testJailBanIP
...
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testBanTimeIncr
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testFlushLogs
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testLogLevel
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testLogTarget
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testLogTargetSYSLOG
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testSyslogSocket
PASS: fail2ban.tests.servertestcase.TransmitterLogging.testSyslogSocketNOK
============================================================================
Testsuite summary
DURATION: 48
END: /usr/lib64/python3-fail2ban/ptest
2025-09-22T07:58
STOP: ptest-runner
TOTAL: 1 FAIL: 0
Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
2 files changed, 51 insertions, 1 deletions
diff --git a/dynamic-layers/meta-python/recipes-security/fail2ban/files/0001-fail2ban-use-putao.unittest.TestRunner-for-ptest-out.patch b/dynamic-layers/meta-python/recipes-security/fail2ban/files/0001-fail2ban-use-putao.unittest.TestRunner-for-ptest-out.patch new file mode 100644 index 0000000..c6729cc --- /dev/null +++ b/dynamic-layers/meta-python/recipes-security/fail2ban/files/0001-fail2ban-use-putao.unittest.TestRunner-for-ptest-out.patch | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | From 7b42974b5bf20d9db8e788e9d6817004556d660d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Haixiao Yan <haixiao.yan.cn@windriver.com> | ||
| 3 | Date: Fri, 19 Sep 2025 15:03:56 +0800 | ||
| 4 | Subject: [PATCH] fail2ban: use putao.unittest.TestRunner for ptest output | ||
| 5 | |||
| 6 | Switch the test runner from unittest's default TextTestRunner to | ||
| 7 | putao.unittest.TestRunner (provided by unittest-automake-output) so | ||
| 8 | that results are reported in Automake-compatible PASS/FAIL format. | ||
| 9 | This enables ptest-runner to correctly parse and summarize individual | ||
| 10 | test results. | ||
| 11 | |||
| 12 | Upstream-Status: Pending | ||
| 13 | |||
| 14 | Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com> | ||
| 15 | --- | ||
| 16 | bin/fail2ban-testcases | 4 ++-- | ||
| 17 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/bin/fail2ban-testcases b/bin/fail2ban-testcases | ||
| 20 | index 48aae4b5ffdc..20db4a01a3d6 100755 | ||
| 21 | --- a/bin/fail2ban-testcases | ||
| 22 | +++ b/bin/fail2ban-testcases | ||
| 23 | @@ -28,7 +28,7 @@ import logging | ||
| 24 | import os | ||
| 25 | import sys | ||
| 26 | import time | ||
| 27 | -import unittest | ||
| 28 | +import putao.unittest | ||
| 29 | |||
| 30 | # Check if local fail2ban module exists, and use if it exists by | ||
| 31 | # modifying the path. This is done so that tests can be used in dev | ||
| 32 | @@ -63,7 +63,7 @@ tests = gatherTests(regexps, opts) | ||
| 33 | # | ||
| 34 | # Run the tests | ||
| 35 | # | ||
| 36 | -testRunner = unittest.TextTestRunner(verbosity=verbosity) | ||
| 37 | +testRunner = putao.unittest.TestRunner() | ||
| 38 | |||
| 39 | tests_results = testRunner.run(tests) | ||
| 40 | |||
| 41 | -- | ||
| 42 | 2.34.1 | ||
| 43 | |||
diff --git a/dynamic-layers/meta-python/recipes-security/fail2ban/python3-fail2ban_git.bb b/dynamic-layers/meta-python/recipes-security/fail2ban/python3-fail2ban_git.bb index c85953a..4238c9f 100644 --- a/dynamic-layers/meta-python/recipes-security/fail2ban/python3-fail2ban_git.bb +++ b/dynamic-layers/meta-python/recipes-security/fail2ban/python3-fail2ban_git.bb | |||
| @@ -13,6 +13,7 @@ DEPENDS = "python3-native" | |||
| 13 | 13 | ||
| 14 | SRCREV = "2856092709470250dc299931bc748f112590059f" | 14 | SRCREV = "2856092709470250dc299931bc748f112590059f" |
| 15 | SRC_URI = "git://github.com/fail2ban/fail2ban.git;branch=master;protocol=https \ | 15 | SRC_URI = "git://github.com/fail2ban/fail2ban.git;branch=master;protocol=https \ |
| 16 | file://0001-fail2ban-use-putao.unittest.TestRunner-for-ptest-out.patch \ | ||
| 16 | file://initd \ | 17 | file://initd \ |
| 17 | file://run-ptest \ | 18 | file://run-ptest \ |
| 18 | " | 19 | " |
| @@ -67,6 +68,12 @@ INSANE_SKIP:${PN}:append = "already-stripped" | |||
| 67 | RDEPENDS:${PN} = "${VIRTUAL-RUNTIME_base-utils-syslog} nftables python3-core python3-pyinotify" | 68 | RDEPENDS:${PN} = "${VIRTUAL-RUNTIME_base-utils-syslog} nftables python3-core python3-pyinotify" |
| 68 | RDEPENDS:${PN} += "python3-sqlite3" | 69 | RDEPENDS:${PN} += "python3-sqlite3" |
| 69 | RDEPENDS:${PN} += " python3-logging python3-fcntl python3-json" | 70 | RDEPENDS:${PN} += " python3-logging python3-fcntl python3-json" |
| 70 | RDEPENDS:${PN}-ptest = "python3-core python3-io python3-modules python3-fail2ban" | 71 | RDEPENDS:${PN}-ptest = " \ |
| 72 | python3-core \ | ||
| 73 | python3-io \ | ||
| 74 | python3-modules \ | ||
| 75 | python3-fail2ban \ | ||
| 76 | python3-unittest-automake-output \ | ||
| 77 | " | ||
| 71 | 78 | ||
| 72 | RRECOMMENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'python3-systemd', '', d)}" | 79 | RRECOMMENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'python3-systemd', '', d)}" |
