You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 10:53:12 UTC

svn commit: r1132165 - in /incubator/mesos/trunk/src: examples/ tests/

Author: benh
Date: Sun Jun  5 08:53:11 2011
New Revision: 1132165

URL: http://svn.apache.org/viewvc?rev=1132165&view=rev
Log:
Cleaned up the test directory (renamed some files, updated some includes, moved some tests into different directories, cleaned up some code).

Added:
    incubator/mesos/trunk/src/tests/configurator_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_configurator.cpp
    incubator/mesos/trunk/src/tests/errors_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_errors.cpp
    incubator/mesos/trunk/src/tests/lxc_isolation_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_lxc_isolation.cpp
    incubator/mesos/trunk/src/tests/master_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_master.cpp
    incubator/mesos/trunk/src/tests/resources_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_resources.cpp
    incubator/mesos/trunk/src/tests/sample_frameworks_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_sample_frameworks.cpp
    incubator/mesos/trunk/src/tests/string_utils_test.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/test_string_utils.cpp
    incubator/mesos/trunk/src/tests/utils.cpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/testing_utils.cpp
    incubator/mesos/trunk/src/tests/utils.hpp
      - copied, changed from r1132164, incubator/mesos/trunk/src/tests/testing_gmock.hpp
Removed:
    incubator/mesos/trunk/src/tests/test_configurator.cpp
    incubator/mesos/trunk/src/tests/test_errors.cpp
    incubator/mesos/trunk/src/tests/test_lxc_isolation.cpp
    incubator/mesos/trunk/src/tests/test_master.cpp
    incubator/mesos/trunk/src/tests/test_resources.cpp
    incubator/mesos/trunk/src/tests/test_sample_frameworks.cpp
    incubator/mesos/trunk/src/tests/test_string_utils.cpp
    incubator/mesos/trunk/src/tests/testing_gmock.hpp
    incubator/mesos/trunk/src/tests/testing_utils.cpp
    incubator/mesos/trunk/src/tests/testing_utils.hpp
Modified:
    incubator/mesos/trunk/src/examples/Makefile.in
    incubator/mesos/trunk/src/tests/Makefile.in
    incubator/mesos/trunk/src/tests/external_test.cpp
    incubator/mesos/trunk/src/tests/main.cpp

Modified: incubator/mesos/trunk/src/examples/Makefile.in
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/Makefile.in?rev=1132165&r1=1132164&r2=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/Makefile.in (original)
+++ incubator/mesos/trunk/src/examples/Makefile.in Sun Jun  5 08:53:11 2011
@@ -37,10 +37,6 @@ ZOOKEEPER = third_party/zookeeper-3.3.1/
 CFLAGS += -g
 CXXFLAGS += -g
 
-# Add source dir to CFLAGS and CXXFLAGS.
-CFLAGS += -I@srcdir@
-CXXFLAGS += -I@srcdir@
-
 # Add include to CFLAGS and CXXFLAGS.
 CFLAGS += -I@top_srcdir@/include
 CXXFLAGS += -I@top_srcdir@/include

Modified: incubator/mesos/trunk/src/tests/Makefile.in
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/Makefile.in?rev=1132165&r1=1132164&r2=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/Makefile.in (original)
+++ incubator/mesos/trunk/src/tests/Makefile.in Sun Jun  5 08:53:11 2011
@@ -22,8 +22,7 @@ LIBPROCESS = third_party/libprocess
 LIBEV = $(LIBPROCESS)/third_party/libev-3.8
 
 GLOG = third_party/glog-0.3.1
-GTEST = third_party/gtest-1.5.0
-SQLITE = third_party/sqlite-3.6.23.1
+GMOCK = third_party/gmock-1.5.0
 
 ZOOKEEPER = third_party/zookeeper-3.3.1/src/c
 
@@ -31,7 +30,7 @@ ZOOKEEPER = third_party/zookeeper-3.3.1/
 CFLAGS += -g
 CXXFLAGS += -g
 
-# Add source dir and build dir to CFLAGS and CXXFLAGS.
+# Add 'src' source dir and build dir to CFLAGS and CXXFLAGS.
 CFLAGS += -I@srcdir@/.. -I..
 CXXFLAGS += -I@srcdir@/.. -I..
 
