CKM: Add error description in error message.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 16 Jan 2015 19:47:43 +0000 (20:47 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Wed, 18 Feb 2015 09:43:01 +0000 (10:43 +0100)
Change-Id: I9769865577579500bc774332dcc1fee12d828a00

tests/ckm/capi-testcases.cpp
tests/ckm/ckm-common.cpp
tests/ckm/ckm-common.h

index fe4a10a..a154faf 100644 (file)
@@ -14,6 +14,8 @@
 #include <ckmc/ckmc-type.h>
 #include <ckmc/ckmc-error.h>
 
+#include <ckm-common.h>
+
 #include <string>
 #include <string.h>
 #include <stdio.h>
@@ -23,8 +25,7 @@
 static const int USER_APP = 5000;
 static const int GROUP_APP = 5000;
 
-namespace
-{
+namespace {
 
 typedef enum {
        ALIAS_KEY,
@@ -91,7 +92,8 @@ ckmc_raw_buffer_s prepare_message_buffer(const char * input)
        retval.size = strlen(input);
        return retval;
 }
-}
+
+} // namespace anonymous
 
 
 RUNNER_TEST_GROUP_INIT (T301_CKMC_CONTROL_C_API);
@@ -101,10 +103,10 @@ RUNNER_TEST(T3011_Control_C_API)
        int temp;
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3012_Control_C_API)
@@ -112,9 +114,9 @@ RUNNER_TEST(T3012_Control_C_API)
        int temp;
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3013_Control_C_API)
@@ -122,7 +124,7 @@ RUNNER_TEST(T3013_Control_C_API)
        int temp;
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3014_Control_C_API)
@@ -130,27 +132,27 @@ RUNNER_TEST(T3014_Control_C_API)
        int temp;
        const uid_t UNIQUE_USER = 15;
 
