mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
support/testing: test_nftables.py: use assertRunNotOk()
Use the helper to simplify the test. Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Acked-by: Fiona Klute <fiona.klute@gmx.de> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
@@ -69,8 +69,7 @@ class TestNftables(infra.basetest.BRTest):
|
||||
# A ping to 127.0.0.2 is expected to fail, because our rule is
|
||||
# supposed to drop it.
|
||||
ping_test_cmd = ping_cmd_prefix + "127.0.0.2"
|
||||
_, exit_code = self.emulator.run(ping_test_cmd)
|
||||
self.assertNotEqual(exit_code, 0)
|
||||
self.assertRunNotOk(ping_test_cmd)
|
||||
|
||||
# We completely delete the table. This should also delete the
|
||||
# chain and the rule.
|
||||
@@ -128,8 +127,7 @@ class TestNftablesInit(TestNftables):
|
||||
# should allow ping to 127.0.0.1, but not 127.0.0.2.
|
||||
ping_cmd_prefix = "ping -c 3 -i 0.5 -W 2 "
|
||||
self.assertRunOk(ping_cmd_prefix + "127.0.0.1")
|
||||
_, exit_code = self.emulator.run(ping_cmd_prefix + "127.0.0.2")
|
||||
self.assertNotEqual(exit_code, 0)
|
||||
self.assertRunNotOk(ping_cmd_prefix + "127.0.0.2")
|
||||
|
||||
# Stop should flush the rules, ping to both addresses should
|
||||
# work now.
|
||||
@@ -140,5 +138,4 @@ class TestNftablesInit(TestNftables):
|
||||
# Start is essentially the same as reload, check that
|
||||
# 127.0.0.2 gets blocked again.
|
||||
self.assertRunOk("/etc/init.d/S35nftables start")
|
||||
_, exit_code = self.emulator.run(ping_cmd_prefix + "127.0.0.2")
|
||||
self.assertNotEqual(exit_code, 0)
|
||||
self.assertRunNotOk(ping_cmd_prefix + "127.0.0.2")
|
||||
|
||||
Reference in New Issue
Block a user