@@ -51,9 +50,9 @@ LDFLAGS += -L@top_builddir@/$(LIBPROCESS
 # Add libev to LDFLAGS.
 LDFLAGS += -L@top_builddir@/$(LIBEV)/.libs
 
-# Add glog and gtest to include paths.
-CXXFLAGS += -I@top_srcdir@/$(GLOG)/src -I@top_builddir@/$(GLOG)/src -I@top_srcdir@/$(GTEST)/include -I@top_srcdir@/$(SQLITE)
-LDFLAGS += -L@top_builddir@/$(GLOG)/.libs -L@top_builddir@/$(GTEST)/lib/.libs -L@top_builddir@/$(SQLITE)/.libs
+# Add glog, and gmock/gtest to include paths and library paths.
+CXXFLAGS += -I@top_srcdir@/$(GLOG)/src -I@top_builddir@/$(GLOG)/src -I@top_srcdir@/$(GMOCK)/include -I@top_srcdir@/$(GMOCK)/gtest/include
+LDFLAGS += -L@top_builddir@/$(GLOG)/.libs -L@top_builddir@/$(GMOCK)/lib/.libs -L@top_builddir@/$(GMOCK)/gtest/lib/.libs
 
 # Add included ZooKeeper to include and lib paths if necessary.
 ifeq ($(WITH_INCLUDED_ZOOKEEPER),1)
@@ -73,8 +72,8 @@ CXXFLAGS += -DBUILD_DATE="\"$$(date '+%Y
 CFLAGS += -DBUILD_USER="\"$$USER\""
 CXXFLAGS += -DBUILD_USER="\"$$USER\""
 
-# Add glog, gtest, libev, libprocess, pthread, and dl to LIBS.
-LIBS += -lglog -lgtest -lprocess -lev -lpthread -ldl -lsqlite3
+# Add glog, gmock, gtest, libev, libprocess, pthread, and dl to LIBS.
+LIBS += -lglog -lgmock -lgtest -lprocess -lev -lpthread -ldl
 
 # Add ZooKeeper if necessary.
 ifeq ($(WITH_ZOOKEEPER),1)
@@ -84,12 +83,12 @@ endif
 SCHED_LIB = $(LIBDIR)/libmesos_sched.a
 EXEC_LIB = $(LIBDIR)/libmesos_exec.a
 
-TESTS_OBJ = main.o test_master.o test_resources.o external_test.o	\
-	    test_sample_frameworks.o testing_utils.o			\
-	    test_configurator.o test_string_utils.o			\
-	    test_lxc_isolation.o test_event_history.o
+TESTS_OBJ = main.o utils.o master_test.o errors_test.o			\
+	    resources_test.o external_test.o sample_frameworks_test.o	\
+	    configurator_test.o string_utils_test.o			\
+	    lxc_isolation_test.o
 
-ALLTESTS_EXE = $(BINDIR)/tests/alltests
+ALLTESTS_EXE = $(BINDIR)/tests/all-tests
 
 EXTERNAL_SCRIPTS =							\
   $(BINDIR)/tests/external/LxcIsolation/HoldMoreMemThanRequested.sh	\
@@ -115,7 +114,7 @@ DIRECTORIES = $(BINDIR)/tests           
 default: all
 
 -include $(patsubst %.o, %.d, $(TESTS_OBJ))
--include $(patsubst %, %.d, alltests)
+-include $(patsubst %, %.d, $(ALLTESTS_EXE))
 
 $(DIRECTORIES): %:
 	mkdir -p $@

Copied: incubator/mesos/trunk/src/tests/configurator_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_configurator.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/configurator_test.cpp?p2=incubator/mesos/trunk/src/tests/configurator_test.cpp&p1=incubator/mesos/trunk/src/tests/test_configurator.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_configurator.cpp (original)
+++ incubator/mesos/trunk/src/tests/configurator_test.cpp Sun Jun  5 08:53:11 2011
@@ -1,20 +1,17 @@
 #include <gtest/gtest.h>
 
-#include <iostream>
 #include <fstream>
 
 #include <boost/lexical_cast.hpp>
 
-#include "testing_utils.hpp"
+#include <configurator/configurator.hpp>
 
-#include "configurator/configurator.hpp"
+#include <tests/utils.hpp>
+
+using boost::lexical_cast;
 
 using std::ofstream;
 using std::string;
-using std::vector;
-using std::cout;
-
-using boost::lexical_cast;
 
 using namespace mesos;
 using namespace mesos::internal;

Copied: incubator/mesos/trunk/src/tests/errors_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_errors.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/errors_test.cpp?p2=incubator/mesos/trunk/src/tests/errors_test.cpp&p1=incubator/mesos/trunk/src/tests/test_errors.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_errors.cpp (original)
+++ incubator/mesos/trunk/src/tests/errors_test.cpp Sun Jun  5 08:53:11 2011
@@ -5,15 +5,15 @@
 
 #include <boost/lexical_cast.hpp>
 
-#include "common/date_utils.hpp"
+#include <common/date_utils.hpp>
 
-#include "local/local.hpp"
+#include <local/local.hpp>
 
-#include "master/master.hpp"
+#include <master/master.hpp>
 
-#include "slave/isolation_module.hpp"
-#include "slave/process_based_isolation_module.hpp"
-#include "slave/slave.hpp"
+#include <slave/isolation_module.hpp>
+#include <slave/process_based_isolation_module.hpp>
+#include <slave/slave.hpp>
 
 using namespace mesos;
 using namespace mesos::internal;

Modified: incubator/mesos/trunk/src/tests/external_test.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/external_test.cpp?rev=1132165&r1=1132164&r2=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/external_test.cpp (original)
+++ incubator/mesos/trunk/src/tests/external_test.cpp Sun Jun  5 08:53:11 2011
@@ -6,14 +6,15 @@
 
 #include <boost/lexical_cast.hpp>
 
-#include "external_test.hpp"
-#include "testing_utils.hpp"
+#include <common/fatal.hpp>
 
-#include "common/fatal.hpp"
+#include <tests/external_test.hpp>
+#include <tests/utils.hpp>
 
-using std::string;
 using namespace mesos::internal::test;
 
+using std::string;
+
 
 /**
  * Run an external test with the given name. The test is expected to be

Copied: incubator/mesos/trunk/src/tests/lxc_isolation_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_lxc_isolation.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/lxc_isolation_test.cpp?p2=incubator/mesos/trunk/src/tests/lxc_isolation_test.cpp&p1=incubator/mesos/trunk/src/tests/test_lxc_isolation.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_lxc_isolation.cpp (original)
+++ incubator/mesos/trunk/src/tests/lxc_isolation_test.cpp Sun Jun  5 08:53:11 2011
@@ -1,6 +1,7 @@
 #include <gtest/gtest.h>
 
-#include "external_test.hpp"
+#include <tests/external_test.hpp>
+
 
 // Run a number of tests for the LXC isolation module.
 // These tests are disabled by default since they require alltests to be run

Modified: incubator/mesos/trunk/src/tests/main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/main.cpp?rev=1132165&r1=1132164&r2=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/main.cpp (original)
+++ incubator/mesos/trunk/src/tests/main.cpp Sun Jun  5 08:53:11 2011
@@ -1,17 +1,17 @@
 #include <glog/logging.h>
+
 #include <gtest/gtest.h>
 
 #include <libgen.h>
 #include <stdlib.h>
 
-#include <iostream>
 #include <string>
 
-#include "testing_utils.hpp"
+#include <common/fatal.hpp>
 
-#include "common/fatal.hpp"
+#include <configurator/configurator.hpp>
 
-#include "configurator/configurator.hpp"
+#include <tests/utils.hpp>
 
 using namespace mesos::internal;
 using namespace mesos::internal::test;

Copied: incubator/mesos/trunk/src/tests/master_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_master.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/master_test.cpp?p2=incubator/mesos/trunk/src/tests/master_test.cpp&p1=incubator/mesos/trunk/src/tests/test_master.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/master_test.cpp Sun Jun  5 08:53:11 2011
@@ -5,15 +5,15 @@
 
 #include <boost/lexical_cast.hpp>
 
-#include "local/local.hpp"
+#include <local/local.hpp>
 
-#include "master/master.hpp"
+#include <master/master.hpp>
 
-#include "slave/isolation_module.hpp"
-#include "slave/process_based_isolation_module.hpp"
-#include "slave/slave.hpp"
+#include <slave/isolation_module.hpp>
+#include <slave/process_based_isolation_module.hpp>
+#include <slave/slave.hpp>
 
-#include "testing_gmock.hpp"
+#include <tests/utils.hpp>
 
 using namespace mesos;
 using namespace mesos::internal;

Copied: incubator/mesos/trunk/src/tests/resources_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_resources.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/resources_test.cpp?p2=incubator/mesos/trunk/src/tests/resources_test.cpp&p1=incubator/mesos/trunk/src/tests/test_resources.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_resources.cpp (original)
+++ incubator/mesos/trunk/src/tests/resources_test.cpp Sun Jun  5 08:53:11 2011
@@ -3,7 +3,7 @@
 
 #include <gtest/gtest.h>
 
-#include "master/master.hpp"
+#include <master/master.hpp>
 
 using namespace mesos;
 using namespace mesos::internal;

Copied: incubator/mesos/trunk/src/tests/sample_frameworks_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_sample_frameworks.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/sample_frameworks_test.cpp?p2=incubator/mesos/trunk/src/tests/sample_frameworks_test.cpp&p1=incubator/mesos/trunk/src/tests/test_sample_frameworks.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_sample_frameworks.cpp (original)
+++ incubator/mesos/trunk/src/tests/sample_frameworks_test.cpp Sun Jun  5 08:53:11 2011
@@ -1,7 +1,9 @@
 #include <gtest/gtest.h>
 
-#include "config/config.hpp"
-#include "external_test.hpp"
+#include <config/config.hpp>
+
+#include <tests/external_test.hpp>
+
 
 // Run each of the sample frameworks in local mode
 TEST_EXTERNAL(SampleFrameworks, CFramework)

Copied: incubator/mesos/trunk/src/tests/string_utils_test.cpp (from r1132164, incubator/mesos/trunk/src/tests/test_string_utils.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/string_utils_test.cpp?p2=incubator/mesos/trunk/src/tests/string_utils_test.cpp&p1=incubator/mesos/trunk/src/tests/test_string_utils.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_string_utils.cpp (original)
+++ incubator/mesos/trunk/src/tests/string_utils_test.cpp Sun Jun  5 08:53:11 2011
@@ -1,10 +1,9 @@
 #include <gtest/gtest.h>
 
-#include <sstream>
 #include <string>
 #include <vector>
 
-#include "common/string_utils.hpp"
+#include <common/string_utils.hpp>
 
 using std::string;
 using std::vector;

Copied: incubator/mesos/trunk/src/tests/utils.cpp (from r1132164, incubator/mesos/trunk/src/tests/testing_utils.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.cpp?p2=incubator/mesos/trunk/src/tests/utils.cpp&p1=incubator/mesos/trunk/src/tests/testing_utils.cpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/testing_utils.cpp (original)
+++ incubator/mesos/trunk/src/tests/utils.cpp Sun Jun  5 08:53:11 2011
@@ -4,7 +4,7 @@
 
 #include <gtest/gtest.h>
 
-#include "testing_utils.hpp"
+#include <tests/utils.hpp>
 
 using std::string;
 

Copied: incubator/mesos/trunk/src/tests/utils.hpp (from r1132164, incubator/mesos/trunk/src/tests/testing_gmock.hpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?p2=incubator/mesos/trunk/src/tests/utils.hpp&p1=incubator/mesos/trunk/src/tests/testing_gmock.hpp&r1=1132164&r2=1132165&rev=1132165&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/testing_gmock.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Sun Jun  5 08:53:11 2011
@@ -1,14 +1,48 @@
-#ifndef __TESTING_GMOCK_HPP__
-#define __TESTING_GMOCK_HPP__
+#ifndef __TESTING_UTILS_HPP__
+#define __TESTING_UTILS_HPP__
 
 #include <string>
 
+#include <mesos_exec.hpp>
+#include <mesos_sched.hpp>
+
+#include <process.hpp>
+
 #include <gmock/gmock.h>
 
 
 namespace mesos { namespace internal { namespace test {
 
 /**
+ * The location where Mesos is installed, used by tests to locate various
+ * frameworks and binaries. For now it points to the src directory, until
+ * we clean up our directory structure a little. Initialized in main.cpp.
+ */
+extern std::string mesosHome;
+
+
+/**
+ * Create and clean up the work directory for a given test, and cd into it,
+ * given the test's test case name and test name.
+ * Test directories are placed in <mesosHome>/test_output/<testCase>/<testName>.
+ */
+void enterTestDirectory(const char* testCase, const char* testName);
+
+
+/**
+ * Macro for running a test in a work directory (using enterTestDirectory).
+ * Used in a similar way to gtest's TEST macro (by adding a body in braces).
+ */
+#define TEST_WITH_WORKDIR(testCase, testName) \
+  void runTestBody_##testCase##_##testName(); \
+  TEST(testCase, testName) { \
+    enterTestDirectory(#testCase, #testName); \
+    runTestBody_##testCase##_##testName(); \
+  } \
+  void runTestBody_##testCase##_##testName() /* User code block follows */
+
+
+/**
  * Definition of a mock Scheduler to be used in tests with gmock.
  */
 class MockScheduler : public Scheduler
@@ -115,7 +149,7 @@ ACTION_P(Trigger, trigger) { trigger->va
   } while (false)
 
 
-}}} // namespace mesos { namespace internal { namespace test {
+}}} // namespace mesos::internal::test
 
 
-#endif /* __TESTING_GMOCK_HPP__ */
+#endif /* __TESTING_UTILS_HPP__ */