Built in engine error exception converter to iloader 20/74220/1
authorKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 08:22:02 +0000 (17:22 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 08:38:38 +0000 (17:38 +0900)
to convert engine internal error to string(by loaded symbol), engine
error exception converter need to loader instance so it's better to be
built in iloader virtual function for being used by both of cs / wp
loaders.

Change-Id: I382344d0b787f2863ca7e2853eb72601bae8b76a
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
14 files changed:
src/CMakeLists.txt
src/framework/service/cs-loader.cpp
src/framework/service/cs-loader.h
src/framework/service/cs-logic.cpp
src/framework/service/em-logic.cpp
src/framework/service/engine-error-converter.h [deleted file]
src/framework/service/iloader.cpp [moved from src/framework/service/engine-error-converter.cpp with 61% similarity]
src/framework/service/iloader.h
src/framework/service/wp-loader.cpp
src/framework/service/wp-loader.h
src/framework/service/wp-logic.cpp
test/internals/CMakeLists.txt
test/internals/test-cs-loader.cpp
test/internals/test-wp-loader.cpp

index 2c1e139..788787a 100755 (executable)
@@ -51,9 +51,9 @@ SET(${TARGET_CSR_SERVER}_SRCS
        framework/service/fs-utils.cpp
        framework/service/file-system.cpp
        framework/service/app-deleter.cpp
+       framework/service/iloader.cpp
        framework/service/cs-loader.cpp
        framework/service/wp-loader.cpp
-       framework/service/engine-error-converter.cpp
        framework/service/dir-blacklist.cpp
        framework/ui/askuser.cpp
 
index cafda29..79dea5f 100644 (file)
 #include <stdexcept>
 #include <dlfcn.h>
 
+#include <csre-error.h>
+
 #include "common/audit/logger.h"
 #include "common/exception.h"
-#include "service/engine-error-converter.h"
 
 namespace Csr {
 
@@ -49,60 +50,57 @@ void CsLoader::checkEngineActivated(csre_cs_context_h c)
 {
        csre_cs_activated_e a = CSRE_CS_NOT_ACTIVATED;
 
-       int ret = this->getEngineActivated(c, &a);
-
-       if (ret != CSRE_ERROR_NONE)
-               toException(ret);
+       this->getEngineActivated(c, &a);
 
        if (a == CSRE_CS_NOT_ACTIVATED)
                ThrowExc(CSR_ERROR_ENGINE_NOT_ACTIVATED, "engine is not activated yet");
 }
 
-int CsLoader::contextCreate(csre_cs_context_h &c)
+void CsLoader::contextCreate(csre_cs_context_h &c)
 {
-       return this->m_pc.fpContextCreate(&c);
+       this->toException(this->m_pc.fpContextCreate(&c));
 }
 
-int CsLoader::contextDestroy(csre_cs_context_h c)
+void CsLoader::contextDestroy(csre_cs_context_h c)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader context destroy");
 
-       return this->m_pc.fpContextDestroy(c);
+       this->toException(this->m_pc.fpContextDestroy(c));
 }
 
-int CsLoader::scanData(csre_cs_context_h c,
-                                          const std::vector<unsigned char> &data,
-                                          csre_cs_detected_h *pdetected)
+void CsLoader::scanData(csre_cs_context_h c,
+                                               const std::vector<unsigned char> &data,
+                                               csre_cs_detected_h *pdetected)
 {
        if (c == nullptr || data.empty() || pdetected == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader scan data");
 
        this->checkEngineActivated(c);
 
-       return this->m_pc.fpScanData(c, data.data(), data.size(), pdetected);
+       this->toException(this->m_pc.fpScanData(c, data.data(), data.size(), pdetected));
 }
 
-int CsLoader::scanFile(csre_cs_context_h c, const std::string &filepath,
-                                          csre_cs_detected_h *pdetected)
+void CsLoader::scanFile(csre_cs_context_h c, const std::string &filepath,
+                                               csre_cs_detected_h *pdetected)
 {
        if (c == nullptr || filepath.empty() || pdetected == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader scan file");
 
        this->checkEngineActivated(c);
 
-       return this->m_pc.fpScanFile(c, filepath.c_str(), pdetected);
+       this->toException(this->m_pc.fpScanFile(c, filepath.c_str(), pdetected));
 }
 
-int CsLoader::scanAppOnCloud(csre_cs_context_h c, const std::string &appdir,
-                                                        csre_cs_detected_h *pdetected)
+void CsLoader::scanAppOnCloud(csre_cs_context_h c, const std::string &appdir,
+                                                         csre_cs_detected_h *pdetected)
 {
        if (c == nullptr || appdir.empty() || pdetected == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader scan app on cloud");
 
        this->checkEngineActivated(c);
 
-       return this->m_pc.fpScanAppOnCloud(c, appdir.c_str(), pdetected);
+       this->toException(this->m_pc.fpScanAppOnCloud(c, appdir.c_str(), pdetected));
 }
 
 bool CsLoader::scanAppOnCloudSupported(void)
@@ -110,26 +108,26 @@ bool CsLoader::scanAppOnCloudSupported(void)
        return this->m_pc.fpScanAppOnCloudSupported() == CSRE_CS_SUPPORTED;
 }
 
-int CsLoader::getSeverity(csre_cs_detected_h d,
-                                                 csre_cs_severity_level_e *pseverity)
+void CsLoader::getSeverity(csre_cs_detected_h d,
+                                                  csre_cs_severity_level_e *pseverity)
 {
        if (d == nullptr || pseverity == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get severity");
 
-       return this->m_pc.fpGetSeverity(d, pseverity);
+       this->toException(this->m_pc.fpGetSeverity(d, pseverity));
 }
 
-int CsLoader::getMalwareName(csre_cs_detected_h d, std::string &value)
+void CsLoader::getMalwareName(csre_cs_detected_h d, std::string &value)
 {
        if (d == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get malware name");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetMalwareName(d, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getDetailedUrl(csre_cs_detected_h d, std::string &value)
+void CsLoader::getDetailedUrl(csre_cs_detected_h d, std::string &value)
 {
        if (d == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get detailed url");
@@ -137,101 +135,100 @@ int CsLoader::getDetailedUrl(csre_cs_detected_h d, std::string &value)
 #ifdef DETAILED_URL_BASE
        DEBUG("get deatiled url with base!");
        std::string name;
-       auto ret = this->getMalwareName(d, name);
-
-       if (ret == CSRE_ERROR_NONE)
-               value = std::string(DETAILED_URL_BASE) + name;
+       this->getMalwareName(d, name);
 
-       return ret;
+       value = std::string(DETAILED_URL_BASE) + name;
 #else
        DEBUG("get detailed url with engine getter API!");
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetDetailedUrl(d, cvalue);
-       });
+       }));
 #endif
 }
 
-int CsLoader::getErrorString(int ec, std::string &value)
+std::string CsLoader::getErrorString(int ec)
 {
-       return getValueCstr(value, [&](const char **cvalue) {
+       std::string value;
+
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetErrorString(ec, cvalue);
-       });
+       }));
+
+       return value;
 }
 
