You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2016/01/19 00:39:27 UTC

mesos git commit: Added a filter for tests using 'perf' hardware events.

Repository: mesos
Updated Branches:
  refs/heads/master 4601b8bce -> 4e98abe58


Added a filter for tests using 'perf' hardware events.

Virtual machines may not always support 'CPU performance counters'. Tests
trying to collect to 'cycle' value of 'perf' will fail under these
circumstances. This will be avoided by disabling these tests if 'perf' hardware
events are not available.

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


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

Branch: refs/heads/master
Commit: 4e98abe584efff7cf29e47dc6a83ca975b80e0ae
Parents: 4601b8b
Author: Jan Schlicht <ja...@mesosphere.io>
Authored: Tue Jan 19 00:20:49 2016 +0100
Committer: Till Toenshoff <to...@me.com>
Committed: Tue Jan 19 00:20:49 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/4e98abe5/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index 20218a0..ebb7660 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -307,6 +307,56 @@ private:
 };
 
 
+class PerfCPUCyclesFilter : public TestFilter
+{
+public:
+  PerfCPUCyclesFilter()
+  {
+#ifdef __linux__
+    bool perfUnavailable = os::system("perf help >&-") != 0;
+    if (perfUnavailable) {
+      perfError = Error(
+          "The 'perf' command wasn't found so tests using it\n"
+          "to sample the 'cpu-cycles' hardware event will not be run.");
+    } else {
+      bool cyclesUnavailable =
+        os::system("perf list hw | grep cpu-cycles >/dev/null") != 0;
+      if (cyclesUnavailable) {
+        perfError = Error(
+            "The 'cpu-cycles' hardware event of 'perf' is not available on\n"
+            "this platform so tests using it will not be run.\n"
+            "One likely reason is that the tests are run in a virtual\n"
+            "machine that does not provide CPU performance counters");
+      }
+    }
+#else
+    perfError = Error("Tests using 'perf' cannot be run on non-Linux systems");
+#endif // __linux__
+
+    if (perfError.isSome()) {
+      std::cerr
+        << "-------------------------------------------------------------\n"
+        << perfError.get().message << "\n"
+        << "-------------------------------------------------------------"
+        << std::endl;
+    }
+  }
+
+  bool disable(const ::testing::TestInfo* test) const
+  {
+    // Disable all tests that try to sample 'cpu-cycles' events using 'perf'.
+    return (matches(test, "ROOT_CGROUPS_Perf") ||
+            matches(test, "ROOT_CGROUPS_Sample") ||
+            matches(test, "ROOT_CGROUPS_UserCgroup") ||
+            matches(test, "CGROUPS_ROOT_PerfRollForward") ||
+            matches(test, "ROOT_Sample")) && perfError.isSome();
+  }
+
+private:
+  Option<Error> perfError;
+};
+
+
 class NetcatFilter : public TestFilter
 {
 public:
@@ -478,6 +528,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 PerfFilter()));
+  filters.push_back(Owned<TestFilter>(new PerfCPUCyclesFilter()));
   filters.push_back(Owned<TestFilter>(new NetcatFilter()));
   filters.push_back(Owned<TestFilter>(new CurlFilter()));