From 4245fefb345e13826be4f088f6491ee013849638 Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Thu, 25 Jun 2026 10:44:39 +0200 Subject: [PATCH] support/testing: TestIptablesNft: add test for iptables with nftables backend The new test inherits from TestIptables, with only minimal changes to use the nftables backend instead. Signed-off-by: Fiona Klute Signed-off-by: Romain Naour --- support/testing/tests/package/test_iptables.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/support/testing/tests/package/test_iptables.py b/support/testing/tests/package/test_iptables.py index 918fa4fb29..c37c615e06 100644 --- a/support/testing/tests/package/test_iptables.py +++ b/support/testing/tests/package/test_iptables.py @@ -24,6 +24,7 @@ class TestIptables(infra.basetest.BRTest): BR2_TARGET_ROOTFS_CPIO_GZIP=y # BR2_TARGET_ROOTFS_TAR is not set """ + iptables_backend = "(legacy)" def test_run(self): img = os.path.join(self.builddir, "images", "rootfs.cpio.gz") @@ -41,7 +42,7 @@ class TestIptables(infra.basetest.BRTest): cmd = "iptables --version" output, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0) - self.assertTrue(output[0].endswith("(legacy)")) + self.assertTrue(output[0].endswith(self.iptables_backend)) # We delete all rules in all chains. We also set default # policies to ACCEPT for INPUT and OUTPUT chains. This should @@ -95,3 +96,14 @@ class TestIptables(infra.basetest.BRTest): # Since we deleted the rule, the ping test command which was # supposed to fail earlier is now supposed to succeed. self.assertRunOk(ping_test_cmd) + + +class TestIptablesNft(TestIptables): + # Build iptables with nftables backend, and run the same test + # procedure as above + config = TestIptables.config + \ + """ + BR2_PACKAGE_IPTABLES_NFTABLES=y + BR2_PACKAGE_IPTABLES_NFTABLES_DEFAULT=y + """ + iptables_backend = "(nf_tables)"