1 /* 2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include <memory> 16 #include <gtest/gtest.h> 17 #include "block_head.h" 18 19 namespace OHOS { 20 namespace SignatureTools { 21 22 /* 23 * 测试套件,固定写法 24 */ 25 class BlockHeadTest : public testing::Test { 26 public: SetUpTestCase(void)27 static void SetUpTestCase(void) 28 { 29 }; TearDownTestCase()30 static void TearDownTestCase() 31 { 32 }; SetUp()33 void SetUp() 34 { 35 }; TearDown()36 void TearDown() 37 { 38 }; 39 }; 40 41 /** 42 * @tc.name: GetBlockHead 43 * @tc.desc: Test get block head for SUCCESS. 44 * @tc.size: MEDIUM 45 * @tc.type: FUNC 46 * @tc.level Level 1 47 * @tc.require: SR000H63TL 48 */ 49 HWTEST_F(BlockHeadTest, GetBlockHead, testing::ext::TestSize.Level1) 50 { 51 std::shared_ptr<BlockHead> api = std::make_shared<BlockHead>(); 52 std::string blockHead = api->GetBlockHead(0, 0, 0, 29148868); 53 EXPECT_NE(blockHead.size(), 0); 54 } 55 56 /** 57 * @tc.name: GetBlockHeadLittleEndian 58 * @tc.desc: Test get block head by little endian for SUCCESS. 59 * @tc.size: MEDIUM 60 * @tc.type: FUNC 61 * @tc.level Level 1 62 * @tc.require: SR000H63TL 63 */ 64 HWTEST_F(BlockHeadTest, GetBlockHeadLittleEndian, testing::ext::TestSize.Level1) 65 { 66 std::shared_ptr<BlockHead> api = std::make_shared<BlockHead>(); 67 std::vector<int8_t> head = api->GetBlockHeadLittleEndian(0, 0, 0, 29148868); 68 EXPECT_NE(head.size(), 0); 69 } 70 71 /** 72 * @tc.name: GetBlockLen 73 * @tc.desc: Test get block length for SUCCESS. 74 * @tc.size: MEDIUM 75 * @tc.type: FUNC 76 * @tc.level Level 1 77 * @tc.require: SR000H63TL 78 */ 79 HWTEST_F(BlockHeadTest, GetBlockLen, testing::ext::TestSize.Level1) 80 { 81 std::shared_ptr<BlockHead> api = std::make_shared<BlockHead>(); 82 int blockLen = api->GetBlockLen(); 83 EXPECT_EQ(blockLen, 8); 84 } 85 86 /** 87 * @tc.name: GetElfBlockLen 88 * @tc.desc: Test get elf block length for SUCCESS. 89 * @tc.size: MEDIUM 90 * @tc.type: FUNC 91 * @tc.level Level 1 92 * @tc.require: SR000H63TL 93 */ 94 HWTEST_F(BlockHeadTest, GetElfBlockLen, testing::ext::TestSize.Level1) 95 { 96 std::shared_ptr<BlockHead> api = std::make_shared<BlockHead>(); 97 int elfBlockLen = api->GetElfBlockLen(); 98 EXPECT_EQ(elfBlockLen, 12); 99 } 100 } // namespace SignatureTools 101 } // namespace OHOS