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 //===----------------------------------------------------------------------===// 8 9 #include "PerfHelper.h" 10 #include "llvm/Config/config.h" 11 #include "gmock/gmock.h" 12 #include "gtest/gtest.h" 13 14 namespace llvm { 15 namespace exegesis { 16 namespace pfm { 17 namespace { 18 19 using ::testing::IsEmpty; 20 using ::testing::Not; 21 TEST(PerfHelperTest,FunctionalTest)22TEST(PerfHelperTest, FunctionalTest) { 23 #ifdef HAVE_LIBPFM 24 ASSERT_FALSE(pfmInitialize()); 25 PerfEvent Event("CYCLES:u"); 26 ASSERT_TRUE(Event.valid()); 27 EXPECT_EQ(Event.name(), "CYCLES:u"); 28 EXPECT_THAT(Event.getPfmEventString(), Not(IsEmpty())); 29 Counter Cnt(std::move(Event)); 30 Cnt.start(); 31 Cnt.stop(); 32 Cnt.read(); 33 pfmTerminate(); 34 #else 35 ASSERT_TRUE(pfmInitialize()); 36 #endif 37 } 38 39 } // namespace 40 } // namespace pfm 41 } // namespace exegesis 42 } // namespace llvm 43