Skip to content

Commit ebd5bcd

Browse files
committed
fix(ci): scope required tests to firmware variant
1 parent ca06d46 commit ebd5bcd

2 files changed

Lines changed: 50 additions & 6 deletions

File tree

scripts/generate-test-report.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,14 +3235,23 @@ def screenshot_filter(fw_version):
32353235
# version-blind set would fail every older-firmware run for a module that
32363236
# legitimately cannot exist yet.
32373237
MUST_RUN_MODULES = {
3238-
'test_msg_signtx_taproot': '7.0.0',
3239-
'test_msg_getaddress_taproot': '7.0.0',
3238+
# (minimum firmware version, variants that ship the capability)
3239+
'test_msg_signtx_taproot': ('7.0.0', frozenset(('full', 'bitcoin-only'))),
3240+
'test_msg_getaddress_taproot': ('7.0.0', frozenset(('full', 'bitcoin-only'))),
32403241
# R-4.1. Gated on requires_message('LoadClearsignSigner'), so if provider
32413242
# loading regressed, all four would skip and the report would certify a
32423243
# feature it never exercised.
3243-
'test_msg_solana_lut_attestation': '7.15.0',
3244+
'test_msg_solana_lut_attestation': ('7.15.0', frozenset(('full',))),
32443245
}
32453246

3247+
3248+
def _skip_is_required(module, fw_version, variant):
3249+
requirement = MUST_RUN_MODULES.get(module)
3250+
if requirement is None:
3251+
return False
3252+
min_version, variants = requirement
3253+
return variant in variants and ver_ge(fw_version, min_version)
3254+
32463255
def screenshot_audit(fw_version, screenshot_root, junit_path=None):
32473256
"""Which SECTIONS tests DECLARED screens but captured none?
32483257
@@ -3283,7 +3292,7 @@ def screenshot_audit(fw_version, screenshot_root, junit_path=None):
32833292
return (len(missing) == 0, missing)
32843293

32853294

3286-
def validate_junit(fw_version, results):
3295+
def validate_junit(fw_version, results, variant='full'):
32873296
"""Check SECTIONS tests against JUnit results. Returns (passed, failed_list).
32883297
32893298
A test is considered failed if it appears in SECTIONS for this firmware version
@@ -3299,7 +3308,7 @@ def validate_junit(fw_version, results):
32993308
status = _lookup(results, mod, meth)
33003309
if status in ('fail', 'error'):
33013310
failures.append((tid, mod, meth, status))
3302-
elif status == 'skip' and ver_ge(fw_version, MUST_RUN_MODULES.get(mod, '99.0.0')):
3311+
elif status == 'skip' and _skip_is_required(mod, fw_version, variant):
33033312
failures.append((tid, mod, meth, 'skipped-but-required'))
33043313
elif not status:
33053314
failures.append((tid, mod, meth, 'missing'))
@@ -3320,6 +3329,8 @@ def main():
33203329
help='Print pytest -k expression for tests needing screenshots, then exit')
33213330
p.add_argument('--validate-junit', action='store_true',
33223331
help='Validate JUnit results against SECTIONS, exit non-zero on failures')
3332+
p.add_argument('--variant', choices=('full', 'bitcoin-only'), default='full',
3333+
help='Firmware capability set used to evaluate required tests')
33233334
args = p.parse_args()
33243335

33253336
fw = args.fw_version
@@ -3347,7 +3358,7 @@ def main():
33473358
print('ERROR: --validate-junit requires --junit=<path>', file=sys.stderr)
33483359
sys.exit(2)
33493360
results = parse_junit(args.junit)
3350-
ok, failures = validate_junit(fw, results)
3361+
ok, failures = validate_junit(fw, results, args.variant)
33513362
if ok:
33523363
print(f'SECTIONS validation passed: all tests for fw {fw} are pass or skip')
33533364
sys.exit(0)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Tests for build-variant requirements in the release evidence catalog."""
2+
3+
import importlib.util
4+
from pathlib import Path
5+
6+
7+
REPORT_PATH = Path(__file__).parents[1] / "scripts" / "generate-test-report.py"
8+
SPEC = importlib.util.spec_from_file_location("generate_test_report", REPORT_PATH)
9+
REPORT = importlib.util.module_from_spec(SPEC)
10+
SPEC.loader.exec_module(REPORT)
11+
12+
13+
def test_solana_lut_attestation_is_required_on_full_firmware():
14+
assert REPORT._skip_is_required(
15+
"test_msg_solana_lut_attestation", "7.15.0", "full"
16+
)
17+
18+
19+
def test_solana_lut_attestation_is_not_required_on_bitcoin_only():
20+
assert not REPORT._skip_is_required(
21+
"test_msg_solana_lut_attestation", "7.15.0", "bitcoin-only"
22+
)
23+
24+
25+
def test_taproot_is_required_on_both_variants():
26+
for variant in ("full", "bitcoin-only"):
27+
assert REPORT._skip_is_required("test_msg_signtx_taproot", "7.15.0", variant)
28+
29+
30+
def test_requirements_do_not_apply_before_their_release():
31+
assert not REPORT._skip_is_required(
32+
"test_msg_solana_lut_attestation", "7.14.9", "full"
33+
)

0 commit comments

Comments
 (0)