File: test_rt.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 (37 lines) | stat: -rw-r--r-- 1,064 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
35
36
37
import re

import pytest

from labgrid.driver import ExecutionError


def test_rt_cyclictest_short(command):
    """Test a basic cyclictest run"""
    try:
        command.run_check("which cyclictest")
    except ExecutionError:
        pytest.skip("cyclictest missing")

    result = command.run_check("cyclictest -SN -D 5 -q")
    result = result[-1].strip()

    pattern = r"Min:\s+(?P<min>\w+)\s+Act:\s+\w+\s+Avg:\s+(?P<avg>\w+)\s+Max:\s+(?P<max>\w+)"
    min, avg, max = map(int, re.search(pattern, result).groups())
    assert min <= avg <= max
    assert avg < 1e6  # avg < 1 milliseconds
    assert max < 10e6  # max < 10 milliseconds


def test_rt_hackbench_short(command):
    """Test a basic hackbench run"""
    try:
        command.run_check("which hackbench")
    except ExecutionError:
        pytest.skip("hackbench missing")

    result = command.run_check("hackbench -f 10")
    result = result[-1].strip()

    pattern = r"Time:\s+(?P<time>\w+)"
    (time,) = map(int, re.search(pattern, result).groups())
    assert time < 20  # max 20 seconds