Commit 96447d24 by Congyi Wu

Fix 2 bugs in online::push tests.

- Fix stack corruption introduced in 9bccf33c due to passing pointer to
local variable _cred_acquire_called.
- Fix strcmp in do_verify_push_status when expected or actual push_status
  is NULL
parent e1859ea1
...@@ -14,6 +14,7 @@ static char *_remote_user; ...@@ -14,6 +14,7 @@ static char *_remote_user;
static char *_remote_pass; static char *_remote_pass;
static git_remote *_remote; static git_remote *_remote;
static bool _cred_acquire_called;
static record_callbacks_data _record_cbs_data = {{ 0 }}; static record_callbacks_data _record_cbs_data = {{ 0 }};
static git_remote_callbacks _record_cbs = RECORD_CALLBACKS_INIT(&_record_cbs_data); static git_remote_callbacks _record_cbs = RECORD_CALLBACKS_INIT(&_record_cbs_data);
...@@ -79,7 +80,9 @@ static void do_verify_push_status(git_push *push, const push_status expected[], ...@@ -79,7 +80,9 @@ static void do_verify_push_status(git_push *push, const push_status expected[],
else else
git_vector_foreach(&actual, i, iter) git_vector_foreach(&actual, i, iter)
if (strcmp(expected[i].ref, iter->ref) || if (strcmp(expected[i].ref, iter->ref) ||
(expected[i].msg && strcmp(expected[i].msg, iter->msg))) { (expected[i].msg && !iter->msg) ||
(!expected[i].msg && iter->msg) ||
(expected[i].msg && iter->msg && strcmp(expected[i].msg, iter->msg))) {
failed = true; failed = true;
break; break;
} }
...@@ -231,7 +234,7 @@ void test_online_push__initialize(void) ...@@ -231,7 +234,7 @@ void test_online_push__initialize(void)
git_vector delete_specs = GIT_VECTOR_INIT; git_vector delete_specs = GIT_VECTOR_INIT;
size_t i; size_t i;
char *curr_del_spec; char *curr_del_spec;
bool cred_acquire_called = false; _cred_acquire_called = false;
_repo = cl_git_sandbox_init("push_src"); _repo = cl_git_sandbox_init("push_src");
...@@ -272,7 +275,7 @@ void test_online_push__initialize(void) ...@@ -272,7 +275,7 @@ void test_online_push__initialize(void)
if (_remote_url) { if (_remote_url) {
cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url)); cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &cred_acquire_called); git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &_cred_acquire_called);
record_callbacks_data_clear(&_record_cbs_data); record_callbacks_data_clear(&_record_cbs_data);
git_remote_set_callbacks(_remote, &_record_cbs); git_remote_set_callbacks(_remote, &_record_cbs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment