[llvm-exegesis] Rename InstructionInstance into InstructionBuilder.
[llvm-core.git] / unittests / tools / llvm-exegesis / PerfHelperTest.cpp
bloba8205f9e3eb274175eaf43e94415ba3531f91fd7
1 //===-- PerfHelperTest.cpp --------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "PerfHelper.h"
11 #include "llvm/Config/config.h"
12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h"
15 namespace exegesis {
16 namespace pfm {
17 namespace {
19 using ::testing::IsEmpty;
20 using ::testing::Not;
22 TEST(PerfHelperTest, FunctionalTest) {
23 #ifdef HAVE_LIBPFM
24 ASSERT_FALSE(pfmInitialize());
25 const PerfEvent SingleEvent("CYCLES:u");
26 const auto &EmptyFn = []() {};
27 std::string CallbackEventName;
28 std::string CallbackEventNameFullyQualifed;
29 int64_t CallbackEventCycles;
30 Measure(llvm::makeArrayRef(SingleEvent),
31 [&](const PerfEvent &Event, int64_t Value) {
32 CallbackEventName = Event.name();
33 CallbackEventNameFullyQualifed = Event.getPfmEventString();
34 CallbackEventCycles = Value;
36 EmptyFn);
37 EXPECT_EQ(CallbackEventName, "CYCLES:u");
38 EXPECT_THAT(CallbackEventNameFullyQualifed, Not(IsEmpty()));
39 pfmTerminate();
40 #else
41 ASSERT_TRUE(pfmInitialize());
42 #endif
45 } // namespace
46 } // namespace pfm
47 } // namespace exegesis