[U-Boot] test/py - test OS boot

Michal Simek monstr at monstr.eu
Fri Apr 29 15:51:21 CEST 2016


Hi Stephen,

2016-04-21 19:43 GMT+02:00 Stephen Warren <swarren at wwwdotorg.org>:

> On 04/18/2016 07:46 AM, Michal Simek wrote:
>
>> Hi Stephen and Simon,
>>
>> have you thought how to use test/py for testing OS boot?
>> I am not experienced with python to quickly hack it myself but in
>> general I think we should support boot till OS (to test OS handoff,
>> legacy, fit formats, bootm subcommands, go, etc) till certain point and
>> then do reset and if that pattern is found test should pass.
>> I was trying to find out a way how to perform reset command and let test
>> pass.
>> Is there any way how to do it?
>>
>
> I think you'd want to do something like the following in the test:
>
> try:
>     orig_to = u_boot_console.p.timeout
>     # wait_for_prompt=False makes the core code not wait for the U-Boot
>     # prompt code to be seen, since it won't be on a successful kernel
>     # boot
>     u_boot_console.run_command('run bootcmd', wait_for_prompt=False)
>     u_boot_console.p.timeout = something_long
>     # You might want to expand wait_for() with options to add extra bad
>     # patterns which immediately indicate a failed boot, or add a new
>     # "with object" function u_boot_console.enable_check() that can
>     # cause extra patterns like the U-Boot console prompt, U-Boot boot
>     # error messages, kernel boot error messages, etc. to fail the
>     # wait_for().
>     u_boot_console.wait_for('login:')
> finally:
>     u_boot_console.p.timeout = orig_to
>     # This forces the console object to be shutdown, so any subsequent
>     # test will reset the board back into U-Boot. We want to force this
>     # no matter whether the kernel boot passed or failed.
>     u_boot_console.drain_console()
>     u_boot_console.cleanup_spawn()
>
> You should probably wrap the timeout manipulation into an automatic object
> that you can use with a "with" statement, similar to how
> u_boot_console_base.py's ConsoleDisableCheck class and disable_check()
> function work. That will isolate the logic a bit.
>
> Perhaps the structure of the above logic could be wrapped into a
> function/"with object":
>
> # Shorter variable name just for email wrapping
> c = u_boot_console
> with c.needs_target_restart_afterwards():
>     c.run_command('run bootcmd', wait_for_prompt=False)
>     with c.temporary_timeout(120):
>         u_boot_console.wait_for('login:')
>
>

This is working nicely. We should add an option to setup timeout to
tftpboot command too
because some images for reading can be quite large.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


More information about the U-Boot mailing list