test_s6_rc.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import os
  2. import infra.basetest
  3. class TestS6Rc(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_S6_RC=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. _, exit_code = self.emulator.run("s6-svscan -h")
  17. self.assertEqual(exit_code, 100)
  18. # Set up two service directories with a dependency
  19. self.assertRunOk("mkdir -p source/testsv1")
  20. self.assertRunOk("mkdir -p source/testsv2")
  21. self.assertRunOk("echo oneshot > source/testsv1/type")
  22. self.assertRunOk("echo oneshot > source/testsv2/type")
  23. self.assertRunOk("echo 'echo foo' > source/testsv1/up")
  24. self.assertRunOk("echo 'echo bar' > source/testsv2/up")
  25. self.assertRunOk("echo testsv1 > source/testsv2/dependencies")
  26. self.assertRunOk("chmod +x source/testsv1/up")
  27. self.assertRunOk("chmod +x source/testsv2/up")
  28. # Compile the service database
  29. self.assertRunOk("s6-rc-compile compiled source")
  30. # Inspect dependencies
  31. cmd = "s6-rc-db -c compiled -d dependencies testsv1"
  32. output, exit_code = self.emulator.run(cmd)
  33. self.assertEqual(exit_code, 0)
  34. self.assertEqual(output[0], "testsv2")
  35. cmd = "s6-rc-db -c compiled dependencies testsv2"
  36. output, exit_code = self.emulator.run(cmd)
  37. self.assertEqual(exit_code, 0)
  38. self.assertEqual(output[0], "testsv1")