Change assert to warn on init state on test 86/74186/1
authorKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 06:13:19 +0000 (15:13 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 06:15:13 +0000 (15:15 +0900)
Change-Id: Iccbdb614c48ef1036a7cf8bd1b439a0a162a6103
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
test/test-api-content-screening-async.cpp
test/test-common.cpp
test/test-common.h
test/test-main.cpp

index 96b70b9..2b26cd4 100644 (file)
@@ -109,10 +109,10 @@ void on_error(int ec, void *userdata)
 
        BOOST_REQUIRE_MESSAGE(ctx->apiReturned,
                "API not returned yet but error callback called with error: " <<
-               Test::capi_ec_to_string(static_cast<csr_error_e>(ec)));
+               Test::capi_ec_to_string(ec));
 
        BOOST_MESSAGE("on_error. async request done with error: " <<
-                                 Test::capi_ec_to_string(static_cast<csr_error_e>(ec)));
+                                 Test::capi_ec_to_string(ec));
 
        ctx->errorCnt++;
        ctx->errorCode = ec;
index d2c00bf..44e49d9 100644 (file)
@@ -135,6 +135,11 @@ std::string capi_ec_to_string(csr_error_e ec)
 }
 #undef ERRORDESCRIBE
 
+std::string capi_ec_to_string(int ec)
+{
+       return capi_ec_to_string(static_cast<csr_error_e>(ec));
+}
+
 template <>
 void _assert<csr_error_e, csr_error_e>(const csr_error_e &value,
                                                                           const csr_error_e &expected,
@@ -169,14 +174,12 @@ void _assert<csr_error_e, int>(const csr_error_e &value,
                BOOST_REQUIRE_MESSAGE(value == expected,
                                                          "[" << filename << " > " << funcname << " : " << line <<
                                                          "] returned[" << capi_ec_to_string(value) << "] expected[" <<
-                                                         capi_ec_to_string(static_cast<csr_error_e>(expected)) <<
-                                                         "] " << msg);
+                                                         capi_ec_to_string(expected) << "] " << msg);
        else
                BOOST_WARN_MESSAGE(value == expected,
                                                          "[" << filename << " > " << funcname << " : " << line <<
                                                          "] returned[" << capi_ec_to_string(value) << "] expected[" <<
-                                                         capi_ec_to_string(static_cast<csr_error_e>(expected)) <<
-                                                         "] " << msg);
+                                                         capi_ec_to_string(expected) << "] " << msg);
 }
 
 template <>
@@ -191,11 +194,11 @@ void _assert<int, csr_error_e>(const int &value,
        if (isAssert)
                BOOST_REQUIRE_MESSAGE(value == expected,
                                                          "[" << filename << " > " << funcname << " : " << line <<
-                                                         "] returned[" << capi_ec_to_string(static_cast<csr_error_e>(value)) <<
+                                                         "] returned[" << capi_ec_to_string(value) <<
                                                          "] expected[" << capi_ec_to_string(expected) << "] " << msg);
                BOOST_WARN_MESSAGE(value == expected,
                                                   "[" << filename << " > " << funcname << " : " << line <<
-                                                  "] returned[" << capi_ec_to_string(static_cast<csr_error_e>(value)) <<
+                                                  "] returned[" << capi_ec_to_string(value) <<
                                                   "] expected[" << capi_ec_to_string(expected) << "] " << msg);
 }
 
index 76fa328..6d86c39 100644 (file)
@@ -183,6 +183,7 @@ void _assert<char *, std::string>(char * const &value,
 void exceptionGuard(const std::function<void()> &);
 
 std::string capi_ec_to_string(csr_error_e ec);
+std::string capi_ec_to_string(int ec);
 
 void make_dir(const char *dir);
 void make_dir_assert(const char *dir);
index 9623b46..8f0207f 100644 (file)
@@ -29,6 +29,8 @@
 
 #include <csr-engine-manager.h>
 
+#include "test-common.h"
+
 namespace {
 
 csr_state_e setEngineState(csr_engine_id_e id, csr_state_e state)
@@ -36,27 +38,37 @@ csr_state_e setEngineState(csr_engine_id_e id, csr_state_e state)
        csr_engine_h handle;
        auto ret = csr_get_current_engine(id, &handle);
        if (ret == CSR_ERROR_ENGINE_NOT_EXIST) {
-               std::cerr << "Engine not exist! engine id: " << static_cast<int>(id) << std::endl;
+               BOOST_MESSAGE("engine not exist! engine id: " << static_cast<int>(id));
+
                return CSR_STATE_DISABLE;
        } else if (ret != CSR_ERROR_NONE) {
-               throw std::logic_error("Failed to csr_get_current_engine.");
+               BOOST_MESSAGE(
+                       "Failed to csr_get_current_engine with ret: " <<
+                       Test::capi_ec_to_string(ret));
+
+               return CSR_STATE_DISABLE;
        }
 
-       csr_state_e current;
+       csr_state_e current = CSR_STATE_DISABLE;
        ret = csr_engine_get_state(handle, &current);
        if (ret == CSR_ERROR_ENGINE_NOT_EXIST) {
-               std::cerr << "Engine not exist! engine id: " << static_cast<int>(id) << std::endl;
+               BOOST_MESSAGE("Engine not exist! engine id: " << static_cast<int>(id));
                return CSR_STATE_DISABLE;
        } else if (ret != CSR_ERROR_NONE) {
-               throw std::logic_error("Failed to csr_get_state.");
+               BOOST_MESSAGE(
+                       "Failed to csr_engine_get_state with ret: " <<
+                       Test::capi_ec_to_string(ret));
+
+               return CSR_STATE_DISABLE;
        }
 
        if (current == state)
                return current;
 
        ret = csr_engine_set_state(handle, state);
-       if (ret != CSR_ERROR_NONE)
-               throw std::logic_error("Failed to csr_engine_set_state.");
+       BOOST_WARN_MESSAGE(ret != CSR_ERROR_NONE,
+               "Failed to csr_engine_set_state with ret: " <<
+               Test::capi_ec_to_string(ret));
 
        return current;
 }