• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Tests a very simple end to end T=1 using the echo backend.
17  */
18 
19 #include <vector>
20 #include <gtest/gtest.h>
21 
22 #include <ese/ese.h>
23 
24 ESE_INCLUDE_HW(ESE_HW_ECHO);
25 
26 using ::testing::Test;
27 
28 class EseInterfaceTest : public virtual Test {
29  public:
EseInterfaceTest()30   EseInterfaceTest() : ese_(ESE_INITIALIZER(ESE_HW_ECHO)) {
31   }
~EseInterfaceTest()32   virtual ~EseInterfaceTest() { }
SetUp()33   virtual void SetUp() {
34     ASSERT_EQ(0, ese_open(&ese_, NULL));
35   }
TearDown()36   virtual void TearDown() {
37     ese_close(&ese_);
38   }
39   struct EseInterface ese_;
40 };
41 
TEST_F(EseInterfaceTest,EseTranscieveOneBlock)42 TEST_F(EseInterfaceTest, EseTranscieveOneBlock) {
43   std::vector<uint8_t> apdu;
44   std::vector<uint8_t> apdu_reply;
45   uint8_t apdu_len = 252;
46   apdu.resize(apdu_len, 'A');
47   apdu_reply.resize(256, 'B');
48   EXPECT_EQ(apdu_len, ese_transceive(&ese_, apdu.data(), apdu_len, apdu_reply.data(), apdu_reply.size()));
49   apdu_reply.resize(apdu_len);
50   EXPECT_EQ(apdu, apdu_reply);
51 };
52