forked from google/autofdo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
instruction_map_test.cc
46 lines (35 loc) · 1.37 KB
/
instruction_map_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: [email protected] (Dehao Chen)
// These tests check to see that instruction_map can read correct information
// from the binary.
#include "instruction_map.h"
#include <string>
#include "addr2line.h"
#include "sample_reader.h"
#include "symbol_map.h"
#include "gtest/gtest.h"
#include "third_party/abseil/absl/flags/flag.h"
ABSL_FLAG(std::string, binary, "", "Binary file name");
using devtools_crosstool_autofdo::Addr2line;
namespace {
class InstructionMapTest : public testing::Test {
protected:
static const char kTestDataDir[];
InstructionMapTest() {}
};
const char InstructionMapTest::kTestDataDir[] =
"/testdata/";
TEST_F(InstructionMapTest, PerFunctionInstructionMap) {
Addr2line *addr2line =
Addr2line::Create(::testing::SrcDir() + kTestDataDir + "test.binary");
devtools_crosstool_autofdo::SymbolMap symbol_map(
::testing::SrcDir() + kTestDataDir + "test.binary");
devtools_crosstool_autofdo::PerfDataSampleReader sample_reader(
::testing::SrcDir() + kTestDataDir + "test.lbr", "test.binary", "");
ASSERT_TRUE(sample_reader.ReadAndSetTotalCount());
devtools_crosstool_autofdo::InstructionMap inst_map(addr2line, &symbol_map);
symbol_map.AddSymbol("longest_match");
inst_map.BuildPerFunctionInstructionMap("longest_match", 0x401680, 0x401871);
delete addr2line;
}
} // namespace