-int CsLoader::getEngineApiVersion(csre_cs_context_h c, std::string &value)
+void CsLoader::getEngineApiVersion(csre_cs_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get error string");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineApiVersion(c, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getEngineVendor(csre_cs_context_h c, std::string &value)
+void CsLoader::getEngineVendor(csre_cs_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine vendor");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineVendor(c, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getEngineName(csre_cs_context_h c, std::string &value)
+void CsLoader::getEngineName(csre_cs_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine name");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineName(c, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getEngineVersion(csre_cs_context_h c, std::string &value)
+void CsLoader::getEngineVersion(csre_cs_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine version");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineVersion(c, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getEngineDataVersion(csre_cs_context_h c, std::string &value)
+void CsLoader::getEngineDataVersion(csre_cs_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine version");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineDataVersion(c, cvalue);
-       });
+       }));
 }
 
-int CsLoader::getEngineLatestUpdateTime(csre_cs_context_h c, time_t *ptime)
+void CsLoader::getEngineLatestUpdateTime(csre_cs_context_h c, time_t *ptime)
 {
        if (c == nullptr || ptime == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get latest update time");
 
-       return this->m_pc.fpGetEngineLatestUpdateTime(c, ptime);
+       this->toException(this->m_pc.fpGetEngineLatestUpdateTime(c, ptime));
 }
 
-int CsLoader::getEngineActivated(csre_cs_context_h c, csre_cs_activated_e *pactivated)
+void CsLoader::getEngineActivated(csre_cs_context_h c, csre_cs_activated_e *pactivated)
 {
        if (c == nullptr || pactivated == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine activated");
 
        auto ret = this->m_pc.fpGetEngineActivated(c, pactivated);
 
-       if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED) {
+       if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED)
                *pactivated = CSRE_CS_NOT_ACTIVATED;
-               return CSRE_ERROR_NONE;
-       } else {
-               return ret;
-       }
+       else if (ret != CSRE_ERROR_NONE)
+               this->toException(ret);
 }
 
-int CsLoader::getEngineVendorLogo(csre_cs_context_h c, std::vector<unsigned char> &value)
+void CsLoader::getEngineVendorLogo(csre_cs_context_h c, std::vector<unsigned char> &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "cs loader get engine vendor logo");
@@ -243,7 +240,7 @@ int CsLoader::getEngineVendorLogo(csre_cs_context_h c, std::vector<unsigned char
        if (retval == CSRE_ERROR_NONE && cvalue != nullptr && size != 0)
                value.assign(cvalue, cvalue + size);
 
-       return retval;
+       this->toException(retval);
 }
 
 void CsLoader::init(const std::string &enginePath, const std::string &roResDir,
@@ -326,23 +323,23 @@ void CsLoader::init(const std::string &enginePath, const std::string &roResDir,
                                 "engine path: " << enginePath << " errno: " << errno);
        }
 
+       try {
 #ifndef DETAILED_URL_BASE
-       this->m_pc.fpGetDetailedUrl = reinterpret_cast<FpGetDetailedUrl>(dlsym(handle,
-                                                                 "csre_cs_detected_get_detailed_url"));
-       if (this->m_pc.fpGetDetailedUrl == nullptr) {
-               dlclose(this->m_pc.dlhandle);
-               this->m_pc.dlhandle = nullptr;
-               ThrowExc(CSR_ERROR_ENGINE_NOT_EXIST, "Failed to load detailed_url getter from "
-                                "engine lib. engine path: " << enginePath << " errno: " << errno);
-       }
+               this->m_pc.fpGetDetailedUrl = reinterpret_cast<FpGetDetailedUrl>(dlsym(handle,
+                                                                         "csre_cs_detected_get_detailed_url"));
+               if (this->m_pc.fpGetDetailedUrl == nullptr)
+                       ThrowExc(CSR_ERROR_ENGINE_NOT_EXIST, "Failed to load detailed_url getter from "
+                                        "engine lib. engine path: " << enginePath << " errno: " << errno);
 #endif
 
-       auto ret = this->m_pc.fpGlobalInit(roResDir.c_str(), rwWorkingDir.c_str());
+               auto ret = this->m_pc.fpGlobalInit(roResDir.c_str(), rwWorkingDir.c_str());
 
-       if (ret != CSRE_ERROR_NONE) {
+               if (ret != CSRE_ERROR_NONE)
+                       this->toException(ret);
+       } catch (...) {
                dlclose(this->m_pc.dlhandle);
                this->m_pc.dlhandle = nullptr;
-               toException(ret);
+               throw;
        }
 }
 
@@ -375,12 +372,16 @@ CsEngineContext::CsEngineContext(const std::shared_ptr<CsLoader> &loader) :
        if (!this->m_loader)
                ThrowExc(CSR_ERROR_ENGINE_NOT_EXIST, "null loader means engine not exist!");
 
