test_iputils.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import infra.basetest
  3. class TestIputils(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_IPUTILS=y
  7. BR2_SYSTEM_DHCP="eth0"
  8. BR2_TARGET_ROOTFS_CPIO=y
  9. # BR2_TARGET_ROOTFS_TAR is not set
  10. """
  11. def test_run(self):
  12. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  13. self.emulator.boot(arch="armv7",
  14. kernel="builtin",
  15. options=["-initrd", cpio_file])
  16. self.emulator.login()
  17. # We check all the main programs of iputils can execute and
  18. # report their version. Note the "-V" option is not accepted
  19. # and fails if the "ping" applet of BusyBox is used instead.
  20. iputils_progs = ["arping", "clockdiff", "ping", "tracepath"]
  21. for prog in iputils_progs:
  22. self.assertRunOk(f"{prog} -V")
  23. # Qemu host IP, See:
  24. # https://wiki.qemu.org/Documentation/Networking#User_Networking_(SLIRP)
  25. qemu_host = "10.0.2.2"
  26. # We test the "arping" program, with 3 pings.
  27. self.assertRunOk(f"arping -c 3 {qemu_host}", timeout=10)
  28. # We test the "ping" program. We use the option "-D" which
  29. # shows a timestamp and is also not supported by the "ping"
  30. # BusyBox applet.
  31. self.assertRunOk(f"ping -D -c 3 {qemu_host}", timeout=10)
  32. # We test the "tracepath" program. We set the max hops to 2,
  33. # since there is no intermediate routers.
  34. self.assertRunOk(f"tracepath -m 2 {qemu_host}", timeout=10)
  35. # We test the "clockdiff" program. We cannot use the Qemu host
  36. # IP for this program as the ICMP TIMESTAMP is used and is not
  37. # responded. We use the local host instead.
  38. self.assertRunOk("clockdiff 127.0.0.1", timeout=10)