コード例 #1
0
    def testLoader1(self):
        files = {
            'rom.dat':
            self.prepareBootRom(),
            'emmc.dat':
            self.prepareEmmc(
                boot=self.prepareBootPartition(patchInitPower=True),
                partitions=[
                    self.prepareFlash1(
                        kernel=self.prepareUpdaterKernel(),
                        initrd=self.prepareUpdaterInitrd(
                            patchUpdaterMain=True),
                        patchConsoleEnable=True,
                    ),
                    self.prepareFlash2(updaterMode=True),
                ],
            ),
        }
        args = self.prepareQemuArgs(bootRom='rom.dat',
                                    emmc='emmc.dat',
                                    patchLoader2LogLevel=True)

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('Astra Loader1'))
            q.expectLine(lambda l: l.startswith('Loader2'))
            q.expectLine(lambda l: l.startswith('LDR:Jump to kernel'))
            q.expectLine(lambda l: l.startswith('BusyBox'))
            time.sleep(.5)
            self.checkShell(q.execShellCommand)
コード例 #2
0
    def testLoader2Updater(self):
        files = {
            'nand.dat':
            self.prepareNand(
                safeBoot=self.prepareSafeBootPartition(),
                normalBoot=self.prepareNormalBootPartition(),
                partitions=[
                    self.prepareFlash1(
                        kernel=self.prepareUpdaterKernel(
                            patchConsoleEnable=True),
                        initrd=self.prepareUpdaterInitrd(shellOnly=True),
                    ),
                    self.prepareFlash2(updaterMode=True,
                                       patchBackupWriteComp=True),
                ],
            ),
        }
        args = self.prepareQemuArgs(nand='nand.dat', patchLoader2LogLevel=True)

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('Loader2'))
            q.expectLine(lambda l: l.startswith('Loader3'))
            q.expectLine(lambda l: l.startswith('LDR:Jump to kernel'))
            q.expectLine(lambda l: l.startswith('BusyBox'))
            time.sleep(.5)
            self.checkShell(q.execShellCommand)
コード例 #3
0
    def testUpdaterUsb(self):
        files = {
            'rom.dat':
            self.prepareBootRom(),
            'nand.dat':
            self.prepareNand(
                boot=self.prepareBootPartition(),
                partitions=[
                    self.prepareFlash1(
                        kernel=self.prepareUpdaterKernel(
                            patchConsoleEnable=True),
                        initrd=self.prepareUpdaterInitrd(
                            patchUpdaterLogLevel=True, patchCasCmd=True),
                    ),
                    self.prepareFlash2(updaterMode=True),
                ],
            ),
        }
        args = self.prepareQemuArgs(bootRom='rom.dat', nand='nand.dat')

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('BusyBox'))
            q.expectLine(
                lambda l: '"DONE onEvent(COMP_START or COMP_STOP)"' in l)

            with usb.PmcaRunner('updatershell',
                                ['-d', 'qemu', '-m', self.MODEL]) as pmca:
                pmca.expectLine(
                    lambda l: l == 'Welcome to the USB debug shell.')
                self.checkShell(
                    lambda c: pmca.execUpdaterShellCommand('shell %s' % c))
                pmca.writeLine('exit')
                pmca.expectLine(lambda l: l == 'Done')
コード例 #4
0
    def testUpdaterKernel(self):
        files = {
            'vmlinux.bin': self.prepareUpdaterKernel(unpackZimage=True),
            'initrd.img': self.prepareUpdaterInitrd(shellOnly=True),
        }
        args = self.prepareQemuArgs(kernel='vmlinux.bin', initrd='initrd.img')

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('BusyBox'))
            time.sleep(.5)
            self.checkShell(q.execShellCommand)
コード例 #5
0
    def testUpdaterUsb(self):
        files = {
            'rom.dat':
            self.prepareBootRom(),
            'nand.dat':
            self.prepareNand(
                safeBoot=self.prepareSafeBootPartition(),
                normalBoot=self.prepareNormalBootPartition(),
                partitions=[
                    self.prepareFlash1(
                        kernel=self.prepareUpdaterKernel(
                            patchConsoleEnable=True),
                        initrd=self.prepareUpdaterInitrd(),
                    ),
                    self.prepareFlash2(updaterMode=True,
                                       patchBackupWriteComp=True),
                ],
            ),
        }
        args = self.prepareQemuArgs(bootRom='rom.dat',
                                    nand='nand.dat',
                                    patchLoader2LogLevel=True)

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('Musashi Loader1'))
            q.expectLine(lambda l: l.startswith('Loader2'))
            q.expectLine(lambda l: l.startswith('Loader3'))
            q.expectLine(lambda l: l.startswith('LDR:Jump to kernel'))
            q.expectLine(lambda l: l.startswith('BusyBox'))
            q.expectLine(lambda l: l.endswith(
                '"DONE onEvent(COMP_START or COMP_STOP)"'))

            with usb.PmcaRunner('updatershell',
                                ['-d', 'qemu', '-m', self.MODEL]) as pmca:
                pmca.expectLine(
                    lambda l: l == 'Welcome to the USB debug shell.')
                self.checkShell(
                    lambda c: pmca.execUpdaterShellCommand('shell %s' % c))
                pmca.writeLine('exit')
                pmca.expectLine(lambda l: l == '>Done')

            q.expectLine(lambda l: l == 'User Update OK')
