--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Krzysztof Jackiewicz <k.jackiewicz@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
+ */
+
+/**
+ * @file debug.h
+ * @brief
+ */
+
+#pragma once
+
+extern "C" {
+
+typedef void (*yaca_error_cb)(const char*);
+
+void yaca_debug_set_error_cb(yaca_error_cb cb);
+
+char *yaca_debug_translate_error(yaca_error_e err);
+
+} /* extern */
--- /dev/null
+/*
+ * Copyright (c) 2000 - 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 yaca-test-common.cpp
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#include <vector>
+#include <string>
+
+#include "yaca-test-common.h"
+
+namespace {
+
+std::vector<std::string> opensslErrors;
+
+} // anonymous
+
+void error_cb(const char *msg)
+{
+ opensslErrors.push_back(msg ? msg : "NULL");
+}
+
+const std::vector<std::string>& get_openssl_errors()
+{
+ return opensslErrors;
+}
+
+void clear_openssl_errors()
+{
+ opensslErrors.clear();
+}
+
+const char *yaca_error(int error)
+{
+ return yaca_debug_translate_error(static_cast<yaca_error_e>(error));
+}
--- /dev/null
+/*
+ * Copyright (c) 2000 - 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 yaca-test-common.h
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#pragma once
+
+#include <utility>
+#include <vector>
+#include <string>
+#include <iostream>
+#include <sstream>
+
+#include <yaca_crypto.h>
+#include <yaca_error.h>
+
+#include <dpl/gdbbacktrace.h>
+#include <dpl/test/test_failed.h>
+#include <dpl/test/test_runner.h>
+
+#include "debug.h"
+
+#define YACA_ASSERT_MSG(test, message) \
+do { \
+ if (!(test)) { \
+ std::ostringstream assertMsg; \
+ assertMsg << message << DPL::gdbbacktrace(); \
+ if (!get_openssl_errors().empty()) { \
+ assertMsg << std::endl << "OPENSSL ERRORS:" << std::endl; \
+ for (auto &err : get_openssl_errors()) \
+ assertMsg << err; \
+ clear_openssl_errors(); \
+ } \
+ DPL::Test::TestFailed e(#test, \
+ __FILE__, \
+ __LINE__, \
+ assertMsg.str()); \
+ if (!std::uncaught_exception()) \
+ throw e; \
+ DPL::Test::TestRunnerSingleton::Instance().addFailReason(e.GetMessage()); \
+ } \
+} while (0)
+
+const char *yaca_error(int error);
+
+void error_cb(const char *msg);
+
+const std::vector<std::string>& get_openssl_errors();
+void clear_openssl_errors();
+
+struct YacaTest {
+ YacaTest() {}
+ ~YacaTest() {}
+
+ void init(const std::string&)
+ {
+ int ret = yaca_initialize();
+ YACA_ASSERT_MSG(ret == 0, "yaca_initialize() failed with " << yaca_error(ret));
+
+ yaca_debug_set_error_cb(&error_cb);
+ }
+
+ void finish()
+ {
+ yaca_cleanup();
+ }
+};
+
+// YACA_ASSERT wrappers
+#define YACA_RESULT(expected, func) \
+do { \
+ int ret = func; \
+ YACA_ASSERT_MSG(ret == (expected), \
+ "Expected: " << yaca_error((expected)) << \
+ " got: " << yaca_error(ret) ); \
+} while(0);
+
+#define YACA_SUCCESS(func) YACA_RESULT(YACA_ERROR_NONE, func);
+
+#define YACA_INVALID_PARAM(func) YACA_RESULT(YACA_ERROR_INVALID_PARAMETER, func);