#include <tests_common.h>
#include <dlog.h>
#include "security_server_clean_env.h"
+#include "security_server_tests_common.h"
#include <summary_collector.h>
-// security server retry timeout in microseconds
-const unsigned int PASSWORD_RETRY_TIMEOUT_US = 500000;
-
// the maximum time (in seconds) passwords can expire in
const unsigned int PASSWORD_INFINITE_EXPIRATION_TIME = 0xFFFFFFFF;
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
// UINT_MAX will cause api error, it is to big value
ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, UINT_MAX);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
// calculate max applicable valid days that will not be rejected by ss
// ensure, that after conversion from days to seconds in ss there will be no uint overflow
unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, UINT_MAX, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(TEST_PASSWORD, "", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
std::string lng_pwd(5000, 'A');
ret = security_server_set_pwd(TEST_PASSWORD,lng_pwd.c_str(), 10, 10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd("", &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST:
- sleep(1);
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
RUNNER_ASSERT_MSG_BT((expire_sec > 172795) && (expire_sec < 172805), "expire_sec = " << expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TESTS
- sleep(1);
ret = security_server_set_pwd_max_challenge(0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_max_challenge(UINT_MAX);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_max_challenge(5);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_max_challenge(6);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
reset_security_server();
ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
+
ret = security_server_set_pwd_max_challenge(6);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, ret);
- sleep(1);
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
// TEST
printf("5 subtests started...");
for (i = 1; i <= 5; i++) {
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i);
}
printf("DONE\n");
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(attempt == 0, "ret = " << ret);
// TEST
printf("10 subtests started...");
for (i = 1; i <= 10; i++) {
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i);
}
// The check, that exceeds max number
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret);
printf("DONE\n");
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
ret = security_server_reset_pwd(TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
RUNNER_ASSERT_MSG_BT((expire_sec < 86402) && (expire_sec > 86396), "expire_sec = " << ret);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TESTS
- sleep(1);
ret = security_server_set_pwd_history(100);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(51);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(-5);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(50);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(INT_MAX);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(INT_MIN);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- sleep(1);
ret = security_server_set_pwd_history(10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
ret = security_server_set_pwd_history(9);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
ret = security_server_reset_pwd("history0", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
sprintf(buf1, "history%d", i);
sprintf(buf2, "history%d", i + 1);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(buf1, buf2, 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
printf("DONE\n");
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd("history11", "history1", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd("history1", "history8", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd("history1", "history12", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
printf("48 subtests started...");
for (i = 12; i < 60; i++) {
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
sprintf(buf1, "history%d", i);
sprintf(buf2, "history%d", i + 1);
int i = 0;
unsigned int attempt, max_attempt, expire_sec;
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd("quickquickquick", &attempt, &max_attempt, &expire_sec);
while (ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER) {
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = settimeofday(&cur_time, NULL);
RUNNER_ASSERT_MSG_BT(ret > -1, ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED, "ret = " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
}
for (size_t pass = 0; pass < max_challenge_tab.size(); ++pass) {
unsigned int max_challenges = max_challenge_tab[pass];
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_max_challenge(max_challenges);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
std::string("attempt = ") + std::to_string(attempt));
// lower max_challenge
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_max_challenge(max_challenge_less);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
verify_chk_pwd(TEST_PASSWORD, SECURITY_SERVER_API_SUCCESS, 1, max_challenge_less);
// remove max attempts limit
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_max_challenge(0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
int ret = security_server_set_pwd_history(history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_reset_pwd(TEST_PASSWORD, max_challenge, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = security_server_set_pwd_history(initial_history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
* Lower history depth. At this point SS should treat THIRD_TEST_PASSWORD as current pwd,
* and SECOND_TEST_PASSWORD as a part of history.
*/
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_history(decreased_history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
* Increase history depth to 3. At this point SS should remember TEST_PASSWORD
* and THIRD_TEST_PASSWORD only.
*/
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_history(increased_history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
attempt,
max_challenge);
- usleep(PASSWORD_RETRY_TIMEOUT_US);
attempt = max_attempt = expire_sec = UINT_MAX;
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
int ret = security_server_set_pwd_history(history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//set new password and fill history
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret);
//reset history limit to no history at all
- usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd_history(empty_history_depth);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(NULL, "12345", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
- sleep(1);
ret = security_server_reset_pwd("12345",0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
- sleep(1);
ret = security_server_set_pwd_history(10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
}
ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd("12345", "12346", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
- sleep(1);
ret = security_server_reset_pwd("12346",0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd("12346", &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
- sleep(1);
ret = security_server_set_pwd_history(10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
}
RUNNER_ASSERT_MSG_BT(max_attempt == 0, "max_attempt = " << max_attempt << ", should be 0.");
RUNNER_ASSERT_MSG_BT(attempt == 0, "attempt = " << attempt << ", should be 0.");
- sleep(1);
-
return 0;
}
return -1;
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD,
"is_pwd_valid should return no password error. Result: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_set_pwd(NULL, "12345", 0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
"set_pwd failed. Result: " << ret);
- sleep(1);
ret = security_server_reset_pwd("12345",0, 0);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
"reset_pwd failed. Result: " << ret);
- sleep(1);
+ usleep(PASSWORD_RETRY_TIMEOUT_US);
ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
"chk_pwd failed. Result: " << ret);
- sleep(1);
ret = security_server_set_pwd_history(10);
RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
"set_pwd_history failed. Result: " << ret);