test_none.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import pexpect
  2. import infra.basetest
  3. from tests.init.base import InitSystemBase as InitSystemBase
  4. class TestInitSystemNone(InitSystemBase):
  5. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  6. """
  7. BR2_INIT_NONE=y
  8. # BR2_TARGET_ROOTFS_TAR is not set
  9. BR2_TARGET_ROOTFS_SQUASHFS=y
  10. """
  11. def test_run(self):
  12. self.start_emulator(fs_type="squashfs", init="/bin/sh")
  13. index = self.emulator.qemu.expect(["/bin/sh: can't access tty; job control turned off", pexpect.TIMEOUT], timeout=60)
  14. if index != 0:
  15. self.emulator.logfile.write("==> System does not boot")
  16. raise SystemError("System does not boot")
  17. index = self.emulator.qemu.expect(["#", pexpect.TIMEOUT], timeout=60)
  18. if index != 0:
  19. self.emulator.logfile.write("==> System does not boot")
  20. raise SystemError("System does not boot")
  21. out, exit_code = self.emulator.run("sh -c 'echo $PPID'")
  22. self.assertEqual(exit_code, 0)
  23. self.assertEqual(out[0], "1")
  24. _, exit_code = self.emulator.run("mount -t proc none /proc")
  25. self.assertEqual(exit_code, 0)
  26. self.check_init("/bin/sh")