File: test_openocd.py

package info (click to toggle)
labgrid 25.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,796 kB
  • sloc: python: 21,352; sh: 846; makefile: 35
file content (34 lines) | stat: -rw-r--r-- 949 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from shutil import which
import subprocess

from labgrid.resource.udev import USBDebugger
from labgrid.driver.openocddriver import OpenOCDDriver


pytestmark = pytest.mark.skipif(not which("openocd"),
                              reason="openocd not available")


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


def test_openocd_driver_activate(target):
    r = USBDebugger(target, name=None, match={"sys_name": "1-12"})
    r.avail = True
    d = OpenOCDDriver(target, name=None)
    target.activate(d)


def test_openocd_driver(target, tmpdir):
    r = USBDebugger(target, name=None, match={"sys_name": "1-12"})
    r.avail = True
    d = OpenOCDDriver(target, name=None, load_commands=["shutdown"])
    target.activate(d)
    d.load(__file__)

    with pytest.raises(subprocess.CalledProcessError):
        d.execute(["invalid_command_labgrid"])

    d.execute(["shutdown"])