All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] test/py - test OS boot
Date: Thu, 21 Apr 2016 11:43:08 -0600	[thread overview]
Message-ID: <5719112C.3030507@wwwdotorg.org> (raw)
In-Reply-To: <5714E53F.2000902@monstr.eu>

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

  reply	other threads:[~2016-04-21 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 13:46 [U-Boot] test/py - test OS boot Michal Simek
2016-04-21 17:43 ` Stephen Warren [this message]
2016-04-29 13:51   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5719112C.3030507@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.