Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/tests/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -358,6 +393,7 @@ Environment::Environment(const Flags& _flags) : flags(_flags)
filters.push_back(Owned<TestFilter>(new BenchmarkFilter()));
filters.push_back(Owned<TestFilter>(new NetworkIsolatorTestFilter()));
filters.push_back(Owned<TestFilter>(new NetcatFilter()));
filters.push_back(Owned<TestFilter>(new PerfFilter()));

// Construct the filter string to handle system or platform specific tests.
::testing::UnitTest* unitTest = ::testing::UnitTest::GetInstance();
Expand Down