mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
71153c7dbb
This extension allows running programs in QEMU similar to running them on a real chip: - 'idf.py qemu' — builds and runs the program in QEMU. User gets a QEMU instance launched, and can work with it as a normal QEMU instance. - 'idf.py qemu monitor' — same, but QEMU is launched in the background, and idf_monitor runs in the foreground, showing QEMU output. Compared to only running 'idf.py qemu' this enables, for example, automatic backtrace decoding. - 'idf.py qemu gdb' — launches QEMU in the background and opens an interactive GDB prompt, connecting it to QEMU. - 'idf.py qemu --gdb monitor' and 'idf.py gdb' in another shell: launches QEMU in the background, keeps it suspended until GDB is connected, and opens idf_monitor. GDB can be used in another shell to debug the application.
39 lines
1.4 KiB
Python
Executable File
39 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
#
|
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
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('Executing action: all')
|
|
logging.info('Waiting for the build to finish...')
|
|
child.expect('Executing action: qemu', timeout=120)
|
|
child.expect('Generating flash image:')
|
|
child.expect('Generating efuse image:')
|
|
child.expect('Executing action: monitor')
|
|
child.expect('Hello world!')
|
|
child.expect('Restarting in 0 seconds', timeout=20)
|
|
child.expect('Restarting now.')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|