-       // clean up environment
-       RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
-                       "Error=" << temp);
-       // unlock with default password
-       RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, NULL)),
-                       "Error=" << temp);
+    // clean up environment
+    RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
+            CKMCReadableError(temp));
+    // unlock with default password
+    RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, NULL)),
+            CKMCReadableError(temp));
        // reset password (NULL, "simple-password")
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        // get rid of NULL DKEK
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        // lock db
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(UNIQUE_USER)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        // try to reset password when db locked
        RUNNER_ASSERT_MSG( CKMC_ERROR_BAD_REQUEST == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
-                       "Error=" << temp);
-       // clean up environment
-       RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
+    // clean up environment
+    RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
+            CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3015_Control_C_API)
@@ -159,14 +161,14 @@ RUNNER_TEST(T3015_Control_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(20, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_change_user_password(20, "test-pass", "new-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(20)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(20)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3016_Control_C_API)
@@ -175,16 +177,16 @@ RUNNER_TEST(T3016_Control_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(20)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(20)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT (T302_CKMC_QUICK_SET_GET_TESTS_C_API);
@@ -195,10 +197,10 @@ RUNNER_TEST(T3021_init_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3022_key_C_API)
@@ -236,11 +238,11 @@ RUNNER_TEST(T3022_key_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3023_certificate_C_API)
@@ -293,11 +295,11 @@ RUNNER_TEST(T3023_certificate_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert(alias, cert, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        ckmc_cert_free(cert2);
 }
@@ -312,16 +314,16 @@ RUNNER_TEST(T3024_certificate_remove_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        ckmc_cert_free(cert2);
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_cert(alias)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE != (temp = ckmc_get_cert(alias, password, &cert2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3025_certificate_list_C_API)
@@ -373,15 +375,15 @@ RUNNER_TEST(T3025_certificate_list_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test1", cert, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test2", cert, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert("cert_test3", cert, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        (current_aliases_num+3) == (temp = count_aliases(ALIAS_CERT)),
@@ -429,10 +431,10 @@ RUNNER_CHILD_TEST(T3026_user_app_save_key_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, passwordPolicy, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        //       RUNNER_ASSERT_MSG(
        //                       key.getDER() == key2.getDER(), "Key value has been changed by service");
@@ -473,11 +475,11 @@ RUNNER_CHILD_TEST(T3027_app_user_save_keys_exportable_flag)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key("appkey1", test_key, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_key("appkey1", password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 
@@ -530,11 +532,11 @@ RUNNER_TEST(T3028_certificate_with_DSA_key_C_API)
        const char *alias = "test-cert-1-DSA";
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert(alias, cert, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias, password, &cert2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        ckmc_cert_free(cert2);
 }
@@ -544,15 +546,15 @@ RUNNER_TEST(T3029_deinit_C_API)
        int temp;
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 
@@ -564,10 +566,10 @@ RUNNER_TEST(T3031_init_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3032_save_keys_get_alias_C_API)
@@ -609,15 +611,15 @@ RUNNER_TEST(T3032_save_keys_get_alias_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey1", test_key, test_policy1)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey2", test_key, test_policy2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key("rootkey3", test_key, test_policy3)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        (current_aliases_num+3) == (temp = count_aliases(ALIAS_KEY)),
@@ -634,15 +636,15 @@ RUNNER_TEST(T3033_remove_key_C_API)
        ckmc_key_s *test_key2;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key("rootkey1", password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_key("rootkey1")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE != (temp = ckmc_get_key("rootkey1", password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3034_deinit_C_API)
@@ -650,15 +652,15 @@ RUNNER_TEST(T3034_deinit_C_API)
        int temp;
 
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT (T3040_CKMC_QUICK_REMOVE_BIN_DATA_TEST_C_API);
@@ -668,10 +670,10 @@ RUNNER_TEST(T3041_init_C_API)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "simple-password")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3042_save_get_bin_data_C_API)
@@ -710,19 +712,19 @@ RUNNER_TEST(T3042_save_get_bin_data_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("data1", testData1, test_policy1)), // should change it as null value
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("data2", testData2, test_policy1)), // should change it as null value
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("data3", testData3, test_policy2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_INVALID_PARAMETER == (temp = ckmc_save_data("data4", testData3, test_policy3)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        (current_aliases_num+3) == (temp = count_aliases(ALIAS_DATA)),
@@ -731,7 +733,7 @@ RUNNER_TEST(T3042_save_get_bin_data_C_API)
        ckmc_raw_buffer_s *testData4;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_data("data2", password, &testData4)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        int compareResult;
        compareResult = (strcmp((const char *)testData2.data, (const char *)testData4->data));
@@ -768,13 +770,13 @@ RUNNER_CHILD_TEST(T3043_app_user_save_bin_data_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata1", testData1, test_policy1)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata2", testData1, test_policy1)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_data("appdata3", testData1, test_policy2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                                (current_aliases_num+3) == (temp = count_aliases(ALIAS_DATA)),
@@ -789,10 +791,10 @@ RUNNER_TEST(T3044_remove_bin_data_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_data("data1")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_data("data3")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                                (current_aliases_num-2) == (temp = count_aliases(ALIAS_DATA)),
@@ -811,7 +813,7 @@ RUNNER_TEST(T3044_remove_bin_data_C_API)
        CKM::RawBuffer buffer;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_data("data2", password, &testData1)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        int compareResult;
        compareResult = (strcmp((const char *)testData2.data, (const char *)testData1->data));
@@ -820,7 +822,7 @@ RUNNER_TEST(T3044_remove_bin_data_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_ALIAS_UNKNOWN == (temp = ckmc_get_data("data3", password, &testData1)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3045_deinit_C_API)
@@ -829,16 +831,16 @@ RUNNER_TEST(T3045_deinit_C_API)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT(T305_CKMC_QUICK_CREATE_PAIR_CAPI);
@@ -849,11 +851,11 @@ RUNNER_TEST(T3051_CAPI_init)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3052_CAPI_create_rsa_key)
@@ -881,7 +883,7 @@ RUNNER_CHILD_TEST(T3052_CAPI_create_rsa_key)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        (current_aliases_num+2) == (temp = count_aliases(ALIAS_KEY)),
@@ -890,29 +892,29 @@ RUNNER_CHILD_TEST(T3052_CAPI_create_rsa_key)
        ckmc_key_s *privateKey;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(private_key_alias, policy_private_key.password,&privateKey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        privateKey->key_type == CKMC_KEY_RSA_PRIVATE,
                        "Key Type Error: expected =" << static_cast<int>(CKMC_KEY_RSA_PRIVATE) << ", actual=" << static_cast<int>(privateKey->key_type));
        RUNNER_ASSERT_MSG(
                        privateKey != NULL && privateKey->key_size > 0 && privateKey->raw_key != NULL,
-                       "Error=" << temp);
+                       "Private key is broken.");
 
        ckmc_key_s *publicKey;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(public_key_alias, policy_public_key.password, &publicKey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        publicKey->key_type == CKMC_KEY_RSA_PUBLIC,
                        "Key Type Error: expected =" << static_cast<int>(CKMC_KEY_RSA_PUBLIC) << ", actual=" << static_cast<int>(publicKey->key_type));
        RUNNER_ASSERT_MSG(
                        publicKey != NULL && publicKey->key_size > 0 && publicKey->raw_key != NULL,
-                       "Error=" << temp);
+                       "Public key is broken.");
 
        // on next attempt to generate keys with the same alias, expect fail (alias exists)
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp << ", ret=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
@@ -934,7 +936,7 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        (current_aliases_num+2) == (temp = count_aliases(ALIAS_KEY)),
@@ -943,10 +945,10 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
        ckmc_key_s *privateKey = 0;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(private_key_alias, policy_private_key.password,&privateKey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        privateKey != NULL && privateKey->key_size > 0 && privateKey->raw_key != NULL,
-                       "Error=" << temp);
+                       "Private key is broken.");
        RUNNER_ASSERT_MSG(
                        privateKey->key_type == CKMC_KEY_DSA_PRIVATE,
                        "Key Type Error: expected =" << static_cast<int>(CKMC_KEY_DSA_PRIVATE) << ", actual=" << static_cast<int>(privateKey->key_type));
@@ -955,10 +957,10 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
        ckmc_key_s *pubKey = 0;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(public_key_alias, policy_public_key.password, &pubKey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        pubKey != NULL && pubKey->key_size > 0 && pubKey->raw_key != NULL,
-                       "Error=" << temp);
+                       "Public key is broken.");
        RUNNER_ASSERT_MSG(
                        pubKey->key_type == CKMC_KEY_DSA_PUBLIC,
                        "Key Type Error: expected =" << static_cast<int>(CKMC_KEY_DSA_PUBLIC) << ", actual=" << static_cast<int>(pubKey->key_type));
@@ -967,7 +969,7 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_dsa_key)
        // on next attempt to generate keys with the same alias, expect fail (alias exists)
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp << ", ret=" << temp);
+                       CKMCReadableError(temp));
 }
 
 
@@ -977,10 +979,10 @@ RUNNER_TEST(T3054_CAPI_deinit)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 
@@ -991,16 +993,16 @@ RUNNER_TEST(T3061_CAPI_init)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3062_CAPI_CreateKeyPairRSA)
@@ -1021,12 +1023,12 @@ RUNNER_TEST(T3062_CAPI_CreateKeyPairRSA)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        // on next attempt to generate keys with the same alias, expect fail (alias exists)
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_create_key_pair_rsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp << ", ret=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3063_CAPI_CreateKeyPairDSA)
@@ -1047,7 +1049,7 @@ RUNNER_TEST(T3063_CAPI_CreateKeyPairDSA)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_dsa(size, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3064_CAPI_CreateKeyPairECDSA)
@@ -1068,7 +1070,7 @@ RUNNER_TEST(T3064_CAPI_CreateKeyPairECDSA)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_key_pair_ecdsa(ectype, private_key_alias, public_key_alias, policy_private_key, policy_public_key)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3065_CAPI_deinit)
@@ -1077,10 +1079,10 @@ RUNNER_TEST(T3065_CAPI_deinit)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 // TODO
@@ -1095,7 +1097,7 @@ RUNNER_TEST(T3071_CAPI_init)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3072_CAPI_get_chain)
@@ -1192,7 +1194,7 @@ RUNNER_TEST(T3072_CAPI_get_chain)
 
        tmp = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
        RUNNER_ASSERT_MSG(
-                       CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+                       CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
 
        int cnt = 0;
        ckmc_cert_list_s *current;
@@ -1208,7 +1210,7 @@ RUNNER_TEST(T3072_CAPI_get_chain)
        ckmc_cert_list_s *untrustedcerts2 = NULL;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_VERIFICATION_FAILED == (tmp = ckmc_get_cert_chain(&c_cert, untrustedcerts2, &cert_chain_list2)),
-                       "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+                       CKMCReadableError(tmp));
 
        RUNNER_ASSERT_MSG(
                        cert_chain_list2 == NULL,
@@ -1307,7 +1309,7 @@ RUNNER_TEST(T3073_CAPI_get_chain_with_alias)
        int tmp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (tmp = ckmc_save_cert(untrusted_alias, c_cert1, test_policy)),
-                       "Error=" << tmp);
+                       CKMCReadableError(tmp));
 
        CharPtr top_label = get_label();
        std::string full_address = aliasWithLabel(top_label.get(), untrusted_alias);
@@ -1316,7 +1318,7 @@ RUNNER_TEST(T3073_CAPI_get_chain_with_alias)
        ckmc_cert_s *c_cert_tmp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (tmp = ckmc_get_cert(full_address.c_str(), NULL, &c_cert_tmp)),
-                       "Error=" << tmp);
+                       CKMCReadableError(tmp));
        ckmc_cert_free(c_cert_tmp);
 
        // get cert chain using alias in full "label alias" form
@@ -1326,8 +1328,7 @@ RUNNER_TEST(T3073_CAPI_get_chain_with_alias)
        ckmc_cert_list_s *cert_chain_list;
 
        tmp = ckmc_get_cert_chain_with_alias(&c_cert, untrustedcerts, &cert_chain_list);
-       RUNNER_ASSERT_MSG(
-                       CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+       RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
        ckmc_alias_list_free(untrustedcerts);
 
 
@@ -1345,7 +1346,7 @@ RUNNER_TEST(T3073_CAPI_get_chain_with_alias)
        ckmc_alias_list_s *untrustedcerts2 = NULL;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_VERIFICATION_FAILED == (tmp = ckmc_get_cert_chain_with_alias(&c_cert, untrustedcerts2, &cert_chain_list2)),
-                       "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+                       CKMCReadableError(tmp));
 
        RUNNER_ASSERT_MSG(
                        cert_chain_list2 == NULL,
@@ -1444,12 +1445,12 @@ RUNNER_TEST(T3074_CAPI_ckmc_ocsp_check)
 
     int        tmp = ckmc_get_cert_chain(&c_cert, &untrustedcerts, &cert_chain_list);
        RUNNER_ASSERT_MSG(
-                       CKMC_ERROR_NONE == tmp, "Error=" << tmp << "/" << CKM::ErrorToString(tmp));
+                       CKMC_ERROR_NONE == tmp, CKMCReadableError(tmp));
 
        RUNNER_ASSERT_MSG(cert_chain_list != NULL, "Wrong size of certificate chain.");
 
     ckmc_ocsp_status_e ocsp_status;
-    RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_ocsp_check(cert_chain_list, &ocsp_status)), "Error: " << tmp);
+    RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_ocsp_check(cert_chain_list, &ocsp_status)), CKMCReadableError(tmp));
     RUNNER_ASSERT_MSG(ocsp_status == CKMC_OCSP_STATUS_GOOD, "Wrong status: " << static_cast<int>(ocsp_status));
 }
 
