RUNNER_ASSERT wrappers moved to ckm-common.h
[platform/core/test/security-tests.git] / tests / ckm / ckm-common.h
index 3d0695a..3b0d514 100644 (file)
 #include <unordered_set>
 #include <memory>
 #include <ckm/ckm-type.h>
+#include <ckmc/ckmc-error.h>
+#include <tests_common.h>
 
 void switch_to_storage_user(const char* label);
 void switch_to_storage_ocsp_user(const char* label);
 
 
+// RUNNER_ASSERT wrappers
+template <typename F, typename... Args>
+void assert_result(int expected, F&& func, Args... args)
+{
+    int ret = func(args...);
+    RUNNER_ASSERT_MSG_BT(ret == expected, "Expected " << expected << " got: " << ret);
+}
+
+template <typename F, typename... Args>
+void assert_positive(F&& func, Args... args)
+{
+    assert_result(CKMC_ERROR_NONE, std::move(func), args...);
+}
+
+template <typename F, typename... Args>
+void assert_invalid_param(F&& func, Args... args)
+{
+    assert_result(CKMC_ERROR_INVALID_PARAMETER, std::move(func), args...);
+}
+
+
+// list operations
+template <typename T>
+size_t list_size(const T* list)
+{
+    size_t size = 0;
+    while(list) {
+        list = list->next;
+        size++;
+    }
+    return size;
+}
+
+
 // service lifecycle management
 enum ServiceIdx {
     LISTENER,