Browse Source

ccid: Lots of CCID helpers have been moved to titan.TestPorts.USB

Change-Id: Ie110ad1511b01fe84e1ad181b0e053e25f80f522
changes/39/27339/1
Harald Welte 1 year ago committed by Eric Wild
parent
commit
6220dc7bf0
  1. 139
      ccid/CCID_Tests.ttcn
  2. 2
      deps/Makefile

139
ccid/CCID_Tests.ttcn

@ -29,13 +29,6 @@ type component Test_CT {
var Slot_CT vc_SLOT[NR_SLOTS];
};
/* per-slot test component; manages one slot */
type component Slot_CT {
var uint8_t g_slot_nr;
port CCID_SLOT_PT CCID;
timer g_Tguard := 120.0;
};
/* maximum number of slots we are supporting in the test suite */
private const integer NR_SLOTS := 16;
@ -96,25 +89,6 @@ private template (value) CCID_ProtocolData ts_ProtoDataT0(ISO7816_Fi fi, ISO7816
type function void_fn() runs on Slot_CT;
/* altstep running on the per-slot test component */
private altstep as_Tguard() runs on Slot_CT {
[] g_Tguard.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
}
}
private altstep as_ccid_any() runs on Slot_CT {
var CCID_PDU pdu;
[] CCID.receive(CCID_PDU:?) -> value pdu {
setverdict(fail, "Received unexpected CCID ", pdu);
self.stop;
}
[] CCID.receive {
setverdict(fail, "Received unexpected non-CCID");
self.stop;
}
}
/* first function inside Slot_CT; wait for CCID_EVENT_UP + call testcase-specific function */
private function f_handler_init(void_fn fn, integer slot_nr) runs on Slot_CT {
g_slot_nr := slot_nr;
@ -163,119 +137,6 @@ private function f_init() runs on Test_CT {
}
/* transceive a CCID command (send 'tx' on OUT; expect 'rx' on IN) */
private function f_ccid_xceive(template (value) CCID_PDU tx, template (present) CCID_PDU exp_rx)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
tx.hdr.bSlot := g_slot_nr;
exp_rx.hdr.bSlot := g_slot_nr;
CCID.send(tx);
alt {
[] CCID.receive(exp_rx) -> value pdu {
return pdu;
}
[] as_ccid_any();
}
return pdu;
}
private template (present) CCID_Header_IN tr_inact :=
tr_CCID_HeaderIN_OK(icc_status := (CCID_ICC_STATUS_PRES_INACT, CCID_ICC_STATUS_NO_ICC));
private template (present) CCID_Header_IN tr_act :=
tr_CCID_HeaderIN_OK(icc_status := CCID_ICC_STATUS_PRES_ACT);
/* Send IccPowerOn on OUT; expect DataBlock in retunr */
private function f_ccid_power_on(CCID_PowerSelect psel := CCID_PWRSEL_AUTO,
template (present) CCID_Header_IN hdr_in := tr_act)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_IccPowerOn(g_slot_nr, psel),
tr_CCID_DataBlock(g_slot_nr, hdr_in := hdr_in) );
return pdu;
}
/* Send IccPowerOn on OUT; expect SlotStatus in return */
private function f_ccid_power_off(template (present) CCID_Header_IN hdr_in := tr_inact)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_IccPowerOff(g_slot_nr),
tr_CCID_SlotStatus(slot := g_slot_nr, hdr_in := hdr_in) );
return pdu;
}
/* Send IccClockCommand on OUT; expect SlotStatus in return */
private function f_ccid_clock_cmd(CCID_ClockCommand cmd,
template (present) CCID_Header_IN hdr_in := tr_CCID_HeaderIN_OK)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_ClockCommand(g_slot_nr, cmd),
tr_CCID_SlotStatus(slot := g_slot_nr, hdr_in := hdr_in));
return pdu;
}
/* Send XfrBlock on OUT; expect DataBlock in return */
private function f_ccid_xfr(octetstring tx, template octetstring rx) runs on Slot_CT return octetstring {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_XfrBlock(g_slot_nr, tx, 0),
tr_CCID_DataBlock(g_slot_nr, ?, ?, rx) );
return pdu.u.DataBlock.abData;
}
/* Send SetParameters on OUT; expect Parameters on IN */
private function f_ccid_set_par(template (value) CCID_ProtocolData par,
template (present) CCID_Header_IN hdr_in := tr_CCID_HeaderIN_OK)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_SetParameters(g_slot_nr, par),
tr_CCID_Parameters(g_slot_nr, hdr_in := hdr_in));
return pdu;
}
/* Send GetParameters on OUT; expect Parameters on IN */
private function f_ccid_get_par(template (present) CCID_Header_IN hdr_in := tr_CCID_HeaderIN_OK)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_GetParameters(g_slot_nr),
tr_CCID_Parameters(g_slot_nr, hdr_in := hdr_in));
return pdu;
}
/* Send ResetParameters on OUT; expect Parameters on IN */
private function f_ccid_reset_par(template (present) CCID_Header_IN hdr_in := tr_CCID_HeaderIN_OK)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
/* [at least] Omnikey seems to have failed to follow the CCID spec here :/ */
if (mp_quirk_resetpar_returns_slotsts) {
pdu := f_ccid_xceive(ts_CCID_ResetParameters(g_slot_nr),
tr_CCID_SlotStatus(g_slot_nr, hdr_in := hdr_in));
} else {
pdu := f_ccid_xceive(ts_CCID_ResetParameters(g_slot_nr),
tr_CCID_Parameters(g_slot_nr, hdr_in := hdr_in));
}
return pdu;
}
/* Send Escape on OUT; expect Escape on IN */
private function f_ccid_escape(template (value) octetstring data,
template (present) CCID_Header_IN hdr_in := tr_CCID_HeaderIN_OK)
runs on Slot_CT return CCID_PDU {
var CCID_PDU pdu;
pdu := f_ccid_xceive(ts_CCID_Escape(g_slot_nr, data),
tr_CCID_EscapeIN(g_slot_nr, hdr_in := hdr_in));
return pdu;
}
/***********************************************************************
* Test behavior regarding valid situations

2
deps/Makefile vendored

@ -126,7 +126,7 @@ titan.TestPorts.TCPasp_commit= R.9.A-5-g2c91bc6
titan.TestPorts.TELNETasp_commit= 873fe539642542cd9a901c208f1ec11c6d2f5387
titan.TestPorts.UDPasp_commit= c20d77a34f288dd70dd4aaa30e520778876e9336
titan.TestPorts.UNIX_DOMAIN_SOCKETasp_commit= R.2.A-13-gd34ab71
titan.TestPorts.USB_commit= 4c742e931aae66c0046cebfe3c1de4618b6f9ffc
titan.TestPorts.USB_commit= a9470fdc99c82fbf988f4508c3161118c9106e28
osmo-uecups_commit= 8362efef7c6fa341eb947a75786878e0685767b7
all: $(foreach dir,$(ALL_REPOS),$(dir)/update)

Loading…
Cancel
Save