1 /*
2 * Copyright (C) 2020 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_symbol_map.h"
18
19 #include <string>
20 #include <vector>
21
22 #include <gtest/gtest.h>
23
24 #include "dso.h"
25
26 using namespace simpleperf;
27
TEST(read_symbol_map,smoke)28 TEST(read_symbol_map, smoke) {
29 std::string content(
30 "\n" // skip
31 " 0x2000 0x20 two \n"
32 "0x4000\n" // skip
33 " 0x40 four\n" // skip
34 "0x1000 0x10 one\n"
35 " \n" // skip
36 "0x5000 0x50five\n" // skip
37 " skip this line\n" // skip
38 "0x6000 0x60 six six\n" // skip
39 "0x3000 48 three \n");
40
41 auto symbols = ReadSymbolMapFromString(content);
42
43 ASSERT_EQ(3u, symbols.size());
44
45 ASSERT_EQ(0x1000, symbols[0].addr);
46 ASSERT_EQ(0x10, symbols[0].len);
47 ASSERT_STREQ("one", symbols[0].Name());
48
49 ASSERT_EQ(0x2000, symbols[1].addr);
50 ASSERT_EQ(0x20, symbols[1].len);
51 ASSERT_STREQ("two", symbols[1].Name());
52
53 ASSERT_EQ(0x3000, symbols[2].addr);
54 ASSERT_EQ(0x30, symbols[2].len);
55 ASSERT_STREQ("three", symbols[2].Name());
56 }
57