Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Update nsdl and grs unit tests to work with memory optimization changes #106

Merged
merged 1 commit into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/nsdl-c/unittest/sn_coap_builder/libCoap_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ TEST(libCoap_builder, build_message_options_uri_path)
{
coap_header.uri_path_ptr = temp;
coap_header.uri_path_len = 2;
CHECK(sn_coap_builder(buffer, &coap_header) == 11);
CHECK(sn_coap_builder(buffer, &coap_header) == 14);
}

TEST(libCoap_builder, build_message_options_content_type)
Expand Down Expand Up @@ -334,7 +334,7 @@ TEST(libCoap_builder, sn_coap_builder_calc_needed_packet_data_size)

// init now the buffer up to 4 bytes, as it will be accessed
memset(header.options_list_ptr->etag_ptr, 0, 4);

header.options_list_ptr->proxy_uri_len = 281;
header.options_list_ptr->block1 = COAP_OPTION_BLOCK_NONE;
header.options_list_ptr->block2 = COAP_OPTION_BLOCK_NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ TEST(libCoap_protocol, sn_coap_protocol_destroy)
memset(msg_ptr, 0, sizeof(coap_send_msg_s));
msg_ptr->send_msg_ptr = (sn_nsdl_transmit_s*)malloc(sizeof(sn_nsdl_transmit_s));
memset(msg_ptr->send_msg_ptr, 0 , sizeof(sn_nsdl_transmit_s));
msg_ptr->send_msg_ptr->uri_path_ptr = (uint8_t*)malloc(2);
msg_ptr->send_msg_ptr->uri_path_len = 2;

ns_list_add_to_end(&handle->linked_list_resent_msgs, msg_ptr);
#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT
Expand Down
440 changes: 255 additions & 185 deletions test/nsdl-c/unittest/sn_grs/test_sn_grs.c

Large diffs are not rendered by default.

26 changes: 4 additions & 22 deletions test/nsdl-c/unittest/sn_nsdl/sn_nsdltest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,11 @@ TEST(sn_nsdl, test_sn_nsdl_send_observation_notification)
CHECK(test_sn_nsdl_send_observation_notification());
}

TEST(sn_nsdl, test_sn_nsdl_send_observation_notification_with_uri_path)
{
CHECK(test_sn_nsdl_send_observation_notification_with_uri_path());
}

TEST(sn_nsdl, test_sn_nsdl_oma_bootstrap)
{
CHECK(test_sn_nsdl_oma_bootstrap());
}

TEST(sn_nsdl, test_sn_nsdl_get_certificates)
{
CHECK(test_sn_nsdl_get_certificates());
}

TEST(sn_nsdl, test_sn_nsdl_update_certificates)
{
CHECK(test_sn_nsdl_update_certificates());
}

TEST(sn_nsdl, test_sn_nsdl_create_oma_device_object)
{
CHECK(test_sn_nsdl_create_oma_device_object());
}

TEST(sn_nsdl, test_sn_nsdl_get_version)
{
CHECK(test_sn_nsdl_get_version());
Expand All @@ -95,7 +75,6 @@ TEST(sn_nsdl, test_sn_nsdl_process_coap)
CHECK(test_sn_nsdl_process_coap());
}


TEST(sn_nsdl, test_sn_nsdl_exec)
{
CHECK(test_sn_nsdl_exec());
Expand Down Expand Up @@ -196,4 +175,7 @@ TEST(sn_nsdl, test_sn_nsdl_set_context)
CHECK(test_sn_nsdl_set_context());
}


TEST(sn_nsdl, test_sn_nsdl_alloc_options_list)
{
CHECK(test_sn_nsdl_alloc_options_list());
}
975 changes: 407 additions & 568 deletions test/nsdl-c/unittest/sn_nsdl/test_sn_nsdl.c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions test/nsdl-c/unittest/sn_nsdl/test_sn_nsdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ bool test_sn_nsdl_set_context();

bool test_sn_nsdl_get_context();

bool test_sn_nsdl_alloc_options_list();

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions test/nsdl-c/unittest/stubs/sn_grs_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extern void sn_grs_free_resource_list(struct grs_s *handle, sn_grs_resource_list
}