-       toException(this->m_loader->contextCreate(this->m_context));
+       this->m_loader->contextCreate(this->m_context);
 }
 
 CsEngineContext::~CsEngineContext()
 {
-       toException(this->m_loader->contextDestroy(this->m_context));
+       try {
+               this->m_loader->contextDestroy(this->m_context);
+       } catch (...) {
+               ERROR("exception in contextDestroy of cs loader");
+       }
 }
 
 csre_cs_context_h &CsEngineContext::get(void)
index 048f92e..924243b 100644 (file)
@@ -39,28 +39,28 @@ public:
                         const std::string &rwWorkingDir);
        virtual ~CsLoader();
 
-       int contextCreate(csre_cs_context_h &);
-       int contextDestroy(csre_cs_context_h);
-       int scanData(csre_cs_context_h, const std::vector<unsigned char> &,
-                                csre_cs_detected_h *);
-       int scanFile(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
-       int scanAppOnCloud(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
+       void contextCreate(csre_cs_context_h &);
+       void contextDestroy(csre_cs_context_h);
+       void scanData(csre_cs_context_h, const std::vector<unsigned char> &,
+                                 csre_cs_detected_h *);
+       void scanFile(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
+       void scanAppOnCloud(csre_cs_context_h, const std::string &, csre_cs_detected_h *);
        bool scanAppOnCloudSupported(void);
 
-       int getSeverity(csre_cs_detected_h, csre_cs_severity_level_e *);
-       int getMalwareName(csre_cs_detected_h, std::string &);
-       int getDetailedUrl(csre_cs_detected_h, std::string &);
+       void getSeverity(csre_cs_detected_h, csre_cs_severity_level_e *);
+       void getMalwareName(csre_cs_detected_h, std::string &);
+       void getDetailedUrl(csre_cs_detected_h, std::string &);
 
-       int getErrorString(int, std::string &);
+       void getEngineApiVersion(csre_cs_context_h, std::string &);
+       void getEngineVendor(csre_cs_context_h, std::string &);
+       void getEngineName(csre_cs_context_h, std::string &);
+       void getEngineVersion(csre_cs_context_h, std::string &);
+       void getEngineDataVersion(csre_cs_context_h, std::string &);
+       void getEngineLatestUpdateTime(csre_cs_context_h, time_t *);
+       void getEngineActivated(csre_cs_context_h, csre_cs_activated_e *);
+       void getEngineVendorLogo(csre_cs_context_h, std::vector<unsigned char> &);
 
-       int getEngineApiVersion(csre_cs_context_h, std::string &);
-       int getEngineVendor(csre_cs_context_h, std::string &);
-       int getEngineName(csre_cs_context_h, std::string &);
-       int getEngineVersion(csre_cs_context_h, std::string &);
-       int getEngineDataVersion(csre_cs_context_h, std::string &);
-       int getEngineLatestUpdateTime(csre_cs_context_h, time_t *);
-       int getEngineActivated(csre_cs_context_h, csre_cs_activated_e *);
-       int getEngineVendorLogo(csre_cs_context_h, std::vector<unsigned char> &);
+       virtual std::string getErrorString(int) override;
 
 private:
        using FpGlobalInit = int(*)(const char *, const char *);
index 8e73911..108b8d3 100644 (file)
@@ -29,7 +29,6 @@
 #include "common/audit/logger.h"
 #include "common/exception.h"
 #include "service/type-converter.h"
-#include "service/engine-error-converter.h"
 #include "service/core-usage.h"
 #include "service/dir-blacklist.h"
 #include "ui/askuser.h"
@@ -137,8 +136,7 @@ CsLogic::CsLogic(const std::shared_ptr<CsLoader> &loader,
 
        if (this->m_loader) {
                CsEngineContext csEngineContext(this->m_loader);
-               toException(this->m_loader->getEngineDataVersion(csEngineContext.get(),
-                                       this->m_dataVersion));
+               this->m_loader->getEngineDataVersion(csEngineContext.get(), this->m_dataVersion);
        }
 }
 
@@ -156,7 +154,7 @@ RawBuffer CsLogic::scanData(const CsContext &context, const RawBuffer &data)
 
        auto timestamp = ::time(nullptr);
 
-       toException(this->m_loader->scanData(c, data, &result));
+       this->m_loader->scanData(c, data, &result);
 
        // detected handle is null if it's safe
        if (result == nullptr)
@@ -177,7 +175,7 @@ RawBuffer CsLogic::scanAppOnCloud(const CsContext &context,
        auto timestamp = ::time(nullptr);
 
        csre_cs_detected_h result = nullptr;
-       toException(this->m_loader->scanAppOnCloud(c, pkgPath, &result));
+       this->m_loader->scanAppOnCloud(c, pkgPath, &result);
 
        if (!result)
                return BinaryQueue::Serialize(CSR_ERROR_NONE).pop();
@@ -210,7 +208,7 @@ CsDetectedPtr CsLogic::scanAppDelta(const std::string &pkgPath, const std::strin
                auto timestamp = ::time(nullptr);
 
                csre_cs_detected_h result = nullptr;
-               toException(this->m_loader->scanFile(c, file->getPath(), &result));
+               this->m_loader->scanFile(c, file->getPath(), &result);
 
                if (!result) {
                        if (lastScanTime != -1)
@@ -386,7 +384,7 @@ RawBuffer CsLogic::scanFileWithoutDelta(const CsContext &context,
        auto timestamp = ::time(nullptr);
 
        csre_cs_detected_h result = nullptr;
-       toException(this->m_loader->scanFile(c, filepath, &result));
+       this->m_loader->scanFile(c, filepath, &result);
 
        // detected handle is null if it's safe
        if (result == nullptr)
@@ -763,9 +761,9 @@ CsDetected CsLogic::convert(csre_cs_detected_h &result, const std::string &targe
 
        csre_cs_severity_level_e eseverity = CSRE_CS_SEVERITY_LOW;
 
-       toException(this->m_loader->getSeverity(result, &eseverity));
-       toException(this->m_loader->getMalwareName(result, d.malwareName));
-       toException(this->m_loader->getDetailedUrl(result, d.detailedUrl));
+       this->m_loader->getSeverity(result, &eseverity);
+       this->m_loader->getMalwareName(result, d.malwareName);
+       this->m_loader->getDetailedUrl(result, d.detailedUrl);
 
        d.ts = timestamp;
        d.severity = Csr::convert(eseverity);
index d961be0..be636e4 100644 (file)
 #include <utility>
 #include <cstdint>
 
+#include <csr-error.h>
+
 #include "common/audit/logger.h"
 #include "common/exception.h"
-#include "service/engine-error-converter.h"
-#include <csr-error.h>
 
 namespace Csr {
 
@@ -74,7 +74,7 @@ RawBuffer EmLogic::getEngineName(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_cs->getEngineName(c, value));
+               this->m_cs->getEngineName(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        } else {
@@ -82,7 +82,7 @@ RawBuffer EmLogic::getEngineName(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_wp->getEngineName(c, value));
+               this->m_wp->getEngineName(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        }
@@ -95,7 +95,7 @@ RawBuffer EmLogic::getEngineVendor(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_cs->getEngineVendor(c, value));
+               this->m_cs->getEngineVendor(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        } else {
@@ -103,7 +103,7 @@ RawBuffer EmLogic::getEngineVendor(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_wp->getEngineVendor(c, value));
+               this->m_wp->getEngineVendor(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        }
@@ -116,7 +116,7 @@ RawBuffer EmLogic::getEngineVersion(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_cs->getEngineVersion(c, value));
+               this->m_cs->getEngineVersion(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        } else {
@@ -124,7 +124,7 @@ RawBuffer EmLogic::getEngineVersion(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_wp->getEngineVersion(c, value));
+               this->m_wp->getEngineVersion(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        }
@@ -137,7 +137,7 @@ RawBuffer EmLogic::getEngineDataVersion(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_cs->getEngineDataVersion(c, value));
+               this->m_cs->getEngineDataVersion(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        } else {
@@ -145,7 +145,7 @@ RawBuffer EmLogic::getEngineDataVersion(const EmContext &context)
                auto &c = engineContext.get();
 
                std::string value;
-               toException(this->m_wp->getEngineDataVersion(c, value));
+               this->m_wp->getEngineDataVersion(c, value);
 
                return BinaryQueue::Serialize(CSR_ERROR_NONE, value).pop();
        }
@@ -158,7 +158,7 @@ RawBuffer EmLogic::getEngineUpdatedTime(const EmContext &context)
                auto &c = engineContext.get();
 
                time_t value;
-               toException(this->m_cs->getEngineLatestUpdateTime(c, &value));
+               this->m_cs->getEngineLatestUpdateTime(c, &value);
 
                int64_t ts64 = static_cast<int64_t>(value);
 
@@ -168,7 +168,7 @@ RawBuffer EmLogic::getEngineUpdatedTime(const EmContext &context)
                auto &c = engineContext.get();
 
                time_t value;
-               toException(this->m_wp->getEngineLatestUpdateTime(c, &value));
+               this->m_wp->getEngineLatestUpdateTime(c, &value);
 
                int64_t ts64 = static_cast<int64_t>(value);
 
@@ -185,7 +185,7 @@ RawBuffer EmLogic::getEngineActivated(const EmContext &context)
                auto &c = engineContext.get();
 
                csre_cs_activated_e value;
-               toException(this->m_cs->getEngineActivated(c, &value));
+               this->m_cs->getEngineActivated(c, &value);
 
                if (value == CSRE_CS_ACTIVATED)
                        activated = CSR_ACTIVATED;
@@ -199,7 +199,7 @@ RawBuffer EmLogic::getEngineActivated(const EmContext &context)
                auto &c = engineContext.get();
 
                csre_wp_activated_e value;
-               toException(this->m_wp->getEngineActivated(c, &value));
+               this->m_wp->getEngineActivated(c, &value);
 
                if (value == CSRE_WP_ACTIVATED)
                        activated = CSR_ACTIVATED;
diff --git a/src/framework/service/engine-error-converter.h b/src/framework/service/engine-error-converter.h
deleted file mode 100644 (file)
index f4459e1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  Copyright (c) 2016 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        engine-error-converter.h
- * @author      Kyungwook Tak (k.tak@samsung.com)
- * @version     1.0
- * @brief       convert engine error to custom exception
- */
-#pragma once
-
-namespace Csr {
-
-// throw converted common exception if it have to.
-void toException(int ee);
-
-}
similarity index 61%
rename from src/framework/service/engine-error-converter.cpp
rename to src/framework/service/iloader.cpp
index 4aec5f1..534a6d2 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        engine-error-converter.cpp
- * @author      Kyungwook Tak (k.tak@samsung.com)
- * @version     1.0
- * @brief       convert engine error to custom exception
+ * @file       iloader.cpp
+ * @author     Kyungwook Tak (k.tak@samsung.com)
+ * @version    1.0
+ * @brief      engine loader abstract class
  */
-#include "service/engine-error-converter.h"
+#include "service/iloader.h"
 
-#include "common/exception.h"
+#include <stdexcept>
 
 #include <csre-error.h>
 
+#include "common/exception.h"
+
 namespace Csr {
 
-void toException(int ee)
+void ILoader::toException(int ee, bool internalErrorToString)
 {
        switch (ee) {
        case CSRE_ERROR_NONE:
@@ -46,7 +48,20 @@ void toException(int ee)
                ThrowExc(CSR_ERROR_ENGINE_NOT_ACTIVATED, "engine is not activated yet");
 
        default:
-               ThrowExc(CSR_ERROR_ENGINE_INTERNAL, "engine internal error. ec: " << ee);
+               if (internalErrorToString) {
+                       std::string errstr;
+                       try {
+                               errstr = this->getErrorString(ee);
+                       } catch (...) {
+                               ERROR("exception from engine loader's getErrorString.");
+                               ThrowExc(CSR_ERROR_ENGINE_INTERNAL, "engine internal error. Failed to "
+                                                "get errno string... engine error code: " << ee);
+                       }
+
+                       ThrowExc(CSR_ERROR_ENGINE_INTERNAL, "engine internal error: " << errstr);
+               } else {
+                       ThrowExc(CSR_ERROR_ENGINE_INTERNAL, "engine internal error. ec: " << ee);
+               }
        }
 }
 
index d851bbd..5674aa3 100644 (file)
@@ -21,6 +21,8 @@
  */
 #pragma once
 
+#include <string>
+
 namespace Csr {
 
 class ILoader {
@@ -32,12 +34,16 @@ public:
                this->init(enginePath, roResDir, rwWorkingDir);
        }
 
+       virtual std::string getErrorString(int) = 0;
+
 protected:
        virtual ~ILoader() = default;
 
        virtual void deinit() = 0;
        virtual void init(const std::string &enginePath, const std::string &roResDir,
                                          const std::string &rwWorkingDir) = 0;
+
+       virtual void toException(int ee, bool internalErrorToString = true);
 };
 
 }
index b3205e8..6c95d2e 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "common/audit/logger.h"
 #include "common/exception.h"
-#include "service/engine-error-converter.h"
 
 namespace Csr {
 
@@ -49,29 +48,26 @@ void WpLoader::checkEngineActivated(csre_wp_context_h c)
 {
        csre_wp_activated_e a = CSRE_WP_NOT_ACTIVATED;
 
-       int ret = this->getEngineActivated(c, &a);
-
-       if (ret != CSRE_ERROR_NONE)
-               toException(ret);
+       this->getEngineActivated(c, &a);
 
        if (a == CSRE_WP_NOT_ACTIVATED)
                ThrowExc(CSR_ERROR_ENGINE_NOT_ACTIVATED, "engine is not activated yet");
 }
 
-int WpLoader::contextCreate(csre_wp_context_h &c)
+void WpLoader::contextCreate(csre_wp_context_h &c)
 {
-       return this->m_pc.fpContextCreate(&c);
+       this->toException(this->m_pc.fpContextCreate(&c));
 }
 
-int WpLoader::contextDestroy(csre_wp_context_h c)
+void WpLoader::contextDestroy(csre_wp_context_h c)
 {
        if (c == nullptr)
                throw std::invalid_argument("wp loader context destroy");
 
-       return this->m_pc.fpContextDestroy(c);
+       this->toException(this->m_pc.fpContextDestroy(c));
 }
 
-int WpLoader::checkUrl(csre_wp_context_h c, const std::string &url,
+void WpLoader::checkUrl(csre_wp_context_h c, const std::string &url,
                                           csre_wp_check_result_h *presult)
 {
        if (c == nullptr || url.empty() || presult == nullptr)
@@ -79,111 +75,111 @@ int WpLoader::checkUrl(csre_wp_context_h c, const std::string &url,
 
        this->checkEngineActivated(c);
 
-       return this->m_pc.fpCheckUrl(c, (const char *)url.c_str(), presult);
+       this->toException(this->m_pc.fpCheckUrl(c, (const char *)url.c_str(), presult));
 }
 
-int WpLoader::getRiskLevel(csre_wp_check_result_h r,
-                                                  csre_wp_risk_level_e *plevel)
+void WpLoader::getRiskLevel(csre_wp_check_result_h r, csre_wp_risk_level_e *plevel)
 {
        if (r == nullptr || plevel == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader Get Risk Level error");
 
-       return this->m_pc.fpGetRiskLevel(r, plevel);
+       this->toException(this->m_pc.fpGetRiskLevel(r, plevel));
 }
 
-int WpLoader::getDetailedUrl(csre_wp_check_result_h r, std::string &value)
+void WpLoader::getDetailedUrl(csre_wp_check_result_h r, std::string &value)
 {
        if (r == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get detailed url error");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetDetailedUrl(r, cvalue);
-       });
+       }));
 }
 
 
-int WpLoader::getErrorString(int ec, std::string &value)
+std::string WpLoader::getErrorString(int ec)
 {
-       return getValueCstr(value, [&](const char **cvalue) {
+       std::string value;
+
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetErrorString(ec, cvalue);
-       });
+       }));
+
+       return value;
 }
 
-int WpLoader::getEngineApiVersion(csre_wp_context_h c, std::string &value)
+void WpLoader::getEngineApiVersion(csre_wp_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get error string");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineApiVersion(c, cvalue);
-       });
+       }));
 }
 
-int WpLoader::getEngineVendor(csre_wp_context_h c, std::string &value)
+void WpLoader::getEngineVendor(csre_wp_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine vendor");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineVendor(c, cvalue);
-       });
+       }));
 }
 
