1 /*
2 * Copyright (C) 2018 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
17 #include "read_dex_file.h"
18
19 #include <gtest/gtest.h>
20
21 #include <algorithm>
22
23 #include "dso.h"
24 #include "get_test_data.h"
25 #include "test_util.h"
26 #include "utils.h"
27
28 using namespace simpleperf;
29
TEST(read_dex_file,smoke)30 TEST(read_dex_file, smoke) {
31 std::vector<Symbol> symbols;
32 auto symbol_callback = [&](DexFileSymbol* symbol) {
33 symbols.emplace_back(symbol->name, symbol->addr, symbol->size);
34 };
35 ASSERT_TRUE(ReadSymbolsFromDexFile(GetTestData("base.vdex"), {0x28}, symbol_callback));
36 ASSERT_EQ(12435u, symbols.size());
37 auto it = std::find_if(symbols.begin(), symbols.end(),
38 [](const Symbol& symbol) { return symbol.addr == 0x6c77e; });
39 ASSERT_NE(it, symbols.end());
40 ASSERT_EQ(it->addr, 0x6c77e);
41 ASSERT_EQ(it->len, 0x16);
42 ASSERT_STREQ(it->Name(), "com.example.simpleperf.simpleperfexamplewithnative.MixActivity$1.run");
43 }
44