Refactor of Security Containers project structure
authorLukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Mon, 31 Mar 2014 17:25:03 +0000 (19:25 +0200)
committerJan Olszak <j.olszak@samsung.com>
Mon, 19 May 2014 11:47:15 +0000 (13:47 +0200)
[Bug/Feature]   Complete refactoring of directory structure
[Cause]         The old structure was hard to mantain in terms
                of keeping filenames and namespaces consistent
                and nicely ordered.
[Solution]      Made the structure more organized and flat,
                refactored several filenames and their namespaces.
                - "common" - holds all the common modules and
                  parts of the code that can be resued between
                  different targets
                - "client" - client target
                - "server" - server target
                - "unit_tests" - target gathering all unit tests
                  and their dependencies
[Verification]  Built, installed, run tests on host, built RPM, built doc

Change-Id: I728fe2de688f8a0398d7fa348888e5ef7cd77dbf
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
95 files changed:
.gitignore
CMakeLists.txt
client/CMakeLists.txt [new file with mode: 0644]
client/exception.hpp [new file with mode: 0644]
client/main.cpp [new file with mode: 0644]
client/security-containers-client.h [moved from src/client/include/security-containers-client.h with 92% similarity]
client/security-containers.pc.in [moved from security-containers.pc.in with 100% similarity]
common/base-exception.hpp [moved from src/server/include/base-exception.hpp with 90% similarity]
common/config/configuration.cpp [moved from src/server/src/scs-configuration.cpp with 96% similarity]
common/config/configuration.hpp [moved from src/server/include/scs-configuration.hpp with 89% similarity]
common/config/exception.hpp [new file with mode: 0644]
common/dbus/connection.cpp [moved from src/server/src/dbus-connection.cpp with 99% similarity]
common/dbus/connection.hpp [moved from src/server/include/dbus-connection.hpp with 97% similarity]
common/dbus/exception.hpp [moved from src/server/include/dbus-exception.hpp with 93% similarity]
common/log/backend-null.hpp [moved from src/server/include/log-backend-null.hpp with 87% similarity]
common/log/backend-stderr.cpp [moved from src/server/src/log-backend-stderr.cpp with 93% similarity]
common/log/backend-stderr.hpp [moved from src/server/include/log-backend-stderr.hpp with 86% similarity]
common/log/backend.hpp [moved from src/server/include/log-backend.hpp with 90% similarity]
common/log/logger.cpp [moved from src/server/src/log.cpp with 96% similarity]
common/log/logger.hpp [moved from src/server/include/log.hpp with 93% similarity]
common/utils/file-wait.cpp [moved from src/server/src/utils-file-wait.cpp with 94% similarity]
common/utils/file-wait.hpp [moved from src/server/include/utils-file-wait.hpp with 90% similarity]
common/utils/glib-loop.cpp [moved from src/server/src/utils-glib-loop.cpp with 95% similarity]
common/utils/glib-loop.hpp [moved from src/server/include/utils-glib-loop.hpp with 92% similarity]
common/utils/latch.cpp [moved from src/server/src/utils-latch.cpp with 96% similarity]
common/utils/latch.hpp [moved from src/server/include/utils-latch.hpp with 93% similarity]
common/utils/paths.hpp [moved from src/server/include/utils.hpp with 94% similarity]
doc/doxygen.cfg
packaging/security-containers.spec
server/CMakeLists.txt [moved from src/server/src/CMakeLists.txt with 77% similarity]
server/configs/CMakeLists.txt [moved from src/CMakeLists.txt with 57% similarity]
server/configs/containers/xminimal.conf [moved from src/server/config/containers/xminimal.conf with 100% similarity]
server/configs/daemon.conf [moved from src/server/config/daemon.conf with 100% similarity]
server/configs/libvirt-config/xminimal.xml [moved from src/server/config/libvirt-config/xminimal.xml with 100% similarity]
server/container-admin.cpp [moved from src/server/src/scs-container-admin.cpp with 98% similarity]
server/container-admin.hpp [moved from src/server/include/scs-container-admin.hpp with 94% similarity]
server/container-config.hpp [moved from src/server/include/scs-container-config.hpp with 84% similarity]
server/container.cpp [moved from src/server/src/scs-container.cpp with 95% similarity]
server/container.hpp [moved from src/server/include/scs-container.hpp with 89% similarity]
server/containers-manager-config.hpp [moved from src/server/include/scs-container-manager-config.hpp with 75% similarity]
server/containers-manager.cpp [moved from src/server/src/scs-container-manager.cpp with 86% similarity]
server/containers-manager.hpp [moved from src/server/include/scs-container-manager.hpp with 80% similarity]
server/exception.hpp [moved from src/server/include/scs-exception.hpp with 80% similarity]
server/main.cpp [moved from src/server/src/main.cpp with 96% similarity]
src/client/CMakeLists.txt [deleted file]
src/client/include/sc-client.hpp [deleted file]
src/client/include/scc-exception.hpp [deleted file]
src/client/src/sc-client.cpp [deleted file]
src/server/CMakeLists.txt [deleted file]
src/server/include/scs.hpp [deleted file]
src/server/src/scs.cpp [deleted file]
src/server/unit_tests/CMakeLists.txt [deleted file]
src/server/unit_tests/config/ut-scs-container-admin/containers/buggy.conf [deleted file]
src/server/unit_tests/config/ut-scs-container-admin/containers/test.conf [deleted file]
unit_tests/CMakeLists.txt [new file with mode: 0644]
unit_tests/config/ut-configuration.cpp [moved from src/server/unit_tests/ut-scs-configuration.cpp with 98% similarity]
unit_tests/dbus/configs/CMakeLists.txt [moved from src/client/src/CMakeLists.txt with 63% similarity]
unit_tests/dbus/configs/ut-connection/ut-dbus.conf [moved from src/server/unit_tests/config/ut-dbus-connection/ut-dbus.conf with 100% similarity]
unit_tests/dbus/test-client.cpp [moved from src/server/unit_tests/dbus-test-client.cpp with 94% similarity]
unit_tests/dbus/test-client.hpp [moved from src/server/unit_tests/dbus-test-client.hpp with 86% similarity]
unit_tests/dbus/test-common.hpp [moved from src/server/unit_tests/dbus-test-common.hpp with 93% similarity]
unit_tests/dbus/test-server.cpp [moved from src/server/unit_tests/dbus-test-server.cpp with 95% similarity]
unit_tests/dbus/test-server.hpp [moved from src/server/unit_tests/dbus-test-server.hpp with 90% similarity]
unit_tests/dbus/ut-connection.cpp [moved from src/server/unit_tests/ut-dbus-connection.cpp with 96% similarity]
unit_tests/log/ut-logger.cpp [moved from src/server/unit_tests/ut-log.cpp with 97% similarity]
unit_tests/scripts/CMakeLists.txt [moved from src/scripts/CMakeLists.txt with 91% similarity]
unit_tests/scripts/sc_all_tests.py [moved from src/scripts/sc_all_tests.py with 100% similarity]
unit_tests/scripts/sc_launch_test.py [moved from src/scripts/sc_launch_test.py with 100% similarity]
unit_tests/scripts/sc_test_parser.py [moved from src/scripts/sc_test_parser.py with 100% similarity]
unit_tests/server/configs/CMakeLists.txt [new file with mode: 0644]
unit_tests/server/configs/ut-container-admin/containers/buggy.conf [new file with mode: 0644]
unit_tests/server/configs/ut-container-admin/containers/missing.conf [moved from src/server/unit_tests/config/ut-scs-container-admin/containers/missing.conf with 100% similarity]
unit_tests/server/configs/ut-container-admin/containers/test.conf [new file with mode: 0644]
unit_tests/server/configs/ut-container-admin/libvirt-config/buggy.xml [moved from src/server/unit_tests/config/ut-scs-container-admin/libvirt-config/buggy.xml with 100% similarity]
unit_tests/server/configs/ut-container-admin/libvirt-config/test.xml [moved from src/server/unit_tests/config/ut-scs-container/libvirt-config/test.xml with 100% similarity]
unit_tests/server/configs/ut-container/containers/buggy.conf [moved from src/server/unit_tests/config/ut-scs-container/containers/buggy.conf with 100% similarity]
unit_tests/server/configs/ut-container/containers/test.conf [moved from src/server/unit_tests/config/ut-scs-container/containers/test.conf with 100% similarity]
unit_tests/server/configs/ut-container/libvirt-config/test.xml [moved from src/server/unit_tests/config/ut-scs-container-admin/libvirt-config/test.xml with 100% similarity]
unit_tests/server/configs/ut-containers-manager/buggy-daemon.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/buggy-daemon.conf with 100% similarity]
unit_tests/server/configs/ut-containers-manager/buggy-foreground-daemon.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/buggy-foreground-daemon.conf with 100% similarity]
unit_tests/server/configs/ut-containers-manager/containers/console1.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/containers/console1.conf with 100% similarity]
unit_tests/server/configs/ut-containers-manager/containers/console2.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/containers/console2.conf with 100% similarity]
unit_tests/server/configs/ut-containers-manager/containers/console3.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/containers/console3.conf with 100% similarity]
unit_tests/server/configs/ut-containers-manager/libvirt-config/console1.xml [moved from src/server/unit_tests/config/ut-scs-container-manager/libvirt-config/console1.xml with 100% similarity]
unit_tests/server/configs/ut-containers-manager/libvirt-config/console2.xml [moved from src/server/unit_tests/config/ut-scs-container-manager/libvirt-config/console2.xml with 100% similarity]
unit_tests/server/configs/ut-containers-manager/libvirt-config/console3.xml [moved from src/server/unit_tests/config/ut-scs-container-manager/libvirt-config/console3.xml with 100% similarity]
unit_tests/server/configs/ut-containers-manager/test-daemon.conf [moved from src/server/unit_tests/config/ut-scs-container-manager/test-daemon.conf with 100% similarity]
unit_tests/server/ut-container-admin.cpp [moved from src/server/unit_tests/ut-scs-container-admin.cpp with 93% similarity]
unit_tests/server/ut-container.cpp [moved from src/server/unit_tests/ut-scs-container.cpp with 85% similarity]
unit_tests/server/ut-containers-manager.cpp [moved from src/server/unit_tests/ut-scs-container-manager.cpp with 71% similarity]
unit_tests/ut.cpp [moved from src/server/unit_tests/ut-main.cpp with 80% similarity]
unit_tests/ut.hpp [moved from src/server/unit_tests/ut.hpp with 87% similarity]
unit_tests/utils/scoped-daemon.cpp [moved from src/server/unit_tests/utils-scoped-daemon.cpp with 97% similarity]
unit_tests/utils/scoped-daemon.hpp [moved from src/server/unit_tests/utils-scoped-daemon.hpp with 91% similarity]
unit_tests/utils/ut-paths.cpp [moved from src/server/unit_tests/ut-utils.cpp with 98% similarity]

index e1a82dd..b12879f 100644 (file)
@@ -19,4 +19,4 @@ Makefile
 
 # Others
 security-containers.pc
