test_s6_networking.py 1.3 KB

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