pytest-embedded 2.8.0__tar.gz → 2.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/PKG-INFO +1 -1
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/__init__.py +1 -1
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/dut_factory.py +84 -1
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/log.py +7 -1
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/plugin.py +106 -4
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/utils.py +4 -2
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/tests/test_base.py +83 -1
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/LICENSE +0 -0
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/README.md +0 -0
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pyproject.toml +0 -0
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/app.py +0 -0
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/dut.py +0 -0
- {pytest_embedded-2.8.0 → pytest_embedded-2.9.0}/pytest_embedded/unity.py +0 -0
|
@@ -13,6 +13,7 @@ from collections import defaultdict
|
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
|
|
15
15
|
if t.TYPE_CHECKING:
|
|
16
|
+
from pytest_embedded_espemu import EspEmu
|
|
16
17
|
from pytest_embedded_idf import LinuxSerial
|
|
17
18
|
from pytest_embedded_idf.dut import IdfDut
|
|
18
19
|
from pytest_embedded_jtag import Gdb, OpenOcd
|
|
@@ -141,6 +142,7 @@ def _fixture_classes_and_options_fn(
|
|
|
141
142
|
erase_all,
|
|
142
143
|
esptool_baud,
|
|
143
144
|
esp_flash_force,
|
|
145
|
+
no_fast_flash,
|
|
144
146
|
part_tool,
|
|
145
147
|
confirm_target_elf_sha256,
|
|
146
148
|
erase_nvs,
|
|
@@ -156,7 +158,12 @@ def _fixture_classes_and_options_fn(
|
|
|
156
158
|
qemu_cli_args,
|
|
157
159
|
qemu_extra_args,
|
|
158
160
|
qemu_efuse_path,
|
|
161
|
+
espemu_image_path,
|
|
162
|
+
espemu_prog_path,
|
|
163
|
+
espemu_cli_args,
|
|
164
|
+
espemu_extra_args,
|
|
159
165
|
wokwi_diagram,
|
|
166
|
+
wokwi_usb_serial_jtag,
|
|
160
167
|
skip_regenerate_image,
|
|
161
168
|
encrypt,
|
|
162
169
|
keyfile,
|
|
@@ -193,6 +200,18 @@ def _fixture_classes_and_options_fn(
|
|
|
193
200
|
'qemu_efuse_path': qemu_efuse_path,
|
|
194
201
|
}
|
|
195
202
|
)
|
|
203
|
+
elif 'espemu' in _services:
|
|
204
|
+
from pytest_embedded_espemu import EspEmuApp
|
|
205
|
+
|
|
206
|
+
classes[fixture] = EspEmuApp
|
|
207
|
+
kwargs[fixture].update(
|
|
208
|
+
{
|
|
209
|
+
'msg_queue': msg_queue,
|
|
210
|
+
'part_tool': part_tool,
|
|
211
|
+
'espemu_image_path': espemu_image_path,
|
|
212
|
+
'skip_regenerate_image': skip_regenerate_image,
|
|
213
|
+
}
|
|
214
|
+
)
|
|
196
215
|
else:
|
|
197
216
|
from pytest_embedded_idf import IdfApp
|
|
198
217
|
|
|
@@ -253,6 +272,7 @@ def _fixture_classes_and_options_fn(
|
|
|
253
272
|
kwargs[fixture].update(
|
|
254
273
|
{
|
|
255
274
|
'app': None,
|
|
275
|
+
'fast_flash': not no_fast_flash if no_fast_flash is not None else True,
|
|
256
276
|
}
|
|
257
277
|
)
|
|
258
278
|
elif 'nuttx' in _services:
|
|
@@ -327,6 +347,24 @@ def _fixture_classes_and_options_fn(
|
|
|
327
347
|
'meta': _meta,
|
|
328
348
|
'dut_index': dut_index,
|
|
329
349
|
}
|
|
350
|
+
elif fixture == 'espemu':
|
|
351
|
+
if 'espemu' in _services:
|
|
352
|
+
from pytest_embedded_espemu import (
|
|
353
|
+
DEFAULT_IMAGE_FN,
|
|
354
|
+
EspEmu,
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
classes[fixture] = EspEmu
|
|
358
|
+
kwargs[fixture] = {
|
|
359
|
+
'msg_queue': msg_queue,
|
|
360
|
+
'espemu_image_path': espemu_image_path
|
|
361
|
+
or os.path.join(app_path or '', build_dir or 'build', DEFAULT_IMAGE_FN),
|
|
362
|
+
'espemu_prog_path': espemu_prog_path,
|
|
363
|
+
'espemu_cli_args': espemu_cli_args,
|
|
364
|
+
'espemu_extra_args': espemu_extra_args,
|
|
365
|
+
'app': None,
|
|
366
|
+
'meta': _meta,
|
|
367
|
+
}
|
|
330
368
|
elif fixture == 'wokwi':
|
|
331
369
|
if 'wokwi' in _services:
|
|
332
370
|
from pytest_embedded_wokwi import Wokwi
|
|
@@ -335,6 +373,7 @@ def _fixture_classes_and_options_fn(
|
|
|
335
373
|
kwargs[fixture].update(
|
|
336
374
|
{
|
|
337
375
|
'wokwi_diagram': wokwi_diagram,
|
|
376
|
+
'wokwi_usb_serial_jtag': wokwi_usb_serial_jtag,
|
|
338
377
|
'msg_queue': msg_queue,
|
|
339
378
|
'app': None,
|
|
340
379
|
'meta': _meta,
|
|
@@ -377,6 +416,15 @@ def _fixture_classes_and_options_fn(
|
|
|
377
416
|
kwargs['wokwi'].update({'firmware_resolver': ArduinoFirmwareResolver()})
|
|
378
417
|
else:
|
|
379
418
|
raise SystemExit('wokwi service should be used together with idf or arduino service')
|
|
419
|
+
elif 'espemu' in _services:
|
|
420
|
+
from pytest_embedded_espemu import EspEmuDut
|
|
421
|
+
|
|
422
|
+
classes[fixture] = EspEmuDut
|
|
423
|
+
kwargs[fixture].update(
|
|
424
|
+
{
|
|
425
|
+
'espemu': None,
|
|
426
|
+
}
|
|
427
|
+
)
|
|
380
428
|
elif 'qemu' in _services:
|
|
381
429
|
if 'nuttx' in _services:
|
|
382
430
|
from pytest_embedded_nuttx import NuttxQemuDut
|
|
@@ -530,6 +578,19 @@ def qemu_gn(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['Q
|
|
|
530
578
|
return cls(**_drop_none_kwargs(kwargs))
|
|
531
579
|
|
|
532
580
|
|
|
581
|
+
def espemu_gn(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['EspEmu']:
|
|
582
|
+
if 'espemu' not in _fixture_classes_and_options.classes:
|
|
583
|
+
return None
|
|
584
|
+
|
|
585
|
+
cls = _fixture_classes_and_options.classes['espemu']
|
|
586
|
+
kwargs = _fixture_classes_and_options.kwargs['espemu']
|
|
587
|
+
|
|
588
|
+
if 'app' in kwargs and kwargs['app'] is None:
|
|
589
|
+
kwargs['app'] = app
|
|
590
|
+
|
|
591
|
+
return cls(**_drop_none_kwargs(kwargs))
|
|
592
|
+
|
|
593
|
+
|
|
533
594
|
def wokwi_gn(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['Wokwi']:
|
|
534
595
|
"""A wokwi subprocess that could read/redirect/write"""
|
|
535
596
|
if 'wokwi' not in _fixture_classes_and_options.classes:
|
|
@@ -551,6 +612,7 @@ def dut_gn(
|
|
|
551
612
|
serial: t.Union['Serial', 'LinuxSerial'] | None,
|
|
552
613
|
qemu: t.Optional['Qemu'],
|
|
553
614
|
wokwi: t.Optional['Wokwi'],
|
|
615
|
+
espemu: t.Optional['EspEmu'] = None,
|
|
554
616
|
) -> Dut | list[Dut]:
|
|
555
617
|
global DUT_GLOBAL_INDEX
|
|
556
618
|
DUT_GLOBAL_INDEX += 1
|
|
@@ -580,6 +642,8 @@ def dut_gn(
|
|
|
580
642
|
kwargs[k] = gdb
|
|
581
643
|
elif k == 'qemu':
|
|
582
644
|
kwargs[k] = qemu
|
|
645
|
+
elif k == 'espemu':
|
|
646
|
+
kwargs[k] = espemu
|
|
583
647
|
elif k == 'wokwi':
|
|
584
648
|
kwargs[k] = wokwi
|
|
585
649
|
return cls(**_drop_none_kwargs(kwargs), mixins=mixins)
|
|
@@ -680,6 +744,7 @@ class DutFactory:
|
|
|
680
744
|
erase_all: bool | None = None,
|
|
681
745
|
esptool_baud: int | None = None,
|
|
682
746
|
esp_flash_force: bool | None = False,
|
|
747
|
+
no_fast_flash: bool | None = None,
|
|
683
748
|
part_tool: str | None = None,
|
|
684
749
|
confirm_target_elf_sha256: bool | None = None,
|
|
685
750
|
erase_nvs: bool | None = None,
|
|
@@ -695,7 +760,12 @@ class DutFactory:
|
|
|
695
760
|
qemu_cli_args: str | None = None,
|
|
696
761
|
qemu_extra_args: str | None = None,
|
|
697
762
|
qemu_efuse_path: str | None = None,
|
|
763
|
+
espemu_image_path: str | None = None,
|
|
764
|
+
espemu_prog_path: str | None = None,
|
|
765
|
+
espemu_cli_args: str | None = None,
|
|
766
|
+
espemu_extra_args: str | None = None,
|
|
698
767
|
wokwi_diagram: str | None = None,
|
|
768
|
+
wokwi_usb_serial_jtag: bool | None = None,
|
|
699
769
|
skip_regenerate_image: bool | None = None,
|
|
700
770
|
encrypt: bool | None = None,
|
|
701
771
|
keyfile: str | None = None,
|
|
@@ -742,7 +812,12 @@ class DutFactory:
|
|
|
742
812
|
qemu_cli_args: QEMU CLI arguments.
|
|
743
813
|
qemu_extra_args: Additional QEMU arguments.
|
|
744
814
|
qemu_efuse_path: Efuse binary path.
|
|
815
|
+
espemu_image_path: esp-emu image path.
|
|
816
|
+
espemu_prog_path: esp-emu program path.
|
|
817
|
+
espemu_cli_args: esp-emu CLI arguments.
|
|
818
|
+
espemu_extra_args: Additional esp-emu arguments.
|
|
745
819
|
wokwi_diagram: Wokwi diagram path.
|
|
820
|
+
wokwi_usb_serial_jtag: Use USB Serial JTAG instead of UART for Wokwi serial communication.
|
|
746
821
|
skip_regenerate_image: Skip image regeneration flag.
|
|
747
822
|
encrypt: Encryption flag.
|
|
748
823
|
keyfile: Keyfile for encryption.
|
|
@@ -797,6 +872,7 @@ class DutFactory:
|
|
|
797
872
|
'erase_all': erase_all,
|
|
798
873
|
'esptool_baud': esptool_baud,
|
|
799
874
|
'esp_flash_force': esp_flash_force,
|
|
875
|
+
'no_fast_flash': no_fast_flash,
|
|
800
876
|
'part_tool': part_tool,
|
|
801
877
|
'confirm_target_elf_sha256': confirm_target_elf_sha256,
|
|
802
878
|
'erase_nvs': erase_nvs,
|
|
@@ -812,7 +888,12 @@ class DutFactory:
|
|
|
812
888
|
'qemu_cli_args': qemu_cli_args,
|
|
813
889
|
'qemu_extra_args': qemu_extra_args,
|
|
814
890
|
'qemu_efuse_path': qemu_efuse_path,
|
|
891
|
+
'espemu_image_path': espemu_image_path,
|
|
892
|
+
'espemu_prog_path': espemu_prog_path,
|
|
893
|
+
'espemu_cli_args': espemu_cli_args,
|
|
894
|
+
'espemu_extra_args': espemu_extra_args,
|
|
815
895
|
'wokwi_diagram': wokwi_diagram,
|
|
896
|
+
'wokwi_usb_serial_jtag': wokwi_usb_serial_jtag,
|
|
816
897
|
'skip_regenerate_image': skip_regenerate_image,
|
|
817
898
|
'encrypt': encrypt,
|
|
818
899
|
'keyfile': keyfile,
|
|
@@ -841,11 +922,13 @@ class DutFactory:
|
|
|
841
922
|
|
|
842
923
|
qemu = qemu_gn(_fixture_classes_and_options, app)
|
|
843
924
|
layout.append(qemu)
|
|
925
|
+
espemu = espemu_gn(_fixture_classes_and_options, app)
|
|
926
|
+
layout.append(espemu)
|
|
844
927
|
|
|
845
928
|
wokwi = wokwi_gn(_fixture_classes_and_options, app)
|
|
846
929
|
layout.append(wokwi)
|
|
847
930
|
|
|
848
|
-
dut = dut_gn(_fixture_classes_and_options, openocd, gdb, app, serial, qemu, wokwi)
|
|
931
|
+
dut = dut_gn(_fixture_classes_and_options, openocd, gdb, app, serial, qemu, wokwi, espemu)
|
|
849
932
|
layout.append(dut)
|
|
850
933
|
|
|
851
934
|
cls.obj_stack.append(layout)
|
|
@@ -154,7 +154,13 @@ class _PopenRedirectProcess(_ctx.Process):
|
|
|
154
154
|
|
|
155
155
|
@staticmethod
|
|
156
156
|
def _forward_io(msg_queue, logfile) -> None:
|
|
157
|
-
|
|
157
|
+
# Binary, because the file is still being written to: a text-mode read finalizes the
|
|
158
|
+
# decoder at every temporary EOF, and a UTF-8 sequence straddling that boundary raises
|
|
159
|
+
# UnicodeDecodeError. `except Exception` below would swallow it and this process would
|
|
160
|
+
# exit 0, cutting the output off for the rest of the session. Decoding here is not
|
|
161
|
+
# needed either - `MessageQueue.put` re-encodes with `to_bytes`, the pexpect buffer is
|
|
162
|
+
# bytes, and the serial transport already forwards `read_all()` undecoded.
|
|
163
|
+
with open(logfile, 'rb') as fr:
|
|
158
164
|
while True:
|
|
159
165
|
try:
|
|
160
166
|
msg_queue.put(fr.read()) # msg_queue may be closed
|
|
@@ -36,6 +36,7 @@ from .dut_factory import (
|
|
|
36
36
|
_pexpect_fr_gn,
|
|
37
37
|
app_fn,
|
|
38
38
|
dut_gn,
|
|
39
|
+
espemu_gn,
|
|
39
40
|
gdb_gn,
|
|
40
41
|
openocd_gn,
|
|
41
42
|
pexpect_proc_fn,
|
|
@@ -60,6 +61,7 @@ from .utils import (
|
|
|
60
61
|
)
|
|
61
62
|
|
|
62
63
|
if t.TYPE_CHECKING:
|
|
64
|
+
from pytest_embedded_espemu import EspEmu
|
|
63
65
|
from pytest_embedded_idf import CaseTester, IdfDut, LinuxSerial
|
|
64
66
|
from pytest_embedded_jtag import Gdb, OpenOcd
|
|
65
67
|
from pytest_embedded_qemu import Qemu
|
|
@@ -70,7 +72,7 @@ if t.TYPE_CHECKING:
|
|
|
70
72
|
_T = t.TypeVar('_T')
|
|
71
73
|
|
|
72
74
|
|
|
73
|
-
def pytest_addoption(parser):
|
|
75
|
+
def pytest_addoption(parser: pytest.Parser):
|
|
74
76
|
base_group = parser.getgroup('embedded')
|
|
75
77
|
base_group.addoption(
|
|
76
78
|
'--count',
|
|
@@ -140,6 +142,7 @@ def pytest_addoption(parser):
|
|
|
140
142
|
'- idf: auto-detect more app info with idf specific rules, auto flash-in\n'
|
|
141
143
|
'- jtag: openocd and gdb\n'
|
|
142
144
|
'- qemu: use qemu simulator instead of the real target\n'
|
|
145
|
+
'- espemu: use esp-emu simulator instead of the real target\n'
|
|
143
146
|
'- arduino: auto-detect more app info with arduino specific rules, auto flash-in\n'
|
|
144
147
|
'- wokwi: use wokwi simulator instead of the real target\n'
|
|
145
148
|
'- nuttx: service for nuttx project, optionally with espressif devices\n'
|
|
@@ -209,6 +212,17 @@ def pytest_addoption(parser):
|
|
|
209
212
|
action='store_true',
|
|
210
213
|
help='force mode for esptool',
|
|
211
214
|
)
|
|
215
|
+
arduino_group = parser.getgroup('embedded-arduino')
|
|
216
|
+
arduino_group.addoption(
|
|
217
|
+
'--no-fast-flash',
|
|
218
|
+
help=(
|
|
219
|
+
'y/yes/true for True and n/no/false for False. '
|
|
220
|
+
'Set to True to disable fast reflashing (--diff-with) for Arduino. '
|
|
221
|
+
'Useful when flash state is unknown, e.g. after OTA updates. '
|
|
222
|
+
'(Default: False)'
|
|
223
|
+
),
|
|
224
|
+
)
|
|
225
|
+
|
|
212
226
|
idf_group = parser.getgroup('embedded-idf')
|
|
213
227
|
idf_group.addoption(
|
|
214
228
|
'--supported-targets', help='Comma-separated list of supported targets for the test case. (Default: None)'
|
|
@@ -293,11 +307,36 @@ def pytest_addoption(parser):
|
|
|
293
307
|
help='Flash Encryption (pre-encrypted workflow) key path. (Default: None)',
|
|
294
308
|
)
|
|
295
309
|
|
|
310
|
+
espemu_group = parser.getgroup('embedded-espemu')
|
|
311
|
+
espemu_group.addoption(
|
|
312
|
+
'--espemu-image-path',
|
|
313
|
+
help='esp-emu image path. (Default: "<app_path>/<build_dir>/espemu_image.bin")',
|
|
314
|
+
)
|
|
315
|
+
espemu_group.addoption(
|
|
316
|
+
'--espemu-prog-path',
|
|
317
|
+
help='esp-emu program path. (Default: "esp-emu")',
|
|
318
|
+
)
|
|
319
|
+
espemu_group.addoption(
|
|
320
|
+
'--espemu-cli-args',
|
|
321
|
+
help='esp-emu cli default arguments. (Default: None)',
|
|
322
|
+
)
|
|
323
|
+
espemu_group.addoption(
|
|
324
|
+
'--espemu-extra-args',
|
|
325
|
+
help='esp-emu cli extra arguments, will append to the argument list. (Default: None)',
|
|
326
|
+
)
|
|
327
|
+
|
|
296
328
|
wokwi_group = parser.getgroup('embedded-wokwi')
|
|
297
329
|
wokwi_group.addoption(
|
|
298
330
|
'--wokwi-diagram',
|
|
299
331
|
help='Path to the wokwi diagram file (Default: None)',
|
|
300
332
|
)
|
|
333
|
+
wokwi_group.addoption(
|
|
334
|
+
'--wokwi-usb-serial-jtag',
|
|
335
|
+
help='y/yes/true for True and n/no/false for False. '
|
|
336
|
+
'Use USB Serial JTAG instead of UART for serial communication in the Wokwi diagram. '
|
|
337
|
+
'When enabled, the diagram will use the USB_SERIAL_JTAG interface and remove $serialMonitor connections. '
|
|
338
|
+
'(Default: False)',
|
|
339
|
+
)
|
|
301
340
|
|
|
302
341
|
|
|
303
342
|
###########
|
|
@@ -842,6 +881,13 @@ def esp_flash_force(request: FixtureRequest) -> str | None:
|
|
|
842
881
|
return _request_param_or_config_option_or_default(request, 'esp_flash_force', False)
|
|
843
882
|
|
|
844
883
|
|
|
884
|
+
@pytest.fixture
|
|
885
|
+
@multi_dut_argument
|
|
886
|
+
def no_fast_flash(request: FixtureRequest) -> bool | None:
|
|
887
|
+
"""Enable parametrization for the same cli option"""
|
|
888
|
+
return _request_param_or_config_option_or_default(request, 'no_fast_flash', None)
|
|
889
|
+
|
|
890
|
+
|
|
845
891
|
@pytest.fixture
|
|
846
892
|
@multi_dut_argument
|
|
847
893
|
def build_dir(request: FixtureRequest) -> str | None:
|
|
@@ -1045,6 +1091,37 @@ def qemu_efuse_path(request: FixtureRequest) -> str | None:
|
|
|
1045
1091
|
return _request_param_or_config_option_or_default(request, 'qemu_efuse_path', None)
|
|
1046
1092
|
|
|
1047
1093
|
|
|
1094
|
+
##########
|
|
1095
|
+
# espemu #
|
|
1096
|
+
##########
|
|
1097
|
+
@pytest.fixture
|
|
1098
|
+
@multi_dut_argument
|
|
1099
|
+
def espemu_image_path(request: FixtureRequest) -> str | None:
|
|
1100
|
+
"""Enable parametrization for the same cli option"""
|
|
1101
|
+
return _request_param_or_config_option_or_default(request, 'espemu_image_path', None)
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
@pytest.fixture
|
|
1105
|
+
@multi_dut_argument
|
|
1106
|
+
def espemu_prog_path(request: FixtureRequest) -> str | None:
|
|
1107
|
+
"""Enable parametrization for the same cli option"""
|
|
1108
|
+
return _request_param_or_config_option_or_default(request, 'espemu_prog_path', None)
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
@pytest.fixture
|
|
1112
|
+
@multi_dut_argument
|
|
1113
|
+
def espemu_cli_args(request: FixtureRequest) -> str | None:
|
|
1114
|
+
"""Enable parametrization for the same cli option"""
|
|
1115
|
+
return _request_param_or_config_option_or_default(request, 'espemu_cli_args', None)
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
@pytest.fixture
|
|
1119
|
+
@multi_dut_argument
|
|
1120
|
+
def espemu_extra_args(request: FixtureRequest) -> str | None:
|
|
1121
|
+
"""Enable parametrization for the same cli option"""
|
|
1122
|
+
return _request_param_or_config_option_or_default(request, 'espemu_extra_args', None)
|
|
1123
|
+
|
|
1124
|
+
|
|
1048
1125
|
@pytest.fixture
|
|
1049
1126
|
@multi_dut_argument
|
|
1050
1127
|
def skip_regenerate_image(request: FixtureRequest) -> str | None:
|
|
@@ -1076,6 +1153,13 @@ def wokwi_diagram(request: FixtureRequest) -> str | None:
|
|
|
1076
1153
|
return _request_param_or_config_option_or_default(request, 'wokwi_diagram', None)
|
|
1077
1154
|
|
|
1078
1155
|
|
|
1156
|
+
@pytest.fixture
|
|
1157
|
+
@multi_dut_argument
|
|
1158
|
+
def wokwi_usb_serial_jtag(request: FixtureRequest) -> bool | None:
|
|
1159
|
+
"""Enable parametrization for the same cli option"""
|
|
1160
|
+
return _request_param_or_config_option_or_default(request, 'wokwi_usb_serial_jtag', None)
|
|
1161
|
+
|
|
1162
|
+
|
|
1079
1163
|
####################
|
|
1080
1164
|
# Private Fixtures #
|
|
1081
1165
|
####################
|
|
@@ -1118,6 +1202,7 @@ def parametrize_fixtures(
|
|
|
1118
1202
|
erase_all,
|
|
1119
1203
|
esptool_baud,
|
|
1120
1204
|
esp_flash_force,
|
|
1205
|
+
no_fast_flash,
|
|
1121
1206
|
part_tool,
|
|
1122
1207
|
confirm_target_elf_sha256,
|
|
1123
1208
|
erase_nvs,
|
|
@@ -1133,7 +1218,12 @@ def parametrize_fixtures(
|
|
|
1133
1218
|
qemu_cli_args,
|
|
1134
1219
|
qemu_extra_args,
|
|
1135
1220
|
qemu_efuse_path,
|
|
1221
|
+
espemu_image_path,
|
|
1222
|
+
espemu_prog_path,
|
|
1223
|
+
espemu_cli_args,
|
|
1224
|
+
espemu_extra_args,
|
|
1136
1225
|
wokwi_diagram,
|
|
1226
|
+
wokwi_usb_serial_jtag,
|
|
1137
1227
|
skip_regenerate_image,
|
|
1138
1228
|
encrypt,
|
|
1139
1229
|
keyfile,
|
|
@@ -1223,6 +1313,13 @@ def qemu(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['Qemu
|
|
|
1223
1313
|
return qemu_gn(**locals())
|
|
1224
1314
|
|
|
1225
1315
|
|
|
1316
|
+
@pytest.fixture
|
|
1317
|
+
@multi_dut_generator_fixture
|
|
1318
|
+
def espemu(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['EspEmu']:
|
|
1319
|
+
"""An esp-emu subprocess that could read/redirect/write"""
|
|
1320
|
+
return espemu_gn(**locals())
|
|
1321
|
+
|
|
1322
|
+
|
|
1226
1323
|
@pytest.fixture
|
|
1227
1324
|
@multi_dut_generator_fixture
|
|
1228
1325
|
def wokwi(_fixture_classes_and_options: ClassCliOptions, app) -> t.Optional['Wokwi']:
|
|
@@ -1240,6 +1337,7 @@ def dut(
|
|
|
1240
1337
|
serial: t.Union['Serial', 'LinuxSerial'] | None,
|
|
1241
1338
|
qemu: t.Optional['Qemu'],
|
|
1242
1339
|
wokwi: t.Optional['Wokwi'],
|
|
1340
|
+
espemu: t.Optional['EspEmu'],
|
|
1243
1341
|
) -> Dut | list[Dut]:
|
|
1244
1342
|
"""
|
|
1245
1343
|
A device under test (DUT) object that could gather output from various sources and redirect them to the pexpect
|
|
@@ -1381,7 +1479,7 @@ class PytestEmbedded:
|
|
|
1381
1479
|
|
|
1382
1480
|
from esp_bool_parser import parse_bool_expr
|
|
1383
1481
|
|
|
1384
|
-
target = config.getoption('
|
|
1482
|
+
target = config.getoption('target', None)
|
|
1385
1483
|
if hasattr(item, 'callspec'):
|
|
1386
1484
|
target = item.callspec.params.get('target', None)
|
|
1387
1485
|
if target == 'auto' or not isinstance(target, str):
|
|
@@ -1457,7 +1555,7 @@ class PytestEmbedded:
|
|
|
1457
1555
|
self._raise_dut_failed_cases_if_exists(all_duts) # type: ignore
|
|
1458
1556
|
|
|
1459
1557
|
@pytest.hookimpl(trylast=True) # combine all possible junit reports should be the last step
|
|
1460
|
-
def pytest_sessionfinish(self, session: Session
|
|
1558
|
+
def pytest_sessionfinish(self, session: Session) -> None:
|
|
1461
1559
|
modifier: JunitMerger = session.config.stash[_junit_merger_key]
|
|
1462
1560
|
_stash_session_tempdir = session.config.stash.get(_session_tempdir_key, None)
|
|
1463
1561
|
_stash_junit_report_path = session.config.stash.get(_junit_report_path_key, None)
|
|
@@ -1475,4 +1573,8 @@ class PytestEmbedded:
|
|
|
1475
1573
|
if self.prettify_junit_report:
|
|
1476
1574
|
_prettify_xml(_stash_junit_report_path)
|
|
1477
1575
|
|
|
1478
|
-
|
|
1576
|
+
# escalate the session exit status to failure if the merged junit report contains failures,
|
|
1577
|
+
# without downgrading an already-failing run
|
|
1578
|
+
current_exitstatus = getattr(session, 'exitstatus', pytest.ExitCode.OK)
|
|
1579
|
+
if modifier.failed and current_exitstatus == pytest.ExitCode.OK:
|
|
1580
|
+
session.exitstatus = pytest.ExitCode.TESTS_FAILED
|
|
@@ -23,19 +23,21 @@ SERVICE_LIB_NAMES = {
|
|
|
23
23
|
'idf': f'{BASE_LIB_NAME}-idf',
|
|
24
24
|
'jtag': f'{BASE_LIB_NAME}-jtag',
|
|
25
25
|
'qemu': f'{BASE_LIB_NAME}-qemu',
|
|
26
|
+
'espemu': f'{BASE_LIB_NAME}-espemu',
|
|
26
27
|
'arduino': f'{BASE_LIB_NAME}-arduino',
|
|
27
28
|
'wokwi': f'{BASE_LIB_NAME}-wokwi',
|
|
28
29
|
'nuttx': f'{BASE_LIB_NAME}-nuttx',
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
FIXTURES_SERVICES = {
|
|
32
|
-
'app': ['base', 'idf', 'qemu', 'arduino', 'nuttx'],
|
|
33
|
+
'app': ['base', 'idf', 'qemu', 'espemu', 'arduino', 'nuttx'],
|
|
33
34
|
'serial': ['serial', 'jtag', 'esp', 'idf', 'arduino', 'nuttx'],
|
|
34
35
|
'openocd': ['jtag'],
|
|
35
36
|
'gdb': ['jtag'],
|
|
36
37
|
'qemu': ['qemu'],
|
|
38
|
+
'espemu': ['espemu'],
|
|
37
39
|
'wokwi': ['wokwi'],
|
|
38
|
-
'dut': ['base', 'serial', 'jtag', 'qemu', 'idf', 'wokwi', 'nuttx'],
|
|
40
|
+
'dut': ['base', 'serial', 'jtag', 'qemu', 'espemu', 'idf', 'wokwi', 'nuttx'],
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
|
|
@@ -35,6 +35,7 @@ def test_services(testdir):
|
|
|
35
35
|
('idf,serial', {'IdfApp', 'Serial', 'SerialDut'}),
|
|
36
36
|
('idf,esp', {'IdfApp', 'IdfSerial', 'IdfDut'}),
|
|
37
37
|
('idf,qemu', {'QemuApp', 'Qemu', 'QemuDut'}),
|
|
38
|
+
('idf,espemu', {'EspEmuApp', 'EspEmu', 'EspEmuDut'}),
|
|
38
39
|
('arduino,esp', {'ArduinoApp', 'ArduinoSerial', 'SerialDut'}),
|
|
39
40
|
],
|
|
40
41
|
indirect=True
|
|
@@ -45,7 +46,7 @@ def test_services(testdir):
|
|
|
45
46
|
|
|
46
47
|
result = testdir.runpytest()
|
|
47
48
|
|
|
48
|
-
result.assert_outcomes(passed=
|
|
49
|
+
result.assert_outcomes(passed=8)
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
def test_fixtures(testdir):
|
|
@@ -1010,3 +1011,84 @@ def test_multi_dut_no_data_loss(testdir):
|
|
|
1010
1011
|
|
|
1011
1012
|
result = testdir.runpytest()
|
|
1012
1013
|
result.assert_outcomes(passed=1)
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
def _drain(q, deadline_s=10):
|
|
1017
|
+
"""Collect everything the queue yields until it stays quiet for a moment."""
|
|
1018
|
+
import queue as _q
|
|
1019
|
+
import time
|
|
1020
|
+
|
|
1021
|
+
chunks = []
|
|
1022
|
+
deadline = time.monotonic() + deadline_s
|
|
1023
|
+
while time.monotonic() < deadline:
|
|
1024
|
+
try:
|
|
1025
|
+
chunks.append(q.get(timeout=0.2))
|
|
1026
|
+
except _q.Empty:
|
|
1027
|
+
if chunks:
|
|
1028
|
+
break
|
|
1029
|
+
return b''.join(chunks)
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
def test_forward_io_survives_split_multibyte_char(tmp_path):
|
|
1033
|
+
"""A multi-byte sequence split across two appends must not kill the forwarder.
|
|
1034
|
+
|
|
1035
|
+
The redirect log is written to while it is being read, so the reader keeps hitting a
|
|
1036
|
+
temporary EOF. Decoding there turns any UTF-8 sequence straddling that boundary into
|
|
1037
|
+
a UnicodeDecodeError, which the forwarder's `except Exception` swallows: the process
|
|
1038
|
+
exits 0 and DUT output stops for the rest of the session.
|
|
1039
|
+
"""
|
|
1040
|
+
import time
|
|
1041
|
+
|
|
1042
|
+
from pytest_embedded.log import MessageQueue, _PopenRedirectProcess
|
|
1043
|
+
|
|
1044
|
+
logfile = str(tmp_path / 'redirect.log')
|
|
1045
|
+
open(logfile, 'wb').close()
|
|
1046
|
+
|
|
1047
|
+
q = MessageQueue()
|
|
1048
|
+
p = _PopenRedirectProcess(q, logfile)
|
|
1049
|
+
p.start()
|
|
1050
|
+
try:
|
|
1051
|
+
with open(logfile, 'ab') as fw:
|
|
1052
|
+
fw.write(b'head\n')
|
|
1053
|
+
fw.flush()
|
|
1054
|
+
assert b'head\n' in _drain(q), 'nothing forwarded before the split'
|
|
1055
|
+
|
|
1056
|
+
# U+2014 EM DASH, torn in half: the reader reaches EOF between the two bytes.
|
|
1057
|
+
with open(logfile, 'ab') as fw:
|
|
1058
|
+
fw.write(b'dash \xe2')
|
|
1059
|
+
fw.flush()
|
|
1060
|
+
time.sleep(0.5)
|
|
1061
|
+
assert p.is_alive(), f'forwarder died on a split sequence (exitcode={p.exitcode})'
|
|
1062
|
+
|
|
1063
|
+
with open(logfile, 'ab') as fw:
|
|
1064
|
+
fw.write(b'\x80\x94 tail\n')
|
|
1065
|
+
fw.flush()
|
|
1066
|
+
assert b'dash \xe2\x80\x94 tail\n' in _drain(q), 'the split character was not reassembled'
|
|
1067
|
+
finally:
|
|
1068
|
+
p.terminate()
|
|
1069
|
+
p.join(timeout=5)
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
def test_forward_io_preserves_carriage_returns(tmp_path):
|
|
1073
|
+
"""The forwarder passes the log through byte for byte, CR included.
|
|
1074
|
+
|
|
1075
|
+
Reading in text mode used to apply universal-newline translation, so a device sending
|
|
1076
|
+
CRLF was forwarded as LF. The serial transport never did that, and the console writer
|
|
1077
|
+
and the Unity parser both handle CRLF themselves.
|
|
1078
|
+
"""
|
|
1079
|
+
from pytest_embedded.log import MessageQueue, _PopenRedirectProcess
|
|
1080
|
+
|
|
1081
|
+
logfile = str(tmp_path / 'redirect.log')
|
|
1082
|
+
open(logfile, 'wb').close()
|
|
1083
|
+
|
|
1084
|
+
q = MessageQueue()
|
|
1085
|
+
p = _PopenRedirectProcess(q, logfile)
|
|
1086
|
+
p.start()
|
|
1087
|
+
try:
|
|
1088
|
+
with open(logfile, 'ab') as fw:
|
|
1089
|
+
fw.write(b'first\r\nsecond\r\n')
|
|
1090
|
+
fw.flush()
|
|
1091
|
+
assert _drain(q) == b'first\r\nsecond\r\n'
|
|
1092
|
+
finally:
|
|
1093
|
+
p.terminate()
|
|
1094
|
+
p.join(timeout=5)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|