tbot.tc Module


tbot.tc.testsuite(*args, **kwargs) → None[source]

Run a number of tests and report, how many of them succeeded.

  • args – Testcases
  • kwargs – Named-Arguments that should be given to each testcase. Be aware that this requires all testcases to have compatible signatures.


import tbot
from tbot import tc, machine

def test_a(lab: machine.linux.LabHost) -> None:
    lab.exec0("echo", "Test", "A")

def test_b(lab: machine.linux.LabHost) -> None:
    lab.exec0("uname", "-a")

def all_tests() -> None:
    with tbot.acquire_lab() as lh:



tbot.tc.shell.copy(p1: tbot.machine.linux.path.Path[H1], p2: tbot.machine.linux.path.Path[H2]) → None[source]

Copy a file, possibly from one host to another.

The following transfers are currently supported:

The following transfers are not supported:

  • SSHMachine 🢥 SSHMachine (There is no guarantee that two remote hosts can connect to each other. If you need this, transfer to the lab-host first and then to the other remote)
  • LabHost 🢥 BoardMachine (Transfers over serial are not (yet) implemented. To ‘upload’ files, connect to your target via ssh or use a tftp download)
  • p1 (linux.Path) – Exisiting path to be copied
  • p2 (linux.Path) – Target where p1 should be copied


class tbot.tc.git.GitRepository(target: tbot.machine.linux.path.Path[H], url: Optional[str] = None, *, clean: bool = True, fetch: bool = True, rev: Optional[str] = None)[source]

Bases: tbot.machine.linux.path.Path

Git repository.

Initialize a git repository from either a remote or an existing repo.

There are two modes in which a repo can be initialized:

  1. Only supplying target: tbot assumes, that a repo exists at target already and will fail if this is not the case.
  2. Also supplying url: If target is not already a git repo, one will be created by cloning url.

If clean is True, the repo will be hard reset and all untracked files/ changes will be removed. If rev is also given, it will be checked out.

If fetch is True and url is given, the latest upstream revision will be checked out.

  • target (linux.Path) – Where the repository is supposed to be.
  • url (str) – Optional remote url. Whether this is set specifies the mode the repo is initialized in.
  • clean (bool) – Whether to clean the working tree. Defaults to True.
  • fetch (bool) – Whether to fetch remote. Defaults to True.
  • rev (str) – Optional revision to checkout. Only has an effect if clean is also set. If you don’t want to clean, but still perform a checkout, call checkout().

Changed in version 0.6.1: GitRepository now fetches latest changes from remote by default.

git(*args) → Tuple[int, str][source]

Run a git subcommand.

Behaves like calling git -C <path/to/repo> <*args>.

Parameters:args – Command line parameters. First one should be a git subcommand.
Return type:tuple[int, str]
Returns:Retcode and command output
git0(*args) → str[source]

Run a git subcommand and ensure its retcode is zero.

Behaves like calling git -C <path/to/repo> <*args>.

Parameters:args – Command line parameters. First one should be a git subcommand.
Return type:str
Returns:Command output
Raises:CommandFailedException – If the command exited with a non-zero return code

Return the current HEAD of this repo.


Return the current HEAD of this repo, as a symbolic if possible.

checkout(rev: str) → None[source]

Checkout a revision or branch.

Parameters:rev (str) – Revision or branch name to be checked out.
reset(rev: str, mode: tbot.tc.git.ResetMode = <ResetMode.MIXED: '--mixed'>) → None[source]

Call git --reset.

  • rev (str) – Revision to reset to
  • mode (ResetMode) – Reset mode to be used. Refer to the git-reset man-page for more info.
clean(force: bool = True, untracked: bool = False, noignore: bool = False) → None[source]

Call git clean.

  • force (bool) – -f
  • untracked (bool) – -d
  • noignore (bool) – -x

Refer to the git-clean man-page for more info.

add(f: tbot.machine.linux.path.Path[H]) → None[source]

Add a file to the index.

commit(msg: str, author: Optional[str] = None) → None[source]

Commit changes.

  • msg (str) – Commit message
  • author (str) – Optional commit author in the Author Name <email@address> format.
am(patch: tbot.machine.linux.path.Path[H]) → int[source]

Apply one or multiple patches.

Parameters:patch (linux.Path) – Either a path to a .patch file or to a directory containing patch files.
Return type:int
Returns:Number of patches applied
apply(patch: tbot.machine.linux.path.Path[H]) → int[source]

Apply one or multiple patches to the working tree.

Parameters:patch (linux.Path) – Either a path to a .patch file or to a directory containing patch files.
Return type:int
Returns:Number of patches applied

New in version 0.6.4.

bisect(good: str, test: Callable[..., bool]) → str[source]

Run a git bisect to find the commit that introduced an error.

Example: Bisect a git repository

  • good (str) – A known good commit, the current head will be assumed as bad.
  • test – A function to check the state of the current commit. Should return True if it is good and False if it is bad. An exception is interpreded as an unexpected error while checking.
Return type:



The first bad commit


tbot.tc.uboot.build(build_machine: Optional[BH] = None, build_info: Optional[Type[tbot.tc.uboot.build_info.BuildInfo]] = None, clean: bool = True) → tbot.machine.linux.path.Path[BH][source]

Build U-Boot.

Deprecated since version 0.6.6: This testcase has serious design flaws. You can still use it until the new version is implemented, but be aware that it will change at some point.

  • build_machine (linux.BuildMachine) – Machine where to build U-Boot
  • build_info (uboot.BuildInfo) –

    Build parameters, defaults to the info associated with the selected board. This info is defined like this:

    class MyBoardUBootBuild(uboot.BuildInfo):
        name = "myboard"
        defconfig = "myboard_defconfig"
        toolchain = "generic-armv7a-hf"
    class MyBoardUBoot(board.UBootMachine[MyBoard]):
        prompt = "=> "
        build = MyBoardUBootBuild
Return type:



Path to the build dir

class tbot.tc.uboot.BuildInfo(h: BH)[source]

Bases: abc.ABC, typing.Generic

Info for building U-Boot.

Inherit this class in your board config to configure building U-Boot.


Name of this build.

Should be unique for each unique U-Boot config.

checkout(clean: bool = True) → tbot.tc.git.GitRepository[BH][source]

Checkout U-Boot for this config.

Defaults to checking out self.uboot_remote (=``git://git.denx.de/u-boot.git``).

Overwrite this method to specify a custom checkout procedure (eg. patching the repo afterwards)


Defconfig to use for U-Boot.


Toolchain for building U-Boot.

Must be defined for the selected BuildMachine.