File: test_sleep.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 (24 lines) | stat: -rw-r--r-- 617 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
from time import monotonic

from pytest import approx


def test_sleep(command):
    # measure the round-trip-time
    timestamp = monotonic()
    stdout, stderr, returncode = command.run("true")
    elapsed_true = monotonic() - timestamp
    assert returncode == 0
    assert not stdout
    assert not stderr

    timestamp = monotonic()
    stdout, stderr, returncode = command.run("sleep 1")
    elapsed_sleep = monotonic() - timestamp
    assert returncode == 0
    assert not stdout
    assert not stderr

    assert elapsed_true < elapsed_sleep

    assert elapsed_sleep - elapsed_true == approx(1.0, abs=1e-2)