[Bug/Feature] Various changes relating to build on Ubuntu and Fedora Linux.
[Cause] N/A
[Solution] N/A
Verification] Build, run server, run tests.
Change-Id: Ie9f8c05a0de96b0dc07d506657a48f6dd1b074b4
INCLUDE(GNUInstallDirs)
## Color output if it's possible:
-IF (( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.3))
+IF (( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ))
ADD_DEFINITIONS("-fdiagnostics-color=always")
ADD_DEFINITIONS(-DUSE_EXEC)
ADD_DEFINITIONS(-D__STDC_LIMIT_MACROS)
-PKG_SEARCH_MODULE(JSON_C REQUIRED json json-c)
-IF(JSON_C_VERSION GREATER 0.11)
- ADD_DEFINITIONS(-DJSON_C_VERSION_NEW)
-ENDIF(JSON_C_VERSION GREATER 0.11)
-
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Warn about documentation problems
ADD_DEFINITIONS("-Wdocumentation")
IF(NOT WITHOUT_DBUS)
ADD_DEFINITIONS(-DDBUS_CONNECTION)
ENDIF(NOT WITHOUT_DBUS)
+IF(NOT WITHOUT_SYSTEMD)
+ ADD_DEFINITIONS(-DHAVE_SYSTEMD)
+ENDIF(NOT WITHOUT_SYSTEMD)
## Python packages directory ###################################################
IF(NOT DEFINED PYTHON_SITELIB)
ADD_SUBDIRECTORY(${LOGGER_FOLDER})
ADD_SUBDIRECTORY(${LXCPP_FOLDER})
+IF(NOT WITHOUT_DBUS)
ADD_SUBDIRECTORY(${DBUS_FOLDER})
+ENDIF(NOT WITHOUT_DBUS)
ADD_SUBDIRECTORY(${CONFIG_FOLDER})
ADD_SUBDIRECTORY(${IPC_FOLDER})
ADD_SUBDIRECTORY(${CLIENT_FOLDER})
ADD_SUBDIRECTORY(${SERVER_FOLDER})
+IF(NOT WITHOUT_DBUS)
ADD_SUBDIRECTORY(${ZONE_SUPPORT_FOLDER})
ADD_SUBDIRECTORY(${ZONE_DAEMON_FOLDER})
+ENDIF(NOT WITHOUT_DBUS)
ADD_SUBDIRECTORY(${TESTS_FOLDER})
ADD_SUBDIRECTORY(${CLI_FOLDER})
ADD_SUBDIRECTORY(${WRAPPER_FOLDER})
## Link libraries ##############################################################
FIND_PACKAGE(Boost COMPONENTS system filesystem)
PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0)
-INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(${IPC_FOLDER})
INCLUDE_DIRECTORIES(${SERVER_FOLDER})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Config SimpleDbus Ipc)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES} Config Ipc)
+IF(NOT WITHOUT_DBUS)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} SimpleDbus)
+ENDIF(NOT WITHOUT_DBUS)
## Generate the pc file ########################################################
CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
## Link libraries ##############################################################
PKG_CHECK_MODULES(CONFIG_DEPS REQUIRED sqlite3 glib-2.0)
-PKG_SEARCH_MODULE(JSON_C json json-c)
+PKG_SEARCH_MODULE(JSON_C REQUIRED json json-c)
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(SYSTEM ${CONFIG_DEPS_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
#include "config/is-visitable.hpp"
#include "config/exception.hpp"
-#ifdef JSON_C_VERSION_NEW
-#include <json-c/json.h>
-#else //JSON_C_VERSION_NEW
-#include <json/json.h>
-#endif //JSON_C_VERSION_NEW
-
+#include <json.h>
#include <string>
#include <vector>
#include "config/from-kvstore-visitor.hpp"
#include "config/is-union.hpp"
-#ifdef JSON_C_VERSION_NEW
-#include <json-c/json.h>
-#else //JSON_C_VERSION_NEW
-#include <json/json.h>
-#endif //JSON_C_VERSION_NEW
+#include <json.h>
namespace config {
#include "config/is-visitable.hpp"
#include "config/exception.hpp"
-#ifdef JSON_C_VERSION_NEW
-#include <json-c/json.h>
-#else //JSON_C_VERSION_NEW
-#include <json/json.h>
-#endif //JSON_C_VERSION_NEW
-
+#include <json.h>
#include <string>
#include <vector>
static json_object* toJsonObject(double value)
{
-#ifdef JSON_C_VERSION_NEW
+#if JSON_C_MINOR_VERSION >= 12
return json_object_new_double_s(value, std::to_string(value).c_str());
-#else //JSON_C_VERSION_NEW
+#else
return json_object_new_double(value);
-#endif //JSON_C_VERSION_NEW
+#endif
}
static json_object* toJsonObject(const std::string& value)
)
## Link libraries ##############################################################
+IF(NOT WITHOUT_SYSTEMD)
PKG_CHECK_MODULES(IPC_DEPS REQUIRED libsystemd-daemon)
+ENDIF(NOT WITHOUT_SYSTEMD)
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
-INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS} ${IPC_DEPS_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${DBUS_DEPS_INCLUDE_DIRS} ${IPC_DEPS_INCLUDE_DIRS} ${CONFIG_DEPS_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${IPC_DEPS_LIBRARIES} Logger Config)
## Generate the pc file ########################################################
#include "utils/exception.hpp"
#include "logger/logger.hpp"
+#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
+#endif // HAVE_SYSTEMD
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
utils::read(mFD, bufferPtr, size);
}
+#ifdef HAVE_SYSTEMD
int Socket::getSystemdSocketInternal(const std::string& path)
{
int n = ::sd_listen_fds(-1 /*Block further calls to sd_listen_fds*/);
LOGW("No usable sockets were passed by systemd.");
return -1;
}
+#endif // HAVE_SYSTEMD
int Socket::createSocketInternal(const std::string& path)
{
Socket Socket::createSocket(const std::string& path)
{
// Initialize a socket
- int fd = getSystemdSocketInternal(path);
+ int fd = -1;
+#ifdef HAVE_SYSTEMD
+ fd = getSystemdSocketInternal(path);
+#endif // HAVE_SYSTEMD
fd = fd != -1 ? fd : createSocketInternal(path);
return Socket(fd);
)
## Link libraries ##############################################################
-PKG_CHECK_MODULES(LOGGER_DEPS libsystemd-journal QUIET)
+IF(NOT WITHOUT_SYSTEMD)
+PKG_CHECK_MODULES(LOGGER_DEPS REQUIRED libsystemd-journal)
+ENDIF(NOT WITHOUT_SYSTEMD)
+
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(SYSTEM ${LOGGER_DEPS_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${LOGGER_DEPS_LIBRARIES})
-## Add constants ###############################################################
-if(LOGGER_DEPS_FOUND)
- ADD_DEFINITIONS(-DHAVE_SYSTEMD_JOURNAL=${LOGGER_DEPS_FOUND})
-endif()
-
## Generate the pc file ########################################################
CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY)
* @author Dariusz Michaluk (d.michaluk@samsung.com)
* @brief Systemd journal backend for logger
*/
-#ifdef HAVE_SYSTEMD_JOURNAL
+
+#ifdef HAVE_SYSTEMD
#include "logger/config.hpp"
#include "logger/backend-journal.hpp"
}
} // namespace logger
-#endif // HAVE_SYSTEMD_JOURNAL
+#endif // HAVE_SYSTEMD
%define tty_group tty
# Default platform is Tizen, setup Fedora with --define 'platform_type FEDORA'
%{!?platform_type:%define platform_type "TIZEN"}
+# Default build with dbus
+%{!?without_dbus:%define without_dbus 0}
+# Default build with systemd
+%{!?without_systemd:%define without_systemd 0}
Name: vasum
Epoch: 1
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: lxc-devel
BuildRequires: readline-devel
+BuildRequires: pkgconfig(sqlite3)
Requires: lxc
+%if !%{without_systemd}
+BuildRequires: pkgconfig(libsystemd-daemon)
+BuildRequires: pkgconfig(libsystemd-journal)
+%endif
%if %{platform_type} == "TIZEN"
+BuildRequires: libjson-devel >= 0.10
Requires: iproute2
Requires(post): libcap-tools
%else
+BuildRequires: json-c-devel
Requires: lxc-templates
Requires: iproute
Requires(post): libcap
%config /etc/vasum/daemon.conf
%attr(755,root,root) /etc/vasum/templates/*.sh
%config /etc/vasum/templates/*.conf
+%if !%{without_systemd}
%{_unitdir}/vasum.service
%{_unitdir}/vasum.socket
%{_unitdir}/multi-user.target.wants/vasum.service
+%endif
+%if !%{without_dbus}
%config /etc/dbus-1/system.d/org.tizen.vasum.host.conf
+%endif
%dir %{_datadir}/zones
%prep
-DINPUT_EVENT_GROUP=%{input_event_group} \
-DDISK_GROUP=%{disk_group} \
-DTTY_GROUP=%{tty_group} \
- -DWITHOUT_DBUS=%{?without_dbus}
+ -DWITHOUT_DBUS=%{?without_dbus} \
+ -DWITHOUT_SYSTEMD=%{?without_systemd}
make -k %{?jobs:-j%jobs}
%install
%make_install
+%if !%{without_systemd}
mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
ln -s ../vasum.service %{buildroot}/%{_unitdir}/multi-user.target.wants/vasum.service
+%endif
mkdir -p %{buildroot}/%{_datadir}/zones
%if %{platform_type} == "TIZEN"
ln -s tizen.conf %{buildroot}/etc/vasum/templates/default.conf
rm -rf %{buildroot}
%post
+%if !%{without_systemd}
# Refresh systemd services list after installation
if [ $1 == 1 ]; then
systemctl daemon-reload || :
fi
+%endif
+
# set needed caps on the binary to allow restart without loosing them
setcap CAP_SYS_ADMIN,CAP_MAC_OVERRIDE,CAP_SYS_TTY_CONFIG+ei %{_bindir}/vasum-server
%preun
+%if !%{without_systemd}
# Stop the service before uninstall
if [ $1 == 0 ]; then
systemctl stop vasum.service || :
fi
+%endif
%postun
+%if !%{without_systemd}
# Refresh systemd services list after uninstall/upgrade
systemctl daemon-reload || :
if [ $1 -ge 1 ]; then
else
echo "Vasum removed. Reboot is required for the changes to take effect..."
fi
+%endif
## Client Package ##############################################################
%package client
%{_libdir}/pkgconfig/vasum-client.pc
%{_libdir}/pkgconfig/vasum.pc
-
+%if !%{without_dbus}
## Zone Support Package ###################################################
%package zone-support
Summary: Vasum Support
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/vasum-zone-daemon
%config /etc/dbus-1/system.d/org.tizen.vasum.zone.daemon.conf
-
+%endif
## Command Line Interface ######################################################
%package cli
Unit tests for both: server and client and integration tests.
%post tests
-systemctl daemon-reload
-systemctl enable vasum-socket-test.socket
-systemctl start vasum-socket-test.socket
+%if !%{without_systemd}
+systemctl daemon-reload || :
+systemctl enable vasum-socket-test.socket || :
+systemctl start vasum-socket-test.socket || :
+%endif
%preun tests
-systemctl stop vasum-socket-test.socket
-systemctl disable vasum-socket-test.socket
+%if !%{without_systemd}
+systemctl stop vasum-socket-test.socket || :
+systemctl disable vasum-socket-test.socket || :
+%endif
%postun tests
-systemctl daemon-reload
+%if !%{without_systemd}
+systemctl daemon-reload || :
+%endif
%files tests
%if %{platform_type} == "TIZEN"
%endif
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/vasum-server-unit-tests
+%if !%{without_systemd}
%attr(755,root,root) %{_bindir}/vasum-socket-test
+%endif
%attr(755,root,root) %{script_dir}/vsm_all_tests.py
%attr(755,root,root) %{script_dir}/vsm_int_tests.py
%attr(755,root,root) %{script_dir}/vsm_launch_test.py
%{script_dir}/vsm_test_parser.py
%config /etc/vasum/tests/*.conf
+%if !%{without_dbus}
%config /etc/vasum/tests/dbus/*.conf
+%config /etc/dbus-1/system.d/org.tizen.vasum.tests.conf
+%endif
%config /etc/vasum/tests/provision/*.conf
%config /etc/vasum/tests/templates/*.conf
%attr(755,root,root) /etc/vasum/tests/templates/*.sh
%config /etc/vasum/tests/utils/*.txt
%{python_sitelib}/vsm_integration_tests
-%config /etc/dbus-1/system.d/org.tizen.vasum.tests.conf
+%if !%{without_systemd}
%{_unitdir}/vasum-socket-test.socket
%{_unitdir}/vasum-socket-test.service
+%endif
## libLogger Package ###########################################################
%package -n libLogger
Summary: Logger library
Group: Security/Other
-BuildRequires: pkgconfig(libsystemd-journal)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%{_includedir}/vasum-tools/logger
%{_libdir}/pkgconfig/libLogger.pc
+%if !%{without_dbus}
## libSimpleDbus Package #######################################################
%package -n libSimpleDbus
Summary: Simple dbus library
%{_libdir}/libSimpleDbus.so
%{_includedir}/vasum-tools/dbus
%{_libdir}/pkgconfig/libSimpleDbus.pc
+%endif
## libConfig Package ##########################################################
%package -n libConfig
Summary: Config library
Group: Security/Other
-BuildRequires: pkgconfig(sqlite3)
%if %{platform_type} == "TIZEN"
-BuildRequires: libjson-devel >= 0.10
Requires: libjson >= 0.10
%else
-BuildRequires: json-c-devel
Requires: json-c
%endif
Requires(post): /sbin/ldconfig
%package -n libIpc
Summary: IPC library
Group: Security/Other
-BuildRequires: pkgconfig(libsystemd-daemon)
Requires: libConfig
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(${CLIENT_FOLDER})
-INCLUDE_DIRECTORIES(SYSTEM ${SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(${SERVER_CODENAME} PROPERTIES
COMPILE_FLAGS "-pthread"
LINK_FLAGS "-pthread"
)
-TARGET_LINK_LIBRARIES(${SERVER_CODENAME} ${SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus Ipc)
+TARGET_LINK_LIBRARIES(${SERVER_CODENAME} ${SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES} Logger Config Ipc)
+IF(NOT WITHOUT_DBUS)
+TARGET_LINK_LIBRARIES(${SERVER_CODENAME} SimpleDbus)
+ENDIF(NOT WITHOUT_DBUS)
## Subdirectories ##############################################################
ADD_SUBDIRECTORY(configs)
FILE(GLOB lxc_templates_CONF templates/*.sh)
## Generate ####################################################################
+IF(NOT WITHOUT_SYSTEMD)
CONFIGURE_FILE(systemd/vasum.service.in
${CMAKE_BINARY_DIR}/systemd/vasum.service)
CONFIGURE_FILE(systemd/vasum.socket.in
${CMAKE_BINARY_DIR}/systemd/vasum.socket)
+ENDIF(NOT WITHOUT_SYSTEMD)
-
-## Install #####################################################################
CONFIGURE_FILE(daemon.conf.in
${CMAKE_BINARY_DIR}/daemon.conf)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/daemon.conf
- DESTINATION ${VSM_CONFIG_INSTALL_DIR})
-
-# preprocess d-bus configs
+IF(NOT WITHOUT_DBUS)
CONFIGURE_FILE(dbus-1/system.d/org.tizen.vasum.host.conf.in
${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.host.conf)
+ENDIF(NOT WITHOUT_DBUS)
+## Install #####################################################################
+INSTALL(FILES ${CMAKE_BINARY_DIR}/daemon.conf
+ DESTINATION ${VSM_CONFIG_INSTALL_DIR})
+
+IF(NOT WITHOUT_DBUS)
INSTALL(FILES ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.host.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
+ENDIF(NOT WITHOUT_DBUS)
INSTALL(DIRECTORY DESTINATION ${DATA_DIR}/zones)
INSTALL(PROGRAMS ${lxc_templates_CONF}
DESTINATION ${VSM_CONFIG_INSTALL_DIR}/templates)
+IF(NOT WITHOUT_SYSTEMD)
INSTALL(FILES
${CMAKE_BINARY_DIR}/systemd/vasum.service
${CMAKE_BINARY_DIR}/systemd/vasum.socket
DESTINATION ${SYSTEMD_UNIT_DIR})
+ENDIF(NOT WITHOUT_SYSTEMD)
+
--- /dev/null
+{
+ "zoneTemplate" : "ubuntu.sh",
+ "initWithArgs" : [],
+ "requestedState" : "stopped",
+ "ipv4Gateway" : "",
+ "ipv4" : "",
+ "cpuQuotaForeground" : -1,
+ "cpuQuotaBackground" : 1000,
+ "privilege" : 10,
+ "vt" : -1,
+ "shutdownTimeout" : 10,
+ "switchToDefaultAfterTimeout" : true,
+ "runMountPoint" : "~NAME~/run",
+ "provisions" : [],
+ "validLinkPrefixes" : [ "/tmp/",
+ "/run/",
+ "/opt/usr/data/",
+ "/opt/usr/dbsapce/" ]
+}
--- /dev/null
+#!/bin/bash
+
+# template script for creating Ubuntu LXC container
+# This script is a wrapper for the lxc-ubuntu template
+#
+# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Contact: Dariusz Michaluk <d.michaluk@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.
+
+usage()
+{
+ cat <<EOF
+usage:
+ $1 -n|--name=<zone_name>
+ [-p|--path=<path>] [--rootfs=<rootfs>] [--vt=<vt>]
+ [--ipv4=<ipv4>] [--ipv4-gateway=<ipv4_gateway>] [-h|--help]
+Mandatory args:
+ -n,--name zone name
+ -p,--path path to zone config files
+ --rootfs path to zone rootfs
+Optional args:
+ --vt zone virtual terminal
+ --ipv4 zone IP address
+ --ipv4-gateway zone gateway
+ -h,--help print help
+EOF
+ return 0
+}
+
+options=$(getopt -o hp:n: -l help,rootfs:,path:,vt:,name:,ipv4:,ipv4-gateway: -- "$@")
+if [ $? -ne 0 ]; then
+ usage $(basename $0)
+ exit 1
+fi
+eval set -- "$options"
+
+while true
+do
+ case "$1" in
+ -h|--help) usage $0 && exit 0;;
+ --rootfs) rootfs=$2; shift 2;;
+ -p|--path) path=$2; shift 2;;
+ --vt) vt=$2; shift 2;;
+ -n|--name) name=$2; shift 2;;
+ --ipv4) ipv4=$2; shift 2;;
+ --ipv4-gateway) ipv4_gateway=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
+ esac
+done
+
+if [ "$(id -u)" != "0" ]; then
+ echo "This script should be run as 'root'"
+ exit 1
+fi
+
+if [ -z $name ]; then
+ echo "Zone name must be given"
+ exit 1
+fi
+
+if [ -z "$path" ]; then
+ echo "'path' parameter is required"
+ exit 1
+fi
+
+if [ -z "$rootfs" ]; then
+ echo "'rootfs' parameter is required"
+ exit 1
+fi
+
+/usr/share/lxc/templates/lxc-ubuntu --name="$name" --path="$path" --rootfs="$rootfs"
* @brief Implementation of a class for communication with server
*/
+#ifdef DBUS_CONNECTION
#include "config.hpp"
#include "host-dbus-connection.hpp"
}
} // namespace vasum
+#endif //DBUS_CONNECTION
#include "logger/logger.hpp"
#include "logger/backend-stderr.hpp"
#include "logger/backend-journal.hpp"
+#include "logger/backend-syslog.hpp"
#include "utils/typeinfo.hpp"
#include "utils/signal.hpp"
Logger::setLogLevel(vm["log-level"].as<std::string>());
#ifdef LOG_TO_CONSOLE
Logger::setLogBackend(new StderrBackend());
-#else
+#elif HAVE_SYSTEMD
Logger::setLogBackend(new SystemdJournalBackend());
+#else
+ Logger::setLogBackend(new SyslogBackend());
#endif
runAsRoot = vm.count("root") > 0;
## Setup target ################################################################
SET(UT_SERVER_CODENAME "${PROJECT_NAME}-server-unit-tests")
-SET(SOCKET_TEST_CODENAME "${PROJECT_NAME}-socket-test")
ADD_EXECUTABLE(${UT_SERVER_CODENAME} ${project_SRCS} ${common_SRCS} ${server_SRCS} ${client_SRCS})
## A fake target to test vasum-client C API
ADD_EXECUTABLE("vasum-client-c-api-compile-test" client/client-c-api-compile-test.c)
+IF(NOT WITHOUT_SYSTEMD)
+SET(SOCKET_TEST_CODENAME "${PROJECT_NAME}-socket-test")
+
## A stub mini-service to test socket functionality
ADD_EXECUTABLE(${SOCKET_TEST_CODENAME} ${socket_test_SRCS} ${common_SRCS} ${client_SRCS})
-
+ENDIF(NOT WITHOUT_SYSTEMD)
## Link libraries ##############################################################
FIND_PACKAGE (Boost COMPONENTS unit_test_framework system filesystem regex)
PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc gio-2.0)
INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_FOLDER} ${UNIT_TESTS_FOLDER} ${CLIENT_FOLDER}
${LIBS_FOLDER} ${SOCKET_TEST_FOLDER})
-INCLUDE_DIRECTORIES(SYSTEM ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${UT_SERVER_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(${UT_SERVER_CODENAME} PROPERTIES
COMPILE_FLAGS "-pthread"
LINK_FLAGS "-pthread"
)
+TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
+ Logger Config Ipc)
+IF(NOT WITHOUT_DBUS)
+TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} SimpleDbus)
+ENDIF(NOT WITHOUT_DBUS)
+
+IF(NOT WITHOUT_SYSTEMD)
SET_TARGET_PROPERTIES(${SOCKET_TEST_CODENAME} PROPERTIES
COMPILE_FLAGS "-pthread"
COMPILE_DEFINITIONS HOST_IPC_SOCKET="${VSM_UNIT_TESTS_IPC_SOCKET_PATH}"
LINK_FLAGS "-pthread"
)
-TARGET_LINK_LIBRARIES(${UT_SERVER_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus Ipc)
TARGET_LINK_LIBRARIES(${SOCKET_TEST_CODENAME} ${UT_SERVER_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Logger Config SimpleDbus Ipc)
+ Logger Config Ipc)
+IF(NOT WITHOUT_DBUS)
+TARGET_LINK_LIBRARIES(${SOCKET_TEST_CODENAME} SimpleDbus)
+ENDIF(NOT WITHOUT_DBUS)
+
+ENDIF(NOT WITHOUT_SYSTEMD)
## Subdirectories ##############################################################
SET(VSM_TEST_CONFIG_INSTALL_DIR ${VSM_CONFIG_INSTALL_DIR}/tests)
## Install #####################################################################
INSTALL(TARGETS ${UT_SERVER_CODENAME} DESTINATION bin)
+
+IF(NOT WITHOUT_SYSTEMD)
INSTALL(TARGETS ${SOCKET_TEST_CODENAME} DESTINATION bin)
+ENDIF(NOT WITHOUT_SYSTEMD)
+
${CMAKE_BINARY_DIR}/test-daemon.conf @ONLY)
FILE(GLOB ut_zone_CONF_GEN ${CMAKE_BINARY_DIR}/*.conf)
+IF(NOT WITHOUT_DBUS)
CONFIGURE_FILE(templates/console-dbus.conf.in
${CMAKE_BINARY_DIR}/templates/console-dbus.conf @ONLY)
+ENDIF(NOT WITHOUT_DBUS)
CONFIGURE_FILE(templates/console-ipc.conf.in
${CMAKE_BINARY_DIR}/templates/console-ipc.conf @ONLY)
FILE(GLOB ut_zone_templates_CONF_GEN ${CMAKE_BINARY_DIR}/templates/*.conf)
+IF(NOT WITHOUT_SYSTEMD)
CONFIGURE_FILE(systemd/vasum-socket-test.service.in
${CMAKE_BINARY_DIR}/systemd/vasum-socket-test.service)
-
+ENDIF(NOT WITHOUT_SYSTEMD)
## Install #####################################################################
INSTALL(FILES ${ut_zone_CONF}
INSTALL(PROGRAMS ${ut_lxc_templates_CONF}
DESTINATION ${VSM_TEST_TEMPLATES_INSTALL_DIR})
+IF(NOT WITHOUT_DBUS)
INSTALL(FILES dbus/ut-dbus.conf
dbus/ut-dbus-system.conf
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/dbus)
+ENDIF(NOT WITHOUT_DBUS)
INSTALL(FILES provision/test-provision.conf
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/provision)
INSTALL(FILES utils/file.txt
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/utils)
+
+IF(NOT WITHOUT_SYSTEMD)
INSTALL(FILES systemd/vasum-socket-test.socket
${CMAKE_BINARY_DIR}/systemd/vasum-socket-test.service
DESTINATION ${SYSTEMD_UNIT_DIR})
+ENDIF(NOT WITHOUT_SYSTEMD)
+IF(NOT WITHOUT_DBUS)
INSTALL(FILES dbus-1/system.d/org.tizen.vasum.tests.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
-
+ENDIF(NOT WITHOUT_DBUS)
{
"zoneTemplate" : "/buggy/path",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
+ "initWithArgs" : ["/bin/bash", "-c", "trap exit SIGTERM; read"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
{
"zoneTemplate" : "minimal.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/dbus/ut-dbus-system.conf --fork; read"],
+ "initWithArgs" : ["/bin/bash", "-c", "trap exit SIGTERM; /bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/dbus/ut-dbus-system.conf --fork; read"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
{
"zoneTemplate" : "minimal.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
+ "initWithArgs" : ["/bin/bash", "-c", "trap exit SIGTERM; read"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
{
"zoneTemplate" : "minimal.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
+ "initWithArgs" : ["/bin/bash", "-c", "trap exit SIGTERM; read"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
{
"zoneTemplate" : "missing.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
+ "initWithArgs" : ["/bin/bash", "-c", "trap exit SIGTERM; read"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
{
"zoneTemplate" : "minimal.sh",
- "initWithArgs" : ["/bin/sh"],
+ "initWithArgs" : ["/bin/bash"],
"requestedState" : "running",
"ipv4Gateway" : "",
"ipv4" : "",
* @brief Example dbus api client
*/
+#ifdef DBUS_CONNECTION
#include "config.hpp"
#include "dbus/test-client.hpp"
} // namespace vasum
+#endif //DBUS_CONNECTION
* @brief Example dbus api server
*/
+#ifdef DBUS_CONNECTION
#include "config.hpp"
#include "dbus/test-server.hpp"
} // namespace vasum
+#endif //DBUS_CONNECTION
* @brief Dbus connection unit tests
*/
+#ifdef DBUS_CONNECTION
#include "config.hpp"
#include "ut.hpp"
#include "dbus/test-server.hpp"
namespace {
-const char* DBUS_DAEMON_PROC = "/usr/bin/dbus-daemon";
+const char* DBUS_DAEMON_PROC = "/bin/dbus-daemon";
const char* const DBUS_DAEMON_ARGS[] = {
DBUS_DAEMON_PROC,
"--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/dbus/ut-dbus.conf",
}
BOOST_AUTO_TEST_SUITE_END()
+#endif //DBUS_CONNECTION
* @brief Socket IPC module tests
*/
+#ifdef HAVE_SYSTEMD
#include "config.hpp"
#include "ut.hpp"
#include "ipc/internals/socket.hpp"
}
BOOST_AUTO_TEST_SUITE_END()
+#endif // HAVE_SYSTEMD
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_CHECK(lxc.getState() == LxcZone::State::STOPPED);
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"trap exit SIGTERM; read",
NULL
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_CHECK(lxc.getState() == LxcZone::State::STOPPED);
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
NULL
};
BOOST_CHECK(lxc.start(argv));
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_CHECK(lxc.getState() == LxcZone::State::STOPPED);
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"echo",
NULL
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_CHECK(lxc.create(ZONE_TEMPLATE, TEMPLATE_ARGS));
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"trap exit SIGTERM; read",
NULL
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_CHECK(lxc.create(ZONE_TEMPLATE, TEMPLATE_ARGS));
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"trap exit SIGTERM; read",
NULL
BOOST_CHECK(lxc.create(ZONE_TEMPLATE, TEMPLATE_ARGS));
BOOST_CHECK(!lxc.create(ZONE_TEMPLATE, TEMPLATE_ARGS));// forbidden
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"trap exit SIGTERM; read",
NULL
LxcZone lxc(ZONE_PATH, ZONE_NAME);
BOOST_REQUIRE(lxc.create(ZONE_TEMPLATE, TEMPLATE_ARGS));
const char* argv[] = {
- "/bin/sh",
+ "/bin/bash",
"-c",
"trap exit SIGTERM; read",
NULL
c->setSchedulerLevel(SchedulerLevel::BACKGROUND);
BOOST_CHECK_EQUAL(c->getSchedulerQuota(), refConfig.cpuQuotaBackground);
}
-
+#ifdef DBUS_CONNECTION
BOOST_AUTO_TEST_CASE(DbusConnection)
{
mRunGuard.create("/tmp/ut-run"); // the same path as in zone template
}
// TODO: DbusReconnection
+#endif //DBUS_CONNECTION
BOOST_AUTO_TEST_CASE(ListNetdev)
{
## Link libraries ##############################################################
FIND_PACKAGE(Boost COMPONENTS system filesystem)
PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0)
-INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
INCLUDE_DIRECTORIES(${LIBS_FOLDER})
INCLUDE_DIRECTORIES(${SERVER_FOLDER})
INCLUDE_DIRECTORIES(${CLIENT_FOLDER})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES}
- Config SimpleDbus Ipc)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES} Config Ipc)
+IF(NOT WITHOUT_DBUS)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} SimpleDbus)
+ENDIF(NOT WITHOUT_DBUS)
## Generate the pc file ########################################################
CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
#include "logger/logger.hpp"
#include "logger/backend-stderr.hpp"
#include "logger/backend-journal.hpp"
+#include "logger/backend-syslog.hpp"
#include "utils/typeinfo.hpp"
#include <boost/program_options.hpp>
Logger::setLogLevel(vm["log-level"].as<std::string>());
#ifdef LOG_TO_CONSOLE
Logger::setLogBackend(new StderrBackend());
-#else
+#elif HAVE_SYSTEMD
Logger::setLogBackend(new SystemdJournalBackend());
+#else
+ Logger::setLogBackend(new SyslogBackend());
#endif
-
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;