[tbot] Handling return code from test case

Stefano Babic sbabic at denx.de
Thu Nov 22 09:18:57 UTC 2018



On 22/11/18 10:08, Stefano Babic wrote:
> Hi,
> 
> I am trying two simple testcases:
> 
> - first testcase boots a board in Linux and run an existing command
> - second testcase boots a board in Linux and run a not existing command
> 
> As desired, tbot reports success for the first one and failure for the
> second one.
> 
> But let's say I want to test that a command fails, that is my tbot
> testcase should be successful if the command is not found.
> 
> When I call exec0, test of course fails but tbot stops. How is this
> managed ?
> 
> Just to make things clear:
> 
> import contextlib
>  import typing
>  import time
>  import tbot
>  from tbot.machine import linux
> 
>  @tbot.testcase
>  def missingcmd(
>      mach: typing.Optional[linux.LinuxMachine] = None,
>  ) -> None:
>      with contextlib.ExitStack() as cx:
>          if mach is None:
>              lh = cx.enter_context(tbot.acquire_lab())
>              b = cx.enter_context(tbot.acquire_board(lh))
>              lnx = cx.enter_context(tbot.acquire_linux(b))
>          else:
>              lnx = mach
> 
>          lnx.exec0("doesnotexist")
> 
> 
> And tbot should be successful if the command cannot be executed (also, I
> want a "reverse" case).
> 

Ok, it seems I must call exec instead of exec0.

Stefano

> Regards,
> Stefano
> 

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the tbot mailing list