diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-06-04 10:47:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-09 12:20:05 +0200 |
commit | e06a8f0bf3151eafce695954109defbcfc4033f4 (patch) | |
tree | 5f705ac69b51733d0030da3d2d22e5dfefe8d02f | |
parent | 67dd66cac92577e4442d8c2d5d7add55e42adf10 (diff) | |
download | barebox-e06a8f0bf3151eafce695954109defbcfc4033f4.tar.gz barebox-e06a8f0bf3151eafce695954109defbcfc4033f4.tar.xz |
test: add bthread test
The bthread -v command already returns an appropriate exit code if
threads can't be scheduled. Have it spawn 16 threads and switch between
them for a second and verify that all of these threads were indeed
terminated.
Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210604084704.17410-14-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | test/kconfig/full.cfg | 2 | ||||
-rw-r--r-- | test/py/test_bthread.py | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/kconfig/full.cfg b/test/kconfig/full.cfg index e69de29bb2..39275768ea 100644 --- a/test/kconfig/full.cfg +++ b/test/kconfig/full.cfg @@ -0,0 +1,2 @@ +CONFIG_BTHREAD=y +CONFIG_CMD_BTHREAD=y diff --git a/test/py/test_bthread.py b/test/py/test_bthread.py new file mode 100644 index 0000000000..6e7b4ba500 --- /dev/null +++ b/test/py/test_bthread.py @@ -0,0 +1,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 |