From 27ebbec30bdeb6d992b2a68e4b2455f583afa893 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Tue, 21 Mar 2023 17:30:40 +0800 Subject: [PATCH] secure_element/aidl: update test case transmit When no logical or basic channel is opened, transmit() resturns an error code CHANNEL_NOT_AVAILABLE with an empty response. Bug: 270091254 Test: atest VtsHalSecureElementTargetTest Change-Id: I7b302ec321089f0b8f1d9d67bb12f9bdddaa4ee1 --- .../vts/VtsHalSecureElementTargetTest.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp index 0925a2188f..839a4ff339 100644 --- a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp +++ b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp @@ -284,14 +284,21 @@ TEST_P(SecureElementAidl, closeChannel) { TEST_P(SecureElementAidl, transmit) { std::vector response; + LogicalChannelResponse logical_channel_response; - // transmit called after init shall succeed. - // Note: no channel is opened for this test and the transmit - // response will have the status SW_LOGICAL_CHANNEL_NOT_SUPPORTED. - // The transmit response shall be larger than 2 bytes as it includes the - // status code. - EXPECT_OK(secure_element_->transmit(kDataApdu, &response)); - EXPECT_GE(response.size(), 2u); + // Note: no channel is opened for this test + // transmit() will return an empty response with the error + // code CHANNEL_NOT_AVAILABLE when the SE cannot be + // communicated with. + EXPECT_ERR(secure_element_->transmit(kDataApdu, &response)); + + EXPECT_OK(secure_element_->openLogicalChannel(kSelectableAid, 0x00, &logical_channel_response)); + EXPECT_GE(logical_channel_response.selectResponse.size(), 2u); + EXPECT_GE(logical_channel_response.channelNumber, 1u); + EXPECT_LE(logical_channel_response.channelNumber, 19u); + + // transmit called on the logical channel should succeed. + EXPECT_EQ(transmit(logical_channel_response.channelNumber), 0x9000); } GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SecureElementAidl);