Lines Matching full:device

12 from twister_harness.device.hardware_adapter import HardwareAdapter
17 @pytest.fixture(name='device')
33 def test_if_hardware_adapter_raise_exception_when_west_not_found(patched_which, device: HardwareAda…
35 device.generate_command()
39 def test_if_get_command_returns_proper_string_1(patched_which, device: HardwareAdapter) -> None:
40 device.device_config.build_dir = Path('build')
41 device.generate_command()
42 assert isinstance(device.command, list)
43 …assert device.command == ['west', 'flash', '--skip-rebuild', '--build-dir', 'build', '--runner', '…
47 def test_if_get_command_returns_proper_string_2(patched_which, device: HardwareAdapter) -> None:
48 device.device_config.build_dir = Path('build')
49 device.device_config.runner = 'pyocd'
50 device.generate_command()
51 assert isinstance(device.command, list)
52 assert device.command == [
58 def test_if_get_command_returns_proper_string_3(patched_which, device: HardwareAdapter) -> None:
59 device.device_config.build_dir = Path('build')
60 device.device_config.runner = 'nrfjprog'
61 device.generate_command()
62 assert isinstance(device.command, list)
63 assert device.command == [
69 def test_if_get_command_returns_proper_string_4(patched_which, device: HardwareAdapter) -> None:
70 device.device_config.build_dir = Path('build')
71 device.device_config.runner = 'openocd'
72 device.device_config.product = 'STM32 STLink'
73 device.generate_command()
74 assert isinstance(device.command, list)
75 assert device.command == [
82 def test_if_get_command_returns_proper_string_5(patched_which, device: HardwareAdapter) -> None:
83 device.device_config.build_dir = Path('build')
84 device.device_config.runner = 'openocd'
85 device.device_config.product = 'EDBG CMSIS-DAP'
86 device.generate_command()
87 assert isinstance(device.command, list)
88 assert device.command == [
95 def test_if_get_command_returns_proper_string_6(patched_which, device: HardwareAdapter) -> None:
96 device.device_config.build_dir = Path('build')
97 device.device_config.runner = 'jlink'
98 device.generate_command()
99 assert isinstance(device.command, list)
100 assert device.command == [
107 def test_if_get_command_returns_proper_string_7(patched_which, device: HardwareAdapter) -> None:
108 device.device_config.build_dir = Path('build')
109 device.device_config.runner = 'stm32cubeprogrammer'
110 device.generate_command()
111 assert isinstance(device.command, list)
112 assert device.command == [
119 def test_if_get_command_returns_proper_string_8(patched_which, device: HardwareAdapter) -> None:
120 device.device_config.build_dir = Path('build')
121 device.device_config.runner = 'openocd'
122 device.device_config.product = 'STLINK-V3'
123 device.generate_command()
124 assert isinstance(device.command, list)
125 assert device.command == [
132 def test_if_get_command_returns_proper_string_with_runner_params_1(patched_which, device: HardwareA…
133 device.device_config.build_dir = Path('build')
134 device.device_config.runner_params = ['--runner-param1', 'runner-param2']
135 device.generate_command()
136 assert isinstance(device.command, list)
137 assert device.command == [
144 def test_if_get_command_returns_proper_string_with_runner_params_2(patched_which, device: HardwareA…
145 device.device_config.build_dir = Path('build')
146 device.device_config.runner = 'openocd'
147 device.device_config.runner_params = [
154 device.device_config.product = 'JTAG-lock-pick Tiny 2'
155 device.generate_command()
156 assert isinstance(device.command, list)
157 assert device.command == [
170 patched_which, device: HardwareAdapter
172 device.device_config.build_dir = Path('build')
173 device.device_config.west_flash_extra_args = ['--board-id=foobar', '--erase']
174 device.device_config.runner = 'pyocd'
175 device.device_config.id = ''
176 device.generate_command()
177 assert isinstance(device.command, list)
178 assert device.command == [
184 def test_if_hardware_adapter_raises_exception_empty_command(device: HardwareAdapter) -> None:
185 device.command = []
188 device._flash_and_run()
191 @mock.patch('twister_harness.device.hardware_adapter.subprocess.Popen')
192 def test_device_log_correct_error_handle(patched_popen, device: HardwareAdapter, tmp_path: Path) ->…
196 device.device_config.build_dir = tmp_path
197 device.command = [
201 …with pytest.raises(expected_exception=TwisterHarnessException, match='Could not flash device p_id'…
202 device._flash_and_run()
203 assert os.path.isfile(device.device_log_path)
204 with open(device.device_log_path, 'r') as file:
208 @mock.patch('twister_harness.device.hardware_adapter.subprocess.Popen')
209 @mock.patch('twister_harness.device.hardware_adapter.serial.Serial')
211 patched_serial, patched_popen, device: HardwareAdapter, monkeypatch: pytest.MonkeyPatch
213 device.device_config.serial_pty = 'script.py'
219 monkeypatch.setattr('twister_harness.device.hardware_adapter.pty.openpty', lambda: (123, 456))
220 …monkeypatch.setattr('twister_harness.device.hardware_adapter.os.ttyname', lambda x: f'/pty/ttytest…
226 device._device_run.set()
227 device.connect()
228 assert device._serial_connection.port == '/pty/ttytest/456' # type: ignore[union-attr]
229 assert device._serial_pty_proc
237 device.disconnect()
238 assert not device._serial_pty_proc
242 device: HardwareAdapter, shell_simulator_path: str
248 device.command = ['echo', 'TEST'] # only to mock flashing command
249 device.device_config.serial_pty = f'python3 {shell_simulator_path}'
250 device.launch()
252 device.write(b'zen\n')
254 lines = device.readlines_until(regex='Namespaces are one honking great idea')
256 device.write(b'quit\n')