-doc/*/
+doc/html
index bc1e262..7558608 100644 (file)
 CMAKE_MINIMUM_REQUIRED (VERSION 2.6.2)
 PROJECT(security-containers)
 
+
 ## pkgconfig ###################################################################
 INCLUDE(FindPkgConfig)
 
+
 ## default CMAKE_INSTALL_* variables ###########################################
 INCLUDE(GNUInstallDirs)
 
-## File names ##################################################################
-SET(SERVER_CODENAME "${PROJECT_NAME}-server")
-SET(CLIENT_CODENAME "${PROJECT_NAME}-client")
-
-
-## Generate the pc file ########################################################
-CONFIGURE_FILE(security-containers.pc.in security-containers.pc @ONLY)
-
 
 ## Compiler flags, depending on the build type #################################
 IF(NOT CMAKE_BUILD_TYPE)
@@ -60,8 +54,10 @@ ADD_DEFINITIONS(-DPROGRAM_VERSION="${VERSION}")
 
 
 ## Subdirectories ##############################################################
-SET(CLIENT_FOLDER ${PROJECT_SOURCE_DIR}/src/client)
-SET(SERVER_FOLDER ${PROJECT_SOURCE_DIR}/src/server)
+SET(COMMON_FOLDER ${PROJECT_SOURCE_DIR}/common)
+SET(CLIENT_FOLDER ${PROJECT_SOURCE_DIR}/client)
+SET(SERVER_FOLDER ${PROJECT_SOURCE_DIR}/server)
+SET(UNIT_TESTS_FOLDER ${PROJECT_SOURCE_DIR}/unit_tests)
 
 IF(NOT DEFINED SYSCONF_INSTALL_DIR)
     SET(SYSCONF_INSTALL_DIR "/etc")
@@ -81,21 +77,7 @@ ENDIF(NOT DEFINED SCRIPT_INSTALL_DIR)
 
 SET(SC_CONFIG_INSTALL_DIR ${SYSCONF_INSTALL_DIR}/security-containers)
 
-ADD_SUBDIRECTORY(src)
-
-
-## Installations ###############################################################
-INSTALL(FILES       ${CLIENT_FOLDER}/include/security-containers-client.h
-        DESTINATION ${INCLUDE_INSTALL_DIR}/security-containers)
-
-INSTALL(FILES       ${CMAKE_BINARY_DIR}/security-containers.pc
-        DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-
-INSTALL(FILES       ${SERVER_FOLDER}/config/daemon.conf
-        DESTINATION ${SC_CONFIG_INSTALL_DIR})
-
-INSTALL(FILES       ${SERVER_FOLDER}/config/containers/xminimal.conf
-        DESTINATION ${SC_CONFIG_INSTALL_DIR}/containers)
+ADD_SUBDIRECTORY(${CLIENT_FOLDER})
+ADD_SUBDIRECTORY(${SERVER_FOLDER})
+ADD_SUBDIRECTORY(${UNIT_TESTS_FOLDER})
 
-INSTALL(FILES       ${SERVER_FOLDER}/config/libvirt-config/xminimal.xml
-        DESTINATION ${SC_CONFIG_INSTALL_DIR}/libvirt-config)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8d45be5
--- /dev/null
@@ -0,0 +1,48 @@
+# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed 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.
+#
+#
+# @file   CMakeLists.txt
+# @author Jan Olszak (j.olszak@samsung.com)
+#
+
+MESSAGE(STATUS "Generating makefile for the Client...")
+FILE(GLOB         project_SRCS *.cpp *.hpp)
+FILE(GLOB_RECURSE common_SRCS ${COMMON_FOLDER}/*.cpp ${COMMON_FOLDER}/*.hpp)
+
+
+## Setup target ################################################################
+SET(CLIENT_CODENAME "${PROJECT_NAME}-client")
+ADD_LIBRARY(${CLIENT_CODENAME} SHARED ${project_SRCS})
+
+
+## Link libraries ##############################################################
+INCLUDE_DIRECTORIES(${COMMON_FOLDER})
+
+
+## Generate the pc file ########################################################
+CONFIGURE_FILE(security-containers.pc.in
+               ${CMAKE_BINARY_DIR}/security-containers.pc @ONLY)
+
+
+## Install #####################################################################
+INSTALL(FILES       ${CMAKE_BINARY_DIR}/security-containers.pc
+        DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+INSTALL(TARGETS     ${CLIENT_CODENAME}
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        COMPONENT   RuntimeLibraries)
+
+INSTALL(FILES       security-containers-client.h
+        DESTINATION ${INCLUDE_INSTALL_DIR}/security-containers)
diff --git a/client/exception.hpp b/client/exception.hpp
new file mode 100644 (file)
index 0000000..2921a3e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Bumjin Im <bj.im@samsung.com>
+ *
+ *  Licensed 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
+ */
+
+/**
+ * @file
+ * @author  Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
+ * @brief   Exceptions for the client
+ */
+
+
+#ifndef CLIENT_EXCEPTION_HPP
+#define CLIENT_EXCEPTION_HPP
+
+#include "base-exception.hpp"
+
+
+namespace security_containers {
+
+
+/**
+ * @brief Base class for exceptions in Security Containers Client
+ */
+struct ClientException: public SecurityContainersException {
+    using SecurityContainersException::SecurityContainersException;
+};
+
+
+}
+
+
+#endif // CLIENT_EXCEPTION_HPP
diff --git a/client/main.cpp b/client/main.cpp
new file mode 100644 (file)
index 0000000..d2f7604
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Bumjin Im <bj.im@samsung.com>
+ *
+ *  Licensed 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
+ */
+
+
+/**
+ * @file
+ * @author  Jan Olszak (j.olszak@samsung.com)
+ * @brief   Main file for the Security Containers Client
+ */
+
+#include "exception.hpp"
similarity index 92%
rename from src/client/include/security-containers-client.h
rename to client/security-containers-client.h
index 6e3a3bc..7e88063 100644 (file)
@@ -20,7 +20,7 @@
 /**
  * @file    security-containers-client.h
  * @author  Jan Olszak (j.olszak@samsung.com)
- * @brief   This file contains the API for Security Containers Client
+ * @brief   This file contains the public API for Security Containers Client
  */
 
 #ifndef SECURITY_CONTAINERS_CLIENT_H
similarity index 90%
rename from src/server/include/base-exception.hpp
rename to common/base-exception.hpp
index 86affcf..2441a5b 100644 (file)
  */
 
 /**
- * @file    base-exception.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Security containers base exception
  */
 
 
-#ifndef BASE_EXCEPTION_HPP
-#define BASE_EXCEPTION_HPP
+#ifndef COMMON_BASE_EXCEPTION_HPP
+#define COMMON_BASE_EXCEPTION_HPP
 
 #include <stdexcept>
 
+
 namespace security_containers {
 
+
 /**
  * Base class security containers exceptions
  */
@@ -39,6 +41,8 @@ struct SecurityContainersException: public std::runtime_error {
     SecurityContainersException() : std::runtime_error(std::string()) {}
 };
 
+
 } // namespace security_containers
 
-#endif // BASE_EXCEPTION_HPP
+
+#endif // COMMON_BASE_EXCEPTION_HPP
similarity index 96%
rename from src/server/src/scs-configuration.cpp
rename to common/config/configuration.cpp
index a31b885..84812ce 100644 (file)
  */
 
 /**
- * @file    scs-configuration.cpp
+ * @file
  * @author  Michal Witanowski (m.witanowski@samsung.com)
  * @brief   Helper class for parsing and storing configurations in JSON format.
  */
 
-#include "scs-exception.hpp"
-#include "log.hpp"
-#include "scs-configuration.hpp"
+#include "log/logger.hpp"
+#include "config/configuration.hpp"
+#include "config/exception.hpp"
+
 #include <string.h>
 #include <fstream>
 
+
 namespace security_containers {
+namespace config {
 
 
 void ConfigurationBase::parseStr(const std::string& str)
@@ -132,4 +135,5 @@ template<> std::string ConfigurationBase::getValueFromJsonObj(json_object* obj)
     return std::string(json_object_get_string(obj));
 }
 
+} // namespace config
 } // namespace security_containers
similarity index 89%
rename from src/server/include/scs-configuration.hpp
rename to common/config/configuration.hpp
index 470d655..28570d5 100644 (file)
 
 
 /**
- * @file    scs-configuration.hpp
+ * @file
  * @author  Michal Witanowski (m.witanowski@samsung.com)
  * @brief   Helper class for parsing and storing configurations in JSON format.
  */
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONFIG_HPP
-#define SECURITY_CONTAINERS_SERVER_CONFIG_HPP
+#ifndef COMMON_CONFIG_CONFIGURATION_HPP
+#define COMMON_CONFIG_CONFIGURATION_HPP
+
+#include "log/logger.hpp"
+#include "config/exception.hpp"
 
-#include "log.hpp"
-#include "scs-exception.hpp"
 #include <json/json.h>
 #include <string>
 #include <vector>
 
