summaryrefslogtreecommitdiffstats
path: root/test/py/test_bthread.py
blob: 6e7b4ba5007eca23d5c5e60d96f0d84545635995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest
from .helper import *

def stale_spawners(barebox):
    threads = barebox.run_check("bthread -i")
    if len(threads) == 0:
        return False
    return len([t for t in threads if t.startswith('spawner')]) > 0

def test_bthread(barebox, barebox_config):
    skip_disabled(barebox_config, "CONFIG_CMD_BTHREAD")

    assert not stale_spawners(barebox)

    _, _, returncode = barebox.run('bthread -vvvv')
    assert returncode == 0

    assert not stale_spawners(barebox)

    switches = int(barebox.run_check("bthread -c")[0].split()[0])
    yields   = int(barebox.run_check("bthread -t")[0].split()[0])

    assert yields < switches