Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Johansson committed Mar 7, 2018
1 parent 89e0106 commit 15d8f88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/salt.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ salt_ret_t salt_protocols_append(salt_protocols_t *p_protocols,
uint8_t size)
{

if (NULL == p_protocols) {
if ((NULL == p_protocols) || (NULL == p_buffer)) {
return SALT_ERROR;
}

Expand Down
23 changes: 20 additions & 3 deletions tests/a1a2.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ static void a1a2_known_host(void **state)

host_ret = salt_create_signature(host_channel);
assert_true(host_ret == SALT_SUCCESS);
host_ret = salt_init_session(host_channel, host_buffer, SALT_HNDSHK_BUFFER_SIZE);
assert_true(host_ret == SALT_SUCCESS);

uint8_t protocol_buf[128];
uint8_t protocol_buf[67];
salt_protocols_t my_protocols;

host_ret = salt_protocols_init(host_channel, &my_protocols, protocol_buf, 8);
assert_true(host_ret == SALT_ERROR);

host_ret = salt_protocols_init(host_channel, &my_protocols, protocol_buf, sizeof(protocol_buf));
assert_true(host_ret == SALT_SUCCESS);
host_ret = salt_protocols_append(&my_protocols, "Echo", 4);
Expand All @@ -134,6 +136,21 @@ static void a1a2_known_host(void **state)
host_ret = salt_protocols_append(&my_protocols, "Sensor", 6);
assert_true(host_ret == SALT_SUCCESS);

host_ret = salt_protocols_append(&my_protocols, "Sensor", 6);
assert_true(host_ret == SALT_ERROR);

host_ret = salt_protocols_append(NULL, "Sensor", 6);
assert_true(host_ret == SALT_ERROR);

host_ret = salt_protocols_append(&my_protocols, NULL, 6);
assert_true(host_ret == SALT_ERROR);

host_ret = salt_protocols_append(&my_protocols, "Sensor", sizeof(salt_protocol_t) + 1);
assert_true(host_ret == SALT_ERROR);

host_ret = salt_init_session(host_channel, host_buffer, SALT_HNDSHK_BUFFER_SIZE);
assert_true(host_ret == SALT_SUCCESS);

client_ret = salt_create_signature(client_channel);
assert_true(client_ret == SALT_SUCCESS);
client_ret = salt_init_session(client_channel, client_buffer, SALT_HNDSHK_BUFFER_SIZE);
Expand Down

0 comments on commit 15d8f88

Please sign in to comment.