Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
app_repository: LedgerHQ/app-boilerplate
app_branch_name: master
upload_app_binaries_artifact: boilerplate_binaries
build_comparison: false

build_boilerplate_application_nanos:
name: Build boilerplate application for Nanos S using the reusable workflow
Expand All @@ -35,6 +36,7 @@ jobs:
app_repository: LedgerHQ/app-boilerplate
app_branch_name: nanos_baseline
upload_app_binaries_artifact: boilerplate_binaries_nanos
build_comparison: false

prepare_matrix:
name: Prepare matrix from TOML file
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.45.2] - 2026-04-29

### Fixed

- `--get-stack-consumption` : fixing case where test does not interact with device


## [1.45.1] - 2026-04-27

### Added
Expand Down
54 changes: 28 additions & 26 deletions src/ragger/conftest/base_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,36 @@ def get_stack_consumption(pytestconfig):

@pytest.fixture(autouse=True)
def stack_consumption_hooks(request, get_stack_consumption: bool):
if get_stack_consumption:
backend = request.getfixturevalue("backend")
_backend_name = request.getfixturevalue("backend_name")
if _backend_name.lower() == "speculos":
try:
backend.exchange(cla=0xB0, ins=0x57, p1=0x00, p2=0x01, data=b"")
except ExceptionRAPDU as e:
msg = (
"Stack consumption not supported: app not built with DEBUG_OS_STACK_CONSUMPTION=1"
if e.status == StatusWords.SWO_INVALID_CLA else
f"Unexpected SW: {e.status:04X}")
pytest.fail(msg)
yield
if get_stack_consumption:
# This fixture is marked `autouse=True` so that it happens automatically
# on tests that interact with the device. However, it should do nothing if
# running tests that _do not_ interact with the device.
# We detect that by verifying if the `backend` fixture is present.
if not get_stack_consumption:
yield
return
try:
backend = request.getfixturevalue("backend")
_backend_name = request.getfixturevalue("backend_name")
if _backend_name.lower() == "speculos":
try:
rapdu_retrieve: RAPDU = backend.exchange(cla=0xB0,
ins=0x57,
p1=0x01,
p2=0x01,
data=b"")
consumption = int.from_bytes(rapdu_retrieve.data, byteorder='big')
print(f"\n[stack consumption] {consumption} bytes.")
_stack_consumption_results[request.node.nodeid] = consumption
except ExceptionRAPDU as e:
pytest.fail(f"Stack consumption retrieve failed with SW: {e.status:04X}")
except pytest.FixtureLookupError:
yield
return
if _backend_name.lower() == "speculos":
try:
backend.exchange(cla=0xB0, ins=0x57, p1=0x00, p2=0x01, data=b"")

yield

rapdu_retrieve: RAPDU = backend.exchange(cla=0xB0, ins=0x57, p1=0x01, p2=0x01, data=b"")
consumption = int.from_bytes(rapdu_retrieve.data, byteorder='big')
print(f"\n[stack consumption] {consumption} bytes.")
_stack_consumption_results[request.node.nodeid] = consumption
except ExceptionRAPDU as e:
msg = (
"Stack consumption not supported: app not built with DEBUG_OS_STACK_CONSUMPTION=1"
if e.status == StatusWords.SWO_INVALID_CLA else f"Unexpected SW: {e.status:04X}")
pytest.fail(msg)
else:
yield


def pytest_terminal_summary(terminalreporter, exitstatus, config):
Expand Down
Loading