From 87a71c956d23e66e73389c957ad9902125a290cd Mon Sep 17 00:00:00 2001 From: Isabel Jimenez Date: Sun, 5 Jul 2015 20:03:13 -0700 Subject: [PATCH] :wqAdding perf check to configure. PerfEventIsolatorTest.ROOT_CGROUPS_Sample requires 'perf' to be installed. Review: https://reviews.apache.org/r/32384 --- src/tests/environment.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp index 4428e547b..ce838201e 100644 --- a/src/tests/environment.cpp +++ b/src/tests/environment.cpp @@ -229,6 +229,41 @@ class NetcatFilter : public TestFilter }; +class PerfFilter : public TestFilter +{ +public: + PerfFilter() + { +#ifdef __linux__ + perfError = os::system("perf help >&-") != 0; + if (perfError) { + std::cerr + << "-------------------------------------------------------------\n" + << "No 'perf' command found so no 'perf' tests will be run\n" + << "-------------------------------------------------------------" + << std::endl; + } +#else + perfError = true; +#endif // __linux__ + } + + bool disable(const ::testing::TestInfo* test) const + { + // Currently all tests that require 'perf' are part of the + // 'PerfTest' test fixture, hence we check for 'Perf' here. + // + // TODO(ijimenez): Replace all tests which require 'perf' with + // the prefix 'PERF_' to be more consistent with the filter + // naming we've done (i.e., ROOT_, CGROUPS_, etc). + return matches(test, "Perf") && perfError; + } + +private: + bool perfError; +}; + + class BenchmarkFilter : public TestFilter { public: @@ -358,6 +393,7 @@ Environment::Environment(const Flags& _flags) : flags(_flags) filters.push_back(Owned(new BenchmarkFilter())); filters.push_back(Owned(new NetworkIsolatorTestFilter())); filters.push_back(Owned(new NetcatFilter())); + filters.push_back(Owned(new PerfFilter())); // Construct the filter string to handle system or platform specific tests. ::testing::UnitTest* unitTest = ::testing::UnitTest::GetInstance();