[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / unittests / tools / llvm-exegesis / PerfHelperTest.cpp
blob7ff256f454fa5088695318ef413bd6e43bdd2bdf
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(
31 makeArrayRef(SingleEvent),
32 [&](const PerfEvent &Event, int64_t Value) {
33 CallbackEventName = Event.name();
34 CallbackEventNameFullyQualifed = Event.getPfmEventString();
35 CallbackEventCycles = Value;
37 EmptyFn);
38 EXPECT_EQ(CallbackEventName, "CYCLES:u");
39 EXPECT_THAT(CallbackEventNameFullyQualifed, Not(IsEmpty()));
40 pfmTerminate();
41 #else
42 ASSERT_TRUE(pfmInitialize());
43 #endif
46 } // namespace
47 } // namespace pfm
48 } // namespace exegesis
49 } // namespace llvm