فهرست منبع

support/testing: add fping runtime test

Signed-off-by: Julien Olivain <ju.o@free.fr>
[Peter: scale delay with timout_multiplier]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Julien Olivain 1 سال پیش
والد
کامیت
cc2ff8a38e
2فایلهای تغییر یافته به همراه46 افزوده شده و 0 حذف شده
  1. 1 0
      DEVELOPERS
  2. 45 0
      support/testing/tests/package/test_fping.py

+ 1 - 0
DEVELOPERS

@@ -1771,6 +1771,7 @@ F:	support/testing/tests/package/test_ddrescue/
 F:	support/testing/tests/package/test_dos2unix.py
 F:	support/testing/tests/package/test_fluidsynth.py
 F:	support/testing/tests/package/test_fluidsynth/
+F:	support/testing/tests/package/test_fping.py
 F:	support/testing/tests/package/test_gawk.py
 F:	support/testing/tests/package/test_glslsandbox_player.py
 F:	support/testing/tests/package/test_glslsandbox_player/

+ 45 - 0
support/testing/tests/package/test_fping.py

@@ -0,0 +1,45 @@
+import os
+import time
+
+import infra.basetest
+
+
+class TestFping(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_FPING=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.
+        self.assertRunOk("fping --version")
+
+        # Fping v5.1 need to wait few seconds after a kernel booted
+        # before starting. This sleep time can be removed when the
+        # issue will be closed and the package updated. See:
+        # https://github.com/schweikert/fping/issues/288
+        time.sleep(5 * self.timeout_multiplier)
+
+        # Run 3 pings on localhost.
+        self.assertRunOk("fping -e -c 3 localhost")
+
+        # Run pings on a local subnet and print statistics.
+        self.assertRunOk("fping -s -g 127.0.0.0/28")
+
+        # Test an IPv6 ping.
+        self.assertRunOk("fping -6 ::1")
+
+        # Create a prohibited route to make fping fail.
+        self.assertRunOk("ip route add to prohibit 192.168.12.0/24")
+
+        # We expect fping to fail when pinging the prohibited network.
+        _, ret = self.emulator.run("fping 192.168.12.34")
+        self.assertNotEqual(ret, 0)