extern const sn_nsdl_resource_info_s *sn_grs_get_first_resource(struct grs_s *handle)
extern sn_nsdl_dynamic_resource_parameters_s *sn_grs_get_first_resource(struct grs_s *handle)
{
if( sn_grs_stub.retNull ){
return NULL;
Expand All @@ -96,7 +96,7 @@ extern const sn_nsdl_resource_info_s *sn_grs_get_first_resource(struct grs_s *ha
}


extern const sn_nsdl_resource_info_s *sn_grs_get_next_resource(struct grs_s *handle, const sn_nsdl_resource_info_s *sn_grs_current_resource)
extern sn_nsdl_dynamic_resource_parameters_s *sn_grs_get_next_resource(struct grs_s *handle, const sn_nsdl_dynamic_resource_parameters_s *sn_grs_current_resource)
{
if( sn_grs_stub.retNull ){
return NULL;
Expand All @@ -120,13 +120,13 @@ extern int8_t sn_grs_delete_resource(struct grs_s *handle, uint16_t pathlen, uin
}


extern int8_t sn_grs_update_resource(struct grs_s *handle, sn_nsdl_resource_info_s *res)
extern int8_t sn_grs_update_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
return sn_grs_stub.expectedInt8;
}


extern int8_t sn_grs_create_resource(struct grs_s *handle, sn_nsdl_resource_info_s *res)
extern int8_t sn_grs_create_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
if( sn_grs_stub.int8SuccessCounter > 0 ){
sn_grs_stub.int8SuccessCounter--;
Expand All @@ -135,7 +135,7 @@ extern int8_t sn_grs_create_resource(struct grs_s *handle, sn_nsdl_resource_info
return sn_grs_stub.expectedInt8;
}

int8_t sn_grs_put_resource(struct grs_s *handle, sn_nsdl_resource_info_s *res)
int8_t sn_grs_put_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
if( sn_grs_stub.int8SuccessCounter > 0 ){
sn_grs_stub.int8SuccessCounter--;
Expand All @@ -154,7 +154,7 @@ extern int8_t sn_grs_send_coap_message(struct nsdl_s *handle, sn_nsdl_addr_s *ad
return sn_grs_stub.expectedInt8;
}

sn_nsdl_resource_info_s *sn_grs_search_resource(struct grs_s *handle, uint16_t pathlen, uint8_t *path, uint8_t search_method)
sn_nsdl_dynamic_resource_parameters_s *sn_grs_search_resource(struct grs_s *handle, uint16_t pathlen, uint8_t *path, uint8_t search_method)
{
if(sn_grs_stub.useMockedPath){
memcpy(path, &sn_grs_stub.mockedPath, sn_grs_stub.mockedPathLen);
Expand Down
2 changes: 1 addition & 1 deletion test/nsdl-c/unittest/stubs/sn_grs_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct {
int8_t expectedInt8;
int8_t int8SuccessCounter;
struct grs_s *expectedGrs;
sn_nsdl_resource_info_s *expectedInfo;
sn_nsdl_dynamic_resource_parameters_s *expectedInfo;
sn_grs_resource_list_s *expectedList;

bool useMockedPath;
Expand Down
29 changes: 7 additions & 22 deletions test/nsdl-c/unittest/stubs/sn_nsdl_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,6 @@ uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *handle, sn_nsdl_addr_s *bootstrap_
return sn_nsdl_stub.expectedUint16;
}

omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle)
{
return NULL;
}

int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t *certificate_ptr, uint8_t certificate_chain)
{
return sn_nsdl_stub.expectedInt8;
}

int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr)
{
return sn_nsdl_stub.expectedInt8;
}

char *sn_nsdl_get_version(void)
{
return NULL;
Expand All @@ -150,7 +135,7 @@ int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time)
return sn_nsdl_stub.expectedInt8;
}

sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path_ptr)
sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path_ptr)
{
return NULL;
}
Expand All @@ -164,7 +149,7 @@ int8_t sn_nsdl_build_registration_body(struct nsdl_s *handle, sn_coap_hdr_s *mes
return sn_nsdl_stub.expectedInt8;
}

int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type)
int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint8_t address_length, uint16_t port, sn_nsdl_addr_type_e address_type)
{
return sn_nsdl_stub.expectedInt8;
}
Expand All @@ -184,7 +169,7 @@ void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *l
{
}

extern int8_t sn_nsdl_update_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res)
extern int8_t sn_nsdl_update_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
return sn_nsdl_stub.expectedInt8;
}
Expand All @@ -194,12 +179,12 @@ extern int8_t sn_nsdl_send_coap_message(struct nsdl_s *handle, sn_nsdl_addr_s *a
return sn_nsdl_stub.expectedInt8;
}

extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res)
extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
return sn_nsdl_stub.expectedInt8;
}

extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res)
extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res)
{
return sn_nsdl_stub.expectedInt8;
}
Expand All @@ -209,12 +194,12 @@ extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint16_t pathlen, u
return sn_nsdl_stub.expectedInt8;
}

extern const sn_nsdl_resource_info_s *sn_nsdl_get_first_resource(struct nsdl_s *handle)
extern const sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_first_resource(struct nsdl_s *handle)
{
return NULL;
}

extern const sn_nsdl_resource_info_s *sn_nsdl_get_next_resource(struct nsdl_s *handle, const sn_nsdl_resource_info_s *resource)
extern const sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_next_resource(struct nsdl_s *handle, const sn_nsdl_dynamic_resource_parameters_s *resource)
{
return NULL;
}
Expand Down
Loading