コード例 #6
0
    def testLoader2Updater(self):
        files = {
            'nand.dat':
            self.prepareNand(
                boot=self.prepareBootPartition(),
                partitions=[
                    self.prepareFlash1(
                        kernel=self.prepareUpdaterKernel(),
                        initrd=self.prepareUpdaterInitrd(),
                    ),
                    self.prepareFlash2(updaterMode=True),
                ],
            ),
        }
        args = self.prepareQemuArgs(nand='nand.dat')

        with qemu.QemuRunner(self.MACHINE, args, files) as q:
            q.expectLine(lambda l: l.startswith('BusyBox'))
            time.sleep(.5)
            self.checkShell(q.execShellCommand)
コード例 #7
0
    def testLoader1Main(self):
        files = {
            'rom.dat':
            self.prepareBootRom(),
            'nand.dat':
            self.prepareNand(
                boot=self.prepareBootPartition(),
                partitions=[
                    b'',
                    self.prepareFlash2(readSettings=True,
                                       patchTouchscreenEnable=True,
                                       playbackMode=True,
                                       ntscOnly=True),
                    self.prepareFlash3(kernel=self.prepareMainKernel(
                        patchConsoleEnable=True)),
                    b'',
                    self.prepareFlash5(),
                    self.prepareFlash6(),
                ],
            ),
            'mmc.dat':
            self.prepareFlash11(),
        }
        args = self.prepareQemuArgs(bootRom='rom.dat',
                                    nand='nand.dat',
                                    mmc='mmc.dat')

        with qemu.QemuRunner(self.MACHINE, args, files, timeout=20) as q:

            def waitScreen():
                q.execShellCommand(
                    'cat /dev/blog_fsk > /dev/null; until egrep \'^.{16}0485040000000003\' /dev/blog_fsk > /dev/null; do usleep 200000; done'
                )
                time.sleep(1)

            def click(x, y):
                q.sendMousePos(x, y)
                q.sendMouseButton(True)
                q.sendMouseButton(False)
                time.sleep(1)

            def checkScreen(fn):
                im = q.screenshot()
                path = os.path.join(self.SCREENSHOT_DIR, fn)
                if ImageChops.difference(im, Image.open(path)).getbbox():
                    raise Exception('%s is different' % fn)

            q.expectLine(lambda l: l.startswith('BusyBox'))
            waitScreen()
            checkScreen('clock1.png')

            click(.9, .9)  # next
            checkScreen('clock2.png')

            click(.5, .9)  # ok
            waitScreen()
            checkScreen('playback.png')

            click(.1, .1)  # home
            checkScreen('home.png')
            click(.9, .1)  # close

            click(.1, .9)  # menu
            checkScreen('menu.png')
            click(.9, .1)  # close
コード例 #8
0
    def testLoader1Main(self):
        files = {
            'rom.dat':
            self.prepareBootRom(),
            'nand.dat':
            self.prepareNand(
                boot=self.prepareBootPartition(),
                partitions=[
                    b'',
                    self.prepareFlash2(readSettings=True,
                                       playbackMode=True,
                                       ntscOnly=True),
                    self.prepareFlash3(kernel=self.prepareMainKernel(
                        patchConsoleEnable=True)),
                    b'',
                    self.prepareFlash5(),
                    self.prepareFlash6(),
                    b'',
                    b'',
                    b'',
                    b'',
                    self.prepareFlash11(),
                ],
            ),
        }
        args = self.prepareQemuArgs(bootRom='rom.dat', nand='nand.dat')

        with qemu.QemuRunner(self.MACHINE, args, files) as q:

            def waitScreen():
                q.execShellCommand(
                    'cat /dev/blog_fsk > /dev/null; until egrep \'^.{8}038504002b20627265774642446973706f73654269746d617000\' /dev/blog_fsk > /dev/null; do usleep 200000; done'
                )
                time.sleep(1)

            def pressKey(key):
                q.sendKey(key, True)
                q.sendKey(key, False)
                time.sleep(.5)

            def checkScreen(fn):
                im = q.screenshot()
                path = os.path.join(self.SCREENSHOT_DIR, fn)
                if ImageChops.difference(im, Image.open(path)).getbbox():
                    raise Exception('%s is different' % fn)

            q.expectLine(lambda l: l.startswith('BusyBox'))
            waitScreen()
            checkScreen('clock.png')

            pressKey('down')
            pressKey('down')
            pressKey('down')
            pressKey('ret')  # ok
            waitScreen()
            checkScreen('playback.png')

            pressKey('h')
            time.sleep(2)
            checkScreen('home.png')
            pressKey('h')

            pressKey('m')
            time.sleep(2)
            checkScreen('menu.png')
            pressKey('m')