1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/unittests/tools/llvm-exegesis/PerfHelperTest.cpp
Clement Courbet 1f97534ae0 [llvm-exegesis][NFC] Let the pfm::Counter own the PerfHelper.
A perf helper is always only ever cretaed to be checked for validity
then passed as Counter ctor argument, never to be touched again.
Its lifetime should outlive that of the counter, and there is never any
reason to have two different counters of top of the perf helper.
Make sure these assumptions always hold by making the Counter consume the
PerfHelper.
2020-04-08 15:37:30 +02:00

43 lines
1.0 KiB
C++

//===-- PerfHelperTest.cpp --------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "PerfHelper.h"
#include "llvm/Config/config.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace pfm {
namespace {
using ::testing::IsEmpty;
using ::testing::Not;
TEST(PerfHelperTest, FunctionalTest) {
#ifdef HAVE_LIBPFM
ASSERT_FALSE(pfmInitialize());
PerfEvent Event("CYCLES:u");
ASSERT_TRUE(Event.valid());
EXPECT_EQ(Event.name(), "CYCLES:u");
EXPECT_THAT(Event.getPfmEventString(), Not(IsEmpty()));
Counter Cnt(std::move(Event));
Cnt.start();
Cnt.stop();
Cnt.read();
pfmTerminate();
#else
ASSERT_TRUE(pfmInitialize());
#endif
}
} // namespace
} // namespace pfm
} // namespace exegesis
} // namespace llvm