Skip to content

Commit fb423e4

Browse files
authored
Merge pull request #413 from Honza0297/fix/only-elf
fix: support testing without flasher_args.json (CII-159)
2 parents 167480f + 7a81a5d commit fb423e4

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

pytest-embedded-idf/pytest_embedded_idf/app.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class IdfApp(App):
2424
flash_args (dict[str, Any]): dict of flasher_args.json
2525
flash_files (list[FlashFile]): list of (offset, file path, encrypted) of files need to be flashed in
2626
flash_settings (dict[str, Any]): dict of flash settings
27+
is_loadable_elf (bool): Chip RAM app (``APP_BUILD_TYPE_RAM`` / ``APP_BUILD_TYPE_ELF_RAM``); esptool
28+
``load_ram`` path.
29+
is_linux_elf (bool): Linux host ELF-only build (``APP_BUILD_TYPE_ELF_ONLY``), no flasher_args.json.
2730
"""
2831

2932
XTENSA_TARGETS: ClassVar[list[str]] = ['esp32', 'esp32s2', 'esp32s3']
@@ -74,10 +77,13 @@ def __init__(
7477
else:
7578
self.is_loadable_elf = False
7679

80+
# Linux target: ELF-only output, no flasher_args.json.
81+
self.is_linux_elf = bool(self.sdkconfig.get('APP_BUILD_TYPE_ELF_ONLY'))
82+
7783
self.bin_file = self._get_bin_file()
7884
self.flash_args, self.flash_files, self.flash_settings = {}, [], {}
7985

80-
if not self.is_loadable_elf:
86+
if not (self.is_loadable_elf or self.is_linux_elf):
8187
self.flash_args, self.flash_files, self.flash_settings = self._parse_flash_args_json()
8288

8389
@property
@@ -153,10 +159,15 @@ def partition_table(self) -> dict[str, Any]:
153159
if self._partition_table is not None:
154160
return self._partition_table
155161

156-
partition_file = os.path.join(
157-
self.binary_path,
158-
self.flash_args.get('partition_table', self.flash_args.get('partition-table', {})).get('file', ''),
162+
# see - vs _ in 'partition table' key name
163+
partition_rel_path = self.flash_args.get('partition_table', self.flash_args.get('partition-table', {})).get(
164+
'file', ''
159165
)
166+
if not partition_rel_path:
167+
self._partition_table = {}
168+
return self._partition_table
169+
170+
partition_file = os.path.join(self.binary_path, partition_rel_path)
160171
process = subprocess.Popen(
161172
[sys.executable, self.parttool_path, partition_file],
162173
stdout=subprocess.PIPE,

pytest-embedded-idf/pytest_embedded_idf/dut.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ def flash_via_jtag(self):
270270
# >>> self.gdb.write('load')
271271
return
272272

273+
if self.app.is_linux_elf:
274+
# linux ELF file. OpenOCD is meaningless
275+
logging.debug('Linux ELF-only build; skipping OpenOCD program_esp.')
276+
return
277+
273278
for _f in self.app.flash_files:
274279
if _f.encrypted:
275280
raise ValueError("Encrypted files can't be flashed in via JTAG")

pytest-embedded-idf/pytest_embedded_idf/serial.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def _start(self):
7272
else:
7373
if self.app.is_loadable_elf:
7474
self.load_ram()
75+
elif self.app.is_linux_elf:
76+
# Host Linux ELF (IDF_TARGET_LINUX); no flasher_args.json.
77+
logging.info('Linux ELF-only build; skipping auto flash.')
78+
super()._start()
7579
else:
7680
self.flash()
7781

0 commit comments

Comments
 (0)