Repository: mesos Updated Branches: refs/heads/master 9197058ae -> fb3e77641
Added 'make bench' make target to run benchmark tests under 'src/'. - The 'benchmark' tests are the GTEST test cases or tests with the name containing 'BENCHMARK_'. - The tests can be inovked by 'make bench' command or 'make check' with a non-zero environment variable MESOS_RUN_BENCHMARKS value. Review: https://reviews.apache.org/r/20017 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fb3e7764 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fb3e7764 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fb3e7764 Branch: refs/heads/master Commit: fb3e7764186c14bddfeaa5bf9f77c4c64ddbe299 Parents: 9197058 Author: Jiang Yan Xu <y...@jxu.me> Authored: Wed Apr 2 21:43:14 2014 -0700 Committer: Jiang Yan Xu <y...@jxu.me> Committed: Tue Apr 8 22:19:23 2014 -0700 ---------------------------------------------------------------------- Makefile.am | 20 ++++++++++++++++++++ src/tests/environment.cpp | 16 +++++++++++++++- src/tests/environment.hpp | 6 +++++- src/tests/flags.hpp | 6 ++++++ src/tests/main.cpp | 2 +- 5 files changed, 47 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/fb3e7764/Makefile.am ---------------------------------------------------------------------- diff --git a/Makefile.am b/Makefile.am index bb96565..b91d8cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,26 @@ PHONY_TARGETS += maven-install endif +# Run benchmark tests. +# Currently benchmark tests exist only under src/ so the top level +# 'bench' rule calls the Makefile under src/ directly to run these +# tests, after it builds the entire program (i.e. 'all') and the test +# prerequisites (libgmock.la). +# TODO(xujyan): The use of variable 'MESOS_BENCHMARKS' on the target +# 'check' is likely going to be replaced by a long-term solution for +# benchmark testing, for which we should consider separating +# benchmark tests from the 'mesos-tests' binary (i.e. the +# 'correctness' tests). +# TODO(xujyan): Consider using `AM_EXTRA_RECURSIVE_TARGETS` macro +# (requires Automake >= 1.13) to define 'bench' as a recursive target +# when we have benchmark tests in multiple subdirs. +bench: all + @cd 3rdparty/libprocess/3rdparty && $(MAKE) $(AM_MAKEFLAGS) libgmock.la + @cd src && MESOS_BENCHMARK=1 $(MAKE) $(AM_MAKEFLAGS) check + +PHONY_TARGETS += bench + + # Using LT_OUTPUT in configure.ac creates config.lt that doesn't get # cleaned up by distclean-libtool. See this bug patch (which doesn't # appear to be in all versions of libtool.m4): http://git-wip-us.apache.org/repos/asf/mesos/blob/fb3e7764/src/tests/environment.cpp ---------------------------------------------------------------------- diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp index feeca04..1267b3e 100644 --- a/src/tests/environment.cpp +++ b/src/tests/environment.cpp @@ -109,6 +109,20 @@ static bool enable(const ::testing::TestInfo& test) return false; } #endif + + // Filter out benchmark tests when we run 'make check'. + if (strings::contains(name, "BENCHMARK_") && !flags.benchmark) { + return false; + } + } + + // Filter out regular tests when we run 'make bench', which + // requires us to check both the test case name and the test name + // at the same time. + if (flags.benchmark && + !strings::contains(test.test_case_name(), "BENCHMARK_") && + !strings::contains(test.name(), "BENCHMARK_")) { + return false; } // Now check the type parameter. @@ -130,7 +144,7 @@ static bool enable(const ::testing::TestInfo& test) // should not effect any other filters that have been put in place // either on the command line or via an environment variable. // N.B. This MUST be done _before_ invoking RUN_ALL_TESTS. -Environment::Environment() +Environment::Environment(const Flags& _flags) : flags(_flags) { // First we split the current filter into enabled and disabled tests // (which are separated by a '-'). http://git-wip-us.apache.org/repos/asf/mesos/blob/fb3e7764/src/tests/environment.hpp ---------------------------------------------------------------------- diff --git a/src/tests/environment.hpp b/src/tests/environment.hpp index 02a897b..9cf14bc 100644 --- a/src/tests/environment.hpp +++ b/src/tests/environment.hpp @@ -26,6 +26,8 @@ #include <stout/try.hpp> +#include "tests/flags.hpp" + namespace mesos { namespace internal { namespace tests { @@ -33,7 +35,7 @@ namespace tests { // Used to set up and manage the test environment. class Environment : public ::testing::Environment { public: - Environment(); + Environment(const Flags& flags); virtual void SetUp(); @@ -49,6 +51,8 @@ public: private: // Temporary directories that we created and need to remove. std::list<std::string> directories; + + const Flags flags; }; http://git-wip-us.apache.org/repos/asf/mesos/blob/fb3e7764/src/tests/flags.hpp ---------------------------------------------------------------------- diff --git a/src/tests/flags.hpp b/src/tests/flags.hpp index 9760a7a..a003e7f 100644 --- a/src/tests/flags.hpp +++ b/src/tests/flags.hpp @@ -43,6 +43,11 @@ public: "Log all severity levels to stderr", false); + add(&Flags::benchmark, + "benchmark", + "Run the benchmark tests (and skip other tests)", + false); + // We determine the defaults for 'source_dir' and 'build_dir' from // preprocessor definitions (at the time this comment was written // these were set via '-DSOURCE_DIR=...' and '-DBUILD_DIR=...' in @@ -63,6 +68,7 @@ public: } bool verbose; + bool benchmark; std::string source_dir; std::string build_dir; }; http://git-wip-us.apache.org/repos/asf/mesos/blob/fb3e7764/src/tests/main.cpp ---------------------------------------------------------------------- diff --git a/src/tests/main.cpp b/src/tests/main.cpp index ba9bf64..442be51 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -100,7 +100,7 @@ int main(int argc, char** argv) // Instantiate our environment. Note that it will be managed by // gtest after we add it via testing::AddGlobalTestEnvironment. - environment = new Environment(); + environment = new Environment(flags); testing::AddGlobalTestEnvironment(environment);