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
;
30 Measure(llvm::makeArrayRef(SingleEvent
),
31 [&](const PerfEvent
&Event
, int64_t Value
) {
32 CallbackEventName
= Event
.name();
33 CallbackEventNameFullyQualifed
= Event
.getPfmEventString();
34 CallbackEventCycles
= Value
;
37 EXPECT_EQ(CallbackEventName
, "CYCLES:u");
38 EXPECT_THAT(CallbackEventNameFullyQualifed
, Not(IsEmpty()));
41 ASSERT_TRUE(pfmInitialize());
47 } // namespace exegesis