Lines Matching +full:instance +full:- +full:id

1 # SPDX-License-Identifier: Apache-2.0
49 self.id = None
65 self.instance: TestInstance | None = None
71 def trace(self) -> bool:
72 return self.instance.handler.options.verbose > 2
75 def status(self) -> TwisterStatus:
79 def status(self, value : TwisterStatus) -> None:
87 def configure(self, instance): argument
88 self.instance = instance
89 config = instance.testsuite.harness_config
90 self.id = instance.testsuite.id
91 self.run_id = instance.run_id
92 if instance.testsuite.ignore_faults:
111 return self.id
113 def translate_record(self, record: dict) -> dict:
127 def parse_record(self, line) -> re.Match:
173 def configure(self, instance): argument
174 super().configure(instance)
175 self.instance = instance
177 config = instance.testsuite.harness_config
188 self.instance.status = TwisterStatus.PASS
189 tc = self.instance.get_case_or_create(self.id)
215 stderr=subprocess.STDOUT, cwd=self.instance.build_dir, env=env) as renode_test_proc:
218 self.instance.execution_time = time.time() - start_time
221 self.instance.status = TwisterStatus.PASS
223 # so its status should be set accordingly to the instance status
225 self.instance.testcases[0].status = TwisterStatus.PASS
228 f"Robot test failure: {handler.sourcedir} for {self.instance.platform.name}"
230 self.instance.status = TwisterStatus.FAIL
231 self.instance.testcases[0].status = TwisterStatus.FAIL
234 with open(os.path.join(self.instance.build_dir, handler.log), 'w') as log:
244 Console Harness id has only TestSuite id without TestCase name suffix.
249 if self.instance and len(self.instance.testcases) == 1:
250 return self.instance.testcases[0].name
253 def configure(self, instance): argument
254 super().configure(instance)
257 tc = self.instance.set_case_status_by_name(
262 raise ConfigurationError(self.instance.name, tc.reason)
273 tc = self.instance.set_case_status_by_name(
278 raise ConfigurationError(self.instance.name, tc.reason)
343 tc = self.instance.get_case_or_create(self.get_testcase_name())
356 def configure(self, instance: TestInstance):
357 super().configure(instance)
358 self.running_dir = instance.build_dir
359 self.source_dir = instance.testsuite.source_dir
372 self.instance.reason = str(pytest_exception)
374 self.instance.record(self.recording)
377 self.instance.handler.make_dut_available(self.reserved_dut)
380 config = self.instance.testsuite.harness_config
381 handler: Handler = self.instance.handler
387 '--twister-harness',
388 '-s', '-v',
389 f'--build-dir={self.running_dir}',
390 f'--junit-xml={self.report_file}',
391 '--log-file-level=DEBUG',
392 '--log-file-format=%(asctime)s.%(msecs)03d:%(levelname)s:%(name)s: %(message)s',
393 f'--log-file={self.pytest_log_file_path}',
394 f'--platform={self.instance.platform.name}'
400 command.append(f'--dut-scope={pytest_dut_scope}')
404 '--log-cli-level=DEBUG',
405 '--log-cli-format=%(levelname)s: %(message)s'
410 command.append(f'--base-timeout={base_timeout}')
417 command.append(f'--device-type={handler.type_str}')
419 command.append('--device-type=custom')
427 command.append(f'--twister-fixture={fixture}')
430 command.append(f'--extra-test-args={shlex.join(handler.options.extra_test_args)}')
440 command = ['--device-type=hardware']
444 # update the instance with the device id to have it in the summary report
445 self.instance.dut = hardware.id
449 command.append(f'--device-serial-pty={hardware.serial_pty}')
452 f'--device-serial={hardware.serial}',
453 f'--device-serial-baud={hardware.baud}'
457 command.append(f'--flash-timeout={hardware.flash_timeout}')
461 command.append(f'--runner={runner}')
465 command.append(f'--runner-params={param}')
468 command.append(f'--west-flash-extra-args={options.west_flash}')
470 if board_id := hardware.probe_id or hardware.id:
471 command.append(f'--device-id={board_id}')
474 command.append(f'--device-product={hardware.product}')
477 command.append(f'--pre-script={hardware.pre_script}')
480 command.append(f'--post-flash-script={hardware.post_flash_script}')
483 command.append(f'--post-script={hardware.post_script}')
486 command.append(f'--flash-before={hardware.flash_before}')
489 command.append(f'--twister-fixture={fixture}')
509 self.instance.reason = 'Pytest timeout'
518 self.instance.reason = f'Pytest error - return code {proc.returncode}'
527 pytest by update PYTHONPATH and append -p argument to pytest command.
531 cmd.extend(['-p', 'twister_harness.plugin'])
536 'pytest-twister-harness',
566 self.instance.testcases = []
573 if not self.instance.testcases:
574 self.instance.init_cases()
576 self.instance.status = self.status if self.status != TwisterStatus.NONE else \
578 if self.instance.status in [TwisterStatus.ERROR, TwisterStatus.FAIL]:
579 self.instance.reason = self.instance.reason or 'Pytest failed'
580 self.instance.add_missing_case_status(TwisterStatus.BLOCK, self.instance.reason)
589 self.instance.reason = (
594 self.instance.reason = 'Error during pytest execution'
599 self.instance.execution_time = float(elem_ts.get('time'))
602 tc = self.instance.add_testcase(f"{self.id}.{elem_tc.get('name')}")
618 self.instance.reason = 'No tests collected'
622 ANSI_ESCAPE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
623 _NAME_PATTERN = "[a-zA-Z_][a-zA-Z0-9_]*"
631 + "\\[----------\\] Global test environment tear-down)"
655 name = "{}.{}.{}".format(self.id, suite_name, test_start_match.group("test_name"))
662 # Check that the instance doesn't exist yet (prevents re-running)
663 tc = self.instance.get_case_by_name(name)
666 # Create the test instance and set the context
667 tc = self.instance.get_case_or_create(name)
676 tc = self.instance.get_case_or_create(self.id)
692 tc = self.instance.get_case_by_name(name)
713 self.id, test_pass_match.group("suite_name"),
720 self.id, test_skip_match.group("suite_name"),
727 self.id, test_fail_match.group("suite_name"),
740 test_case_start_pattern = re.compile(r"START - (test_)?([a-zA-Z0-9_-]+)")
742 r".*(PASS|FAIL|SKIP) - (test_)?(\S*) in (\d*[.,]?\d*) seconds"
745 r"SUITE (?P<suite_status>\S*) - .* \[(?P<suite_name>\S*)\]:"
749 r" - (PASS|FAIL|SKIP) - \[([^\.]*).(test_)?(\S*)\] duration = (\d*[.,]?\d*) seconds"
760 if ts_name not in self.instance.testsuite.ztest_suite_names:
762 f"not present among: {self.instance.testsuite.ztest_suite_names}")
769 # First, try to match the test case ID to the first running Ztest suite with this test name.
773 tc_fq_id = self.instance.compose_case_name(f"{ts_name_}.{tc_name}")
774 if tc := self.instance.get_case_by_name(tc_fq_id):
782 tc_id = self.instance.compose_case_name(tc_name)
783 return self.instance.get_case_or_create(tc_id)
788 if suite_name not in self.instance.testsuite.ztest_suite_names:
810 self.started_suites[suite_name]['count'] -= 1
813 self.started_suites[suite_name]['count'] -= 1
835 self.started_cases[tc_name]['count'] -= 1
903 logger.debug(f"not a ztest and no state for {self.id}")
904 tc = self.instance.get_case_or_create(self.id)
924 if self.instance is None:
927 original_exe_path: str = os.path.join(self.instance.build_dir, 'zephyr', 'zephyr.exe')
929 logger.warning('Cannot copy bsim exe - cannot find original executable.')
934 logger.warning('Cannot copy bsim exe - BSIM_OUT_PATH not provided.')
937 new_exe_name: str = self.instance.testsuite.harness_config.get('bsim_exe_name', '')
939 new_exe_name = f'bs_{self.instance.platform.name}_{new_exe_name}'
941 new_exe_name = self.instance.name