@@ -1459,10 +1460,10 @@ RUNNER_TEST(T3075_CAPI_deinit)
 
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
 }
 
 
@@ -1474,19 +1475,19 @@ RUNNER_TEST(T3081_CAPI__init)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3082_CAPI__rsa_key_create_verify)
@@ -1568,11 +1569,11 @@ RUNNER_TEST(T3082_CAPI__rsa_key_create_verify)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_signature(
@@ -1582,7 +1583,7 @@ RUNNER_TEST(T3082_CAPI__rsa_key_create_verify)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -1592,7 +1593,7 @@ RUNNER_TEST(T3082_CAPI__rsa_key_create_verify)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3083_CAPI__rsa_key_create_verify_negative)
@@ -1616,7 +1617,7 @@ RUNNER_TEST(T3083_CAPI__rsa_key_create_verify_negative)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -1626,7 +1627,7 @@ RUNNER_TEST(T3083_CAPI__rsa_key_create_verify_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
        memcpy((void*)signature->data, "BROKEN", 6);
@@ -1639,7 +1640,7 @@ RUNNER_TEST(T3083_CAPI__rsa_key_create_verify_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
@@ -1689,10 +1690,10 @@ RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_signature(
@@ -1702,7 +1703,7 @@ RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -1712,7 +1713,7 @@ RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
        memcpy((void*)signature->data, "BROKEN", 6);
@@ -1725,7 +1726,7 @@ RUNNER_TEST(T3084_CAPI__ec_key_create_verify)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
@@ -1799,10 +1800,10 @@ RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert(pub_alias, cert, certpolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
 
        RUNNER_ASSERT_MSG(
@@ -1813,7 +1814,7 @@ RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -1823,7 +1824,7 @@ RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
        memcpy((void*)signature->data, "BROKEN", 6);
@@ -1836,7 +1837,7 @@ RUNNER_TEST(T3085_CAPI__rsa_cert_create_verify_signature)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
@@ -1902,11 +1903,11 @@ RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pub_alias, pubkey, pubpolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_signature(
@@ -1916,7 +1917,7 @@ RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        // positive test
        RUNNER_ASSERT_MSG(
@@ -1927,7 +1928,7 @@ RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        // negative test
        ckmc_raw_buffer_s invalid_msg_buff = prepare_message_buffer("invalid message test");
@@ -1939,7 +1940,7 @@ RUNNER_TEST(T3086_CAPI__dsa_ext_key_create_verify_with_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        ckmc_buffer_free(signature);
 }
@@ -1977,11 +1978,11 @@ RUNNER_TEST(T3087_CAPI__dsa_int_key_create_verify_with_negative)
        ckmc_key_s *prikey = NULL;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(pri_alias, 0, &prikey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(pub_alias, 0, &pubkey)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_signature(
@@ -1991,7 +1992,7 @@ RUNNER_TEST(T3087_CAPI__dsa_int_key_create_verify_with_negative)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        // positive test
        RUNNER_ASSERT_MSG(
@@ -2002,7 +2003,7 @@ RUNNER_TEST(T3087_CAPI__dsa_int_key_create_verify_with_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        // negative test
        ckmc_raw_buffer_s invalid_msg_buff = prepare_message_buffer("invalid message test");
@@ -2014,7 +2015,7 @@ RUNNER_TEST(T3087_CAPI__dsa_int_key_create_verify_with_negative)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        ckmc_key_free(prikey);
        ckmc_key_free(pubkey);
@@ -2086,10 +2087,10 @@ RUNNER_TEST(T3088_CAPI__ecdsa_cert_create_verify_signature)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert(pub_alias, cert, certpolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pri_alias, prikey, pripolicy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_create_signature(
@@ -2099,7 +2100,7 @@ RUNNER_TEST(T3088_CAPI__ecdsa_cert_create_verify_signature)
                                        hash_algo,
                                        pad_algo,
                                        &signature)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -2109,7 +2110,7 @@ RUNNER_TEST(T3088_CAPI__ecdsa_cert_create_verify_signature)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(signature->size > 6, "Signature is too small");
        memcpy((void*)signature->data, "BROKEN", 6);
@@ -2122,7 +2123,7 @@ RUNNER_TEST(T3088_CAPI__ecdsa_cert_create_verify_signature)
                                        *signature,
                                        hash_algo,
                                        pad_algo)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3089_CAPI__deinit)
@@ -2131,10 +2132,10 @@ RUNNER_TEST(T3089_CAPI__deinit)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 
@@ -2171,16 +2172,16 @@ RUNNER_TEST(T3091_CAPI_TYPE_init)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3092_CAPI_TYPE_KEY)
@@ -2353,7 +2354,7 @@ RUNNER_TEST(T3095_CAPI_TYPE_load_cert_file)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (ret = ckmc_load_cert_from_file(file_name, &pcert)),
-                       "Error=" << CKM::ErrorToString(ret));
+            CKMCReadableError(ret));
 
        RUNNER_ASSERT_MSG(
                        pcert != NULL && pcert->cert_size > 0,"Fail to load cert from file.");
@@ -2365,7 +2366,7 @@ RUNNER_TEST(T3095_CAPI_TYPE_load_cert_file)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (ret = ckmc_save_cert(lcert_alias, *pcert, policy)),
-                       "Error=" << CKM::ErrorToString(ret));
+                       CKMCReadableError(ret));
 
        remove(file_name);
 }
@@ -2396,12 +2397,12 @@ RUNNER_TEST(T3096_CAPI_TYPE_load_p12_file) {
        const char *pkey_alias = "pkey_alias";
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(pkey_alias, *private_key, policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        const char *cert_alias = "cert_alias";
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_cert(cert_alias, *cert, policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        std::string caCertAlias = "ca_cert_alias_";
        const char *idx = "0";
        int cnt = 0;
@@ -2410,7 +2411,7 @@ RUNNER_TEST(T3096_CAPI_TYPE_load_p12_file) {
                caCertAlias.append(idx);
                RUNNER_ASSERT_MSG(
                                CKMC_ERROR_NONE == (temp = ckmc_save_cert(caCertAlias.c_str(), *(tmpList->cert), policy)),
-                               "Error=" << temp);
+                               CKMCReadableError(temp));
                tmpList = tmpList->next;
                cnt ++;
        }
@@ -2432,7 +2433,7 @@ RUNNER_TEST(T3097_CAPI_TYPE_load_p12_file2) {
 
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_load_from_pkcs12_file2(p12file, password, &ppkcs12)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     RUNNER_ASSERT_MSG(ppkcs12->priv_key != NULL, "Null private_key");
     RUNNER_ASSERT_MSG(ppkcs12->cert != NULL, "Null cert");
     RUNNER_ASSERT_MSG(ppkcs12->ca_chain != NULL, "Null ca_cert_list");
@@ -2445,12 +2446,12 @@ RUNNER_TEST(T3097_CAPI_TYPE_load_p12_file2) {
     const char *pkey_alias = "pkey_alias2";
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_save_key(pkey_alias, *(ppkcs12->priv_key), policy)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     const char *cert_alias = "cert_alias2";
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_save_cert(cert_alias, *(ppkcs12->cert), policy)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     std::string caCertAlias = "ca_cert_alias_2_";
     const char *idx = "0";
     int cnt = 0;
@@ -2459,7 +2460,7 @@ RUNNER_TEST(T3097_CAPI_TYPE_load_p12_file2) {
         caCertAlias.append(idx);
         RUNNER_ASSERT_MSG(
                 CKMC_ERROR_NONE == (temp = ckmc_save_cert(caCertAlias.c_str(), *(tmpList->cert), policy)),
-                "Error=" << temp);
+                CKMCReadableError(temp));
         tmpList = tmpList->next;
         cnt ++;
     }
@@ -2474,16 +2475,16 @@ RUNNER_TEST(T3098_CAPI_TYPE_deinit)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT(T310_CKMC_CAPI_PKCS12);
@@ -2502,10 +2503,10 @@ RUNNER_TEST(T3101_CAPI_PKCS12_init)
     int temp;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     ckmc_remove_pkcs12(alias_PKCS_collision);
     ckmc_remove_pkcs12(alias_PKCS_exportable);
@@ -2521,7 +2522,7 @@ RUNNER_TEST(T3102_CAPI_PKCS12_negative_wrong_password)
     int temp;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_INVALID_FORMAT == (temp = ckmc_load_from_pkcs12_file2("/usr/share/ckm-test/test1801.pkcs12", wrong_passwd, &ppkcs12)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3103_CAPI_PKCS12_add_bundle_with_chain_certs)
@@ -2530,7 +2531,7 @@ RUNNER_TEST(T3103_CAPI_PKCS12_add_bundle_with_chain_certs)
     int temp;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_load_from_pkcs12_file2("/usr/share/ckm-test/pkcs.p12", NULL, &ppkcs12)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     RUNNER_ASSERT_MSG(NULL != ppkcs12->cert, "no certificate in PKCS12");
     RUNNER_ASSERT_MSG(NULL != ppkcs12->priv_key, "no private key in PKCS12");
@@ -2547,39 +2548,39 @@ RUNNER_TEST(T3103_CAPI_PKCS12_add_bundle_with_chain_certs)
 
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_save_pkcs12(alias_PKCS_exportable, ppkcs12, exportable, exportable)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_save_pkcs12(alias_PKCS_exportable, ppkcs12, exportable, exportable)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_save_pkcs12(alias_PKCS_not_exportable, ppkcs12, notExportable, notExportable)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_EXISTS == (temp = ckmc_save_pkcs12(alias_PKCS_not_exportable, ppkcs12, notExportable, notExportable)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     // try to lookup key
     ckmc_key_s *key_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_get_key(alias_PKCS_exportable, NULL, &key_lookup)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     ckmc_key_free(key_lookup);
     key_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_key(alias_PKCS_not_exportable, "", &key_lookup)),
-            "Error=" << temp << "  CKMC_ERROR_NOT_EXPORTABLE=" << CKMC_ERROR_NOT_EXPORTABLE << "   CKMC_ERROR_DB_ERROR=" << CKMC_ERROR_DB_ERROR);
+            CKMCReadableError(temp));
     ckmc_key_free(key_lookup);
 
     // try to lookup certificate
     ckmc_cert_s *cert_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_get_cert(alias_PKCS_exportable, NULL, &cert_lookup)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     ckmc_cert_free(cert_lookup);
     cert_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_cert(alias_PKCS_not_exportable, NULL, &cert_lookup)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     ckmc_cert_free(cert_lookup);
 }
 
@@ -2593,21 +2594,21 @@ RUNNER_TEST(T3103_CAPI_PKCS12_get_PKCS)
     // fail - no entry
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_UNKNOWN == (temp = ckmc_get_pkcs12("i-do-not-exist", &pkcs)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     ckmc_pkcs12_free(pkcs);
     pkcs = NULL;
 
     // fail - not exportable
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NOT_EXPORTABLE == (temp = ckmc_get_pkcs12(alias_PKCS_not_exportable, &pkcs)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
     ckmc_pkcs12_free(pkcs);
     pkcs = NULL;
 
     // success - exportable
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_get_pkcs12(alias_PKCS_exportable, &pkcs)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     RUNNER_ASSERT_MSG(NULL != pkcs->cert, "no certificate in PKCS12");
     RUNNER_ASSERT_MSG(NULL != pkcs->priv_key, "no private key in PKCS12");
@@ -2640,7 +2641,7 @@ RUNNER_TEST(T3104_CAPI_PKCS12_create_and_verify_signature)
                     hash_algo,
                     pad_algo,
                     &signature)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_verify_signature(
@@ -2650,7 +2651,7 @@ RUNNER_TEST(T3104_CAPI_PKCS12_create_and_verify_signature)
                     *signature,
                     hash_algo,
                     pad_algo)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 }
 
 RUNNER_TEST(T3105_CAPI_PKCS12_remove_bundle_with_chain_certs)
@@ -2660,34 +2661,34 @@ RUNNER_TEST(T3105_CAPI_PKCS12_remove_bundle_with_chain_certs)
     // remove the whole PKCS12 bundles
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (tmp = ckmc_remove_pkcs12(alias_PKCS_exportable)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (tmp = ckmc_remove_pkcs12(alias_PKCS_not_exportable)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
 
     // expect lookup fails due to unknown alias
     // try to lookup key
     ckmc_key_s *key_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_key(alias_PKCS_exportable, NULL, &key_lookup)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
     ckmc_key_free(key_lookup);
     key_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_key(alias_PKCS_not_exportable, NULL, &key_lookup)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
     ckmc_key_free(key_lookup);
 
     // try to lookup certificate
     ckmc_cert_s *cert_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_cert(alias_PKCS_exportable, NULL, &cert_lookup)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
     ckmc_cert_free(cert_lookup);
     cert_lookup = NULL;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_DB_ALIAS_UNKNOWN == (tmp = ckmc_get_cert(alias_PKCS_not_exportable, NULL, &cert_lookup)),
-            "Error=" << tmp);
+            CKMCReadableError(tmp));
     ckmc_cert_free(cert_lookup);
 }
 
@@ -2696,7 +2697,7 @@ RUNNER_TEST(T3109_CAPI_PKCS12_deinit)
     int temp;
     RUNNER_ASSERT_MSG(
             CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-            "Error=" << temp);
+            CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT(T3110_CAPI_LOCKTYPE_TESTS);
@@ -2711,10 +2712,8 @@ RUNNER_CHILD_TEST(T3111_CAPI_init_lock_key)
        char *null_password = NULL;
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,USER_PASS,null_password)),
-               CKM::ErrorToString(tmp));
-       RUNNER_ASSERT_MSG(
-               CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
-               CKM::ErrorToString(tmp));
+               CKMCReadableError(tmp));
+       RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)), CKMCReadableError(tmp));
 }
 
 RUNNER_CHILD_TEST(T3112_CAPI_unlock_default_passwd)
