You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/08/25 21:57:55 UTC

[02/11] mesos git commit: Moved setns test helper to the common test helper.

Moved setns test helper to the common test helper.

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


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

Branch: refs/heads/master
Commit: c1c8b3ef21f98296967a23bd3c2122b8ea9ba2c2
Parents: 6755a1f
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Aug 22 13:07:52 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 | 13 +++------
 src/tests/CMakeLists.txt                        |  7 +++++
 src/tests/cmake/MesosTestsConfigure.cmake       |  7 -----
 src/tests/containerizer/CMakeLists.txt          | 16 -----------
 src/tests/containerizer/ns_tests.cpp            |  4 +--
 src/tests/containerizer/setns_test_helper.cpp   | 11 +++++++-
 src/tests/containerizer/setns_test_helper.hpp   |  8 ++++++
 .../containerizer/setns_test_helper_main.cpp    | 28 --------------------
 src/tests/test_helper_main.cpp                  |  9 +++++++
 9 files changed, 40 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index f226b8f..120a715 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1906,15 +1906,6 @@ disk_full_framework_SOURCES = examples/disk_full_framework.cpp
 disk_full_framework_CPPFLAGS = $(MESOS_CPPFLAGS)
 disk_full_framework_LDADD = libmesos.la $(LDADD)
 
-if OS_LINUX
-check_PROGRAMS += setns-test-helper
-setns_test_helper_SOURCES =					\
-  tests/containerizer/setns_test_helper_main.cpp		\
-  tests/containerizer/setns_test_helper.cpp
-setns_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
-setns_test_helper_LDADD = libmesos.la $(LDADD)
-endif
-
 check_PROGRAMS += test-helper
 test_helper_SOURCES =						\
   tests/active_user_test_helper.cpp				\
@@ -1922,6 +1913,10 @@ test_helper_SOURCES =						\
   tests/test_helper_main.cpp					\
   tests/utils.cpp						\
   tests/containerizer/memory_test_helper.cpp
+if OS_LINUX
+test_helper_SOURCES +=						\
+  tests/containerizer/setns_test_helper.cpp
+endif
 test_helper_CPPFLAGS = $(mesos_tests_CPPFLAGS)
 test_helper_LDADD = libmesos.la $(mesos_tests_LDADD)
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 085ddf8..bb9f908 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -26,6 +26,13 @@ set(TEST_HELPER_SRC
   containerizer/memory_test_helper.cpp
   )
 
+if (LINUX)
+  set(TEST_HELPER_SRC
+    ${TEST_HELPER_SRC}
+    containerizer/setns_test_helper.cpp
+    )
+endif (LINUX)
+
 add_subdirectory(containerizer/)
 
 # TODO(hausdorff): Add the other tests here.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/cmake/MesosTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/src/tests/cmake/MesosTestsConfigure.cmake b/src/tests/cmake/MesosTestsConfigure.cmake
index d593b54..99435d7 100644
--- a/src/tests/cmake/MesosTestsConfigure.cmake
+++ b/src/tests/cmake/MesosTestsConfigure.cmake
@@ -19,13 +19,6 @@ set(
   CACHE STRING "Test helper target to run tests that require a subprocess."
   )
 
-if (LINUX)
-  set(
-    SETNS_TEST_HELPER_TARGET setns-test-helper
-    CACHE STRING "Test helper target that allows changing the test to its parent namespace."
-    )
-endif (LINUX)
-
 # COMPILER CONFIGURATION.
 #########################
 if (WIN32)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/CMakeLists.txt b/src/tests/containerizer/CMakeLists.txt
index 031823e..7a2dc0a 100644
--- a/src/tests/containerizer/CMakeLists.txt
+++ b/src/tests/containerizer/CMakeLists.txt
@@ -16,13 +16,6 @@
 
 # CONTAINERIZER TESTS.
 ######################
-if (LINUX)
-  set(SETNS_TEST_HELPER_SRC
-    ${SETNS_TEST_HELPER_SRC}
-    setns_test_helper_main.cpp
-    setns_test_helper.cpp
-    )
-endif (LINUX)
 
 # INCLUDE DIRECTIVES FOR CONTAINERIZER TEST BINARY (generates, e.g., -I/path/to/thing
 # on Linux).
