xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_s6_networking.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5
6class TestS6Networking(infra.basetest.BRTest):
7    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
8        """
9        BR2_PACKAGE_S6_NETWORKING=y
10        BR2_TARGET_ROOTFS_CPIO=y
11        # BR2_TARGET_ROOTFS_TAR is not set
12        """
13
14    def test_run(self):
15        img = os.path.join(self.builddir, "images", "rootfs.cpio")
16        self.emulator.boot(arch="armv5",
17                           kernel="builtin",
18                           options=["-initrd", img])
19        self.emulator.login()
20
21        # Test the TAICLOCK server and client
22        _, exit_code = self.emulator.run("s6-taiclockd &")
23        self.emulator.run("sleep 2")
24        cmd = "s6-taiclock 127.0.0.1 | s6-clockview"
25        output, exit_code = self.emulator.run(cmd)
26        self.assertEqual(exit_code, 0)
27        self.assertEqual(output[0][0:6], "before")
28        self.assertEqual(output[1][0:5], "after")
29
30        # Test the TCP server and client
31        _, exit_code = self.emulator.run("s6-tcpserver4 127.0.0.1 1024 cat &")
32        self.emulator.run("sleep 2")
33        cmd = "echo foobar | s6-tcpclient 127.0.0.1 1024 s6-ioconnect -67"
34        output, exit_code = self.emulator.run(cmd)
35        self.assertEqual(exit_code, 0)
36        self.assertEqual(output[0], "foobar")
37