Skip to content

Commit f747a95

Browse files
committed
scripts: twister: fixing compliance checks and minor issues
Fixing minor compliance errors and issues popping up after rebase. Fixing unit tests. Signed-off-by: Artur Dobrynin <[email protected]>
1 parent e07b196 commit f747a95

File tree

9 files changed

+40
-112
lines changed

9 files changed

+40
-112
lines changed

scripts/pylib/twister/twisterlib/harness.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# SPDX-License-Identifier: Apache-2.0
2+
23
from __future__ import annotations
34

45
import glob
56
import json
67
import logging
78
import os
89
import platform
10+
import random
911
import re
1012
import shlex
1113
import shutil
@@ -14,7 +16,6 @@
1416
import threading
1517
import time
1618
import xml.etree.ElementTree as ET
17-
import random
1819
from collections import OrderedDict
1920
from enum import Enum
2021

@@ -974,6 +975,9 @@ def _get_exe_path(self, index):
974975
return self._exe_paths[index if index < len(self._exe_paths) else 0]
975976

976977
def configure(self, instance):
978+
def replacer(exe_name):
979+
return exe_name.replace(os.path.sep, '_').replace('.', '_').replace('@', '_')
980+
977981
super().configure(instance)
978982

979983
if not self._bsim_out_path:
@@ -982,11 +986,10 @@ def configure(self, instance):
982986
exe_names = []
983987
for exe_name in self.instance.testsuite.harness_config.get('bsim_exe_name', []):
984988
new_exe_name = f'bs_{self.instance.platform.name}_{exe_name}'
985-
exe_names.append(
986-
new_exe_name.replace(os.path.sep, '_').replace('.', '_').replace('@', '_'))
989+
exe_names.append(replacer(new_exe_name))
987990

988991
if not exe_names:
989-
exe_names = [f'bs_{self.instance.name}']
992+
exe_names = [f'bs_{replacer(self.instance.name)}']
990993

991994
self._exe_paths = \
992995
[os.path.join(self._bsim_out_path, exe_name) for exe_name in exe_names]

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from domains import Domains
4545
from twisterlib.coverage import run_coverage_instance
4646
from twisterlib.environment import TwisterEnv
47-
from twisterlib.harness import Ctest, HarnessImporter, Pytest, Bsim
47+
from twisterlib.harness import Bsim, Ctest, HarnessImporter, Pytest
4848
from twisterlib.log_helper import log_command
4949
from twisterlib.platform import Platform
5050
from twisterlib.testinstance import TestInstance
@@ -1792,7 +1792,7 @@ def run(self):
17921792
harness.bsim_run(instance.handler.get_test_timeout())
17931793
else:
17941794
instance.status = TwisterStatus.ERROR
1795-
instance.reason = str("BSIM not ready")
1795+
instance.reason = "BSIM not ready"
17961796
logger.error(instance.reason)
17971797
else:
17981798
instance.handler.handle(harness)
@@ -1988,7 +1988,8 @@ def add_tasks_to_queue(
19881988
expr_parser.reserved.keys()
19891989
)
19901990

1991-
if test_only or instance.testsuite.no_build and instance.run:
1991+
if (test_only and instance.run) or\
1992+
(instance.testsuite.no_build and instance.testsuite.harness == 'bsim'):
19921993
task_list.append({"op": "run", "test": instance})
19931994
elif instance.filter_stages and "full" not in instance.filter_stages:
19941995
task_list.append({"op": "filter", "test": instance})

scripts/tests/twister/test_harness.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ def test_gtest_repeated_run(gtest):
12111211

12121212

12131213
def test_bsim_build(monkeypatch, tmp_path):
1214+
monkeypatch.setenv("BSIM_OUT_PATH", str(tmp_path))
1215+
12141216
mocked_instance = mock.Mock()
12151217
build_dir = tmp_path / "build_dir"
12161218
os.makedirs(build_dir)
@@ -1219,9 +1221,8 @@ def test_bsim_build(monkeypatch, tmp_path):
12191221
mocked_instance.testsuite.harness_config = {}
12201222

12211223
harness = Bsim()
1222-
harness.instance = mocked_instance
1224+
harness.configure(mocked_instance)
12231225

1224-
monkeypatch.setenv("BSIM_OUT_PATH", str(tmp_path))
12251226
os.makedirs(os.path.join(tmp_path, "bin"), exist_ok=True)
12261227
zephyr_exe_path = os.path.join(build_dir, "zephyr", "zephyr.exe")
12271228
os.makedirs(os.path.dirname(zephyr_exe_path), exist_ok=True)

scripts/tests/twister/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,8 +2320,8 @@ def test_projectbuilder_run(
23202320
pytest_mock = mock.Mock(spec=Pytest)
23212321
harness_mock = mock.Mock()
23222322

2323-
def mock_harness(name):
2324-
if name == 'Pytest':
2323+
def mock_harness(inst):
2324+
if instance_mock.testsuite.harness == 'pytest':
23252325
return pytest_mock
23262326
else:
23272327
return harness_mock

tests/bsim/bluetooth/host/att/read_fill_buf/testcase.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tests:
1414
bsim_verbosity: 2
1515
bsim_sim_length: 60e6
1616
bsim_test_ids:
17-
- the_test
18-
- the_test
17+
- cli
18+
- srv
1919
bsim_options:
2020
- -RealEncryption=1

tests/bsim/bluetooth/host/gatt/ccc_store/test_scripts/ccc_store_no_long_wq.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/bsim/bluetooth/host/gatt/ccc_store/testcase.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests:
2424
- '["-flash=ccc_store_client.log.bin", "-flash=ccc_store_server.log.bin"]'
2525
- -argstest
2626
- '10'
27-
bluetooth.host.gatt.ccc_no_store_on_write:
27+
bluetooth.host.gatt.ccc_store_no_store_on_write:
2828
harness_config:
2929
bsim_exe_name:
3030
- tests_bsim_bluetooth_host_gatt_ccc_store_overlay-no_store_on_write_conf
@@ -37,6 +37,12 @@ tests:
3737
EXTRA_CONF_FILE=overlay-no_store_on_write.conf
3838
bluetooth.host.gatt.ccc_store_no_long_wq:
3939
harness_config:
40-
bsim_exe_name: tests_bsim_bluetooth_host_gatt_ccc_store_overlay-no_long_wq_conf
40+
bsim_exe_name:
41+
- tests_bsim_bluetooth_host_gatt_ccc_store_overlay-no_long_wq_conf
42+
bsim_options:
43+
- '["-flash=ccc_store_no_long_wq_client.log.bin",
44+
"-flash=ccc_store_no_long_wq_server.log.bin"]'
45+
- -argstest
46+
- '10'
4147
extra_args:
4248
EXTRA_CONF_FILE=overlay-no_long_wq.conf

tests/bsim/bluetooth/host/security/ccc_update/test_scripts/ccc_update_no_long_wq.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/bsim/bluetooth/host/security/ccc_update/testcase.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,32 @@ common:
1515
bsim_options:
1616
- -RealEncryption=1
1717
- -flash_rm
18-
- "['-flash=ccc_update_client.log.bin', '-flash=ccc_update_bad_client.log.bin',
19-
'-flash=ccc_update_server.log.bin']"
2018

2119
tests:
2220
bluetooth.host.security.ccc_update:
2321
harness_config:
2422
bsim_exe_name:
2523
- tests_bsim_bluetooth_host_security_ccc_update_prj_conf
24+
bsim_options:
25+
- "['-flash=ccc_update_client.log.bin', '-flash=ccc_update_bad_client.log.bin',
26+
'-flash=ccc_update_server.log.bin']"
27+
bluetooth.host.security.ccc_update_no_lazy_load:
2628
harness_config:
2729
bsim_exe_name:
2830
- tests_bsim_bluetooth_host_security_ccc_update_overlay-no_lazy_load_conf
31+
bsim_options:
32+
- "['-flash=ccc_update_no_lazy_load_client.log.bin',
33+
'-flash=ccc_update_no_lazy_load_bad_client.log.bin',
34+
'-flash=ccc_update_no_lazy_load_server.log.bin']"
2935
extra_args:
3036
EXTRA_CONF_FILE=overlay-no_lazy_load.conf
3137
bluetooth.host.security.ccc_update_no_long_wq:
3238
harness_config:
33-
bsim_exe_name: tests_bsim_bluetooth_host_security_ccc_update_overlay-no_long_wq_conf
39+
bsim_exe_name:
40+
- tests_bsim_bluetooth_host_security_ccc_update_overlay-no_long_wq_conf
41+
bsim_options:
42+
- "['-flash=ccc_update_no_long_wq_client.log.bin',
43+
'-flash=ccc_update_no_long_wq_bad_client.log.bin',
44+
'-flash=ccc_update_no_long_wq_server.log.bin']"
3445
extra_args:
3546
EXTRA_CONF_FILE=overlay-no_long_wq.conf

0 commit comments

Comments
 (0)