@@ -2756,14 +2755,14 @@ RUNNER_CHILD_TEST(T3112_CAPI_unlock_default_passwd)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_save_key(alias, test_key, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_get_key(alias, password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_key(alias)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3113_CAPI_init_change_user_password)
@@ -2778,17 +2777,17 @@ RUNNER_CHILD_TEST(T3113_CAPI_init_change_user_password)
        // database has been automatically unlocked with NULL pw in previous test. Lock it now
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
-               CKM::ErrorToString(tmp));
+               CKMCReadableError(tmp));
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,null_password,USER_PASS)),
-               CKM::ErrorToString(tmp));
+               CKMCReadableError(tmp));
        // get rid of NULL DKEK
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (tmp = ckmc_unlock_user_key(USER_APP,USER_PASS)),
-               CKM::ErrorToString(tmp));
+               CKMCReadableError(tmp));
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
-               CKM::ErrorToString(tmp));
+               CKMCReadableError(tmp));
 }
 
 RUNNER_CHILD_TEST(T3114_CAPI_unlock_default_passwd_negative)
@@ -2830,11 +2829,11 @@ RUNNER_CHILD_TEST(T3114_CAPI_unlock_default_passwd_negative)
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_LOCKED == (temp = ckmc_save_key(alias, test_key, test_policy)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias, password, &test_key2)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3119_CAPI_deinit)
@@ -2842,10 +2841,10 @@ RUNNER_CHILD_TEST(T3119_CAPI_deinit)
        int temp;
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
        RUNNER_ASSERT_MSG(
                        CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
-                       "Error=" << temp);
+                       CKMCReadableError(temp));
 }
 
 RUNNER_TEST_GROUP_INIT(T320_CAPI_EMPTY_DATABASE);
