Renamed test to utest
authorAndriy Gudz <a.gudz@samsung.com>
Mon, 15 May 2017 16:05:29 +0000 (19:05 +0300)
committerAndriy Gudz <a.gudz@samsung.com>
Mon, 15 May 2017 16:05:29 +0000 (19:05 +0300)
19 files changed:
device_core/CMakeLists.txt
device_core/nmdaemon/nmdaemon.manifest
device_core/nmlib/CMakeLists.txt
device_core/nmlib/REST/inc/log.h [deleted file]
device_core/nmlib/REST/inc/rest_helper.h [deleted file]
device_core/nmlib/REST/src/rest_helper.cpp [deleted file]
device_core/packaging/ioswsec.spec
device_core/scripts/build.sh
device_core/scripts/deploy.sh
device_core/test/test_REST.cpp [deleted file]
device_core/utest/CMakeLists.txt [moved from device_core/test/CMakeLists.txt with 100% similarity]
device_core/utest/test_IoT.cpp [moved from device_core/test/test_IoT.cpp with 100% similarity]
device_core/utest/test_all.cpp [moved from device_core/test/test_all.cpp with 100% similarity]
device_core/utest/test_iot_dev_manager.cpp [moved from device_core/test/test_iot_dev_manager.cpp with 100% similarity]
device_core/utest/test_iot_notification.cpp [moved from device_core/test/test_iot_notification.cpp with 100% similarity]
device_core/utest/test_json.cpp [moved from device_core/test/test_json.cpp with 100% similarity]
device_core/utest/test_nmdaemon.cpp [moved from device_core/test/test_nmdaemon.cpp with 100% similarity]
device_core/utest/test_nmlibapi.cpp [moved from device_core/test/test_nmlibapi.cpp with 100% similarity]
device_core/utest/tests.manifest [moved from device_core/test/tests.manifest with 76% similarity]

index a4ba690..30f14fc 100644 (file)
@@ -24,8 +24,6 @@ IF("${FLAVOR}" STREQUAL "UBUNTU")
        SET (MANIFESTDIR "${INSTALL_DIR}/usr/share/packages")
        SET (GTEST_LIB gtest gtest_main)
 
-       set(ENV{TIZEN_ROOT_3_0} "$ENV{HOME}/tizen-studio/platforms/tizen-3.0/mobile/rootstraps/mobile-3.0-emulator.core/")
-
        if (NOT DEFINED ENV{IOTIVITY_HOME})
                set(ENV{IOTIVITY_HOME} "$ENV{HOME}/iotivity/")
                message(WARNING "IOTIVITY_HOME is not defined. Setting to: $ENV{IOTIVITY_HOME}")
@@ -99,13 +97,10 @@ set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DWITH_CLOUD -DWITH_TCP")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
 
-IF("${FLAVOR}" STREQUAL "UBUNTU")
-       add_subdirectory(nmlib)
-       add_subdirectory(test)
-       add_subdirectory(nmdaemon)
+if("${FLAVOR}" STREQUAL "UBUNTU")
        add_subdirectory(secserver)
-else()
-       add_subdirectory(nmlib)
-       add_subdirectory(test)
-       add_subdirectory(nmdaemon)
 endif()
+
+add_subdirectory(nmlib)
+add_subdirectory(utest)
+add_subdirectory(nmdaemon)
index 7286b99..1e9b88b 100644 (file)
@@ -1,8 +1,7 @@
 <manifest>
     <define>
         <domain name="nmdaemon" />
-        <request>
-            <smack request="device::app_logging" type="w"/>
+               <request>
             <smack request="System::Use_internet" type="rw"/>
             <smack request="System::Run" type="rwxat"/>
         </request>
index 43cf37d..7a4e229 100644 (file)
@@ -6,7 +6,6 @@ add_definitions(-DPS_PATH=${LIBDIR})
 
 include_directories(
        include
-       REST/inc
        dpm/inc
        IoT/inc
        ctrl_app/inc
@@ -30,7 +29,6 @@ if(NOT "${FLAVOR}" STREQUAL "UBUNTU")
 endif()
 
 SET( LIB_SOURCES 
-    REST/src/rest_helper.cpp
        ${DPM_SRCS}
     ${CTRL_APP_SUPPORT_SRCS}
        ${IOT_SRC}
@@ -38,7 +36,6 @@ SET( LIB_SOURCES
 )
 
 add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
-add_dependencies (${PROJECT_NAME} iotbridge)
 
 target_link_libraries(${PROJECT_NAME}
        curl
diff --git a/device_core/nmlib/REST/inc/log.h b/device_core/nmlib/REST/inc/log.h
deleted file mode 100644 (file)
index 1fb6a93..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __LOG_H__
-#define __LOG_H__
-
-#include <cstdio>
-
-#define LOG_INFO(fmt, ...)  printf("[INFO] " fmt "\n", ##__VA_ARGS__)
-#define LOG_ERR(fmt, ...)  printf("[ERR] " fmt "\n", ##__VA_ARGS__)
-
-#endif
\ No newline at end of file
diff --git a/device_core/nmlib/REST/inc/rest_helper.h b/device_core/nmlib/REST/inc/rest_helper.h
deleted file mode 100644 (file)
index 0a900c5..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
-    @file rest_helper.h
-    @brief Represents something with rest.
-    @author Aleksey Volkov (a.volkov@samsung.com)
-    @date Created Jul 20, 2016
-    @par In Samsung Ukraine R&D Center (SRK) under a contract between
-    @par LLC "Samsung Electronics Ukraine Company" (Kyiv, Ukraine)
-    @par and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
-    @par Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
-**/
-
-#ifndef REST_HELPER_H_
-#define REST_HELPER_H_
-
-#include <curl/curl.h>
-
-#include <map>
-#include <string>
-
-
-namespace network
-{
-/**
- * @class RestHelper
- * @brief Provide simple API over libcurl functions
- */
-class RestHelper final
-{
-public:
-    /**
-     * @typedef Params
-     * @brief HTTP request parameters map type
-     */
-    typedef std::map<std::string, std::string> Params;
-
-    /**
-     * @enum class Result
-     * @brief HTTP result enum type
-     */
-    enum Result : int
-    {
-        REST_SUCCESS    = 200,
-        BAD_REQUEST     = 400,
-        REST_RESTRICTED = 401,
-        REST_FORBIDDEN  = 403,
-        REST_NOTFOUND   = 404
-    };
-
-public:
-    /**
-     * @brief Default constructor
-     * @param[in] IP or hostname
-     */
-    RestHelper(const std::string&);
-
-    /**
-     * @brief Destructor
-     */
-    ~RestHelper();
-
-    /**
-     * @brief PUT type request method
-     * @param[in] Param map with request parameters
-     * @param[in] request uri string
-     * @param[in] request body
-     * @return HTTP result
-     */
-    Result          PutRequest(const Params& param, const std::string& uri, const std::string& body);
-
-    /**
-     * @brief POST type request method
-     * @param[in] Param map with request parameters
-     * @param[in] request uri string
-     * @param[in] request body
-     * @return HTTP result
-     */
-    Result          PostRequest(const Params& param, const std::string& uri, const std::string& body);
-
-    /**
-     * @brief GET type request method
-     * @param[in] Param map with request parameters
-     * @param[in] request uri string
-     * @param[out] response body
-     * @return HTTP result
-     */
-    Result          GetRequest(const Params& param, const std::string& uri, std::string& body);
-
-    /**
-     * @brief Used to get latest request response body.
-     * @return Last response body string
-     */
-    std::string     GetLastBody();
-
-private:
-
-    /**
-     * @brief Internal method to perform HTTP requests
-     * @param[in] Param map with request parameters
-     * @param[in] uri string
-     */
-    Result  ProcessRequest(const Params&, const std::string&);
-
-    /**
-     * @brief cURL write callback function
-     */
-    static size_t WriteCallback(void*, size_t, size_t, void*);
-
-    /**
-     * @brief cURL read callback function
-     */
-    static size_t ReadCallback(void*, size_t, size_t, void*);
-
-private:
-
-    CURL*       m_curlHandle;   /**< cURL handle */
-    std::string m_urlBase;      /**< Hostname or IP */
-    std::string m_readBody;     /**< Buffer string for read callback */
-    std::string m_writeBody;    /**< Buffer string for write call back */
-
-};
-
-} // namespace network
-
-#endif //REST_HELPER_H_ 
diff --git a/device_core/nmlib/REST/src/rest_helper.cpp b/device_core/nmlib/REST/src/rest_helper.cpp
deleted file mode 100644 (file)
index ad3bd8d..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
-    @file rest_helper.cpp
-    @brief Represents something with rest.
-    @author Aleksey Volkov (a.volkov@samsung.com)
-    @date Created Jul 20, 2016
-    @par In Samsung Ukraine R&D Center (SRK) under a contract between
-    @par LLC "Samsung Electronics Ukraine Company" (Kyiv, Ukraine)
-    @par and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
-    @par Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
-**/
-
-
-#include "rest_helper.h"
-#include "log.h"
-
-#include <cstring>
-
-static class CurlInitializer
-{
-public:
-    CurlInitializer()
-    {
-        curl_global_init(CURL_GLOBAL_ALL);
-    }
-
-    ~CurlInitializer()
-    {
-        curl_global_cleanup();
-    }
-} curlGlobalInitialize;
-
-
-namespace network
-{
-
-RestHelper::RestHelper(const std::string& url)
-    : m_curlHandle(nullptr)
-    , m_urlBase(url)
-    , m_readBody()
-    , m_writeBody()
-{
-    m_curlHandle = curl_easy_init();
-
-    if (!m_curlHandle)
-    {
-        throw std::runtime_error("cURL init error!");
-    }
-
-    curl_easy_setopt(m_curlHandle, CURLOPT_TIMEOUT, 5);
-}
-
-RestHelper::~RestHelper()
-{
-    if (m_curlHandle)
-    {
-        curl_easy_cleanup(m_curlHandle);
-    }
-}
-
-RestHelper::Result
-RestHelper::PutRequest(const Params& params, const std::string& uri, const std::string& putBody)
-{
-    m_readBody = putBody;
-    curl_easy_setopt(m_curlHandle, CURLOPT_PUT, 1L);
-    curl_easy_setopt(m_curlHandle, CURLOPT_UPLOAD, 1L);
-    curl_easy_setopt(m_curlHandle, CURLOPT_READFUNCTION, ReadCallback);
-    curl_easy_setopt(m_curlHandle, CURLOPT_READDATA, this);
-    curl_easy_setopt(m_curlHandle, CURLOPT_INFILESIZE, static_cast<long>(putBody.length()));
-
-    return ProcessRequest(params, uri);
-}
-
-RestHelper::Result
-RestHelper::PostRequest(const Params& params, const std::string& uri, const std::string& postBody)
-{
-    curl_easy_setopt(m_curlHandle, CURLOPT_POST, 1L);
-    curl_easy_setopt(m_curlHandle, CURLOPT_POSTFIELDS, postBody.c_str());
-    curl_easy_setopt(m_curlHandle, CURLOPT_POSTFIELDSIZE, postBody.size());
-
-    return ProcessRequest(params, uri);
-}
-
-RestHelper::Result
-RestHelper::GetRequest(const Params& params, const std::string& uri, std::string& body)
-{
-    Result res = ProcessRequest(params, uri);
-    body = GetLastBody();
-
-    return res;
-}
-
-std::string
-RestHelper::GetLastBody()
-{
-    return m_writeBody;
-}
-
-RestHelper::Result
-RestHelper::ProcessRequest(const Params& params, const std::string& uri)
-{
-    m_writeBody.erase();
-    std::string strParam;
-
-    for (auto i : params)
-    {
-        strParam.push_back(strParam.empty() ? '?' : '&');
-        strParam.append(i.first);
-        strParam.push_back('=');
-        strParam.append(i.second);
-    }
-
-    std::string url = m_urlBase;
-    url.append(uri);
-    url.append(strParam);
-
-    curl_easy_setopt(m_curlHandle, CURLOPT_URL, url.c_str());
-
-    curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, WriteCallback);
-    curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this);
-
-    LOG_INFO("Performing request to: [%s]", url.c_str());
-
-    CURLcode res = curl_easy_perform(m_curlHandle);
-
-    if (res != CURLE_OK)
-    {
-        std::string err("cURL perform request error: ");
-        throw std::runtime_error(err + curl_easy_strerror(res));
-    }
-
-    long code;
-    curl_easy_getinfo(m_curlHandle, CURLINFO_RESPONSE_CODE, &code);
-
-    curl_easy_reset(m_curlHandle);
-
-    return static_cast<Result>(code);
-}
-
-size_t RestHelper::WriteCallback(void* data, size_t size, size_t nmemb, void* ptr)
-{
-    RestHelper& r = *(reinterpret_cast<RestHelper*>(ptr));
-    r.m_writeBody.append(reinterpret_cast<char*>(data), size * nmemb);
-
-    return (size * nmemb);
-}
-
-size_t RestHelper::ReadCallback(void* data, size_t size, size_t nmemb, void* ptr)
-{
-    RestHelper& r = *(reinterpret_cast<RestHelper*>(ptr));
-    size_t curlLen = size * nmemb;
-    size_t readLen = r.m_readBody.length() < curlLen ? r.m_readBody.length() : curlLen;
-
-    std::memcpy(data, r.m_readBody.data(), readLen);
-
-    r.m_readBody.erase(0, readLen);
-
-    return readLen;
-}
-
-}// namespace network
-
index 06befe8..1b62ba3 100644 (file)
@@ -47,15 +47,17 @@ export COVFILE=~/%{_covfile}
 cov01 -1
 %endif
 
-cmake . \
+cmake -H./ -B./build-gbs \
     -DLIB_INSTALL_DIR=%{_libdir} \
     -DMANIFESTDIR=%{_manifestdir} \
     -DTESTS_DIR=%{_tests_dir} \
     -DGTEST_LIB=%{_gtest_lib} \
     %{?USE_DEBUG: -DDEBUG=ON}
+cd build-gbs
 make %{?jobs:-j%jobs} VERBOSE=1
 
 %install
+cd build-gbs
 %make_install
 
 %clean
@@ -89,7 +91,7 @@ Google tests
 
 %files test
 %manifest %{_manifestdir}/tests.manifest
-%attr(0755,root,root) %{_tests_dir}/test
+%attr(0755,root,root) %{_tests_dir}/utest
 
 ##############################################
 # nmdaemon
index d67afde..61e3493 100755 (executable)
@@ -14,7 +14,6 @@ if [ -z "$1" ]; then
 else
        DEVICE=$1
 fi
-echo "$DEVICE" > $DEVICE_TEMP
 
 GREEN='\033[0;32m'
 NC='\033[0m'
index 675d648..dfa0ed9 100755 (executable)
@@ -13,7 +13,6 @@ if [ -z "$1" ]; then
 else
        DEVICE=$1
 fi
-echo "$DEVICE" > $DEVICE_TEMP
 
 GREEN='\033[0;32m'
 NC='\033[0m'
@@ -60,4 +59,4 @@ sdb push ${RPMS_TO_PUSH} /tmp/nm/
 
 sdb shell "rpm -Uvi --nodeps --force --replacefiles /tmp/nm/nwmanager-*.rpm"
 
-#sdb shell "/usr/apps/network-manager/test"
+sdb shell "/usr/apps/network-manager/utest"
diff --git a/device_core/test/test_REST.cpp b/device_core/test/test_REST.cpp
deleted file mode 100644 (file)
index 891eb66..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <iostream>
-#include <gtest/gtest.h>
-#include <rest_helper.h>
-#include <string>
-#include <stdexcept>
-
-using namespace std;
-
-
-TEST(test_REST, simple_get)
-{
-    try
-    {
-        network::RestHelper request("http://example.com");
-        string uri("");
-        string response;
-        network::RestHelper::Params params;
-        ASSERT_EQ(network::RestHelper::REST_SUCCESS, request.GetRequest(params, uri, response));
-    }
-    catch (exception& e)
-    {
-        cerr << "EXCEPTION: " << e.what() << endl;
-    }
-}
-
-TEST(test_REST, simple_post)
-{
-    try
-    {
-        network::RestHelper request("http://example.com");
-        string uri("/");
-        string post = "param2=1&param2=2&param3=3";
-        network::RestHelper::Params params{{"user", "anon"}, {"id", "123"}};
-        ASSERT_EQ(network::RestHelper::REST_SUCCESS, request.PostRequest(params, uri, post));
-    }
-    catch (exception& e)
-    {
-        cerr << "EXCEPTION: " << e.what() << endl;
-    }
-}
-
-/**
- * TODO 405 instead of 200 for some reasons
- */
-TEST(DISABLED_test_REST, simple_put)
-{
-    try
-    {
-        network::RestHelper request("http://example.com");
-        string uri("/");
-        string put = "param2=1&param2=2&param3=3";
-        network::RestHelper::Params params;//{{"values", "10"}, {"id", "321"}};
-        ASSERT_EQ(network::RestHelper::REST_SUCCESS, request.PutRequest(params, uri, put));
-    }
-    catch (exception& e)
-    {
-        cerr << "EXCEPTION: " << e.what() << endl;
-    }
-}
similarity index 76%
rename from device_core/test/tests.manifest
rename to device_core/utest/tests.manifest
index a910777..615de73 100644 (file)
@@ -1,8 +1,7 @@
 <manifest>
     <define>
         <domain name="iot-sec-test" />
-        <request>
-            <smack request="device::app_logging" type="w"/>
+               <request>
             <smack request="System::Use_internet" type="rw"/>
             <smack request="System::Privileged" type="rwxat"/>
             <smack request="System::Run" type="rwxat"/>
@@ -16,6 +15,6 @@
                <domain name="iot-sec-test"/>
     </request>
        <assign>
-               <filesystem path="/usr/apps/network-manager/test" exec_label="System::Privileged"/>
+               <filesystem path="/usr/apps/iotswsec/utest" exec_label="System::Privileged"/>
        </assign>
 </manifest>