-int WpLoader::getEngineName(csre_wp_context_h c, std::string &value)
+void WpLoader::getEngineName(csre_wp_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine name");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineName(c, cvalue);
-       });
+       }));
 }
 
-int WpLoader::getEngineVersion(csre_wp_context_h c, std::string &value)
+void WpLoader::getEngineVersion(csre_wp_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine version");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineVersion(c, cvalue);
-       });
+       }));
 }
 
-int WpLoader::getEngineDataVersion(csre_wp_context_h c, std::string &value)
+void WpLoader::getEngineDataVersion(csre_wp_context_h c, std::string &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine version");
 
-       return getValueCstr(value, [&](const char **cvalue) {
+       this->toException(getValueCstr(value, [&](const char **cvalue) {
                return this->m_pc.fpGetEngineDataVersion(c, cvalue);
-       });
+       }));
 }
 
-int WpLoader::getEngineLatestUpdateTime(csre_wp_context_h c, time_t *ptime)
+void WpLoader::getEngineLatestUpdateTime(csre_wp_context_h c, time_t *ptime)
 {
        if (c == nullptr || ptime == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get latest update time");
 
-       return this->m_pc.fpGetEngineLatestUpdateTime(c, ptime);
+       this->toException(this->m_pc.fpGetEngineLatestUpdateTime(c, ptime));
 }
 
-int WpLoader::getEngineActivated(csre_wp_context_h c,
-                                                                csre_wp_activated_e *pactivated)
+void WpLoader::getEngineActivated(csre_wp_context_h c, csre_wp_activated_e *pactivated)
 {
        if (c == nullptr || pactivated == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine activated");
 
        auto ret = this->m_pc.fpGetEngineActivated(c, pactivated);
 
-       if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED) {
+       if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED)
                *pactivated = CSRE_WP_NOT_ACTIVATED;
-               return CSRE_ERROR_NONE;
-       } else {
-               return ret;
-       }
+       else if (ret != CSRE_ERROR_NONE)
+               this->toException(ret);
 }
 
-int WpLoader::getEngineVendorLogo(csre_wp_context_h c, std::vector<unsigned char> &value)
+void WpLoader::getEngineVendorLogo(csre_wp_context_h c, std::vector<unsigned char> &value)
 {
        if (c == nullptr)
                ThrowExc(CSR_ERROR_INVALID_PARAMETER, "wp loader get engine vendor logo");
@@ -195,7 +191,7 @@ int WpLoader::getEngineVendorLogo(csre_wp_context_h c, std::vector<unsigned char
        if (retval == CSRE_ERROR_NONE && cvalue != nullptr && size != 0)
                value.assign(cvalue, cvalue + size);
 
-       return retval;
+       this->toException(retval);
 }
 
 void WpLoader::init(const std::string &enginePath, const std::string &roResDir,
@@ -273,7 +269,7 @@ void WpLoader::init(const std::string &enginePath, const std::string &roResDir,
        if (ret != CSRE_ERROR_NONE) {
                dlclose(this->m_pc.dlhandle);
                this->m_pc.dlhandle = nullptr;
-               toException(ret);
+               this->toException(ret, false);
        }
 }
 
@@ -306,12 +302,16 @@ WpEngineContext::WpEngineContext(const std::shared_ptr<WpLoader> &loader) :
        if (!this->m_loader)
                ThrowExc(CSR_ERROR_ENGINE_NOT_EXIST, "null loader means engine not exist!");
 
-       toException(this->m_loader->contextCreate(this->m_context));
+       this->m_loader->contextCreate(this->m_context);
 }
 
 WpEngineContext::~WpEngineContext()
 {
-       toException(this->m_loader->contextDestroy(this->m_context));
+       try {
+               this->m_loader->contextDestroy(this->m_context);
+       } catch (...) {
+               ERROR("exception in contextDestroy of wp loader");
+       }
 }
 
 csre_wp_context_h &WpEngineContext::get(void)
index b32a7c4..22835e8 100644 (file)
@@ -39,21 +39,22 @@ public:
                         const std::string &rwWorkingDir);
        virtual ~WpLoader();
 
-       int contextCreate(csre_wp_context_h &);
-       int contextDestroy(csre_wp_context_h);
-       int checkUrl(csre_wp_context_h handle, const std::string &,
+       void contextCreate(csre_wp_context_h &);
+       void contextDestroy(csre_wp_context_h);
+       void checkUrl(csre_wp_context_h handle, const std::string &,
                                 csre_wp_check_result_h *);
-       int getRiskLevel(csre_wp_check_result_h, csre_wp_risk_level_e *);
-       int getDetailedUrl(csre_wp_check_result_h, std::string &);
-       int getErrorString(int, std::string &);
-       int getEngineApiVersion(csre_wp_context_h, std::string &);
-       int getEngineVendor(csre_wp_context_h, std::string &);
-       int getEngineName(csre_wp_context_h, std::string &);
-       int getEngineVersion(csre_wp_context_h, std::string &);
-       int getEngineDataVersion(csre_wp_context_h, std::string &);
-       int getEngineLatestUpdateTime(csre_wp_context_h, time_t *);
-       int getEngineActivated(csre_wp_context_h, csre_wp_activated_e *);
-       int getEngineVendorLogo(csre_wp_context_h, std::vector<unsigned char> &);
+       void getRiskLevel(csre_wp_check_result_h, csre_wp_risk_level_e *);
+       void getDetailedUrl(csre_wp_check_result_h, std::string &);
+       void getEngineApiVersion(csre_wp_context_h, std::string &);
+       void getEngineVendor(csre_wp_context_h, std::string &);
+       void getEngineName(csre_wp_context_h, std::string &);
+       void getEngineVersion(csre_wp_context_h, std::string &);
+       void getEngineDataVersion(csre_wp_context_h, std::string &);
+       void getEngineLatestUpdateTime(csre_wp_context_h, time_t *);
+       void getEngineActivated(csre_wp_context_h, csre_wp_activated_e *);
+       void getEngineVendorLogo(csre_wp_context_h, std::vector<unsigned char> &);
+
+       virtual std::string getErrorString(int) override;
 
 private:
        using FpGlobalInit = int(*)(const char *, const char *);
index 93cd443..c7fd03b 100644 (file)
@@ -26,7 +26,6 @@
 #include "common/audit/logger.h"
 #include "common/exception.h"
 #include "service/type-converter.h"
-#include "service/engine-error-converter.h"
 #include "ui/askuser.h"
 #include <csr-error.h>
 
@@ -41,8 +40,7 @@ WpLogic::WpLogic(const std::shared_ptr<WpLoader> &loader,
 
        if (this->m_loader) {
                WpEngineContext wpEngineContext(this->m_loader);
-               toException(this->m_loader->getEngineDataVersion(wpEngineContext.get(),
-                                       this->m_dataVersion));
+               this->m_loader->getEngineDataVersion(wpEngineContext.get(), this->m_dataVersion);
        }
 }
 
@@ -55,7 +53,7 @@ RawBuffer WpLogic::checkUrl(const WpContext &context, const std::string &url)
        auto &c = engineContext.get();
 
        csre_wp_check_result_h result;
-       toException(this->m_loader->checkUrl(c, url.c_str(), &result));
+       this->m_loader->checkUrl(c, url.c_str(), &result);
 
        auto wr = convert(result);
 
@@ -115,8 +113,8 @@ WpResult WpLogic::convert(csre_wp_check_result_h &r)
        WpResult wr;
        csre_wp_risk_level_e elevel;
 
-       toException(this->m_loader->getDetailedUrl(r, wr.detailedUrl));
-       toException(this->m_loader->getRiskLevel(r, &elevel));
+       this->m_loader->getDetailedUrl(r, wr.detailedUrl);
+       this->m_loader->getRiskLevel(r, &elevel);
        wr.riskLevel = Csr::convert(elevel);
 
        return wr;
index 2bfee59..ce815d4 100644 (file)
@@ -47,9 +47,9 @@ SET(${TARGET_CSR_INTERNAL_TEST}_SRCS
        ${CSR_FW_SRC_PATH}/service/fs-utils.cpp
        ${CSR_FW_SRC_PATH}/service/file-system.cpp
        ${CSR_FW_SRC_PATH}/service/app-deleter.cpp
+       ${CSR_FW_SRC_PATH}/service/iloader.cpp
        ${CSR_FW_SRC_PATH}/service/cs-loader.cpp
        ${CSR_FW_SRC_PATH}/service/wp-loader.cpp
-       ${CSR_FW_SRC_PATH}/service/engine-error-converter.cpp
        ${CSR_FW_SRC_PATH}/service/dir-blacklist.cpp
        ${CSR_FW_SRC_PATH}/ui/popup/package-info.cpp
 
index 758ec06..ed8aec0 100644 (file)
@@ -51,17 +51,17 @@ inline void checkDetected(Csr::CsLoader &loader,
        CHECK_IS_NOT_NULL(detected);
 
        csre_cs_severity_level_e severity;
-       ASSERT_IF(loader.getSeverity(detected, &severity), CSRE_ERROR_NONE);
+       loader.getSeverity(detected, &severity);
        ASSERT_IF(severity, expected_severity);
 
        std::string malware_name;
-       ASSERT_IF(loader.getMalwareName(detected, malware_name), CSRE_ERROR_NONE);
+       loader.getMalwareName(detected, malware_name);
 
        if (expected_malware_name != nullptr)
                ASSERT_IF(malware_name, expected_malware_name);
 
        std::string detailed_url;
-       ASSERT_IF(loader.getDetailedUrl(detected, detailed_url), CSRE_ERROR_NONE);
+       loader.getDetailedUrl(detected, detailed_url);
 
        if (expected_detailed_url != nullptr)
                ASSERT_IF(detailed_url, expected_detailed_url);
@@ -75,12 +75,12 @@ struct Handle {
                           ENGINE_DIR,
                           ENGINE_RW_WORKING_DIR)
        {
-               ASSERT_IF(loader.contextCreate(context), CSRE_ERROR_NONE);
+               loader.contextCreate(context);
        }
 
        ~Handle()
        {
-               ASSERT_IF(loader.contextDestroy(context), CSRE_ERROR_NONE);
+               loader.contextDestroy(context);
        }
 
        Csr::CsLoader loader;
@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(scan_data_clear)
 
        csre_cs_detected_h detected;
        std::vector<unsigned char> data(cdata, cdata + strlen(cdata));
-       ASSERT_IF(h.loader.scanData(h.context, data, &detected), CSRE_ERROR_NONE);
+       h.loader.scanData(h.context, data, &detected);
 
        CHECK_IS_NULL(detected);
 
@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(scan_data_high)
 
        csre_cs_detected_h detected;
        std::vector<unsigned char> data(cdata, cdata + strlen(cdata));
-       ASSERT_IF(h.loader.scanData(h.context, data, &detected), CSRE_ERROR_NONE);
+       h.loader.scanData(h.context, data, &detected);
 
        CHECK_IS_NOT_NULL(detected);
 
@@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(scan_data_medium)
 
        csre_cs_detected_h detected;
        std::vector<unsigned char> data(cdata, cdata + strlen(cdata));
-       ASSERT_IF(h.loader.scanData(h.context, data, &detected), CSRE_ERROR_NONE);
+       h.loader.scanData(h.context, data, &detected);
 
        CHECK_IS_NOT_NULL(detected);
 
@@ -174,8 +174,7 @@ BOOST_AUTO_TEST_CASE(scan_file_normal)
        Handle h;
 
        csre_cs_detected_h detected;
-       ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_NORMAL, &detected),
-                         CSRE_ERROR_NONE);
+       h.loader.scanFile(h.context, TEST_FILE_NORMAL, &detected);
 
        CHECK_IS_NULL(detected);
 
@@ -189,8 +188,7 @@ BOOST_AUTO_TEST_CASE(scan_file_malware)
        Handle h;
 
        csre_cs_detected_h detected;
-       ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_MALWARE, &detected),
-                         CSRE_ERROR_NONE);
+       h.loader.scanFile(h.context, TEST_FILE_MALWARE, &detected);
 
        CHECK_IS_NOT_NULL(detected);
 
@@ -210,8 +208,7 @@ BOOST_AUTO_TEST_CASE(scan_file_risky)
        Handle h;
 
        csre_cs_detected_h detected;
-       ASSERT_IF(h.loader.scanFile(h.context, TEST_FILE_RISKY, &detected),
-                         CSRE_ERROR_NONE);
+       h.loader.scanFile(h.context, TEST_FILE_RISKY, &detected);
 
        CHECK_IS_NOT_NULL(detected);
 
@@ -231,8 +228,7 @@ BOOST_AUTO_TEST_CASE(scan_app_on_cloud)
        Handle h;
 
        csre_cs_detected_h detected;
-       ASSERT_IF(h.loader.scanAppOnCloud(h.context, TEST_APP_ROOT, &detected),
-                         CSRE_ERROR_NONE);
+       h.loader.scanAppOnCloud(h.context, TEST_APP_ROOT, &detected);
 
        CHECK_IS_NOT_NULL(detected);
 
@@ -262,9 +258,7 @@ BOOST_AUTO_TEST_CASE(error_string_positive)
 
        Handle h;
 
-       std::string str;
-
-       ASSERT_IF(h.loader.getErrorString(CSRE_ERROR_UNKNOWN, str), CSRE_ERROR_NONE);
+       std::string str = h.loader.getErrorString(CSRE_ERROR_UNKNOWN);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -277,7 +271,7 @@ BOOST_AUTO_TEST_CASE(get_vendor)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineVendor(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineVendor(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -290,7 +284,7 @@ BOOST_AUTO_TEST_CASE(get_vendor_logo)
        Handle h;
 
        std::vector<unsigned char> logo;
-       ASSERT_IF(h.loader.getEngineVendorLogo(h.context, logo), CSRE_ERROR_NONE);
+       h.loader.getEngineVendorLogo(h.context, logo);
 
        EXCEPTION_GUARD_END
 }
@@ -302,7 +296,7 @@ BOOST_AUTO_TEST_CASE(get_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineVersion(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -315,7 +309,7 @@ BOOST_AUTO_TEST_CASE(get_data_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineDataVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineDataVersion(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -328,8 +322,7 @@ BOOST_AUTO_TEST_CASE(get_latest_update_time)
        Handle h;
 
        time_t time = 0;
-       ASSERT_IF(h.loader.getEngineLatestUpdateTime(h.context, &time),
-                         CSRE_ERROR_NONE);
+       h.loader.getEngineLatestUpdateTime(h.context, &time);
 
        EXCEPTION_GUARD_END
 }
@@ -341,7 +334,7 @@ BOOST_AUTO_TEST_CASE(get_engine_activated)
        Handle h;
 
        csre_cs_activated_e activated;
-       ASSERT_IF(h.loader.getEngineActivated(h.context, &activated), CSRE_ERROR_NONE);
+       h.loader.getEngineActivated(h.context, &activated);;
 
        EXCEPTION_GUARD_END
 }
@@ -353,7 +346,7 @@ BOOST_AUTO_TEST_CASE(get_api_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineApiVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineApiVersion(h.context, str);
        ASSERT_IF(str == CSRE_CS_API_VERSION, true);
 
        EXCEPTION_GUARD_END
index 8ecb267..8007943 100755 (executable)
@@ -61,11 +61,11 @@ inline void checkResult(Csr::WpLoader &loader,
        CHECK_IS_NOT_NULL(result);
 
        csre_wp_risk_level_e risk_level;
-       ASSERT_IF(loader.getRiskLevel(result, &risk_level), CSRE_ERROR_NONE);
+       loader.getRiskLevel(result, &risk_level);
        ASSERT_IF(risk_level, expected.second.risk_level);
 
        std::string detailed_url;
-       ASSERT_IF(loader.getDetailedUrl(result, detailed_url), CSRE_ERROR_NONE);
+       loader.getDetailedUrl(result, detailed_url);
        ASSERT_IF(detailed_url, expected.second.detailed_url);
 
        EXCEPTION_GUARD_END
@@ -77,12 +77,12 @@ struct Handle {
                           ENGINE_DIR,
                           ENGINE_RW_WORKING_DIR)
        {
-               ASSERT_IF(loader.contextCreate(context), CSRE_ERROR_NONE);
+               loader.contextCreate(context);
        }
 
        ~Handle()
        {
-               ASSERT_IF(loader.contextDestroy(context), CSRE_ERROR_NONE);
+               loader.contextDestroy(context);
        }
 
        Csr::WpLoader loader;
@@ -112,8 +112,7 @@ BOOST_AUTO_TEST_CASE(check_url)
 
        for (const auto &expected : ExpectedResult) {
                csre_wp_check_result_h result;
-               ASSERT_IF(h.loader.checkUrl(h.context, expected.first.c_str(), &result),
-                                 CSRE_ERROR_NONE);
+               h.loader.checkUrl(h.context, expected.first.c_str(), &result);
                checkResult(h.loader, result, expected);
        }
 
@@ -127,9 +126,7 @@ BOOST_AUTO_TEST_CASE(error_string)
 
        Handle h;
 
-       std::string str;
-
-       ASSERT_IF(h.loader.getErrorString(CSRE_ERROR_UNKNOWN, str), CSRE_ERROR_NONE);
+       std::string str = h.loader.getErrorString(CSRE_ERROR_UNKNOWN);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -142,7 +139,7 @@ BOOST_AUTO_TEST_CASE(get_vendor)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineVendor(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineVendor(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -155,7 +152,7 @@ BOOST_AUTO_TEST_CASE(get_vendor_logo)
        Handle h;
 
        std::vector<unsigned char> logo;
-       ASSERT_IF(h.loader.getEngineVendorLogo(h.context, logo), CSRE_ERROR_NONE);
+       h.loader.getEngineVendorLogo(h.context, logo);
 
        EXCEPTION_GUARD_END
 }
@@ -167,7 +164,7 @@ BOOST_AUTO_TEST_CASE(get_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineVersion(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -180,7 +177,7 @@ BOOST_AUTO_TEST_CASE(get_data_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineDataVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineDataVersion(h.context, str);
        ASSERT_IF(str.empty(), false);
 
        EXCEPTION_GUARD_END
@@ -193,8 +190,7 @@ BOOST_AUTO_TEST_CASE(get_latest_update_time)
        Handle h;
 
        time_t time = 0;
-       ASSERT_IF(h.loader.getEngineLatestUpdateTime(h.context, &time),
-                         CSRE_ERROR_NONE);
+       h.loader.getEngineLatestUpdateTime(h.context, &time);
 
        EXCEPTION_GUARD_END
 }
@@ -206,7 +202,7 @@ BOOST_AUTO_TEST_CASE(get_engine_activated)
        Handle h;
 
        csre_wp_activated_e activated;
-       ASSERT_IF(h.loader.getEngineActivated(h.context, &activated), CSRE_ERROR_NONE);
+       h.loader.getEngineActivated(h.context, &activated);
 
        EXCEPTION_GUARD_END
 }
@@ -218,7 +214,7 @@ BOOST_AUTO_TEST_CASE(get_api_version)
        Handle h;
 
        std::string str;
-       ASSERT_IF(h.loader.getEngineApiVersion(h.context, str), CSRE_ERROR_NONE);
+       h.loader.getEngineApiVersion(h.context, str);
        ASSERT_IF(str == CSRE_CS_API_VERSION, true);
 
        EXCEPTION_GUARD_END