diff --git a/pytest-embedded-idf/pyproject.toml b/pytest-embedded-idf/pyproject.toml index 66c303c2..56a2b359 100644 --- a/pytest-embedded-idf/pyproject.toml +++ b/pytest-embedded-idf/pyproject.toml @@ -30,6 +30,7 @@ requires-python = ">=3.7" dependencies = [ "pytest-embedded~=1.4.2", + "esp-idf-panic-decoder", ] [project.optional-dependencies] diff --git a/pytest-embedded-idf/pytest_embedded_idf/dut.py b/pytest-embedded-idf/pytest_embedded_idf/dut.py index 31ce5262..404afd80 100644 --- a/pytest-embedded-idf/pytest_embedded_idf/dut.py +++ b/pytest-embedded-idf/pytest_embedded_idf/dut.py @@ -1,3 +1,4 @@ +import importlib.util import logging import os import re @@ -74,16 +75,18 @@ def panic_output_decode_script(self) -> t.Optional[str]: Returns: Panic output decode script path """ - script_filepath = self._panic_output_decode_script or os.path.join( - os.getenv('IDF_PATH', 'IDF_PATH'), - 'tools', - 'gdb_panic_server.py', - ) - if not os.path.isfile(script_filepath): - raise ValueError( - 'Panic output decode script not found. Please use --panic-output-decode-script flag ' - 'to provide script or set IDF_PATH (Default: $IDF_PATH/tools/gdb_panic_server.py)' - ) + + script_filepath = self._panic_output_decode_script + if not script_filepath or not os.path.isfile(script_filepath): + module = importlib.util.find_spec('esp_idf_panic_decoder.gdb_panic_server') + if not module: + raise ValueError( + 'Panic output decode script not found. ' + 'Please use the --panic-output-decode-script flag to provide a script ' + 'or install esp-idf-panic-decoder using the command: `pip install esp-idf-panic-decoder` .' + ) + script_filepath = module.origin + return os.path.realpath(script_filepath) def _check_panic_decode_trigger(self): # type: () -> None diff --git a/pytest-embedded/pytest_embedded/plugin.py b/pytest-embedded/pytest_embedded/plugin.py index 8b306e3a..a9a795e6 100644 --- a/pytest-embedded/pytest_embedded/plugin.py +++ b/pytest-embedded/pytest_embedded/plugin.py @@ -193,7 +193,7 @@ def pytest_addoption(parser): idf_group.addoption( '--panic-output-decode-script', help='Panic output decode script that is used in conjunction with the check-panic-coredump option ' - 'to parse panic output. (Default: $IDF_PATH/tools/gdb_panic_server.py)', + 'to parse panic output. (Default: use gdb_panic_server.py from package esp_idf_panic_decoder)', ) jtag_group = parser.getgroup('embedded-jtag')