Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: add socat runtime test
@ 2024-04-23 17:11 Julien Olivain
  2024-05-09 16:22 ` Thomas Petazzoni via buildroot
  2024-06-03 15:46 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-04-23 17:11 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 DEVELOPERS                                  |  1 +
 support/testing/tests/package/test_socat.py | 56 +++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 support/testing/tests/package/test_socat.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 399b2931ff3..104588136f2 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1857,6 +1857,7 @@ F:	support/testing/tests/package/test_rdma_core.py
 F:	support/testing/tests/package/test_rdma_core/
 F:	support/testing/tests/package/test_screen.py
 F:	support/testing/tests/package/test_sed.py
+F:	support/testing/tests/package/test_socat.py
 F:	support/testing/tests/package/test_sox.py
 F:	support/testing/tests/package/test_sqlite.py
 F:	support/testing/tests/package/test_strace.py
diff --git a/support/testing/tests/package/test_socat.py b/support/testing/tests/package/test_socat.py
new file mode 100644
index 00000000000..67b32448435
--- /dev/null
+++ b/support/testing/tests/package/test_socat.py
@@ -0,0 +1,56 @@
+import os
+import time
+
+import infra.basetest
+
+
+class TestSoCat(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_NETCAT=y
+        BR2_PACKAGE_SOCAT=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()
+
+        # Some values, for the test.
+        msg = "Hello Buildroot!"
+        out_file = "output.txt"
+        port1 = 11111
+        port2 = 22222
+
+        # Check the program can execute.
+        self.assertRunOk("socat -V")
+
+        # We start the receiver netcat on tcp/port2.
+        cmd = f"nc -n -l -p {port2} > {out_file} 2> /dev/null &"
+        self.assertRunOk(cmd)
+
+        time.sleep(2 * self.timeout_multiplier)
+
+        # We start socat in background to listen on tcp/port1 and
+        # forward to tcp/port2.
+        cmd = f"socat TCP4-LISTEN:{port1} TCP4:127.0.0.1:{port2} &"
+        self.assertRunOk(cmd)
+
+        time.sleep(2 * self.timeout_multiplier)
+
+        # We write a message on tcp/port1. Socat is expected to
+        # forward the message to the receiver on tcp/port2, and write
+        # our message in a file.
+        cmd = f"echo '{msg}' | nc -n -c 127.0.0.1 {port1}"
+        self.assertRunOk(cmd)
+
+        # We check the output file contains our message.
+        cmd = f"cat {out_file}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], msg)
-- 
2.44.0

_______________________________________________
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 socat runtime test
  2024-04-23 17:11 [Buildroot] [PATCH 1/1] support/testing: add socat runtime test Julien Olivain
@ 2024-05-09 16:22 ` Thomas Petazzoni via buildroot
  2024-06-03 15:46 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-05-09 16:22 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On Tue, 23 Apr 2024 19:11:18 +0200
Julien Olivain <ju.o@free.fr> wrote:

> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
>  DEVELOPERS                                  |  1 +
>  support/testing/tests/package/test_socat.py | 56 +++++++++++++++++++++
>  2 files changed, 57 insertions(+)
>  create mode 100644 support/testing/tests/package/test_socat.py

Applied to master, 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 socat runtime test
  2024-04-23 17:11 [Buildroot] [PATCH 1/1] support/testing: add socat runtime test Julien Olivain
  2024-05-09 16:22 ` Thomas Petazzoni via buildroot
@ 2024-06-03 15:46 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-06-03 15:46 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, 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-06-03 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 17:11 [Buildroot] [PATCH 1/1] support/testing: add socat runtime test Julien Olivain
2024-05-09 16:22 ` Thomas Petazzoni via buildroot
2024-06-03 15:46 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox