jolly has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42806?usp=email )
(
8 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: CCID: Check if reader handles Abort correctly ......................................................................
CCID: Check if reader handles Abort correctly
The tests aborts an ongoing case 2 APDU (according to ISO 7816). The SIM responds with a NULL procedure byte so that the reader does not time out.
The abort messages are sent on both, the control pipe and the bulk pipe with the same sequence number.
This test fails with osmo-ccid-firmware, because the abort message/handling is not yet implemented.
Change-Id: Iebe97e73497b8468ebf08faf2c4db700fc76997f --- M ccid/CCID_Tests.ttcn 1 file changed, 72 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, approved Hoernchen: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/ccid/CCID_Tests.ttcn b/ccid/CCID_Tests.ttcn index 643f78f..00387d4 100644 --- a/ccid/CCID_Tests.ttcn +++ b/ccid/CCID_Tests.ttcn @@ -803,6 +803,77 @@ f_start_and_wait(); }
+/* The SIM transfer is aborted. */ +private function f_TC_abort() runs on CardemSlot_CT +{ + var octetstring req := c_SIM_READ_BINARY; + var CCID_PDU ccid_pdu; + var boolean v_slot_status_received := false; + + /* We need to emulate a SIM that does not respond, so we can be sure + * that the reader is still waiting while we abort. + */ + f_cardem_manager(); + + f_ccid_power_on(CCID_PWRSEL_3V0); + + /* Send a request towards reader. */ + CCID.send(ts_CCID_XfrBlock(g_slot_nr, req, 0)); + /* Receive the request by SIM. */ + f_cardem_receive(tr_SIMTRACE_CEMU_RX_DATA(?, req)); + /* Transmit NULL procedure byte by SIM. */ + f_cardem_transmit(ts_SIMTRACE_CEMU_TX_DATA(ts_CardEmu_DataFlags(pb_and_tx := true, final := true), + '60'O)); + /* Send abort toward reader. Note that CCID_Emulation.ttcn will detect + * the PC_to_RDR_Abort message type and sends another abort message to + * the control pipe in advance with the same sequence number. This is + * done there, because the sequence number is set at CCID_Emulation.ttcn + * upon transmission of the two messages. */ + CCID.send(ts_CCID_Abort(g_slot_nr, 0)); + /* Wait for slot status, but eat the possible 'DataBlock' that will be received after timeout. */ + timer T := 3.0; + T.start; + alt { + [] CCID.receive(tr_CCID_DataBlock(g_slot_nr, ?, ?, ?)) -> value ccid_pdu { + log("Eating 'DataBlock'."); + if (ccid_pdu.hdr_in.bStatus.bmCommandStatus != CCID_CMD_STATUS_FAILED) { + setverdict(fail, "Unexpected Datablock status after abort command."); + mtc.stop; + } + if (ccid_pdu.hdr_in.bError != CCID_ERR_CMD_ABORTED) { + setverdict(fail, "Unexpected Datablock error code after abort command."); + mtc.stop; + } + repeat; + } + [] CCID.receive(tr_CCID_SlotStatus(g_slot_nr, ?, ?, ?)) -> value ccid_pdu { + v_slot_status_received := true; + if (ccid_pdu.hdr_in.bStatus.bmCommandStatus != CCID_CMD_STATUS_OK) { + setverdict(fail, "Unexpected Response to abort command."); + mtc.stop; + } + } + [] T.timeout { } + } + + if (not v_slot_status_received) { + setverdict(fail, "No response to abort command."); + mtc.stop; + } + + /* Stop simtrace emulation, to prevent race condition. */ + vc_Cardem.stop; + vc_Cardem.done; +} +testcase TC_abort() runs on Test_CT +{ + f_init(); + + f_start_handler(refers(f_TC_abort), mp_simtrace_slot, true); + + f_start_and_wait(); +} +
/* TODO */ @@ -1205,6 +1276,7 @@ execute( TC_256_bytes_response() ); execute( TC_null_procedure_byte() ); execute( TC_255_bytes_request() ); + execute( TC_abort() );
/* error handling */ execute( TC_inval_slot() );