@@ -2854,11 +2853,11 @@ RUNNER_TEST(T3201_CAPI_unlock_database)
 {
        int temp;
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "simple-password")),
-               "Error=" << temp);
+               CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3202_CAPI_get_data_from_empty_database)
@@ -2879,7 +2878,7 @@ RUNNER_CHILD_TEST(T3203_CAPI_lock_database)
 {
        int temp;
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
 }
 
 RUNNER_CHILD_TEST(T3204_CAPI_get_data_from_locked_database)
@@ -2891,7 +2890,7 @@ RUNNER_CHILD_TEST(T3204_CAPI_get_data_from_locked_database)
 
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias, password, &test_key)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(NULL == test_key, "Key value should not be changed");
 }
@@ -2900,6 +2899,6 @@ RUNNER_TEST(T3204_deinit)
 {
        int temp;
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(0)),
-               "Error=" << temp);
+               CKMCReadableError(temp));
 }
 
index df289db..ce4e0cf 100644 (file)
@@ -18,6 +18,7 @@
  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
  * @version    1.0
  */
+#include <string>
 
 #include <sys/smack.h>
 #include <ckmc/ckmc-type.h>
@@ -110,3 +111,41 @@ ScopedLabel::~ScopedLabel()
      */
     change_label(m_original_label.get());
 }
