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