Generic tbot config implementation

This implements the apporach for an generic tbot configuration configured through ini files.

class tbottest.labgeneric.boardPicocomConnector(mach: LinuxShell)[source]

Bases: PicocomConnector

Parameters:

mach (LinuxShell) – A cloneable lab-host machine. The ConsoleConnector will try to clone this machine’s connection and use that to connect to the board. This means that you have to make sure you give the correct lab-host for your respecitive board to the constructor here.

class tbottest.labgeneric.boardScriptConnector(mach: LinuxShell)[source]

Bases: ScriptConnector

Parameters:

mach (LinuxShell) – A cloneable lab-host machine. The ConsoleConnector will try to clone this machine’s connection and use that to connect to the board. This means that you have to make sure you give the correct lab-host for your respecitive board to the constructor here.

class tbottest.labgeneric.boardKermitConnector(mach: LinuxShell)[source]

Bases: KermitConnector

Parameters:

mach (LinuxShell) – A cloneable lab-host machine. The ConsoleConnector will try to clone this machine’s connection and use that to connect to the board. This means that you have to make sure you give the correct lab-host for your respecitive board to the constructor here.

class tbottest.labgeneric.boardSSHConnector(host: Optional[LinuxShell] = None)[source]

Bases: SSHConnector

property authenticator: Union[PasswordAuthenticator, PrivateKeyAuthenticator, NoneAuthenticator, UndefinedAuthenticator]

Return an authenticator that allows logging in on this machine.

See tbot.machine.linux.auth for available authenticators.

Danger

It is strongly advised to use key authentication. If you use password auth, THE PASSWORD WILL BE LEAKED and MIGHT EASILY BE STOLEN by other users on your labhost. It will also be visible in the log file.

If you decide to use this, you’re doing this on your own risk.

The only case where I support using passwords is when connecting to a test board with a default password.

Return type:

tbot.machine.linux.auth.Authenticator

class tbottest.labgeneric.boardGpioControl[source]

Bases: GpiopmControl

power_check() bool[source]

Check if the board is already on and someone else might be using it.

Implementations of this function should raise an exception in case they detect the board to be on or return False. If the board is off and ready to be used, an implementation should return True.

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardPowerShellControl[source]

Bases: PowerShellScriptControl

power_check() bool[source]

Check if the board is already on and someone else might be using it.

Implementations of this function should raise an exception in case they detect the board to be on or return False. If the board is off and ready to be used, an implementation should return True.

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardSisControl[source]

Bases: SispmControl

power_check() bool[source]

Check if the board is already on and someone else might be using it.

Implementations of this function should raise an exception in case they detect the board to be on or return False. If the board is off and ready to be used, an implementation should return True.

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardTMControl[source]

Bases: TM021Control

power_check() bool[source]

Check if the board is already on and someone else might be using it.

Implementations of this function should raise an exception in case they detect the board to be on or return False. If the board is off and ready to be used, an implementation should return True.

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardTFControl[source]

Bases: TinkerforgeControl

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

tbottest.labgeneric.BOARDCTL

alias of boardSisControl

class tbottest.labgeneric.boardControlUUU[source]

Bases: boardSisControl, UUULoad

get_uuu_tool()[source]
def get_uuu_tool(self) -> linux.Path:

return lh.workdir / “tools”

Return type:

linux.Path

Returns:

Path to the uuu directory on your LabHost

uuu_loader_steps()[source]

return list of steps to do for uuu tool

def uuu_loader_steps(self):

p = self.host.yocto_result_dir() return [linux.Raw(f”SDP: boot -f /srv/tftpboot/SPL”),

linux.Raw(f”SDPV: delay 100”), linux.Raw(f”SDPV: write -f /srv/tftpboot/u-boot-dtb.img -addr 0x877fffc0 -skipfhdr”), linux.Raw(f”SDPV: jump -addr 0x877fffc0”), ]