+
+const char * CKMCErrorToString(int error) {
+#define ERRORDESCRIBE(name) case name: return #name
+    switch(error) {
+        ERRORDESCRIBE(CKMC_ERROR_NONE);
+        ERRORDESCRIBE(CKMC_ERROR_INVALID_PARAMETER);
+        ERRORDESCRIBE(CKMC_ERROR_OUT_OF_MEMORY);
+        ERRORDESCRIBE(CKMC_ERROR_PERMISSION_DENIED);
+        ERRORDESCRIBE(CKMC_ERROR_SOCKET);
+        ERRORDESCRIBE(CKMC_ERROR_BAD_REQUEST);
+        ERRORDESCRIBE(CKMC_ERROR_BAD_RESPONSE);
+        ERRORDESCRIBE(CKMC_ERROR_SEND_FAILED);
+        ERRORDESCRIBE(CKMC_ERROR_RECV_FAILED);
+        ERRORDESCRIBE(CKMC_ERROR_AUTHENTICATION_FAILED);
+        ERRORDESCRIBE(CKMC_ERROR_BUFFER_TOO_SMALL);
+        ERRORDESCRIBE(CKMC_ERROR_SERVER_ERROR);
+        ERRORDESCRIBE(CKMC_ERROR_DB_LOCKED);
+        ERRORDESCRIBE(CKMC_ERROR_DB_ERROR);
+        ERRORDESCRIBE(CKMC_ERROR_DB_ALIAS_EXISTS);
+        ERRORDESCRIBE(CKMC_ERROR_DB_ALIAS_UNKNOWN);
+        ERRORDESCRIBE(CKMC_ERROR_VERIFICATION_FAILED);
+        ERRORDESCRIBE(CKMC_ERROR_INVALID_FORMAT);
+        ERRORDESCRIBE(CKMC_ERROR_FILE_ACCESS_DENIED);
+        ERRORDESCRIBE(CKMC_ERROR_NOT_EXPORTABLE);
+        ERRORDESCRIBE(CKMC_ERROR_UNKNOWN);
+        default: return "Error not defined";
+    }
+#undef ERRORDESCRIBE
+}
+
+std::string CKMCReadableError(int error) {
+    std::string output("Error: ");
+    output += std::to_string(error);
+    output += " Description: ";
+    output += CKMCErrorToString(error);
+    return output;
+}
+
index 694e265..3d0695a 100644 (file)
@@ -37,6 +37,9 @@ enum ServiceIdx {
 void start_service(ServiceIdx idx);
 void stop_service(ServiceIdx idx);
 
+// support for error printing
+const char * CKMCErrorToString(int error);
+std::string CKMCReadableError(int error);
 
 // Class responsible for db cleanup after positive tests. Will remove all used aliases in destructor
 class DBCleanup