fix: follow-up test-script review findings (v3.5.14)
- The SCP80 counter write-back resolves the preset by NAME first (the run
snapshot prefers the name) and only falls back to an ICCID-looking
value: presets with digits in their names are found after a page reload
(the previous fallback ran cardsNormIccid on the name and gave up).
- testScriptProblem validates the *selected* SCP80 source (like the form
and the server), so source=apdu with only sp filled is caught locally
instead of failing with a server 400.
- _test_run_start cleans up (_TEST_RUNNING=False, run state error) when
the worker thread cannot be created/started, and the endpoint answers
500 with a clear error instead of leaving the card blocked behind a run
that never started.
- The 5 s poll writes the counter back whenever a run is finished
(idempotent), so a reloaded page saves it without visiting the pill.
- Mask wildcards ('?') are stripped from the hex fields that cannot carry
a mask (APDU, secured packet, event/file data, TAR/SPI overrides, DCS,
extra TLVs); check values keep them.
Tests: frontend +3 (write-back by name / by ICCID, mask-free fields,
source-aware script check), Python +1 (failed thread start unblocks).
586 frontend / 471 Python green; version 3.5.14; sw simple-v267.
This commit is contained in:
@@ -31,7 +31,7 @@ from osmocom.tlv import BER_TLV_IE
|
||||
from osmocom.utils import rpad
|
||||
|
||||
|
||||
VERSION = '3.5.13'
|
||||
VERSION = '3.5.14'
|
||||
|
||||
MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE
|
||||
|
||||
@@ -4598,10 +4598,22 @@ def _test_run_start(server, script, preset):
|
||||
_finish_pending_menu(server, server.scc)
|
||||
except Exception as e:
|
||||
sys.stderr.write('TEST-RUN: finishing pending menu failed: %s\n' % e)
|
||||
_TEST_THREAD = threading.Thread(target=_test_run_worker,
|
||||
args=(server, script, preset),
|
||||
name='test-script', daemon=True)
|
||||
_TEST_THREAD.start()
|
||||
try:
|
||||
_TEST_THREAD = threading.Thread(target=_test_run_worker,
|
||||
args=(server, script, preset),
|
||||
name='test-script', daemon=True)
|
||||
_TEST_THREAD.start()
|
||||
except Exception:
|
||||
# A run that never starts must not leave the card blocked (the 409
|
||||
# guard keys off _TEST_RUNNING, and no worker would ever clear it).
|
||||
_TEST_THREAD = None
|
||||
_TEST_RUNNING = False
|
||||
with _TEST_LOCK:
|
||||
_TEST_RUN['running'] = False
|
||||
_TEST_RUN['status'] = 'error'
|
||||
_TEST_RUN['error'] = 'could not start the run worker'
|
||||
_TEST_RUN['finished'] = time.time()
|
||||
raise
|
||||
|
||||
|
||||
class PysimHandler(BaseHTTPRequestHandler):
|
||||
@@ -4931,7 +4943,13 @@ class PysimHandler(BaseHTTPRequestHandler):
|
||||
self._send_json(resp, 400)
|
||||
self._log_resp(resp)
|
||||
return
|
||||
_test_run_start(self.server, script, preset)
|
||||
try:
|
||||
_test_run_start(self.server, script, preset)
|
||||
except Exception as e:
|
||||
resp = {'error': 'could not start the test run: %s' % e}
|
||||
self._send_json(resp, 500)
|
||||
self._log_resp(resp)
|
||||
return
|
||||
resp = _test_state_snapshot()
|
||||
self._send_json(resp)
|
||||
self._log_resp(resp)
|
||||
|
||||
Reference in New Issue
Block a user