@@ -36,18 +29,9 @@ link_directories(${CONTAINERIZER_TEST_LIB_DIRS})
 
 # THE CONTAINERIZER TEST EXECUTABLE (generates, e.g., stout_tests, etc., on Linux).
 ###########################################################################
-if (LINUX)
-  add_executable(${SETNS_TEST_HELPER_TARGET} ${SETNS_TEST_HELPER_SRC})
-endif (LINUX)
 
 # ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
 ######################################################
-if (LINUX)
-  target_link_libraries(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_LIBS})
-endif (LINUX)
 
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-if (LINUX)
-  add_dependencies(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_DEPENDENCIES})
-endif (LINUX)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/ns_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/ns_tests.cpp b/src/tests/containerizer/ns_tests.cpp
index cd668eb..1f9d679 100644
--- a/src/tests/containerizer/ns_tests.cpp
+++ b/src/tests/containerizer/ns_tests.cpp
@@ -78,11 +78,11 @@ TEST(NsTest, ROOT_setns)
   }
 
   vector<string> argv;
-  argv.push_back("setns-test-helper");
+  argv.push_back("test-helper");
   argv.push_back(SetnsTestHelper::NAME);
 
   Try<Subprocess> s = subprocess(
-      getTestHelperPath("setns-test-helper"),
+      getTestHelperPath("test-helper"),
       argv,
       Subprocess::FD(STDIN_FILENO),
       Subprocess::FD(STDOUT_FILENO),

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper.cpp b/src/tests/containerizer/setns_test_helper.cpp
index b7788ab..045caf6 100644
--- a/src/tests/containerizer/setns_test_helper.cpp
+++ b/src/tests/containerizer/setns_test_helper.cpp
@@ -28,7 +28,12 @@
 using std::set;
 using std::string;
 
-const char SetnsTestHelper::NAME[] = "SetnsTestHelper";
+namespace mesos {
+namespace internal {
+namespace tests {
+
+const char SetnsTestHelper::NAME[] = "Setns";
+
 
 int SetnsTestHelper::execute()
 {
@@ -59,3 +64,7 @@ int SetnsTestHelper::execute()
 
   return 0;
 }
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper.hpp b/src/tests/containerizer/setns_test_helper.hpp
index bd1a985..b052497 100644
--- a/src/tests/containerizer/setns_test_helper.hpp
+++ b/src/tests/containerizer/setns_test_helper.hpp
@@ -19,6 +19,10 @@
 
 #include <stout/subcommand.hpp>
 
+namespace mesos {
+namespace internal {
+namespace tests {
+
 class SetnsTestHelper : public Subcommand
 {
 public:
@@ -30,4 +34,8 @@ protected:
   virtual int execute();
 };
 
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
+
 #endif // __SETNS_TEST_HELPER_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper_main.cpp b/src/tests/containerizer/setns_test_helper_main.cpp
deleted file mode 100644
index b8f20c3..0000000
--- a/src/tests/containerizer/setns_test_helper_main.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stout/subcommand.hpp>
-
-#include "tests/containerizer/setns_test_helper.hpp"
-
-int main(int argc, char** argv)
-{
-  return Subcommand::dispatch(
-      None(),
-      argc,
-      argv,
-      new SetnsTestHelper());
-}

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
index dd1be67..06aacc3 100644
--- a/src/tests/test_helper_main.cpp
+++ b/src/tests/test_helper_main.cpp
@@ -20,9 +20,15 @@
 #include "tests/active_user_test_helper.hpp"
 
 #include "tests/containerizer/memory_test_helper.hpp"
+#ifdef __linux__
+#include "tests/containerizer/setns_test_helper.hpp"
+#endif
 
 using mesos::internal::tests::ActiveUserTestHelper;
 using mesos::internal::tests::MemoryTestHelper;
+#ifdef __linux__
+using mesos::internal::tests::SetnsTestHelper;
+#endif
 
 
 int main(int argc, char** argv)
@@ -31,6 +37,9 @@ int main(int argc, char** argv)
       None(),
       argc,
       argv,
+#ifdef __linux__
+      new SetnsTestHelper(),
+#endif
       new ActiveUserTestHelper(),
       new MemoryTestHelper());
 }