This property is required.

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardControlLauterbach[source]

Bases: boardSisControl, LauterbachLoad

get_host()[source]
def get_trace32_path(self) -> linux.Bash:

return self.host

Return type:

str

Returns:

Host on which the trace32 tool is installed

get_trace32_install_path()[source]
def get_trace32_path(self) -> str:

return “/opt/t32”

Return type:

str

Returns:

Path to the trace32 directory on your Host

get_trace32_cmd()[source]
def get_trace32_path(self) -> str:

return “/opt/t32/bin/pc_linux64/t32marm-qt”

Return type:

str

Returns:

Path to the trace32 directory on your Host

get_trace32_config()[source]
def get_trace32_path(self) -> str:

return “<pathto>/config.t32”

Return type:

str

Returns:

Path to the config.t32 file on your Host

get_trace32_script()[source]
def get_trace32_path(self) -> str:

return “<pathto>/autoboot.cmm”

Return type:

str

Returns:

Path to the cript file on your Host

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

class tbottest.labgeneric.boardControlSegger[source]

Bases: boardSisControl, SeggerLoad

get_host()[source]
def get_host(self) -> linux.Bash:

return self.host

Return type:

str

Returns:

Host on which the segger tools are installed

get_segger_cmds()[source]
def get_segger_cmds(self) -> str:

return [{“cmd”:”foo”, “prompt”:”pro1”, {“cmd”:”bar”, “prompt”:”por2”}]

Return type:

list

ch: channel.Channel

Channel to communicate with this machine.

Warning

Please refrain from interacting with the channel directly. Instead, write a Shell that wraps around the channel interaction. That way, the state of the channel is only managed in a single place and you won’t have to deal with nasty bugs when multiple parties make assumptions about the state of the channel.

tbottest.labgeneric.BOARDCTRL

alias of boardSisControl

tbottest.labgeneric.BOARDCON

alias of boardKermitConnector

class tbottest.labgeneric.boardControlFull(mach: LinuxShell)[source]

Bases: boardKermitConnector, boardSisControl, Board

Parameters:

mach (LinuxShell) – A cloneable lab-host machine. The ConsoleConnector will try to clone this machine’s connection and use that to connect to the board. This means that you have to make sure you give the correct lab-host for your respecitive board to the constructor here.

class tbottest.labgeneric.boardExtPower(mach: LinuxShell)[source]

Bases: boardKermitConnector, Board

Parameters:

mach (LinuxShell) – A cloneable lab-host machine. The ConsoleConnector will try to clone this machine’s connection and use that to connect to the board. This means that you have to make sure you give the correct lab-host for your respecitive board to the constructor here.

class tbottest.labgeneric.GenericLab(host: Optional[LinuxShell] = None)[source]

Bases: SSHConnector, Bash, Lab, Builder

property ssh_config: List[str]

if ProxyJump does not work, execute this command from hand on the lab PC with BatchMode=no” -> answer allwith “yes” If again password question pops up, copy id_rsa.pub from lab PC to authorized_keys on build PC

property authenticator: Union[PasswordAuthenticator, PrivateKeyAuthenticator, NoneAuthenticator, UndefinedAuthenticator]

Return an authenticator that allows logging in on this machine.

See tbot.machine.linux.auth for available authenticators.

Danger

It is strongly advised to use key authentication. If you use password auth, THE PASSWORD WILL BE LEAKED and MIGHT EASILY BE STOLEN by other users on your labhost. It will also be visible in the log file.

If you decide to use this, you’re doing this on your own risk.

The only case where I support using passwords is when connecting to a test board with a default password.

Return type:

tbot.machine.linux.auth.Authenticator

tftp_root_path() Path[GenericLab][source]

returns root tftp path

tftp_dir_board() Path[GenericLab][source]

returns tftp path for u-boot tftp command

workdir() Path[GenericLab][source]

returns tbot workdir for this lab

tmpdir() Path[GenericLab][source]

returns tbot tmpdir for this lab

tmpmntdir(name: str) Path[GenericLab][source]

returns tbot tmpdir for mounting stuff on this lab

nfsbasedir() Path[GenericLab][source]

returns nfs base directory, configured in section [LABHOST] in `tbot.ini`, key value `nfs_base_path`

nfsboardbasedir() Path[GenericLab][source]

returns nfs base directory for the specific board, configured in section [default] in `BOARDNAME.ini`, key value `nfs_path`

toolsdir() Path[GenericLab][source]

returns directory where tbot finds tools

yocto_result_dir() Path[GenericLab][source]

returns path to directory where tbot finds yocto build results

property toolchains: Dict[str, Toolchain]

Return a dictionary of all toolchains that exist on this buildhost.

Example:

@property
def toolchains(self) -> typing.Dict[str, linux.build.Toolchain]:
    return {
        "armv7a": linux.build.DistroToolchain("arm", "arm-linux-gnueabi-"),
        "armv8": linux.build.DistroToolchain("aarch64", "aarch64-linux-gnu-"),
        "mipsel": linux.build.DistroToolchain("mips", "mipsel-linux-gnu-"),
    }
lab_set_sd_mux_mode(mode: str)[source]

set sd mux mode to lab or dut

set_bootmode(wantbootmode: Optional[str] = None) bool[source]

set the bootmode defined in config file section [BOOTMODE_<boardname>]

example config for gpio setup:

[BOOTMODE_testboard]
modes = [{"name":"bootmode:uart0", "gpios":"26:1 19:0"}, {"name":"bootmode:spinor", "gpios":"26:0 19:0"} ]
-f bootmode:uart0
-f bootmode:spinor

example config for sd mux:

[BOOTMODE_testboard]
modes = [{"name":"bootmode:sd", "sdwire":"dut"}, {"name":"bootmode:emmc", "sdwire":"lab"} ]
-f bootmode:sd
-f bootmode:emmc

example config for calling function in tbotconfig/labcallbacks.py:

[BOOTMODE_testboard]
modes = [{"name":"bootmode:usb", "func":"board_setbootmode_usb"}, {"name":"bootmode:emmc", "func":"board_setbootmode_emmc"} ]
-f bootmode:usb
-f bootmode:emmc

Warning

This is a hack !

You need to add the new file tbotconfig/labcallbacks.py and implement there the files you define in “modes”

Only use it, for fast testing, then implement it in a class!

Currently there is only one argument passed:

Example code

def board_setbootmode_usb(
    lab: linux.LinuxShell = None,
) -> None:  # noqa: D107
    # call commands on lab with
    # lab.exec0("....")
    return True
Parameters:

wantbootmode – str, bootmode string, use this, when you call the function from within python function

init() None[source]

An optional hook that allows running some code after the machine is initialized.

Example:

class FooUBoot(board.Connector, board.UBootShell):
    name = "foo-u-boot"
    prompt = "=> "

    def init(self):
        self.env("autoload", "no")
        self.exec0("dhcp")

        self.env("serverip", "192.168.1.2")
class tbottest.labgeneric.SSHMachine(host: Optional[LinuxShell] = None)[source]

Bases: SSHConnector, Bash

property workdir: Path[SSHMachine]

Path to a directory which testcases can use to store files in.

If configured properly, tbot will make sure this directory exists. Testcases should be able to deal with corrupt or missing files in this directory. Implementations should use tbot.machine.linux.Workdir.

Example:

# This is the defaut implementation
@property
def workdir(self):
    return linux.Workdir.xdg_data(self, "")
init() None[source]

An optional hook that allows running some code after the machine is initialized.

Example:

class FooUBoot(board.Connector, board.UBootShell):
    name = "foo-u-boot"
    prompt = "=> "

    def init(self):
        self.env("autoload", "no")
        self.exec0("dhcp")

        self.env("serverip", "192.168.1.2")