[LLVM][NFC] remove unused fields
[llvm-complete.git] / unittests / tools / llvm-exegesis / PerfHelperTest.cpp
blob39942afb85c8ccad9aca68ffc613493b83472595
1 //===-- PerfHelperTest.cpp --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "PerfHelper.h"
10 #include "llvm/Config/config.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
14 namespace llvm {
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
48 } // namespace llvm