Repository: mesos
Updated Branches:
  refs/heads/master b8f2335ec -> 920930fe8


Adding perf check to configure.

PerfEventIsolatorTest.ROOT_CGROUPS_Sample requires 'perf' to be
installed.

Review: https://reviews.apache.org/r/32384


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/920930fe
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/920930fe
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/920930fe

Branch: refs/heads/master
Commit: 920930fe89f55ac08493829aa5797ba85d104367
Parents: b8f2335
Author: Isabel Jimenez <[email protected]>
Authored: Sun Jul 5 20:03:13 2015 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Sun Jul 5 20:34:27 2015 -0700

----------------------------------------------------------------------
 src/tests/environment.cpp | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/920930fe/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index f111a77..6a881ca 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -204,6 +204,41 @@ private:
 };
 
 
+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:
@@ -332,6 +367,7 @@ Environment::Environment(const Flags& _flags) : 
flags(_flags)
   filters.push_back(Owned<TestFilter>(new DockerFilter()));
   filters.push_back(Owned<TestFilter>(new BenchmarkFilter()));
   filters.push_back(Owned<TestFilter>(new NetworkIsolatorTestFilter()));
+  filters.push_back(Owned<TestFilter>(new PerfFilter()));
 
   // Construct the filter string to handle system or platform specific tests.
   ::testing::UnitTest* unitTest = ::testing::UnitTest::GetInstance();

Reply via email to