Files
esp-idf/tools/test_idf_py/test_idf_qemu.py
T
Marek FialaandCursor bf630eac15 test(tools): Added minimal supported cmake versions build system tests
Backport of !49288 to release/v5.4 (cmake@3.16.3).

Adapted for release/v5.4:

- Linux/macOS jobs added in .gitlab/ci/build.yml (build-system pytest
  lives there on v5.4, not host-test.yml).
- Known-failure download uses get_known_failure_cases_file.py.
- macOS jobs keep .before_script:build:macos / macos_shell tags.
- Windows minimal-cmake job follows v5.4 install/tags conventions.
- Skip test_idf_qemu on Windows (pexpect.spawn unavailable).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 09:31:45 +02:00

46 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import logging
import os
import sys
import tempfile
import unittest
if sys.platform == 'win32':
import pytest
pytest.skip('pexpect.spawn is not available on Windows', allow_module_level=True)
else:
import pexpect
class IdfPyQemuTest(unittest.TestCase):
def test_idf_qemu(self) -> None:
build_dir = tempfile.mkdtemp()
idf_path = os.environ['IDF_PATH']
hello_world_dir = os.path.join(idf_path, 'examples', 'get-started', 'hello_world')
idf_py = os.path.join(idf_path, 'tools', 'idf.py')
args = [idf_py, '-C', hello_world_dir, '-B', build_dir, 'qemu', '--qemu-extra-args', '-no-reboot', 'monitor']
logfile_name = os.path.join(os.environ['IDF_PATH'], 'qemu_log.out')
with open(logfile_name, 'w+b') as logfile, pexpect.spawn(sys.executable, args=args, logfile=logfile) as child:
child.expect_exact('Executing action: all')
logging.info('Waiting for the build to finish...')
child.expect_exact('Executing action: qemu', timeout=120)
child.expect_exact('Generating flash image:')
child.expect_exact('Generating efuse image:')
child.expect_exact('Executing action: monitor')
child.expect_exact('Hello world!')
child.expect_exact('Restarting in 0 seconds', timeout=20)
child.expect_exact('Restarting now.')
args = [idf_py, '-C', hello_world_dir, '-B', build_dir, 'qemu', 'efuse-summary', '--format=summary']
with open(logfile_name, 'w+b') as logfile, pexpect.spawn(sys.executable, args=args, logfile=logfile) as child:
child.expect_exact('Executing action: efuse-summary')
child.expect_exact('WR_DIS (BLOCK0)')
if __name__ == '__main__':
unittest.main()