mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
1f97534ae0
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.
43 lines
1.0 KiB
C++
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
|