diff --git a/DEVELOPERS b/DEVELOPERS index 8d280eff47..a03018ab2b 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1822,6 +1822,7 @@ F: support/testing/tests/package/test_strace.py F: support/testing/tests/package/test_stress_ng.py F: support/testing/tests/package/test_tcl.py F: support/testing/tests/package/test_tcl/ +F: support/testing/tests/package/test_tcpdump.py F: support/testing/tests/package/test_weston.py F: support/testing/tests/package/test_weston/ F: support/testing/tests/package/test_xz.py diff --git a/support/testing/tests/package/test_tcpdump.py b/support/testing/tests/package/test_tcpdump.py new file mode 100644 index 0000000000..42bfc96082 --- /dev/null +++ b/support/testing/tests/package/test_tcpdump.py @@ -0,0 +1,46 @@ +import os +import time + +import infra.basetest + + +class TestTcpdump(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y + BR2_PACKAGE_TCPDUMP=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() + + capture_file = "capture.pcap" + decode_log = "decode.log" + + # Check the program can execute. + self.assertRunOk("tcpdump --version") + + # Run ping in background. + cmd = "ping localhost >/dev/null &" + self.assertRunOk(cmd) + + time.sleep(1) + + # Capture 3 packets with the message. + cmd = f"tcpdump -c 3 -w {capture_file} icmp" + self.assertRunOk(cmd) + + # Decode the capture file. + cmd = f"tcpdump -r {capture_file} > {decode_log}" + self.assertRunOk(cmd) + + # Check we have ICMP echo requests/replies in the + # decoded capture. + cmd = f"grep -E 'ICMP echo (request|reply)' {decode_log}" + self.assertRunOk(cmd)