Verified Commit df90ed2f authored by Harald Seiler's avatar Harald Seiler
Browse files

Initial version


Signed-off-by: Harald Seiler's avatarHarald Seiler <hws@denx.de>
parents
__pycache__/
*.pyc
.mypy_cache/
/log/
-b
config/hws.py
-l
config/hws.py
-vv
--log-auto
from tbot.machine import board, linux
class BoardUBoot(board.Connector, board.UBootAutobootIntercept, board.UBootShell):
"""
Default configuration for the Board's U-Boot machine
"""
name = "board-uboot"
prompt = "=> "
class BoardLinux(board.LinuxUbootConnector, board.LinuxBootLogin, linux.Ash):
"""
Default configuration for the Board's Linux machine
"""
name = "board-linux"
uboot = BoardUBoot
def do_boot(self, ub):
return ub.boot("run", "bootcmd")
from tbot.machine import connector, linux, board
import lab_base
import board_base
class HwsLab(connector.SubprocessConnector, linux.Bash, lab_base.LabBase):
name = "hws-lab"
# Configuration of the common interfaces defined in the lab-base class:
def source_dir(self):
return self.fsroot / "/home/hws/Documents/Development/tbot"
def enable_tftp_server(self):
self.exec0("sudo", "systemctl", "start", "tftp.socket")
server_hostname = "hws-lab"
ipaddr = "192.0.2.1"
class HwsBoard(connector.ConsoleConnector, board.PowerControl, board.Board):
name = "board-hws"
def poweron(self):
self.host.exec0("power-control.sh", self.name, "on")
def poweroff(self):
self.host.exec0("power-control.sh", self.name, "off")
def connect(self, mach):
return mach.open_channel("picocom", "-q", "-b", str(115200), "/dev/ttyUSB1")
LAB = HwsLab
BOARD = HwsBoard
UBOOT = board_base.BoardUBoot
LINUX = board_base.BoardLinux
import abc
from tbot.machine import linux
class LabBase(linux.Lab):
"""
Base-Class for the different developers' lab-hosts.
This base-class defines common 'interfaces' (i.e. methods and attributes)
that each lab-host should implement.
"""
# Example for an 'optional' method. Not implementing this one could lead
# to runtime errors when calling testcases that want to use it.
def source_dir(self):
raise NotImplementedError(f"{self!r} does not implement lh.source_dir()")
# Example for a 'mandatory' method. You cannot start any testcases when
# this method isn't configured properly for a lab.
@abc.abstractmethod
def enable_tftp_server(self):
pass
# Example for an optional attribute. Either give it a default value here
# of set it to `None` to indicate a missing value.
server_hostname = "localhost"
# Example for a 'mandatory' attribute. This attribute needs to be
# configured for a lab-config to be usable.
#
# While it needs to look like a method here, it is configured as a normal
# attribute in the lab-config:
#
# ipaddr = "192.0.2.1"
@property
@abc.abstractmethod
def ipaddr(self):
pass
import tbot
@tbot.testcase
@tbot.with_lab
def test_foo_bar(lh):
# In a testcase, you can now make use of the common interfaces from `lab_base.py`:
lh.enable_tftp_server()
path = lh.source_dir()
assert path.exists()
tbot.log.message(f"Host {lh.server_hostname} has ip {lh.ipaddr}")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment