scripts: west robot & simulation: Fix OOT
The current version of scipts do not consider OOT boards use cases and the tests with robot now are strict to only one robot file, which is not realistic for real environment. This address those issues and allow multiple testsuits at command line and lists at tests entries. It add another test parameter to allow configure robotframework options. Fixes: #74563 Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
parent
0825f24910
commit
768b8bbca3
8 changed files with 78 additions and 12 deletions
|
@ -615,8 +615,11 @@ harness_config: <harness configuration options>
|
|||
If the scope is set to ``function``, DUT is launched for every test case
|
||||
in python script. For ``session`` scope, DUT is launched only once.
|
||||
|
||||
robot_test_path: <robot file path> (default empty)
|
||||
Specify a path to a file containing a Robot Framework test suite to be run.
|
||||
robot_testsuite: <robot file path> (default empty)
|
||||
Specify one or more paths to a file containing a Robot Framework test suite to be run.
|
||||
|
||||
robot_option: <robot option> (default empty)
|
||||
One or more options to be send to robotframework.
|
||||
|
||||
bsim_exe_name: <string>
|
||||
If provided, the executable filename when copying to BabbleSim's bin
|
||||
|
@ -673,7 +676,33 @@ harness_config: <harness configuration options>
|
|||
robot.example:
|
||||
harness: robot
|
||||
harness_config:
|
||||
robot_test_path: [robot file path]
|
||||
robot_testsuite: [robot file path]
|
||||
|
||||
It can be more than one test suite using a list.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
tests:
|
||||
robot.example:
|
||||
harness: robot
|
||||
harness_config:
|
||||
robot_testsuite:
|
||||
- [robot file path 1]
|
||||
- [robot file path 2]
|
||||
- [robot file path n]
|
||||
|
||||
One or more options can be passed to robotframework.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
tests:
|
||||
robot.example:
|
||||
harness: robot
|
||||
harness_config:
|
||||
robot_testsuite: [robot file path]
|
||||
robot_option:
|
||||
- --exclude tag
|
||||
- --stop-on-error
|
||||
|
||||
filter: <expression>
|
||||
Filter whether the test scenario should be run by evaluating an expression
|
||||
|
|
|
@ -75,4 +75,4 @@ tests:
|
|||
sample.shell.shell_module.robot:
|
||||
harness: robot
|
||||
harness_config:
|
||||
robot_test_path: shell_module.robot
|
||||
robot_testsuite: shell_module.robot
|
||||
|
|
|
@ -18,6 +18,7 @@ import sys
|
|||
import threading
|
||||
import time
|
||||
|
||||
from pathlib import Path
|
||||
from queue import Queue, Empty
|
||||
from twisterlib.environment import ZEPHYR_BASE, strip_ansi_sequences
|
||||
from twisterlib.error import TwisterException
|
||||
|
@ -241,7 +242,11 @@ class BinaryHandler(Handler):
|
|||
# os.path.join cannot be used on a Mock object, so we are
|
||||
# explicitly checking the type
|
||||
if isinstance(self.instance.platform, Platform):
|
||||
resc = os.path.join(self.options.coverage_basedir, self.instance.platform.resc)
|
||||
for board_dir in self.options.board_root:
|
||||
path = os.path.join(Path(board_dir).parent, self.instance.platform.resc)
|
||||
if os.path.exists(path):
|
||||
resc = path
|
||||
break
|
||||
uart = self.instance.platform.uart
|
||||
command = ["renode-test",
|
||||
"--variable", "KEYWORDS:" + keywords,
|
||||
|
|
|
@ -160,7 +160,8 @@ class Robot(Harness):
|
|||
|
||||
config = instance.testsuite.harness_config
|
||||
if config:
|
||||
self.path = config.get('robot_test_path', None)
|
||||
self.path = config.get('robot_testsuite', None)
|
||||
self.option = config.get('robot_option', None)
|
||||
|
||||
def handle(self, line):
|
||||
''' Test cases that make use of this harness care about results given
|
||||
|
@ -176,7 +177,24 @@ class Robot(Harness):
|
|||
start_time = time.time()
|
||||
env = os.environ.copy()
|
||||
|
||||
if self.option:
|
||||
if isinstance(self.option, list):
|
||||
for option in self.option:
|
||||
for v in str(option).split():
|
||||
command.append(f'{v}')
|
||||
else:
|
||||
for v in str(self.option).split():
|
||||
command.append(f'{v}')
|
||||
|
||||
if self.path is None:
|
||||
raise PytestHarnessException(f'The parameter robot_testsuite is mandatory')
|
||||
|
||||
if isinstance(self.path, list):
|
||||
for suite in self.path:
|
||||
command.append(os.path.join(handler.sourcedir, suite))
|
||||
else:
|
||||
command.append(os.path.join(handler.sourcedir, self.path))
|
||||
|
||||
with subprocess.Popen(command, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, cwd=self.instance.build_dir, env=env) as renode_test_proc:
|
||||
out, _ = renode_test_proc.communicate()
|
||||
|
|
|
@ -120,8 +120,11 @@ schema;scenario-schema:
|
|||
required: false
|
||||
sequence:
|
||||
- type: str
|
||||
"robot_test_path":
|
||||
type: str
|
||||
"robot_testsuite":
|
||||
type: any
|
||||
required: false
|
||||
"robot_option":
|
||||
type: any
|
||||
required: false
|
||||
"record":
|
||||
type: map
|
||||
|
|
|
@ -133,7 +133,8 @@ def test_robot_configure(tmp_path):
|
|||
|
||||
instance = TestInstance(testsuite=mock_testsuite, platform=mock_platform, outdir=outdir)
|
||||
instance.testsuite.harness_config = {
|
||||
'robot_test_path': '/path/to/robot/test'
|
||||
'robot_testsuite': '/path/to/robot/test',
|
||||
'robot_option': 'test_option'
|
||||
}
|
||||
robot_harness = Robot()
|
||||
|
||||
|
@ -143,6 +144,7 @@ def test_robot_configure(tmp_path):
|
|||
#Assert
|
||||
assert robot_harness.instance == instance
|
||||
assert robot_harness.path == '/path/to/robot/test'
|
||||
assert robot_harness.option == 'test_option'
|
||||
|
||||
|
||||
def test_robot_handle(tmp_path):
|
||||
|
@ -190,6 +192,7 @@ def test_robot_run_robot_test(tmp_path, caplog, exp_out, returncode, expected_st
|
|||
handler.log = "handler.log"
|
||||
|
||||
path = "path"
|
||||
option = "option"
|
||||
|
||||
mock_platform = mock.Mock()
|
||||
mock_platform.name = "mock_platform"
|
||||
|
@ -209,6 +212,7 @@ def test_robot_run_robot_test(tmp_path, caplog, exp_out, returncode, expected_st
|
|||
|
||||
robot = Robot()
|
||||
robot.path = path
|
||||
robot.option = option
|
||||
robot.instance = instance
|
||||
proc_mock = mock.Mock(
|
||||
returncode = returncode,
|
||||
|
|
|
@ -28,6 +28,8 @@ class RenodeRobotRunner(ZephyrBinaryRunner):
|
|||
@classmethod
|
||||
def do_add_parser(cls, parser):
|
||||
parser.add_argument('--testsuite',
|
||||
metavar='SUITE',
|
||||
action='append',
|
||||
help='path to Robot test suite')
|
||||
parser.add_argument('--renode-robot-arg',
|
||||
metavar='ARG',
|
||||
|
@ -54,7 +56,8 @@ class RenodeRobotRunner(ZephyrBinaryRunner):
|
|||
for arg in self.renode_robot_arg:
|
||||
cmd.append(arg)
|
||||
if self.testsuite is not None:
|
||||
cmd.append(self.testsuite)
|
||||
for suite in self.testsuite:
|
||||
cmd.append(suite)
|
||||
else:
|
||||
self.logger.error("No Robot testsuite passed to renode-test! Use the `--testsuite` argument to provide one.")
|
||||
subprocess.run(cmd, check=True)
|
||||
|
|
|
@ -8,4 +8,8 @@ common:
|
|||
tests:
|
||||
drivers.console.line_splitting:
|
||||
harness_config:
|
||||
robot_test_path: line_splitting.robot
|
||||
robot_testsuite: line_splitting.robot
|
||||
drivers.console.line_splitting.plus.some_option:
|
||||
harness_config:
|
||||
robot_testsuite: line_splitting.robot
|
||||
robot_option: --exclude some_flag
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue