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;
}
#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,
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 <>
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);
}
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);
#include <csr-engine-manager.h>
+#include "test-common.h"
+
namespace {
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, ¤t);
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;
}