1 //===-- PerfHelperTest.cpp --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "PerfHelper.h"
10 #include "llvm/Config/config.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
19 using ::testing::IsEmpty
;
22 TEST(PerfHelperTest
, FunctionalTest
) {
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
;
31 makeArrayRef(SingleEvent
),
32 [&](const PerfEvent
&Event
, int64_t Value
) {
33 CallbackEventName
= Event
.name();
34 CallbackEventNameFullyQualifed
= Event
.getPfmEventString();
35 CallbackEventCycles
= Value
;
38 EXPECT_EQ(CallbackEventName
, "CYCLES:u");
39 EXPECT_THAT(CallbackEventNameFullyQualifed
, Not(IsEmpty()));
42 ASSERT_TRUE(pfmInitialize());
48 } // namespace exegesis