* [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test
@ 2024-07-21 17:09 Julien Olivain
2024-07-22 12:29 ` Thomas Petazzoni via buildroot
2024-08-31 11:34 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-07-21 17:09 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
DEVELOPERS | 1 +
.../testing/tests/package/test_iproute2.py | 77 +++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 support/testing/tests/package/test_iproute2.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 333e26d74e..77a798b25c 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1878,6 +1878,7 @@ F: support/testing/tests/package/test_hwloc.py
F: support/testing/tests/package/test_iozone.py
F: support/testing/tests/package/test_iperf.py
F: support/testing/tests/package/test_iperf3.py
+F: support/testing/tests/package/test_iproute2.py
F: support/testing/tests/package/test_iptables.py
F: support/testing/tests/package/test_jailhouse.py
F: support/testing/tests/package/test_jq.py
diff --git a/support/testing/tests/package/test_iproute2.py b/support/testing/tests/package/test_iproute2.py
new file mode 100644
index 0000000000..91d9006e23
--- /dev/null
+++ b/support/testing/tests/package/test_iproute2.py
@@ -0,0 +1,77 @@
+import os
+
+import infra.basetest
+
+
+class TestIpRoute2(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_PACKAGE_IPROUTE2=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def test_run(self):
+ cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+ self.emulator.boot(arch="armv5",
+ kernel="builtin",
+ options=["-initrd", cpio_file])
+ self.emulator.login()
+
+ # Check the program can execute. This also check we are
+ # actually using the version from the iproute2 package, rather
+ # than the BusyBox version (which does not understand this
+ # option).
+ self.assertRunOk("ip -Version")
+
+ # We run simple invocations of iproute2 tools.
+ self.assertRunOk("ifstat")
+ self.assertRunOk("ip link show dev lo")
+
+ # Buildroot is supposed to have setup the loopback "lo"
+ # interface. We should be able to ping any address in
+ # the 127.0.0.0/8 subnet.
+ addrs = ["127.0.0.1", "127.0.1.2", "127.1.2.3"]
+ ping_cmd = "ping -c 3 -i 0.2"
+ for addr in addrs:
+ self.assertRunOk(f"{ping_cmd} {addr}")
+
+ # We now change this 127.0.0.1/8 to a /16.
+ self.assertRunOk("ip addr del 127.0.0.1/8 dev lo")
+ self.assertRunOk("ip addr add 127.0.0.1/16 dev lo")
+
+ # The IPs in the 127.0.0.0/16 subnet are still supposed to
+ # ping...
+ addrs = ["127.0.0.1", "127.0.1.2"]
+ for addr in addrs:
+ self.assertRunOk(f"{ping_cmd} {addr}")
+ # ...but the IP outside is supposed to fail.
+ _, ret = self.emulator.run(f"{ping_cmd} 127.1.2.3")
+ self.assertNotEqual(ret, 0)
+
+ # We add a prohibited route.
+ self.assertRunOk("ip route add prohibit 127.0.1.0/24")
+
+ # Now, only 127.0.0.1 is supposed to ping...
+ self.assertRunOk(f"{ping_cmd} 127.0.0.1")
+ # ...while the other IPs expected to fail.
+ addrs = ["127.0.1.2", "127.1.2.3"]
+ for addr in addrs:
+ _, ret = self.emulator.run(f"{ping_cmd} {addr}")
+ self.assertNotEqual(ret, 0)
+
+ # We should be able to see our prohibited route.
+ out, ret = self.emulator.run("ip route list")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0].strip(), "prohibit 127.0.1.0/24")
+
+ # We create a new network namespace, and create a new shell
+ # process in it.
+ self.assertRunOk("ip netns add br-test")
+ self.assertRunOk("ip netns exec br-test /bin/sh")
+
+ # Since we are in a new namespace, we should no longer see the
+ # prohibited route. The route list output should be empty.
+ out, ret = self.emulator.run("ip route list")
+ self.assertEqual(ret, 0)
+ self.assertEqual(len(out), 0)
--
2.45.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test
2024-07-21 17:09 [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test Julien Olivain
@ 2024-07-22 12:29 ` Thomas Petazzoni via buildroot
2024-08-31 11:34 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-07-22 12:29 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
On Sun, 21 Jul 2024 19:09:12 +0200
Julien Olivain <ju.o@free.fr> wrote:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> DEVELOPERS | 1 +
> .../testing/tests/package/test_iproute2.py | 77 +++++++++++++++++++
> 2 files changed, 78 insertions(+)
> create mode 100644 support/testing/tests/package/test_iproute2.py
I'm not an expert into what would be a good test for iproute2, but what
you proposed seemed like a reasonable set of basic tests, so applied.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test
2024-07-21 17:09 [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test Julien Olivain
2024-07-22 12:29 ` Thomas Petazzoni via buildroot
@ 2024-08-31 11:34 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-08-31 11:34 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
Committed to 2024.02.x and 2024.05.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-31 11:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21 17:09 [Buildroot] [PATCH 1/1] support/testing: add iproute2 runtime test Julien Olivain
2024-07-22 12:29 ` Thomas Petazzoni via buildroot
2024-08-31 11:34 ` Peter Korsgaard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.