aboutsummaryrefslogtreecommitdiff
path: root/support/testing/tests/init/test_none.py
blob: c8a79f0bab8d95d9207d9638ac2ef48564122d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pexpect

import infra.basetest
from tests.init.base import InitSystemBase as InitSystemBase


class TestInitSystemNone(InitSystemBase):
    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
        """
        BR2_INIT_NONE=y
        # BR2_TARGET_ROOTFS_TAR is not set
        BR2_TARGET_ROOTFS_SQUASHFS=y
        """

    def test_run(self):
        self.startEmulator(fs_type="squashfs", init="/bin/sh")
        index = self.emulator.qemu.expect(["/bin/sh: can't access tty; job control turned off", pexpect.TIMEOUT], timeout=60)
        if index != 0:
            self.emulator.logfile.write("==> System does not boot")
            raise SystemError("System does not boot")
        index = self.emulator.qemu.expect(["#", pexpect.TIMEOUT], timeout=60)
        if index != 0:
            self.emulator.logfile.write("==> System does not boot")
            raise SystemError("System does not boot")

        out, exit_code = self.emulator.run("sh -c 'echo $PPID'")
        self.assertEqual(exit_code, 0)
        self.assertEqual(out[0], "1")

        _, exit_code = self.emulator.run("mount -t proc none /proc")
        self.assertEqual(exit_code, 0)

        self.checkInit("/bin/sh")