From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Thu, 21 Apr 2016 11:43:08 -0600 Subject: [U-Boot] test/py - test OS boot In-Reply-To: <5714E53F.2000902@monstr.eu> References: <5714E53F.2000902@monstr.eu> Message-ID: <5719112C.3030507@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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:')