1 /* 2 * Copyright (c) 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 16 #include <gtest/gtest.h> 17 #include <string> 18 #include "disassembler.h" 19 20 using namespace testing::ext; 21 22 namespace panda::disasm { 23 class DisasmReleaseTest : public testing::Test { 24 public: SetUpTestCase(void)25 static void SetUpTestCase(void) {}; TearDownTestCase(void)26 static void TearDownTestCase(void) {}; SetUp()27 void SetUp() {}; TearDown()28 void TearDown() {}; 29 }; 30 31 /** 32 * @tc.name: disassembler_line_release_test_001 33 * @tc.desc: Check abc file line number function in release. 34 * @tc.type: FUNC 35 * @tc.require: file path and name 36 */ 37 HWTEST_F(DisasmReleaseTest, disassembler_line_release_test_001, TestSize.Level1) 38 { 39 const std::string file_name = GRAPH_TEST_ABC_DIR "line_number_release.abc"; 40 panda::disasm::Disassembler disasm {}; 41 disasm.Disassemble(file_name, false, false); 42 disasm.CollectInfo(); 43 // The known line number in the abc file 44 std::vector<size_t> expectedLineNumber = {17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38, 40, 45 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58, 60, 61, 62, 64, 46 66, -1}; 47 std::vector<size_t> lineNumber = disasm.GetLineNumber(); 48 ASSERT_EQ(expectedLineNumber.size(), lineNumber.size()); 49 for (size_t i = 0; i < lineNumber.size(); ++i) { 50 std::cout << lineNumber[i] << std::endl; 51 EXPECT_EQ(expectedLineNumber[i], lineNumber[i]); 52 } 53 } 54 55 }