6 class InitSystemBase(infra.basetest.BRTest):
8 def startEmulator(self, fs_type, kernel=None, dtb=None, init=None):
9 img = os.path.join(self.builddir, "images", "rootfs.{}".format(fs_type))
10 subprocess.call(["truncate", "-s", "%1M", img])
13 "file={},if=sd,format=raw".format(img),
19 kernel = os.path.join(self.builddir, "images", kernel)
20 options.extend(["-dtb", os.path.join(self.builddir, "images",
21 "{}.dtb".format(dtb))])
23 kernel_cmdline = ["root=/dev/mmcblk0",
24 "rootfstype={}".format(fs_type),
30 kernel_cmdline.extend(["init={}".format(init)])
32 self.emulator.boot(arch="armv7",
34 kernel_cmdline=kernel_cmdline,
40 def checkInit(self, path):
41 cmd = "cmp /proc/1/exe {}".format(path)
42 _, exit_code = self.emulator.run(cmd)
43 self.assertEqual(exit_code, 0)
45 def checkNetwork(self, interface, exitCode=0):
46 cmd = "ip addr show {} |grep inet".format(interface)
47 _, exit_code = self.emulator.run(cmd)
48 self.assertEqual(exit_code, exitCode)