+
 namespace security_containers {
+namespace config {
+
 
 enum class ConfigProcessMode : int {
     Read,
     Write
 };
 
-#define CONFIG_REGISTER         void process(json_object* obj, ConfigProcessMode mode)
+#define CONFIG_REGISTER \
+    void process(json_object* obj, security_containers::config::ConfigProcessMode mode)
 
 /**
  * Use this macro to declare config value (class attribute). Declare means that it will be
@@ -47,18 +52,20 @@ enum class ConfigProcessMode : int {
  * Currently supported types are:
  * int, bool, double, std::string and std::vector of all the mentioned.
  */
-#define CONFIG_VALUE(name)      if (mode == ConfigProcessMode::Read) \
-                                    readValue(obj, name, #name);     \
-                                else                                 \
-                                    writeValue(obj, name, #name);
+#define CONFIG_VALUE(name) \
+    if (mode == security_containers::config::ConfigProcessMode::Read) \
+        readValue(obj, name, #name);                                  \
+    else                                                              \
+        writeValue(obj, name, #name);
 /**
  * Use this macro to declare configuration sub object (nested config tree).
  * The type of passed argument must inherit from ConfigurationBase or be std::vector of such type.
  */
-#define CONFIG_SUB_OBJECT(name) if (mode == ConfigProcessMode::Read) \
-                                    readSubObj(obj, name, #name);    \
-                                else                                 \
-                                    writeSubObj(obj, name, #name);
+#define CONFIG_SUB_OBJECT(name) \
+    if (mode == security_containers::config::ConfigProcessMode::Read) \
+        readSubObj(obj, name, #name);                                 \
+    else                                                              \
+        writeSubObj(obj, name, #name);
 
 /**
     @brief Override this abstract class to enable reading/writing a class members from/to JSON
@@ -259,6 +266,9 @@ private:
     static json_object* getJsonObjFromValue(const T& val);
 };
 
+
+} // namespace config
 } // namespace security_containers
 
-#endif // SECURITY_CONTAINERS_SERVER_CONFIG_HPP
+
+#endif // COMMON_CONFIG_CONFIGURATION_HPP
diff --git a/common/config/exception.hpp b/common/config/exception.hpp
new file mode 100644 (file)
index 0000000..2b41c62
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Bumjin Im <bj.im@samsung.com>
+ *
+ *  Licensed 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
+ */
+
+/**
+ * @file
+ * @author  Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
+ * @brief   Exceptions for the configuration
+ */
+
+
+#ifndef COMMON_CONFIG_EXCEPTION_HPP
+#define COMMON_CONFIG_EXCEPTION_HPP
+
+#include "base-exception.hpp"
+
+
+namespace security_containers {
+namespace config {
+
+
+/**
+ * Base class for exceptions in configuration.
+ * Error occured during a config file parsing,
+ * e.g. syntax error
+ */
+struct ConfigException: public SecurityContainersException {
+    using SecurityContainersException::SecurityContainersException;
+};
+
+
+} // namespace config
+} // namespace security_containers
+
+
+#endif // COMMON_CONFIG_EXCEPTION_HPP
similarity index 99%
rename from src/server/src/dbus-connection.cpp
rename to common/dbus/connection.cpp
index 608df83..b3107b1 100644 (file)
  */
 
 /**
- * @file    dbus-connection.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Dbus connection class
  */
 
-#include "dbus-connection.hpp"
-#include "dbus-exception.hpp"
-#include "log.hpp"
+#include "dbus/connection.hpp"
+#include "dbus/exception.hpp"
+#include "log/logger.hpp"
+
 
 namespace security_containers {
 namespace dbus {
 
+
 namespace {
 
 const std::string SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket";
@@ -349,5 +351,6 @@ GVariantPtr DbusConnection::callMethod(const std::string& busName,
     return GVariantPtr(result, g_variant_unref);
 }
 
+
 } // namespace dbus
 } // namespace security_containers
similarity index 97%
rename from src/server/include/dbus-connection.hpp
rename to common/dbus/connection.hpp
index 4f98523..ba5ba23 100644 (file)
  */
 
 /**
- * @file    dbus-connection.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Dbus connection class
  */
 
-#ifndef DBUS_CONNECTION_HPP
-#define DBUS_CONNECTION_HPP
+#ifndef COMMON_DBUS_CONNECTION_HPP
+#define COMMON_DBUS_CONNECTION_HPP
 
 #include <memory>
 #include <string>
 #include <functional>
 #include <gio/gio.h>
 
+
 namespace security_containers {
 namespace dbus {
 
+
 typedef std::unique_ptr<GVariant, void(*)(GVariant*)> GVariantPtr;
 
 /**
@@ -156,7 +158,9 @@ private:
                              gpointer userData);
 };
 
+
 } // namespace dbus
 } // namespace security_containers
 
-#endif //DBUS_CONNECTION_HPP
+
+#endif // COMMON_DBUS_CONNECTION_HPP
similarity index 93%
rename from src/server/include/dbus-exception.hpp
rename to common/dbus/exception.hpp
index 058c1de..b1f9fb4 100644 (file)
  */
 
 /**
- * @file    dbus-exception.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Dbus exceptions
  */
 
 
-#ifndef DBUS_EXCEPTION_HPP
-#define DBUS_EXCEPTION_HPP
+#ifndef COMMON_DBUS_EXCEPTION_HPP
+#define COMMON_DBUS_EXCEPTION_HPP
 
 #include "base-exception.hpp"
 
+
 namespace security_containers {
 namespace dbus {
 
+
 /**
  * Base class for dbus exceptions
  */
@@ -66,7 +68,9 @@ struct DbusInvalidArgumentException: public DbusException {
     using DbusException::DbusException;
 };
 
+
 } // namespace dbus
 } // namespace security_containers
 
-#endif // DBUS_EXCEPTION_HPP
+
+#endif // COMMON_DBUS_EXCEPTION_HPP
similarity index 87%
rename from src/server/include/log-backend-null.hpp
rename to common/log/backend-null.hpp
index 2f20426..68ba223 100644 (file)
  */
 
 /**
- * @file    log-backend-null.hpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Null backend for logger
  */
 
 
-#ifndef LOG_BACKEND_NULL_HPP
-#define LOG_BACKEND_NULL_HPP
+#ifndef COMMON_LOG_BACKEND_NULL_HPP
+#define COMMON_LOG_BACKEND_NULL_HPP
+
+#include "log/backend.hpp"
 
-#include "log-backend.hpp"
 
 namespace security_containers {
 namespace log {
 
+
 /**
     Null logging backend
  */
@@ -39,7 +41,9 @@ public:
     void log(const std::string& /*message*/) override {}
 };
 
+
 } // namespace log
 } // namespace security_containers
 
-#endif // LOG_BACKEND_NULL_HPP
+
+#endif // COMMON_LOG_BACKEND_NULL_HPP
similarity index 93%
rename from src/server/src/log-backend-stderr.cpp
rename to common/log/backend-stderr.cpp
index 3bf1c77..d2c703c 100644 (file)
  */
 
 /**
- * @file    log-backend-stderr.cpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Stderr backend for logger
  */
 
-
-#include "log-backend-stderr.hpp"
+#include "log/backend-stderr.hpp"
 
 #include <stdio.h>
 
+
 namespace security_containers {
 namespace log {
 
+
 void StderrBackend::log(const std::string& message)
 {
     fprintf(stderr, "%s", message.c_str());
 }
 
+
 } // namespace log
 } // namespace security_containers
similarity index 86%
rename from src/server/include/log-backend-stderr.hpp
rename to common/log/backend-stderr.hpp
index 2868ea2..7baf524 100644 (file)
  */
 
 /**
- * @file    log-backend-stderr.hpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Stderr backend for logger
  */
 
+#ifndef COMMON_LOG_BACKEND_STDERR_HPP
+#define COMMON_LOG_BACKEND_STDERR_HPP
 
-#ifndef LOG_BACKEND_STDERR_HPP
-#define LOG_BACKEND_STDERR_HPP
+#include "log/backend.hpp"
 
-#include "log-backend.hpp"
 
 namespace security_containers {
 namespace log {
 
+
 /**
     Stderr logging backend
  */
@@ -39,7 +40,9 @@ public:
     void log(const std::string& message) override;
 };
 
+
 } // namespace log
 } // namespace security_containers
 
-#endif // LOG_BACKEND_STDERR_HPP
+
+#endif // COMMON_LOG_BACKEND_STDERR_HPP
similarity index 90%
rename from src/server/include/log-backend.hpp
rename to common/log/backend.hpp
index 3a97399..3d1d3c5 100644 (file)
  */
 
 /**
- * @file    log-backend.hpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Logging backend
  */
 
 
-#ifndef LOG_BACKEND_HPP
-#define LOG_BACKEND_HPP
+#ifndef COMMON_LOG_BACKEND_HPP
+#define COMMON_LOG_BACKEND_HPP
 
 #include <string>
 
+
 namespace security_containers {
 namespace log {
 
+
 /**
     Abstract class for logger
  */
@@ -40,7 +42,9 @@ public:
     virtual ~LogBackend() {}
 };
 
+
 } // namespace log
 } // namespace security_containers
 
-#endif // LOG_BACKEND_HPP
+
+#endif // COMMON_LOG_BACKEND_HPP
similarity index 96%
rename from src/server/src/log.cpp
rename to common/log/logger.cpp
index 06fcaf9..357fce4 100644 (file)
  */
 
 /**
- * @file    log.cpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Logger
  */
 
-#include "log.hpp"
-#include "log-backend-null.hpp"
+#include "log/logger.hpp"
+#include "log/backend-null.hpp"
 
 #include <iomanip>
 #include <memory>
 #include <mutex>
 
+
 namespace security_containers {
 namespace log {
 
+
 namespace {
 
 volatile LogLevel gLogLevel = LogLevel::DEBUG;
similarity index 93%
rename from src/server/include/log.hpp
rename to common/log/logger.hpp
index 52ef745..6937eb9 100644 (file)
  */
 
 /**
- * @file    log.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Logger
  */
 
 
-#ifndef LOG_HPP
-#define LOG_HPP
+#ifndef COMMON_LOG_LOGGER_HPP
+#define COMMON_LOG_LOGGER_HPP
 
-#include "log-backend.hpp"
+#include "log/backend.hpp"
 
 #include <sstream>
 #include <string.h>
 
+
 namespace security_containers {
 namespace log {
 
+
 enum class LogLevel {
     TRACE, DEBUG, INFO, WARN, ERROR
 };
@@ -75,4 +77,4 @@ private:
 #define LOGT(MESSAGE) LOG(TRACE, MESSAGE)
 
 
-#endif // LOG_HPP
+#endif // COMMON_LOG_LOGGER_HPP
similarity index 94%
rename from src/server/src/utils-file-wait.cpp
rename to common/utils/file-wait.cpp
index a9504e7..c55afc9 100644 (file)
  */
 
 /**
- * @file    utils-file-wait.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Wait for file utility function
  */
 
-#include "utils-file-wait.hpp"
-#include "log.hpp"
+#include "utils/file-wait.hpp"
+#include "log/logger.hpp"
+
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdexcept>
 
+
 namespace security_containers {
 namespace utils {
 
+
 const unsigned int GRANULARITY = 10;
 
 void waitForFile(const std::string& filename, const unsigned int timeoutMs)
@@ -50,5 +53,6 @@ void waitForFile(const std::string& filename, const unsigned int timeoutMs)
     }
 }
 
+
 } // namespace utils
 } // namespace security_containers
similarity index 90%
rename from src/server/include/utils-file-wait.hpp
rename to common/utils/file-wait.hpp
index 7c30196..f488725 100644 (file)
  */
 
 /**
- * @file    utils-file-wait.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Wait for file utility function
  */
 
-#ifndef UTILS_FILE_WAIT_HPP
-#define UTILS_FILE_WAIT_HPP
+#ifndef COMMON_UTILS_FILE_WAIT_HPP
+#define COMMON_UTILS_FILE_WAIT_HPP
 
 #include <string>
 
+
 namespace security_containers {
 namespace utils {
 
+
 //TODO It is used in unit tests now, but it is unclear
 //     whether the same solution will be used in daemon.
 void waitForFile(const std::string& filename, const unsigned int timeoutMs);
 
+
 } // namespace utils
 } // namespace security_containers
 
-#endif // UTILS_FILE_WAIT_HPP
+
+#endif // COMMON_UTILS_FILE_WAIT_HPP
similarity index 95%
rename from src/server/src/utils-glib-loop.cpp
rename to common/utils/glib-loop.cpp
index c712913..8b9fb30 100644 (file)
  */
 
 /**
- * @file    utils-glib-loop.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   C++ wrapper of glib main loop
  */
 
-#include "utils-glib-loop.hpp"
+#include "utils/glib-loop.hpp"
+
 #include <glib.h>
 
+
 namespace security_containers {
 namespace utils {
 
+
 ScopedGlibLoop::ScopedGlibLoop()
     : mLoop(g_main_loop_new(NULL, FALSE), g_main_loop_unref)
 {
@@ -45,5 +48,6 @@ ScopedGlibLoop::~ScopedGlibLoop()
     mLoopThread.join();
 }
 
+
 } // namespace utils
 } // namespace security_containers
similarity index 92%
rename from src/server/include/utils-glib-loop.hpp
rename to common/utils/glib-loop.hpp
index 5fba251..c9acf60 100644 (file)
  */
 
 /**
- * @file    utils-glib-loop.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   C++ wrapper of glib main loop
  */
 
-#ifndef UTILS_GLIB_LOOP_HPP
-#define UTILS_GLIB_LOOP_HPP
+#ifndef COMMON_UTILS_GLIB_LOOP_HPP
+#define COMMON_UTILS_GLIB_LOOP_HPP
 
 #include <thread>
 #include <memory>
 struct _GMainLoop;
 typedef struct _GMainLoop GMainLoop;
 
+
 namespace security_containers {
 namespace utils {
 
+
 /**
  * Glib loop controller. Loop is running in separate thread.
  */
@@ -54,7 +56,9 @@ private:
     std::thread mLoopThread;
 };
 
+
 } // namespace utils
 } // namespace security_containers
 
-#endif //UTILS_GLIB_LOOP_HPP
+
+#endif // COMMON_UTILS_GLIB_LOOP_HPP
similarity index 96%
rename from src/server/src/utils-latch.cpp
rename to common/utils/latch.cpp
index e096f2e..ec9e88f 100644 (file)
  */
 
 /**
- * @file    utils-latch.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Synchronization latch
  */
 
-#include "utils-latch.hpp"
+#include "utils/latch.hpp"
+
 
 namespace security_containers {
 namespace utils {
 
+
 Latch::Latch()
     : mCount(0)
 {
@@ -63,5 +65,6 @@ bool Latch::empty()
     return mCount == 0;
 }
 
+
 } // namespace utils
 } // namespace security_containers
similarity index 93%
rename from src/server/include/utils-latch.hpp
rename to common/utils/latch.hpp
index 9268fc3..4405b90 100644 (file)
  */
 
 /**
- * @file    utils-latch.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Synchronization latch
  */
 
-#ifndef UTILS_LATCH_HPP
-#define UTILS_LATCH_HPP
+#ifndef COMMON_UTILS_LATCH_HPP
+#define COMMON_UTILS_LATCH_HPP
 
 #include <mutex>
 #include <condition_variable>
 
+
 namespace security_containers {
 namespace utils {
 
+
 /**
  * A synchronization aid that allows one thread to wait until
  * an operation being performed in other thread completes.
@@ -67,7 +69,9 @@ private:
     int mCount;
 };
 
+
 } // namespace utils
 } // namespace security_containers
 
-#endif // UTILS_LATCH_HPP
+
+#endif // COMMON_UTILS_LATCH_HPP
similarity index 94%
rename from src/server/include/utils.hpp
rename to common/utils/paths.hpp
index 18d37c0..33b1070 100644 (file)
  */
 
 /**
- * @file    utils.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
- * @brief   Utility function declaration
+ * @brief   Path utility functions declaration
  */
 
+#ifndef COMMON_UTILS_PATHS_HPP
+#define COMMON_UTILS_PATHS_HPP
 
 #include <string>
 #include <vector>
@@ -31,6 +33,7 @@
 namespace security_containers {
 namespace utils {
 
+
 template <class ...Paths> std::string createFilePath(const Paths& ... paths)
 {
     std::vector<std::string> pathVec = {paths...};
@@ -102,5 +105,9 @@ inline std::string dirName(std::string path)
     return path;
 }
 
+
 } // namespace utils
 } // namespace security_containers
+
+
+#endif // COMMON_UTILS_PATHS_HPP
index 5317aab..7e304e5 100644 (file)
@@ -128,7 +128,7 @@ FULL_PATH_NAMES        = YES
 # If left blank the directory from which doxygen is run is used as the
 # path to strip.
 
-STRIP_FROM_PATH        = ../src/
+STRIP_FROM_PATH        = 
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
 # the path mentioned in the documentation of a class, which tells
@@ -137,7 +137,7 @@ STRIP_FROM_PATH        = ../src/
 # definition is used. Otherwise one should specify the include paths that
 # are normally passed to the compiler using the -I flag.
 
-STRIP_FROM_INC_PATH    = ../src/
+STRIP_FROM_INC_PATH    = 
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
 # (but less readable) file names. This can be useful if your file system
@@ -647,7 +647,7 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
-INPUT                  = ../src/
+INPUT                  = ../common ../client ../server
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
index 38dfedc..7991de6 100644 (file)
@@ -47,7 +47,6 @@ make -k %{?jobs:-j%jobs}
 
 %install
 %make_install
-mkdir -p %{buildroot}/etc/security-containers/config/libvirt-config/
 
 %clean
 rm -rf %{buildroot}
@@ -103,11 +102,11 @@ Unit tests for both: server and client.
 %attr(755,root,root) %{script_dir}/sc_all_tests.py
 %attr(755,root,root) %{script_dir}/sc_launch_test.py
 %{script_dir}/sc_test_parser.py
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container-manager/*.conf
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container-manager/containers/*.conf
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container-manager/libvirt-config/*.xml
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container/containers/*.conf
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container/libvirt-config/*.xml
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container-admin/containers/*.conf
-%config %attr(644,root,root) /etc/security-containers/tests/ut-scs-container-admin/libvirt-config/*.xml
-%config %attr(644,root,root) /etc/security-containers/tests/ut-dbus-connection/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/dbus/ut-connection/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-containers-manager/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-containers-manager/containers/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-containers-manager/libvirt-config/*.xml
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-container/containers/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-container/libvirt-config/*.xml
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-container-admin/containers/*.conf
+%config %attr(644,root,root) /etc/security-containers/tests/server/ut-container-admin/libvirt-config/*.xml
similarity index 77%
rename from src/server/src/CMakeLists.txt
rename to server/CMakeLists.txt
index ae8f50b..3daba33 100644 (file)
 #
 
 MESSAGE(STATUS "Generating makefile for the Server...")
-FILE(GLOB_RECURSE project_SRCS *.cpp *.cxx *.cc *.C *.c *.h *.hpp)
+FILE(GLOB         project_SRCS *.cpp *.hpp)
+FILE(GLOB_RECURSE common_SRCS ${COMMON_FOLDER}/*.cpp ${COMMON_FOLDER}/*.hpp)
+
 
 ## Setup target ################################################################
 SET(SERVER_CODENAME "${PROJECT_NAME}-server")
-ADD_EXECUTABLE(${SERVER_CODENAME} ${project_SRCS} )
+ADD_EXECUTABLE(${SERVER_CODENAME} ${project_SRCS} ${common_SRCS})
+
 
 ## Link libraries ##############################################################
 FIND_PACKAGE (Boost COMPONENTS program_options REQUIRED)
 
 PKG_CHECK_MODULES(SERVER_DEPS REQUIRED libvirt json gio-2.0)
-INCLUDE_DIRECTORIES(SYSTEM ${SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
 TARGET_LINK_LIBRARIES(${SERVER_CODENAME} ${SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES})
 
+
+## Subdirectories ##############################################################
+ADD_SUBDIRECTORY(configs)
+
+
 ## Install #####################################################################
 INSTALL(TARGETS ${SERVER_CODENAME} DESTINATION bin)
similarity index 57%
rename from src/CMakeLists.txt
rename to server/configs/CMakeLists.txt
index 8a1f570..adf68f3 100644 (file)
 #
 #
 # @file   CMakeLists.txt
-# @author Jan Olszak (j.olszak@samsung.com)
+# @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
 #
 
-ADD_SUBDIRECTORY(client)
-ADD_SUBDIRECTORY(server)
-ADD_SUBDIRECTORY(scripts)
+MESSAGE(STATUS "Installing configs to " ${SC_CONFIG_INSTALL_DIR})
+
+
+## Installations ###############################################################
+INSTALL(FILES       daemon.conf
+        DESTINATION ${SC_CONFIG_INSTALL_DIR})
+
+INSTALL(FILES       containers/xminimal.conf
+        DESTINATION ${SC_CONFIG_INSTALL_DIR}/containers)
+
+INSTALL(FILES       libvirt-config/xminimal.xml
+        DESTINATION ${SC_CONFIG_INSTALL_DIR}/libvirt-config)
similarity index 98%
rename from src/server/src/scs-container-admin.cpp
rename to server/container-admin.cpp
index 8b3fa65..3f736ec 100644 (file)
  */
 
 /**
- * @file    scs-container-admin.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Implementation of class for administrating one container
  */
 
-#include "scs-container-admin.hpp"
-#include "scs-exception.hpp"
-#include "log.hpp"
+#include "container-admin.hpp"
+#include "exception.hpp"
+#include "log/logger.hpp"
 
 #include <assert.h>
 #include <string>
 #include <memory>
 #include <cstdint>
 
+
 namespace security_containers {
 
+
 const std::uint64_t DEFAULT_CPU_SHARES = 1024;
 const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000;
 
@@ -45,7 +47,7 @@ ContainerAdmin::ContainerAdmin(ContainerConfig& config)
     std::ifstream t(mConfig.config);
     if (!t.is_open()) {
         LOGE("libvirt config file is missing");
-        throw ConfigException();
+        throw config::ConfigException();
     }
     std::string libvirtConfig((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
     define(libvirtConfig);
@@ -354,4 +356,5 @@ std::int64_t ContainerAdmin::getSchedulerQuota()
     return quota;
 }
 
+
 } // namespace security_containers
similarity index 94%
rename from src/server/include/scs-container-admin.hpp
rename to server/container-admin.hpp
index 7aa7977..61bb63b 100644 (file)
  */
 
 /**
- * @file    scs-container-admin.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Declaration of the class for administrating one container
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONTAINER_ADMIN_HPP
-#define SECURITY_CONTAINERS_SERVER_CONTAINER_ADMIN_HPP
+#ifndef SERVER_CONTAINER_ADMIN_HPP
+#define SERVER_CONTAINER_ADMIN_HPP
 
-#include "scs-container-config.hpp"
+#include "container-config.hpp"
 
 #include <string>
 #include <cstdint>
 #include <libvirt/libvirt.h>
 
+
 namespace security_containers {
 
+
 enum class SchedulerLevel {
     FOREGROUND,
     BACKGROUND
@@ -137,5 +139,9 @@ private:
     int  getState();   // get the libvirt's domain state
     void setSchedulerParams(std::uint64_t cpuShares, std::uint64_t vcpuPeriod, std::int64_t vcpuQuota);
 };
+
+
 }
-#endif // SECURITY_CONTAINERS_SERVER_CONTAINER_ADMIN_HPP
+
+
+#endif // SERVER_CONTAINER_ADMIN_HPP
similarity index 84%
rename from src/server/include/scs-container-config.hpp
rename to server/container-config.hpp
index 5787182..1b3b55d 100644 (file)
  */
 
 /**
- * @file    scs-container-config.hpp
+ * @file
  * @author  Michal Witanowski (m.witanowski@samsung.com)
  * @brief   Declaration of the class for storing container configuration
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONTAINER_CONFIG_HPP
-#define SECURITY_CONTAINERS_SERVER_CONTAINER_CONFIG_HPP
+#ifndef SERVER_CONTAINER_CONFIG_HPP
+#define SERVER_CONTAINER_CONFIG_HPP
+
+#include "config/configuration.hpp"
 
-#include "scs-configuration.hpp"
 #include <string>
 
+
 namespace security_containers {
 
-struct ContainerConfig : public ConfigurationBase {
+
+struct ContainerConfig : public config::ConfigurationBase {
     /**
      * Privilege of the container.
      * The smaller the value the more important the container
@@ -62,6 +65,8 @@ struct ContainerConfig : public ConfigurationBase {
     }
 };
 
+
 }
 
-#endif // SECURITY_CONTAINERS_SERVER_CONTAINER_CONFIG_HPP
+
+#endif // SERVER_CONTAINER_CONFIG_HPP
similarity index 95%
rename from src/server/src/scs-container.cpp
rename to server/container.cpp
index 17d1c53..a56c575 100644 (file)
  */
 
 /**
- * @file    scs-container.cpp
+ * @file
  * @author  Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
  * @brief   Implementation of class for managing one container
  */
 
-#include "scs-container.hpp"
-#include "utils.hpp"
-#include "log.hpp"
+#include "container.hpp"
+#include "log/logger.hpp"
+#include "utils/paths.hpp"
 
 #include <assert.h>
 #include <string>
 
+
 namespace security_containers {
 
+
 Container::Container(const std::string& containerConfigPath)
 {
     mConfig.parseFile(containerConfigPath);
@@ -48,60 +50,50 @@ Container::Container(const std::string& containerConfigPath)
     mAdmin.reset(new ContainerAdmin(mConfig));
 }
 
-
 Container::~Container()
 {
 }
 
-
 std::string Container::getId()
 {
     return mAdmin->getId();
 }
 
-
 int Container::getPrivilege()
 {
     return mConfig.privilege;
 }
 
-
 void Container::start()
 {
     return mAdmin->start();
 }
 
-
 void Container::stop()
 {
     return mAdmin->stop();
 }
 
-
 void Container::goForeground()
 {
     mAdmin->setSchedulerLevel(SchedulerLevel::FOREGROUND);
 }
 
-
 void Container::goBackground()
 {
     mAdmin->setSchedulerLevel(SchedulerLevel::BACKGROUND);
 }
 
-
 bool Container::isRunning()
 {
     return mAdmin->isRunning();
 }
 
-
 bool Container::isStopped()
 {
     return mAdmin->isStopped();
 }
 
-
 bool Container::isPaused()
 {
     return mAdmin->isPaused();
similarity index 89%
rename from src/server/include/scs-container.hpp
rename to server/container.hpp
index 3fc12e7..2f53c7c 100644 (file)
  */
 
 /**
- * @file    scs-container.hpp
+ * @file
  * @author  Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
  * @brief   Declaration of the class for managing one container
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONTAINER_HPP
-#define SECURITY_CONTAINERS_SERVER_CONTAINER_HPP
+#ifndef SERVER_CONTAINER_HPP
+#define SERVER_CONTAINER_HPP
 
-#include "scs-container-config.hpp"
-#include "scs-container-admin.hpp"
+#include "container-config.hpp"
+#include "container-admin.hpp"
 
 #include <string>
 #include <memory>
 
+
 namespace security_containers {
 
+
 class Container {
 
 public:
@@ -97,6 +99,8 @@ private:
     std::unique_ptr<ContainerAdmin> mAdmin;
 };
 
+
 }
 
-#endif // SECURITY_CONTAINERS_SERVER_CONTAINER_HPP
+
+#endif // SERVER_CONTAINER_HPP
similarity index 75%
rename from src/server/include/scs-container-manager-config.hpp
rename to server/containers-manager-config.hpp
index 1bfa8be..0a9d9b4 100644 (file)
  */
 
 /**
- * @file    scs-container-manager-config.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Declaration of the class for storing container manager configuration
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_CONFIG_HPP
-#define SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_CONFIG_HPP
+#ifndef SERVER_CONTAINERS_MANAGER_CONFIG_HPP
+#define SERVER_CONTAINERS_MANAGER_CONFIG_HPP
+
+#include "config/configuration.hpp"
 
-#include "scs-configuration.hpp"
 #include <string>
 #include <vector>
 
+
 namespace security_containers {
 
-const std::string CONTAINER_MANAGER_CONFIG_PATH = "/etc/security-containers/config/daemon.conf";
 
-struct ContainerManagerConfig : public ConfigurationBase {
+const std::string CONTAINERS_MANAGER_CONFIG_PATH = "/etc/security-containers/config/daemon.conf";
+
+struct ContainersManagerConfig : public config::ConfigurationBase {
     /**
      * List of containers' configs that we manage.
      * File paths can be relative to the ContainerManager config file.
@@ -52,6 +55,8 @@ struct ContainerManagerConfig : public ConfigurationBase {
     }
 };
 
-}
 
-#endif // SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_CONFIG_HPP
+} // namespace security_containers
+
+
+#endif // SERVER_CONTAINERS_MANAGER_CONFIG_HPP
similarity index 86%
rename from src/server/src/scs-container-manager.cpp
rename to server/containers-manager.cpp
index da31f67..39f0f23 100644 (file)
  */
 
 /**
- * @file    scs-container-manager.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Definition of the class for managing containers
  */
 
-#include "scs-container-manager.hpp"
-#include "scs-container-admin.hpp"
-#include "scs-exception.hpp"
-#include "utils.hpp"
-#include "log.hpp"
+#include "containers-manager.hpp"
+#include "container-admin.hpp"
+#include "exception.hpp"
+#include "utils/paths.hpp"
+#include "log/logger.hpp"
 
 #include <assert.h>
 #include <string>
 #include <climits>
 
+
 namespace security_containers {
 
 
-ContainerManager::ContainerManager(const std::string& managerConfigPath)
+ContainersManager::ContainersManager(const std::string& managerConfigPath)
 {
     mConfig.parseFile(managerConfigPath);
     connect();
@@ -58,7 +59,7 @@ ContainerManager::ContainerManager(const std::string& managerConfigPath)
 }
 
 
-ContainerManager::~ContainerManager()
+ContainersManager::~ContainersManager()
 {
     try {
         stopAll();
@@ -69,7 +70,7 @@ ContainerManager::~ContainerManager()
 }
 
 
-void ContainerManager::focus(const std::string& containerId)
+void ContainersManager::focus(const std::string& containerId)
 {
     /* try to access the object first to throw immediately if it doesn't exist */
     ContainerMap::mapped_type& foregroundContainer = mContainers.at(containerId);
@@ -82,7 +83,7 @@ void ContainerManager::focus(const std::string& containerId)
 }
 
 
-void ContainerManager::startAll()
+void ContainersManager::startAll()
 {
     bool isForegroundFound = false;
 
@@ -107,7 +108,7 @@ void ContainerManager::startAll()
 }
 
 
-void ContainerManager::stopAll()
+void ContainersManager::stopAll()
 {
     for (auto& container : mContainers) {
         container.second->stop();
@@ -115,7 +116,7 @@ void ContainerManager::stopAll()
 }
 
 
-std::string ContainerManager::getRunningForegroundContainerId()
+std::string ContainersManager::getRunningForegroundContainerId()
 {
     for (auto& container : mContainers) {
         if (container.first == mConfig.foregroundId &&
@@ -127,7 +128,7 @@ std::string ContainerManager::getRunningForegroundContainerId()
 }
 
 
-void ContainerManager::connect()
+void ContainersManager::connect()
 {
     assert(mVir == NULL);
 
@@ -139,7 +140,7 @@ void ContainerManager::connect()
 }
 
 
-void ContainerManager::disconnect()
+void ContainersManager::disconnect()
 {
     if (mVir == NULL) {
         return;
similarity index 80%
rename from src/server/include/scs-container-manager.hpp
rename to server/containers-manager.hpp
index 7f2cba2..56620e0 100644 (file)
  */
 
 /**
- * @file    scs-container-manager.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Declaration of the class for managing many containers
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_HPP
-#define SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_HPP
+#ifndef SERVER_CONTAINERS_MANAGER_HPP
+#define SERVER_CONTAINERS_MANAGER_HPP
 
-#include "scs-container.hpp"
-#include "scs-container-manager-config.hpp"
+#include "container.hpp"
+#include "containers-manager-config.hpp"
 
 #include <string>
 #include <unordered_map>
-
 #include <libvirt/libvirt.h>
 
+
 namespace security_containers {
 
-class ContainerManager final {
+
+class ContainersManager final {
 
 public:
-    ContainerManager(const std::string& managerConfigPath);
-    ~ContainerManager();
+    ContainersManager(const std::string& managerConfigPath);
+    ~ContainersManager();
 
     /**
      * Focus this container, put it to the foreground.
@@ -66,7 +67,7 @@ public:
     std::string getRunningForegroundContainerId();
 
 private:
-    ContainerManagerConfig mConfig;
+    ContainersManagerConfig mConfig;
     // TODO: secure this pointer from exceptions (e.g. in constructor)
     virConnectPtr mVir = NULL; // pointer to the connection with libvirt
     typedef std::unordered_map<std::string, std::unique_ptr<Container>> ContainerMap;
@@ -75,5 +76,9 @@ private:
     void connect();
     void disconnect();
 };
+
+
 }
-#endif // SECURITY_CONTAINERS_SERVER_CONTAINER_MANAGER_HPP
+
+
+#endif // SERVER_CONTAINERS_MANAGER_HPP
similarity index 80%
rename from src/server/include/scs-exception.hpp
rename to server/exception.hpp
index 6cc1fde..5c510de 100644 (file)
  */
 
 /**
- * @file    scs-exception.hpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Exceptions for the server
  */
 
 
-#ifndef SECURITY_CONTAINERS_SERVER_EXCEPTION_HPP
-#define SECURITY_CONTAINERS_SERVER_EXCEPTION_HPP
+#ifndef SERVER_EXCEPTION_HPP
+#define SERVER_EXCEPTION_HPP
 
 #include "base-exception.hpp"
 
+
 namespace security_containers {
 
+
 /**
  * Base class for exceptions in Security Containers Server
  */
@@ -52,14 +54,8 @@ struct DomainOperationException: public ServerException {
     using ServerException::ServerException;
 };
 
-/**
- * Error occured during a config file parsing,
- * e.g. syntax error
- */
-struct ConfigException: public ServerException {
-    using ServerException::ServerException;
-};
 
 }
 
-#endif // SECURITY_CONTAINERS_SERVER_EXCEPTION_HPP
+
+#endif // SERVER_EXCEPTION_HPP
similarity index 96%
rename from src/server/src/main.cpp
rename to server/main.cpp
index 3bfb92c..f98afd3 100644 (file)
 
 
 /**
- * @file    main.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Main file for the Security Containers Daemon
  */
 
-#include "log.hpp"
-#include "log-backend-stderr.hpp"
-#include "utils-glib-loop.hpp"
-#include "utils-latch.hpp"
+#include "log/logger.hpp"
+#include "log/backend-stderr.hpp"
+#include "utils/glib-loop.hpp"
+#include "utils/latch.hpp"
 
 #include <boost/algorithm/string.hpp>
 #include <boost/program_options.hpp>
@@ -39,6 +39,7 @@ namespace po = boost::program_options;
 namespace security_containers {
 namespace {
 
+
 utils::Latch signalLatch;
 
 void signalHandler(int sig)
@@ -66,8 +67,10 @@ void runDaemon()
 } // namespace
 } // namespace security_containers
 
+
 namespace {
 
+
 const std::string PROGRAM_NAME_AND_VERSION =
     "Security Containers Server " PROGRAM_VERSION;
 
@@ -101,6 +104,7 @@ LogLevel validateLogLevel(const std::string& s)
 
 } // namespace
 
+
 int main(int argc, char* argv[])
 {
     try {
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
deleted file mode 100644 (file)
index f0e5c53..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed 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.
-#
-#
-# @file   CMakeLists.txt
-# @author Jan Olszak (j.olszak@samsung.com)
-#
-
-INCLUDE_DIRECTORIES ("${CLIENT_FOLDER}/include")
-ADD_SUBDIRECTORY(src)
\ No newline at end of file
diff --git a/src/client/include/sc-client.hpp b/src/client/include/sc-client.hpp
deleted file mode 100644 (file)
index 426c3db..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef SC_CLIENT_H
-#define SC_CLIENT_H
-
-#endif /*SC_CLIENT_H*/
diff --git a/src/client/include/scc-exception.hpp b/src/client/include/scc-exception.hpp
deleted file mode 100644 (file)
index c805cdc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef SECURITY_CONTAINERS_CLIENT_EXCEPTION_HPP
-#define SECURITY_CONTAINERS_CLIENT_EXCEPTION_HPP
-
-#include <stdexcept>
-
-namespace security_containers {
-
-/**
- * @brief Base class for exceptions in Security Containers Client
- */
-struct ClientException: public std::runtime_error {
-    ServerException(const std::string& mess = "Security Containers Client Exception"):
-        std::runtime_error(mess) {};
-};
-
-}
-
-#endif // SECURITY_CONTAINERS_CLIENT_EXCEPTION_HPP
diff --git a/src/client/src/sc-client.cpp b/src/client/src/sc-client.cpp
deleted file mode 100644 (file)
index ab5ade2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include <sc-client.hpp>
\ No newline at end of file
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
deleted file mode 100644 (file)
index b893c48..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed 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.
-#
-#
-# @file   CMakeLists.txt
-# @author Jan Olszak (j.olszak@samsung.com)
-#
-
-INCLUDE_DIRECTORIES ("${SERVER_FOLDER}/include")
-ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(unit_tests)
diff --git a/src/server/include/scs.hpp b/src/server/include/scs.hpp
deleted file mode 100644 (file)
index ccda2ce..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef SECURITY_CONTAINERS_SERVER_SCS_H
-#define SECURITY_CONTAINERS_SERVER_SCS_H
-
-#endif // SECURITY_CONTAINERS_SERVER_SCS_H
diff --git a/src/server/src/scs.cpp b/src/server/src/scs.cpp
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/server/unit_tests/CMakeLists.txt b/src/server/unit_tests/CMakeLists.txt
deleted file mode 100644 (file)
index 1b48518..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed 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.
-#
-#
-# @file   CMakeLists.txt
-# @author Jan Olszak (j.olszak@samsung.com)
-#
-
-MESSAGE(STATUS "Generating makefile for the Server unit tests...")
-FILE(GLOB_RECURSE project_SRCS *.cpp)
-FILE(GLOB src_SRCS ${SERVER_FOLDER}/src/dbus-connection.cpp
-                   ${SERVER_FOLDER}/src/log.cpp
-                   ${SERVER_FOLDER}/src/log-backend.cpp
-                   ${SERVER_FOLDER}/src/log-backend-stderr.cpp
-                   ${SERVER_FOLDER}/src/scs-container-admin.cpp
-                   ${SERVER_FOLDER}/src/scs-container.cpp
-                   ${SERVER_FOLDER}/src/scs-container-manager.cpp
-                   ${SERVER_FOLDER}/src/scs-configuration.cpp
-                   ${SERVER_FOLDER}/src/utils-glib-loop.cpp
-                   ${SERVER_FOLDER}/src/utils-file-wait.cpp
-                   ${SERVER_FOLDER}/src/utils-latch.cpp)
-
-
-## Setup target ################################################################
-SET(UT_SERVER_CODENAME "${PROJECT_NAME}-server-unit-tests")
-ADD_EXECUTABLE(${UT_SERVER_CODENAME} ${project_SRCS} ${src_SRCS})
-
-## Link libraries ##############################################################
-FIND_PACKAGE (Boost COMPONENTS unit_test_framework REQUIRED)
-
-PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED libvirt json gio-2.0)
-
-INCLUDE_DIRECTORIES(SYSTEM ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
-TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES})
-
-## Install #####################################################################
-INSTALL(TARGETS ${UT_SERVER_CODENAME} DESTINATION bin)
-
-FILE(GLOB manager_manager_CONF      ${SERVER_FOLDER}/unit_tests/config/ut-scs-container-manager/*.conf)
-FILE(GLOB manager_container_CONF    ${SERVER_FOLDER}/unit_tests/config/ut-scs-container-manager/containers/*.conf)
-FILE(GLOB manager_admin_CONF        ${SERVER_FOLDER}/unit_tests/config/ut-scs-container-manager/libvirt-config/*.xml)
-
-FILE(GLOB container_container_CONF  ${SERVER_FOLDER}/unit_tests/config/ut-scs-container/containers/*.conf)
-FILE(GLOB container_admin_CONF      ${SERVER_FOLDER}/unit_tests/config/ut-scs-container/libvirt-config/*.xml)
-
-FILE(GLOB admin_container_CONF      ${SERVER_FOLDER}/unit_tests/config/ut-scs-container-admin/containers/*.conf)
-FILE(GLOB admin_admin_CONF          ${SERVER_FOLDER}/unit_tests/config/ut-scs-container-admin/libvirt-config/*.xml)
-
-FILE(GLOB dbus_CONF                 ${SERVER_FOLDER}/unit_tests/config/ut-dbus-connection/*.conf)
-
-INSTALL(FILES        ${manager_manager_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container-manager)
-INSTALL(FILES        ${manager_container_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container-manager/containers)
-INSTALL(FILES        ${manager_admin_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container-manager/libvirt-config)
-
-INSTALL(FILES        ${container_container_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container/containers)
-INSTALL(FILES        ${container_admin_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container/libvirt-config)
-
-INSTALL(FILES        ${admin_container_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container-admin/containers)
-INSTALL(FILES        ${admin_admin_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-scs-container-admin/libvirt-config)
-
-INSTALL(FILES        ${dbus_CONF}
-        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/ut-dbus-connection)
diff --git a/src/server/unit_tests/config/ut-scs-container-admin/containers/buggy.conf b/src/server/unit_tests/config/ut-scs-container-admin/containers/buggy.conf
deleted file mode 100644 (file)
index aba5971..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-    "privilege" : 10,
-    "config" : "/etc/security-containers/tests/ut-scs-container-admin/libvirt-config/buggy.xml",
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000
-}
diff --git a/src/server/unit_tests/config/ut-scs-container-admin/containers/test.conf b/src/server/unit_tests/config/ut-scs-container-admin/containers/test.conf
deleted file mode 100644 (file)
index c87fde0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-    "privilege" : 10,
-    "config" : "/etc/security-containers/tests/ut-scs-container-admin/libvirt-config/test.xml",
-    "cpuQuotaForeground" : -1,
-    "cpuQuotaBackground" : 1000
-}
diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2f6c2b6
--- /dev/null
@@ -0,0 +1,50 @@
+# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed 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.
+#
+#
+# @file   CMakeLists.txt
+# @author Jan Olszak (j.olszak@samsung.com)
+#
+
+MESSAGE(STATUS "Generating makefile for the Unit Tests...")
+FILE(GLOB_RECURSE project_SRCS *.cpp *.hpp)
+FILE(GLOB_RECURSE common_SRCS ${COMMON_FOLDER}/*.cpp ${COMMON_FOLDER}/*.hpp)
+FILE(GLOB         server_SRCS ${SERVER_FOLDER}/*.cpp ${SERVER_FOLDER}/*.hpp)
+
+FILE(GLOB         main_SRC ${SERVER_FOLDER}/main.cpp)
+LIST(REMOVE_ITEM server_SRCS ${main_SRC})
+
+
+## Setup target ################################################################
+SET(UT_SERVER_CODENAME "${PROJECT_NAME}-server-unit-tests")
+ADD_EXECUTABLE(${UT_SERVER_CODENAME} ${project_SRCS} ${common_SRCS} ${server_SRCS})
+
+
+## Link libraries ##############################################################
+FIND_PACKAGE (Boost COMPONENTS unit_test_framework REQUIRED)
+
+PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED libvirt json gio-2.0)
+INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_FOLDER} ${UNIT_TESTS_FOLDER}
+                    ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES})
+
+
+## Subdirectories ##############################################################
+ADD_SUBDIRECTORY(scripts)
+ADD_SUBDIRECTORY(dbus/configs)
+ADD_SUBDIRECTORY(server/configs)
+
+
+## Install #####################################################################
+INSTALL(TARGETS ${UT_SERVER_CODENAME} DESTINATION bin)
similarity index 98%
rename from src/server/unit_tests/ut-scs-configuration.cpp
rename to unit_tests/config/ut-configuration.cpp
index 59dad02..4a95cf9 100644 (file)
 
 
 /**
- * @file    ut-scs-configuration.cpp
+ * @file
  * @author  Michal Witanowski (m.witanowski@samsung.com)
  * @brief   Unit test of ConfigurationBase
  */
 
 #include "ut.hpp"
-#include "scs-configuration.hpp"
+#include "config/configuration.hpp"
 
 using namespace security_containers;
+using namespace security_containers::config;
 
 BOOST_AUTO_TEST_SUITE(ConfigSuite)
 
similarity index 63%
rename from src/client/src/CMakeLists.txt
rename to unit_tests/dbus/configs/CMakeLists.txt
index ba9e314..3bfa40b 100644 (file)
 #
 #
 # @file   CMakeLists.txt
-# @author Jan Olszak (j.olszak@samsung.com)
+# @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
 #
 
-MESSAGE(STATUS "Generating makefile for the Client...")
-FILE(GLOB_RECURSE project_SRCS *.cpp *.cxx *.cc *.C *.c *.h *.hpp)
+MESSAGE(STATUS "Installing configs for the DBus Unit Tests to " ${SC_CONFIG_INSTALL_DIR})
+FILE(GLOB dbus_CONF                 ut-connection/*.conf)
 
-ADD_LIBRARY(${CLIENT_CODENAME} SHARED ${project_SRCS})
-INSTALL(TARGETS     ${CLIENT_CODENAME}
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}
-        COMPONENT   RuntimeLibraries)
+
+## Install #####################################################################
+INSTALL(FILES        ${dbus_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/dbus/ut-connection)
similarity index 94%
rename from src/server/unit_tests/dbus-test-client.cpp
rename to unit_tests/dbus/test-client.cpp
index 0741711..6d94b8d 100644 (file)
  */
 
 /**
- * @file    dbus-test-client.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Example dbus api client
  */
 
-#include "dbus-test-client.hpp"
-#include "dbus-connection.hpp"
-#include "dbus-test-common.hpp"
+#include "dbus/test-client.hpp"
+#include "dbus/test-common.hpp"
+
+#include "dbus/connection.hpp"
+
 
 namespace security_containers {
 
+
 DbusTestClient::DbusTestClient()
 {
     mConnection = dbus::DbusConnection::create(DBUS_ADDRESS);
@@ -68,4 +71,5 @@ void DbusTestClient::throwException(int arg)
                             "()");
 }
 
+
 } // namespace security_containers
similarity index 86%
rename from src/server/unit_tests/dbus-test-client.hpp
rename to unit_tests/dbus/test-client.hpp
index 5a02bb5..9b983b3 100644 (file)
  */
 
 /**
- * @file    dbus-test-client.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Example dbus api client
  */
 
-#ifndef DBUS_TEST_CLIENT_HPP
-#define DBUS_TEST_CLIENT_HPP
+#ifndef UNIT_TESTS_DBUS_TEST_CLIENT_HPP
+#define UNIT_TESTS_DBUS_TEST_CLIENT_HPP
+
+#include "dbus/connection.hpp" //TODO dbus/connection-iface.h
 
-#include "dbus-connection.hpp" //TODO dbus-connection-iface.h
 #include <string>
 #include <memory>
 
+
 namespace security_containers {
 
+
 /**
  * Simple dbus client for test purposes.
  * Class used to test all possible kinds of dbus calls.
@@ -48,6 +51,8 @@ private:
     dbus::DbusConnection::Pointer mConnection;
 };
 
+
 } // namespace security_containers
 
-#endif //DBUS_TEST_CLIENT_HPP
+
+#endif // UNIT_TESTS_DBUS_TEST_CLIENT_HPP
similarity index 93%
rename from src/server/unit_tests/dbus-test-common.hpp
rename to unit_tests/dbus/test-common.hpp
index 2223560..35cf6e8 100644 (file)
  */
 
 /**
- * @file    dbus-test-common.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Common definitions for dbus tests
  */
 
-#ifndef DBUS_TEST_COMMON_HPP
-#define DBUS_TEST_COMMON_HPP
+#ifndef UNIT_TESTS_DBUS_TEST_COMMON_HPP
+#define UNIT_TESTS_DBUS_TEST_COMMON_HPP
 
 #include <string>
 
+
 namespace security_containers {
 
+
 const std::string DBUS_SOCKET_FILE       = "/tmp/container_socket";
 const std::string DBUS_ADDRESS           = "unix:path=" + DBUS_SOCKET_FILE;
 
@@ -53,6 +55,8 @@ const std::string TESTAPI_DEFINITION =
     "  </interface>"
     "</node>";
 
+
 } // namespace security_containers
 
-#endif //DBUS_TEST_COMMON_HPP
+
+#endif // UNIT_TESTS_DBUS_TEST_COMMON_HPP
similarity index 95%
rename from src/server/unit_tests/dbus-test-server.cpp
rename to unit_tests/dbus/test-server.cpp
index 7ab442c..2a1c0a8 100644 (file)
  */
 
 /**
- * @file    dbus-test-server.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Example dbus api server
  */
 
-#include "dbus-test-server.hpp"
-#include "dbus-connection.hpp"
-#include "dbus-exception.hpp"
-#include "dbus-test-common.hpp"
-#include "log.hpp"
+#include "dbus/test-server.hpp"
+#include "dbus/test-common.hpp"
+
+#include "dbus/connection.hpp"
+#include "dbus/exception.hpp"
+#include "log/logger.hpp"
+
 
 namespace security_containers {
 
+
 DbusTestServer::DbusTestServer()
     : mNameAcquired(false)
     , mPendingDisconnect(false)
@@ -133,4 +136,5 @@ void DbusTestServer::onMessageCall(
     }
 }
 
+
 } // namespace security_containers
similarity index 90%
rename from src/server/unit_tests/dbus-test-server.hpp
rename to unit_tests/dbus/test-server.hpp
index 73fe331..eb396a2 100644 (file)
  */
 
 /**
- * @file    dbus-test-server.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Example dbus api server
  */
 
-#ifndef DBUS_TEST_SERVER_HPP
-#define DBUS_TEST_SERVER_HPP
+#ifndef UNIT_TESTS_DBUS_TEST_SERVER_HPP
+#define UNIT_TESTS_DBUS_TEST_SERVER_HPP
+
+#include "dbus/connection.hpp" // TODO dbus-connection-iface.h
 
-#include "dbus-connection.hpp" // TODO dbus-connection-iface.h
 #include <string>
 #include <memory>
 #include <mutex>
 #include <condition_variable>
 
+
 namespace security_containers {
 
+
 /**
  * Simple dbus server for test purposes.
  * Class used to test all possible kinds of callbacks.
@@ -72,6 +75,8 @@ private:
         dbus::MethodResultBuilder& result);
 };
 
+
 } // namespace security_containers
 
-#endif //DBUS_TEST_SERVER_HPP
+
+#endif // UNIT_TESTS_DBUS_TEST_SERVER_HPP
similarity index 96%
rename from src/server/unit_tests/ut-dbus-connection.cpp
rename to unit_tests/dbus/ut-connection.cpp
index 628ed0b..2f33609 100644 (file)
  */
 
 /**
- * @file    ut-dbus-connection.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Dbus connection unit tests
  */
 
 #include "ut.hpp"
-#include "dbus-connection.hpp"
-#include "dbus-exception.hpp"
-#include "utils-scoped-daemon.hpp"
-#include "utils-glib-loop.hpp"
-#include "utils-file-wait.hpp"
-#include "utils-latch.hpp"
-#include "dbus-test-server.hpp"
-#include "dbus-test-client.hpp"
-#include "dbus-test-common.hpp"
-#include "log.hpp"
+#include "dbus/test-server.hpp"
+#include "dbus/test-client.hpp"
+#include "dbus/test-common.hpp"
+#include "utils/scoped-daemon.hpp"
+
+#include "dbus/connection.hpp"
+#include "dbus/exception.hpp"
+#include "utils/glib-loop.hpp"
+#include "utils/file-wait.hpp"
+#include "utils/latch.hpp"
+#include "log/logger.hpp"
+
 #include <thread>
 #include <mutex>
 #include <condition_variable>
@@ -49,7 +51,7 @@ namespace {
 const char* DBUS_DAEMON_PROC = "/bin/dbus-daemon";
 const char* const DBUS_DAEMON_ARGS[] = {
     DBUS_DAEMON_PROC,
-    "--config-file=/etc/security-containers/tests/ut-dbus-connection/ut-dbus.conf",
+    "--config-file=/etc/security-containers/tests/dbus/ut-connection/ut-dbus.conf",
     "--nofork",
     NULL
 };
similarity index 97%
rename from src/server/unit_tests/ut-log.cpp
rename to unit_tests/log/ut-logger.cpp
index f4b74e7..863e3f9 100644 (file)
 
 
 /**
- * @file    ut-log.cpp
+ * @file
  * @author  Pawel Broda (p.broda@partner.samsung.com)
  * @brief   Unit tests of the log utility
  */
 
 #include "ut.hpp"
-#include "log.hpp"
-#include "log-backend.hpp"
-#include "log-backend-stderr.hpp"
+
+#include "log/logger.hpp"
+#include "log/backend.hpp"
+#include "log/backend-stderr.hpp"
 
 
 BOOST_AUTO_TEST_SUITE(LogSuite)
similarity index 91%
rename from src/scripts/CMakeLists.txt
rename to unit_tests/scripts/CMakeLists.txt
index 248b106..5680173 100644 (file)
@@ -20,4 +20,6 @@
 MESSAGE(STATUS "Installing scripts to " ${SCRIPT_INSTALL_DIR})
 FILE(GLOB_RECURSE scripts *.py)
 
+
+## Install #####################################################################
 INSTALL(PROGRAMS ${scripts} DESTINATION ${SCRIPT_INSTALL_DIR})
diff --git a/unit_tests/server/configs/CMakeLists.txt b/unit_tests/server/configs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2254427
--- /dev/null
@@ -0,0 +1,48 @@
+# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed 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.
+#
+#
+# @file   CMakeLists.txt
+# @author Jan Olszak (j.olszak@samsung.com)
+#
+
+MESSAGE(STATUS "Installing configs for the Server Unit Tests to " ${SC_CONFIG_INSTALL_DIR})
+FILE(GLOB manager_manager_CONF      ut-containers-manager/*.conf)
+FILE(GLOB manager_container_CONF    ut-containers-manager/containers/*.conf)
+FILE(GLOB manager_admin_CONF        ut-containers-manager/libvirt-config/*.xml)
+
+FILE(GLOB container_container_CONF  ut-container/containers/*.conf)
+FILE(GLOB container_admin_CONF      ut-container/libvirt-config/*.xml)
+
+FILE(GLOB admin_container_CONF      ut-container-admin/containers/*.conf)
+FILE(GLOB admin_admin_CONF          ut-container-admin/libvirt-config/*.xml)
+
+
+## Install #####################################################################
+INSTALL(FILES        ${manager_manager_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-containers-manager)
+INSTALL(FILES        ${manager_container_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-containers-manager/containers)
+INSTALL(FILES        ${manager_admin_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-containers-manager/libvirt-config)
+
+INSTALL(FILES        ${container_container_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-container/containers)
+INSTALL(FILES        ${container_admin_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-container/libvirt-config)
+
+INSTALL(FILES        ${admin_container_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-container-admin/containers)
+INSTALL(FILES        ${admin_admin_CONF}
+        DESTINATION  ${SC_CONFIG_INSTALL_DIR}/tests/server/ut-container-admin/libvirt-config)
diff --git a/unit_tests/server/configs/ut-container-admin/containers/buggy.conf b/unit_tests/server/configs/ut-container-admin/containers/buggy.conf
new file mode 100644 (file)
index 0000000..42fd422
--- /dev/null
@@ -0,0 +1,6 @@
+{
+    "privilege" : 10,
+    "config" : "/etc/security-containers/tests/server/ut-container-admin/libvirt-config/buggy.xml",
+    "cpuQuotaForeground" : -1,
+    "cpuQuotaBackground" : 1000
+}
diff --git a/unit_tests/server/configs/ut-container-admin/containers/test.conf b/unit_tests/server/configs/ut-container-admin/containers/test.conf
new file mode 100644 (file)
index 0000000..a0f368f
--- /dev/null
@@ -0,0 +1,6 @@
+{
+    "privilege" : 10,
+    "config" : "/etc/security-containers/tests/server/ut-container-admin/libvirt-config/test.xml",
+    "cpuQuotaForeground" : -1,
+    "cpuQuotaBackground" : 1000
+}
similarity index 93%
rename from src/server/unit_tests/ut-scs-container-admin.cpp
rename to unit_tests/server/ut-container-admin.cpp
index e638be5..4fa7a30 100644 (file)
 
 
 /**
- * @file    ut-scs-container-admin.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Unit tests of the ContainerAdmin class
  */
 
 #include "ut.hpp"
-#include "scs-container-admin.hpp"
-#include "scs-exception.hpp"
+
+#include "container-admin.hpp"
+#include "exception.hpp"
 
 #include <memory>
 #include <string>
 BOOST_AUTO_TEST_SUITE(ContainerAdminSuite)
 
 using namespace security_containers;
+using namespace security_containers::config;
 
-const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-admin/containers/test.conf";
-const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-admin/containers/buggy.conf";
-const std::string MISSING_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-admin/containers/missing.conf";
+const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/server/ut-container-admin/containers/test.conf";
+const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/server/ut-container-admin/containers/buggy.conf";
+const std::string MISSING_CONFIG_PATH = "/etc/security-containers/tests/server/ut-container-admin/containers/missing.conf";
 
 
 BOOST_AUTO_TEST_CASE(ConstructorTest)
similarity index 85%
rename from src/server/unit_tests/ut-scs-container.cpp
rename to unit_tests/server/ut-container.cpp
index 8d49caa..645e12d 100644 (file)
 
 
 /**
- * @file    ut-scs-container.cpp
+ * @file
  * @author  Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
  * @brief   Unit tests of the Container class
  */
 
 #include "ut.hpp"
-#include "scs-container.hpp"
-#include "scs-exception.hpp"
+
+#include "container.hpp"
+#include "exception.hpp"
 
 #include <memory>
 #include <string>
 BOOST_AUTO_TEST_SUITE(ContainerSuite)
 
 using namespace security_containers;
+using namespace security_containers::config;
 
-const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container/containers/test.conf";
-const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container/containers/buggy.conf";
+const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/server/ut-container/containers/test.conf";
+const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/server/ut-container/containers/buggy.conf";
 const std::string MISSING_CONFIG_PATH = "/this/is/a/missing/file/path/config.conf";
 
 
@@ -53,7 +55,7 @@ BOOST_AUTO_TEST_CASE(DestructorTest)
 
 BOOST_AUTO_TEST_CASE(BuggyConfigTest)
 {
-    BOOST_REQUIRE_THROW(Container c(BUGGY_CONFIG_PATH), ServerException);
+    BOOST_REQUIRE_THROW(Container c(BUGGY_CONFIG_PATH), ConfigException);
 }
 
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 
 
 /**
- * @file    ut-scs-container.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
- * @brief   Unit tests of the Container class
+ * @brief   Unit tests of the ContainersManager class
  */
 
 #include "ut.hpp"
-#include "scs-container-manager.hpp"
-#include "scs-exception.hpp"
+
+#include "containers-manager.hpp"
+#include "exception.hpp"
 
 #include <memory>
 #include <string>
 
 
-BOOST_AUTO_TEST_SUITE(ContainerManagerSuite)
+BOOST_AUTO_TEST_SUITE(ContainersManagerSuite)
 
 using namespace security_containers;
+using namespace security_containers::config;
 
-const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-manager/test-daemon.conf";
-const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-manager/buggy-daemon.conf";
-const std::string BUGGY_FOREGROUND_CONFIG_PATH = "/etc/security-containers/tests/ut-scs-container-manager/buggy-foreground-daemon.conf";
+const std::string TEST_CONFIG_PATH = "/etc/security-containers/tests/server/ut-containers-manager/test-daemon.conf";
+const std::string BUGGY_CONFIG_PATH = "/etc/security-containers/tests/server/ut-containers-manager/buggy-daemon.conf";
+const std::string BUGGY_FOREGROUND_CONFIG_PATH = "/etc/security-containers/tests/server/ut-containers-manager/buggy-foreground-daemon.conf";
 const std::string MISSING_CONFIG_PATH = "/this/is/a/missing/file/path/missing-daemon.conf";
 
 
 BOOST_AUTO_TEST_CASE(ConstructorTest)
 {
-    BOOST_REQUIRE_NO_THROW(ContainerManager cm(TEST_CONFIG_PATH););
+    BOOST_REQUIRE_NO_THROW(ContainersManager cm(TEST_CONFIG_PATH););
 }
 
 BOOST_AUTO_TEST_CASE(DestructorTest)
 {
-    std::unique_ptr<ContainerManager> cm(new ContainerManager(TEST_CONFIG_PATH));
+    std::unique_ptr<ContainersManager> cm(new ContainersManager(TEST_CONFIG_PATH));
     BOOST_REQUIRE_NO_THROW(cm.reset());
 }
 
 BOOST_AUTO_TEST_CASE(BuggyConfigTest)
 {
-    BOOST_REQUIRE_THROW(ContainerManager cm(BUGGY_CONFIG_PATH), ConfigException);
+    BOOST_REQUIRE_THROW(ContainersManager cm(BUGGY_CONFIG_PATH), ConfigException);
 }
 
 BOOST_AUTO_TEST_CASE(MissingConfigTest)
 {
-    BOOST_REQUIRE_THROW(ContainerManager cm(MISSING_CONFIG_PATH), ConfigException);
+    BOOST_REQUIRE_THROW(ContainersManager cm(MISSING_CONFIG_PATH), ConfigException);
 }
 
 BOOST_AUTO_TEST_CASE(StartAllTest)
 {
-    ContainerManager cm(TEST_CONFIG_PATH);
+    ContainersManager cm(TEST_CONFIG_PATH);
     BOOST_REQUIRE_NO_THROW(cm.startAll());
     BOOST_CHECK(cm.getRunningForegroundContainerId() == "console1");
 }
 
 BOOST_AUTO_TEST_CASE(BuggyForegroundTest)
 {
-    ContainerManager cm(BUGGY_FOREGROUND_CONFIG_PATH);
+    ContainersManager cm(BUGGY_FOREGROUND_CONFIG_PATH);
     BOOST_REQUIRE_NO_THROW(cm.startAll());
     BOOST_CHECK(cm.getRunningForegroundContainerId() == "console2");
 }
 
 BOOST_AUTO_TEST_CASE(StopAllTest)
 {
-    ContainerManager cm(TEST_CONFIG_PATH);
+    ContainersManager cm(TEST_CONFIG_PATH);
     BOOST_REQUIRE_NO_THROW(cm.startAll());
     BOOST_REQUIRE_NO_THROW(cm.stopAll());
     BOOST_CHECK(cm.getRunningForegroundContainerId().empty());
@@ -86,7 +88,7 @@ BOOST_AUTO_TEST_CASE(StopAllTest)
 
 BOOST_AUTO_TEST_CASE(FocusTest)
 {
-    ContainerManager cm(TEST_CONFIG_PATH);
+    ContainersManager cm(TEST_CONFIG_PATH);
     BOOST_REQUIRE_NO_THROW(cm.startAll());
     BOOST_REQUIRE_NO_THROW(cm.focus("console2"));
     BOOST_CHECK(cm.getRunningForegroundContainerId() == "console2");
similarity index 80%
rename from src/server/unit_tests/ut-main.cpp
rename to unit_tests/ut.cpp
index 4d96821..27f6b88 100644 (file)
 
 
 /**
- * @file    ut-main.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Main file for the Security Containers Daemon unit tests
  */
 
-#include "log.hpp"
-#include "log-backend-stderr.hpp"
+#define BOOST_TEST_MAIN init_unit_test_suite
+#include "ut.hpp"
 
-#include <boost/test/included/unit_test.hpp>
-#include <boost/test/unit_test.hpp>  // for unit_test framework
+#include "log/logger.hpp"
+#include "log/backend-stderr.hpp"
 
 
 using namespace boost::unit_test;
 using namespace security_containers::log;
 
-test_suite* init_unit_test_suite(int /*argc*/, char** /*argv*/)
+test_suite* BOOST_TEST_MAIN(int /*argc*/, char** /*argv*/)
 {
     Logger::setLogLevel(LogLevel::TRACE);
     Logger::setLogBackend(new StderrBackend());
similarity index 87%
rename from src/server/unit_tests/ut.hpp
rename to unit_tests/ut.hpp
index 7327041..d012cd2 100644 (file)
  */
 
 /**
- * @file    ut.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Common unit tests include file
  */
 
-#ifndef SECURITY_CONTAINERS_UT_HPP
-#define SECURITY_CONTAINERS_UT_HPP
+#ifndef UNIT_TESTS_UT_HPP
+#define UNIT_TESTS_UT_HPP
 
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/unit_test.hpp>
 
-#endif //SECURITY_CONTAINERS_UT_HPP
+#endif // UNIT_TESTS_UT_HPP
similarity index 97%
rename from src/server/unit_tests/utils-scoped-daemon.cpp
rename to unit_tests/utils/scoped-daemon.cpp
index 537683a..502ddf5 100644 (file)
  */
 
 /**
- * @file    utils-scoped-daemon.cpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Starts external daemon in constructor, stops it in destructor
  */
 
-#include "utils-scoped-daemon.hpp"
-#include "log.hpp"
+#include "utils/scoped-daemon.hpp"
+
+#include "log/logger.hpp"
+
 #include <unistd.h>
 #include <sys/wait.h>
 #include <sys/prctl.h>
 #include <stdexcept>
 
+
 namespace security_containers {
 namespace utils {
 
+
 /*
  * Scoped Daemon - sequence diagram.
  *
@@ -156,5 +160,6 @@ void ScopedDaemon::stop()
     mPid = -1;
 }
 
+
 } // namespace utils
 } // namespace security_containers
similarity index 91%
rename from src/server/unit_tests/utils-scoped-daemon.hpp
rename to unit_tests/utils/scoped-daemon.hpp
index f138a70..344abe4 100644 (file)
  */
 
 /**
- * @file    utils-scoped-daemon.hpp
+ * @file
  * @author  Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
  * @brief   Starts external daemon in constructor, stops it in destructor
  */
 
-#ifndef UTILS_SCOPED_DAEMON_HPP
-#define UTILS_SCOPED_DAEMON_HPP
+#ifndef UNIT_TESTS_UTILS_SCOPED_DAEMON_HPP
+#define UNIT_TESTS_UTILS_SCOPED_DAEMON_HPP
 
 #include <sys/types.h>
 
+
 namespace security_containers {
 namespace utils {
 
+
 /**
  * External daemon launcher helper.
  */
@@ -56,7 +58,9 @@ private:
     pid_t mPid;
 };
 
+
 } // namespace utils
 } // namespace security_containers
 
-#endif // UTILS_SCOPED_DAEMON_HPP
+
+#endif // UNIT_TESTS_UTILS_SCOPED_DAEMON_HPP
similarity index 98%
rename from src/server/unit_tests/ut-utils.cpp
rename to unit_tests/utils/ut-paths.cpp
index c5533cf..e4c4f9e 100644 (file)
 
 
 /**
- * @file    ut-utils.cpp
+ * @file
  * @author  Jan Olszak (j.olszak@samsung.com)
  * @brief   Unit tests of utils
  */
 
 #include "ut.hpp"
-#include "utils.hpp"
+
+#include "utils/paths.hpp"
 
 #include <memory>