Skip to content

Commit

Permalink
Tests: add test for Lauterbach Resources and Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Merkle committed Sep 8, 2023
1 parent 7553acf commit f21d593
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ dev = [
# labgrid[kasa]
"python-kasa>=0.4.0",

# labgrid[lauterbach]
"lauterbach-trace32-pystart>=0.1.7",

# labgrid[modbus]
"pyModbusTCP>=0.1.10",

Expand Down
71 changes: 71 additions & 0 deletions tests/test_lauterbach.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import pytest
import subprocess

from collections import namedtuple

from labgrid.driver.lauterbachdriver import LauterbachDriver
from labgrid.resource.udev import USBLauterbachDebugger
from labgrid.resource.lauterbach import NetworkLauterbachDebugger, NetworkUSBLauterbachDebugger
from labgrid.util.helper import get_uname_machine

pytest.importorskip("lauterbach.trace32.pystart")

PseudoUSBDevice = namedtuple("Device", ["sys_name", "sys_path", "subsystem", "device_type", "properties"])
PSEUDOUSB = PseudoUSBDevice("1-12", "/dev/null", "usb", "usb_device", {"BUSNUM" : "1", "DEVNUM" : "12"})

def check_t32tcpusb_present():
if get_uname_machine()!="amd64":
return False
tcpusb = "/opt/t32/bin/pc_linux64/t32tcpusb"
if not os.path.isfile(tcpusb):
return False
return True

def test_lauterbach_usb_resource(target):
r = USBLauterbachDebugger(target, name=None, match={"sys_name": "1-12"})

def test_lauterbach_network_resource(target):
r = NetworkLauterbachDebugger(target, name=None, node="test")

def test_lauterbach_usb_driver_activate(target):
r = USBLauterbachDebugger(target, name=None, match={"sys_name": "1-12"}, device=PSEUDOUSB)
r.avail = True
d = LauterbachDriver(target, name=None)
target.activate(d)

assert(d.connection)

target.deactivate(d)

def test_lauterbach_network_driver_activate(target):
r = NetworkLauterbachDebugger(target, name=None, node="test")
r.avail = True
d = LauterbachDriver(target, name=None)
target.activate(d)

assert(d.connection)

target.deactivate(d)

@pytest.mark.skipif(not check_t32tcpusb_present(),
reason="t32tcpusb not installed on machine")
@pytest.mark.skipif(True, reason="don't know how to test NetworkUSB.. resources")
def test_lauterbach_networkusb_driver_activate(target):
r = NetworkUSBLauterbachDebugger(
target,
name=None,
host="localhost",
busnum=0,
devnum=1,
path='0:1',
vendor_id=0x0,
model_id=0x0,
architecture="amd64"
)
r.avail = True
d = LauterbachDriver(target, name=None)
target.activate(d)

assert(d.connection)
assert(d.t32tcpusb)

0 comments on commit f21d593

Please sign in to comment.