All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] test/py - test OS boot
@ 2016-04-18 13:46 Michal Simek
  2016-04-21 17:43 ` Stephen Warren
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2016-04-18 13:46 UTC (permalink / raw)
  To: u-boot

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?

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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160418/f38ce5df/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] test/py - test OS boot
  2016-04-18 13:46 [U-Boot] test/py - test OS boot Michal Simek
@ 2016-04-21 17:43 ` Stephen Warren
  2016-04-29 13:51   ` Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2016-04-21 17:43 UTC (permalink / raw)
  To: u-boot

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:')

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] test/py - test OS boot
  2016-04-21 17:43 ` Stephen Warren
@ 2016-04-29 13:51   ` Michal Simek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2016-04-29 13:51 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

2016-04-21 19:43 GMT+02:00 Stephen Warren <swarren@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-29 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-18 13:46 [U-Boot] test/py - test OS boot Michal Simek
2016-04-21 17:43 ` Stephen Warren
2016-04-29 13:51   ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.