File: test_example.py

package info (click to toggle)
labgrid 0.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,232 kB
  • sloc: python: 17,045; makefile: 30; sh: 12
file content (45 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
import pytest

from labgrid.exceptions import NoDriverFoundError


@pytest.fixture()
def strategy(target):
    try:
        return target.get_driver('ExampleStrategy')
    except NoDriverFoundError:
        pytest.skip("strategy not found")


@pytest.fixture(scope="function")
def bootloader(target, strategy, capsys):
    with capsys.disabled():
        strategy.transition("barebox")
    return target['CommandProtocol'] # this will return the BareboxDriver


@pytest.fixture(scope="function")
def shell(target, strategy, capsys):
    with capsys.disabled():
        strategy.transition("shell")
    return target['CommandProtocol'] # this will return the ShellDriver


def test_barebox(bootloader):
    stdout, stderr, returncode = bootloader.run('version')
    assert returncode == 0
    assert stdout
    assert not stderr
    assert 'barebox' in '\n'.join(stdout)


def test_shell(shell):
    stdout, stderr, returncode = shell.run('cat /proc/version')
    assert returncode == 0
    assert stdout
    assert not stderr
    assert 'Linux' in stdout[0]


def test_barebox_2(bootloader):
    bootloader.run_check('true')