[Buildroot] [git commit] support/testing: add tio runtime test
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Sun Dec 28 21:57:20 UTC 2025
commit: https://git.buildroot.net/buildroot/commit/?id=7c8c8e01fa4ea1eb0fc1370e1e52f8dcec12e1f5
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
Signed-off-by: Julien Olivain <ju.o at free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
DEVELOPERS | 1 +
support/testing/tests/package/test_tio.py | 74 +++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
diff --git a/DEVELOPERS b/DEVELOPERS
index c876be2cb6..34dee3fc7a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2021,6 +2021,7 @@ 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_tesseract_ocr.py
+F: support/testing/tests/package/test_tio.py
F: support/testing/tests/package/test_trace_cmd.py
F: support/testing/tests/package/test_trace_cmd/
F: support/testing/tests/package/test_tree.py
diff --git a/support/testing/tests/package/test_tio.py b/support/testing/tests/package/test_tio.py
new file mode 100644
index 0000000000..f7d612b9dd
--- /dev/null
+++ b/support/testing/tests/package/test_tio.py
@@ -0,0 +1,74 @@
+import os
+import time
+
+import infra.basetest
+
+
+class TestTio(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_PACKAGE_LUA=y
+ BR2_PACKAGE_SOCAT=y
+ BR2_PACKAGE_TIO=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def get_tty_name(self):
+ out, ret = self.emulator.run("tty")
+ self.assertEqual(ret, 0)
+ return out[0]
+
+ 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()
+
+ # We check the program can run
+ self.assertRunOk("tio --version")
+
+ # We save our tty name for later.
+ initial_tty = self.get_tty_name()
+
+ # We define two arbitrary pseudo-terminals, for our test.
+ pty1 = "pty1_getty"
+ pty2 = "pty2_tio"
+
+ # We create our 2 PTYs with socat and connect them together.
+ cmd = "( socat"
+ for pty in [pty1, pty2]:
+ cmd += f" PTY,link=/dev/{pty},rawer,b115200"
+ cmd += " &> /dev/null & )"
+ self.assertRunOk(cmd)
+
+ # We wait for socat to be ready...
+ for attempt in range(3 * self.timeout_multiplier):
+ time.sleep(1)
+ cmd = f"test -e /dev/{pty1} -a -e /dev/{pty2}"
+ _, ret = self.emulator.run(cmd)
+ if ret == 0:
+ break
+ else:
+ self.fail("Timeout while waiting for socat.")
+
+ # We start getty on our first PTY.
+ self.assertRunOk(f"setsid getty {pty1} 115200 vt100")
+
+ # We start tio on our second PTY and send a new line.
+ # We wait for tio to be ready then send a new line.
+ # After that, we expect to see a new login.
+ self.emulator.qemu.sendline(f"tio /dev/{pty2}")
+ self.emulator.qemu.expect(f"Connected to /dev/{pty2}")
+ self.emulator.qemu.sendline()
+
+ # We try to re-login, in tio this time.
+ self.emulator.login()
+
+ # We get again our tty name.
+ tio_tty = self.get_tty_name()
+
+ # We check our second login TTY name is different from the one
+ # in the first login.
+ self.assertNotEqual(initial_tty, tio_tty)
More information about the buildroot
mailing list