[tbot] Problem with context exit (and serial transmission)

Stefano Babic sbabic at denx.de
Sun Feb 3 10:16:33 UTC 2019


Hi Lukasz,

On 02/02/19 23:57, Lukasz Majewski wrote:
> Dear tbot users,
> 
> 
> I'm trying to build a more sophisticated tbot scenario:
> 
> 1. I allow board to boot till linux prompt and change the u-boot env
> variable with fw_setenv foo "AAA" (this is one test - separate one ->
> linux_falcon_boot)
> 
> 2. Then I start another test, which in u-boot updates fitImage
> (uboot_kernel_write)
> 
> Please find following snippet:
> 
> def kernel_active_update(
>     lab: typing.Optional[linux.LabHost] = None,
> ) -> None:
>      linux_falcon_boot(falcon_status="disable")
> # --------- Problem / why do I need this code ?
>      with lab or tbot.acquire_lab() as lh:
>          lh.exec0("pkill", "-9", "picocom")
>          time.sleep(3)
> # ---------
>      uboot_kernel_write(reset=True, serverip="192.168.2.222")
> 
> 
> The linux_falcon_boot() and uboot_kernel_write() works without problems
> when executed as standalone tests (and I only expect them to be run one
> by one).
> 
> The question is - why do I need to kill manually the picocom process
> and put some sleep between invocation of those two tests?

This should not be necessary and I do not see this issue running tests
that do not require a reboot. I just guess that this is caused when:

         if reset:
             ub.exec0("reset")

Do you have the same effect if tests does not require to restart the
board ? I cannot state this in case of testcases in sequence.

> 
> From the doc I thought that when we exit context (from one test with
> disabling power) and start the context again (and power up in another
> test), the "channel" would be put into default state (I mean the picocom
> would be killed and re-spawned accordingly).
> 
> When I comment lines between #---- I do see following error
> (for /dev/tty_display5 or ttyUSB0):
> 
> │   BlockingIOError: [Errno 11] Resource temporarily unavailable
>> │   During handling of the above exception, another exception occurred:
>      File"/root/.local/lib/python3.7/site-packages/tbot-0.6.6-py3.7.egg/tbot/machine/channel/subprocess.py",
> line 85, in recv 
> │       raise channel.ChannelClosedException() 
> │tbot.machine.channel.channel.ChannelClosedException
> 
> 
> 
> Thanks in advance for help.
> 
> 
> 
> The separate tests in questions (for a reference):
> tc_uboot_kernel_write.py:
> -------------------------
> 
> import contextlib
> import typing
> import tbot
> from tbot.machine import board
> from tbot.machine import linux
> 
> TFTP_DIR = "/srv/tftp"
> 
> @tbot.testcase
> def uboot_kernel_write(
>     lab: typing.Optional[tbot.selectable.LabHost] = None,
>     uboot: typing.Optional[board.UBootMachine] = None,
>     serverip: str = "192.168.2.222",
>     reset: bool = False,
> ) -> None:
>     with contextlib.ExitStack() as cx:
>         lh = cx.enter_context(lab or tbot.acquire_lab())
>         if uboot is not None:
>             ub = uboot
>         else:
>             b = cx.enter_context(tbot.acquire_board(lh))
>             ub = cx.enter_context(tbot.acquire_uboot(b))
> 
>         p = linux.Path(lh, TFTP_DIR+"/fitImage")
>         if not p.is_file():
>             raise Exception(f"{p} must be a fitImage file!")
> 
>         ub.exec0("setenv", "serverip", serverip)
>         ub.exec0("run", "tftp_mmc_fitImg")
>         if reset:
>             ub.exec0("reset")
> 
> 
> tc_linux_falcon_boot.py
> -----------------------
> 
> import contextlib
> import typing
> import tbot
> from tbot.machine import linux, board
> 
> @tbot.testcase
> def linux_falcon_boot(
>     lab: typing.Optional[linux.LabHost] = None,
>     board_linux: typing.Optional[board.LinuxStandaloneMachine] = None,
>     falcon_status: str = "disable",
> ) -> None:
>     with contextlib.ExitStack() as cx:
>         if board_linux is None:
>             lh  = cx.enter_context(lab or tbot.acquire_lab())
>             b   = cx.enter_context(tbot.acquire_board(lh))
>             lnx = cx.enter_context(tbot.acquire_linux(b))
>         else:
>             lnx = board_linux
> 
>         lnx.exec0("fw_setenv", "boot_os", "y" if falcon_status ==
>         "enable" else "" )
> 
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