Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
test_sn_nsdl.c
00001 /* 00002 * Copyright (c) 2015 ARM. All rights reserved. 00003 */ 00004 #include "test_sn_nsdl.h" 00005 #include <string.h> 00006 #include <inttypes.h> 00007 00008 #include "sn_coap_header.h" 00009 #include "sn_nsdl.h" 00010 #include "sn_nsdl_lib.h" 00011 #include "sn_grs.h" 00012 00013 #include "sn_grs_stub.h" 00014 #include "sn_coap_builder_stub.h" 00015 #include "sn_coap_protocol_stub.h" 00016 00017 int retCounter = 0; 00018 uint8_t rxRetVal = 0; 00019 00020 void* myMalloc(uint16_t size) 00021 { 00022 if( retCounter > 0 ){ 00023 retCounter--; 00024 return malloc(size); 00025 }else { 00026 return NULL; 00027 } 00028 } 00029 00030 void myFree(void* ptr){ 00031 free(ptr); 00032 } 00033 00034 void myBootstrapCallback(sn_nsdl_oma_server_info_t *server_info_ptr){ 00035 00036 } 00037 00038 void myBootstrapCallbackHandle(sn_nsdl_oma_server_info_t *server_info_ptr, struct nsdl_s *a){ 00039 00040 } 00041 00042 uint8_t nsdl_tx_callback(struct nsdl_s *a, sn_nsdl_capab_e b, uint8_t *c, uint16_t d, sn_nsdl_addr_s *e) 00043 { 00044 00045 } 00046 00047 uint8_t nsdl_rx_callback(struct nsdl_s *a, sn_coap_hdr_s *b, sn_nsdl_addr_s *c) 00048 { 00049 return rxRetVal; 00050 } 00051 00052 bool test_sn_nsdl_destroy() 00053 { 00054 if( SN_NSDL_FAILURE != sn_nsdl_destroy(NULL) ){ 00055 return false; 00056 } 00057 00058 struct nsdl_s* handle = (struct nsdl_s*)malloc(sizeof(struct nsdl_s)); 00059 handle->sn_nsdl_alloc = myMalloc; 00060 handle->sn_nsdl_free = myFree; 00061 handle->oma_bs_address_ptr = (uint8_t*)malloc(5); 00062 00063 handle->ep_information_ptr = (sn_nsdl_ep_parameters_s *)malloc(sizeof(sn_nsdl_ep_parameters_s)); 00064 memset(handle->ep_information_ptr,0,sizeof(sn_nsdl_ep_parameters_s)); 00065 handle->ep_information_ptr->endpoint_name_ptr = (uint8_t*)malloc(5); 00066 handle->ep_information_ptr->domain_name_ptr = (uint8_t*)malloc(5); 00067 handle->ep_information_ptr->type_ptr = (uint8_t*)malloc(5); 00068 handle->ep_information_ptr->lifetime_ptr = (uint8_t*)malloc(5); 00069 handle->ep_information_ptr->location_ptr = (uint8_t*)malloc(5); 00070 00071 handle->nsp_address_ptr = (sn_nsdl_oma_server_info_t *)malloc(sizeof(sn_nsdl_oma_server_info_t)); 00072 handle->nsp_address_ptr->omalw_address_ptr = (sn_nsdl_addr_s*)malloc(sizeof(sn_nsdl_addr_s)); 00073 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(5); 00074 00075 handle->grs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00076 00077 int8_t ret = sn_nsdl_destroy(handle); 00078 return ret == SN_NSDL_SUCCESS; 00079 } 00080 00081 bool test_sn_nsdl_init() 00082 { 00083 if( NULL != sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, NULL) ){ 00084 return false; 00085 } 00086 00087 retCounter = 0; 00088 if( NULL != sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree) ){ 00089 return false; 00090 } 00091 00092 retCounter = 1; 00093 if( NULL != sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree) ){ 00094 return false; 00095 } 00096 00097 sn_grs_stub.retNull = true; 00098 retCounter = 2; 00099 if( NULL != sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree) ){ 00100 return false; 00101 } 00102 00103 sn_grs_stub.retNull = false; 00104 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); //gets deleted during call 00105 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00106 retCounter = 4; 00107 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00108 sn_grs_stub.expectedGrs = NULL; 00109 if( NULL == handle ){ 00110 return false; 00111 } 00112 sn_nsdl_destroy(handle); 00113 00114 return true; 00115 } 00116 00117 bool test_sn_nsdl_register_endpoint() 00118 { 00119 if( 0 != sn_nsdl_register_endpoint(NULL, NULL) ){ 00120 return false; 00121 } 00122 sn_grs_stub.retNull = false; 00123 retCounter = 5; 00124 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00125 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00126 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00127 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 00128 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 00129 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 00130 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 00131 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 00132 00133 sn_nsdl_ep_parameters_s *eptr = (sn_nsdl_ep_parameters_s*)malloc(sizeof(sn_nsdl_ep_parameters_s)); 00134 memset(eptr, 0, sizeof(sn_nsdl_ep_parameters_s)); 00135 00136 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00137 return false; 00138 } 00139 00140 retCounter = 0; 00141 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00142 return false; 00143 } 00144 00145 retCounter = 1; 00146 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00147 return false; 00148 } 00149 00150 bool ret = true; 00151 00152 retCounter = 2; 00153 eptr->endpoint_name_ptr = (uint8_t*)malloc(2); 00154 eptr->endpoint_name_ptr[0] = 'a'; 00155 eptr->endpoint_name_ptr[1] = '\0'; 00156 eptr->endpoint_name_len = 1; 00157 eptr->type_ptr = (uint8_t*)malloc(2); 00158 eptr->type_ptr[0] = 'a'; 00159 eptr->type_ptr[1] = '\0'; 00160 eptr->type_len = 1; 00161 eptr->lifetime_ptr = (uint8_t*)malloc(2); 00162 eptr->lifetime_ptr[0] = 'a'; 00163 eptr->lifetime_ptr[1] = '\0'; 00164 eptr->lifetime_len = 1; 00165 eptr->domain_name_ptr = (uint8_t*)malloc(2); 00166 eptr->domain_name_ptr[0] = 'a'; 00167 eptr->domain_name_ptr[1] = '\0'; 00168 eptr->domain_name_len = 1; 00169 eptr->binding_and_mode = 0x07; 00170 00171 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00172 ret = false; 00173 goto end; 00174 } 00175 00176 //Test validateParameters here --> 00177 ret = true; 00178 00179 retCounter = 2; 00180 eptr->endpoint_name_ptr[0] = '&'; 00181 eptr->endpoint_name_ptr[1] = '\0'; 00182 eptr->endpoint_name_len = 1; 00183 eptr->type_ptr[0] = 'a'; 00184 eptr->type_ptr[1] = '\0'; 00185 eptr->type_len = 1; 00186 eptr->lifetime_ptr[0] = 'a'; 00187 eptr->lifetime_ptr[1] = '\0'; 00188 eptr->lifetime_len = 1; 00189 eptr->domain_name_ptr[0] = 'a'; 00190 eptr->domain_name_ptr[1] = '\0'; 00191 eptr->domain_name_len = 1; 00192 eptr->binding_and_mode = 0x07; 00193 00194 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00195 ret = false; 00196 goto end; 00197 } 00198 00199 ret = true; 00200 00201 retCounter = 2; 00202 eptr->endpoint_name_ptr[0] = 'a'; 00203 eptr->endpoint_name_ptr[1] = '\0'; 00204 eptr->endpoint_name_len = 1; 00205 eptr->type_ptr[0] = '&'; 00206 eptr->type_ptr[1] = '\0'; 00207 eptr->type_len = 1; 00208 eptr->lifetime_ptr[0] = 'a'; 00209 eptr->lifetime_ptr[1] = '\0'; 00210 eptr->lifetime_len = 1; 00211 eptr->domain_name_ptr[0] = 'a'; 00212 eptr->domain_name_ptr[1] = '\0'; 00213 eptr->domain_name_len = 1; 00214 eptr->binding_and_mode = 0x07; 00215 00216 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00217 ret = false; 00218 goto end; 00219 } 00220 00221 ret = true; 00222 00223 retCounter = 2; 00224 eptr->endpoint_name_ptr[0] = 'a'; 00225 eptr->endpoint_name_ptr[1] = '\0'; 00226 eptr->endpoint_name_len = 1; 00227 eptr->type_ptr[0] = 'a'; 00228 eptr->type_ptr[1] = '\0'; 00229 eptr->type_len = 1; 00230 eptr->lifetime_ptr[0] = '&'; 00231 eptr->lifetime_ptr[1] = '\0'; 00232 eptr->lifetime_len = 1; 00233 eptr->domain_name_ptr[0] = 'a'; 00234 eptr->domain_name_ptr[1] = '\0'; 00235 eptr->domain_name_len = 1; 00236 eptr->binding_and_mode = 0x07; 00237 00238 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00239 ret = false; 00240 goto end; 00241 } 00242 00243 ret = true; 00244 00245 retCounter = 2; 00246 eptr->endpoint_name_ptr[0] = 'a'; 00247 eptr->endpoint_name_ptr[1] = '\0'; 00248 eptr->endpoint_name_len = 1; 00249 eptr->type_ptr[0] = 'a'; 00250 eptr->type_ptr[1] = '\0'; 00251 eptr->type_len = 1; 00252 eptr->lifetime_ptr[0] = 'a'; 00253 eptr->lifetime_ptr[1] = '\0'; 00254 eptr->lifetime_len = 1; 00255 eptr->domain_name_ptr[0] = '&'; 00256 eptr->domain_name_ptr[1] = '\0'; 00257 eptr->domain_name_len = 1; 00258 eptr->binding_and_mode = 0x07; 00259 00260 if( 0 != sn_nsdl_register_endpoint(handle, eptr) ){ 00261 ret = false; 00262 goto end; 00263 } 00264 eptr->domain_name_ptr[0] = 'a'; 00265 //<-- Test validateParameters here 00266 00267 eptr->binding_and_mode = 0x07; 00268 retCounter = 3; 00269 sn_grs_stub.infoRetCounter = 2; 00270 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00271 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00272 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00273 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00274 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00275 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00276 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00277 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00278 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00279 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00280 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00281 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00282 00283 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00284 sn_grs_stub.expectedInfo->path[0] = 'a'; 00285 sn_grs_stub.expectedInfo->path[1] = '\0'; 00286 sn_grs_stub.expectedInfo->pathlen = 1; 00287 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00288 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00289 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00290 sn_grs_stub.expectedInfo->resourcelen = 1; 00291 sn_grs_stub.expectedInfo->publish_uri = 1; 00292 //sn_nsdl_build_registration_body == SN_NSDL_FAILURE 00293 int8_t val = sn_nsdl_register_endpoint(handle, eptr); 00294 00295 free(sn_grs_stub.expectedInfo->resource); 00296 free(sn_grs_stub.expectedInfo->path); 00297 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00298 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00299 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00300 free(sn_grs_stub.expectedInfo); 00301 sn_grs_stub.expectedInfo = NULL; 00302 if( 0 != val ){ 00303 ret = false; 00304 goto end; 00305 } 00306 00307 //creates payload 00308 sn_grs_stub.info2ndRetCounter = 0; 00309 sn_grs_stub.infoRetCounter = 1; 00310 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00311 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00312 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00313 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00314 sn_grs_stub.expectedInfo->publish_uri = 1; 00315 eptr->binding_and_mode = 0x06; 00316 retCounter = 4; 00317 //set_endpoint_info == -1 00318 val = sn_nsdl_register_endpoint(handle, eptr); 00319 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00320 free(sn_grs_stub.expectedInfo); 00321 00322 if( 0 != val ){ 00323 ret = false; 00324 goto end; 00325 } 00326 00327 00328 handle->ep_information_ptr->domain_name_ptr = (uint8_t*)malloc(3); 00329 handle->ep_information_ptr->endpoint_name_ptr = (uint8_t*)malloc(3); 00330 eptr->binding_and_mode = 0x06; 00331 retCounter = 4; 00332 //set_endpoint_info == -1 00333 val = sn_nsdl_register_endpoint(handle, eptr); 00334 if( 0 != val ){ 00335 ret = false; 00336 goto end; 00337 } 00338 00339 //creates payload 00340 sn_grs_stub.info2ndRetCounter = 2; 00341 sn_grs_stub.infoRetCounter = 2; 00342 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00343 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00344 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00345 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00346 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00347 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00348 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00349 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00350 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00351 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00352 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00353 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00354 00355 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00356 sn_grs_stub.expectedInfo->path[0] = 'a'; 00357 sn_grs_stub.expectedInfo->path[1] = '\0'; 00358 sn_grs_stub.expectedInfo->pathlen = 1; 00359 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00360 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00361 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00362 sn_grs_stub.expectedInfo->resourcelen = 1; 00363 sn_grs_stub.expectedInfo->publish_uri = 1; 00364 eptr->binding_and_mode = 0x06; 00365 retCounter = 7; 00366 00367 sn_coap_builder_stub.expectedUint16 = 1; 00368 sn_coap_protocol_stub.expectedInt16 = 1; 00369 //passes 00370 val = sn_nsdl_register_endpoint(handle, eptr); 00371 free(sn_grs_stub.expectedInfo->resource); 00372 free(sn_grs_stub.expectedInfo->path); 00373 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00374 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00375 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00376 free(sn_grs_stub.expectedInfo); 00377 00378 if( 0 != val ){ 00379 ret = false; 00380 goto end; 00381 } 00382 00383 //test resource_type_len overflow 00384 sn_grs_stub.info2ndRetCounter = 2; 00385 sn_grs_stub.infoRetCounter = 2; 00386 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00387 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00388 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00389 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = UINT16_MAX; 00390 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(UINT16_MAX); 00391 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00392 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00393 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00394 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00395 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00396 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00397 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00398 00399 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00400 sn_grs_stub.expectedInfo->path[0] = 'a'; 00401 sn_grs_stub.expectedInfo->path[1] = '\0'; 00402 sn_grs_stub.expectedInfo->pathlen = 1; 00403 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00404 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00405 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00406 sn_grs_stub.expectedInfo->resourcelen = 1; 00407 sn_grs_stub.expectedInfo->publish_uri = 1; 00408 eptr->binding_and_mode = 0x06; 00409 retCounter = 7; 00410 00411 sn_coap_builder_stub.expectedUint16 = 1; 00412 sn_coap_protocol_stub.expectedInt16 = 1; 00413 //passes 00414 val = sn_nsdl_register_endpoint(handle, eptr); 00415 free(sn_grs_stub.expectedInfo->resource); 00416 free(sn_grs_stub.expectedInfo->path); 00417 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00418 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00419 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00420 free(sn_grs_stub.expectedInfo); 00421 00422 if( 0 != val ){ 00423 ret = false; 00424 goto end; 00425 } 00426 00427 //test interface len overflow 00428 sn_grs_stub.info2ndRetCounter = 2; 00429 sn_grs_stub.infoRetCounter = 2; 00430 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00431 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00432 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00433 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00434 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00435 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00436 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00437 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00438 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00439 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00440 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00441 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00442 00443 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00444 sn_grs_stub.expectedInfo->path[0] = 'a'; 00445 sn_grs_stub.expectedInfo->path[1] = '\0'; 00446 sn_grs_stub.expectedInfo->pathlen = UINT16_MAX; 00447 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00448 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00449 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00450 sn_grs_stub.expectedInfo->resourcelen = 1; 00451 sn_grs_stub.expectedInfo->publish_uri = 1; 00452 eptr->binding_and_mode = 0x06; 00453 retCounter = 7; 00454 00455 sn_coap_builder_stub.expectedUint16 = 1; 00456 sn_coap_protocol_stub.expectedInt16 = 1; 00457 //passes 00458 val = sn_nsdl_register_endpoint(handle, eptr); 00459 free(sn_grs_stub.expectedInfo->resource); 00460 free(sn_grs_stub.expectedInfo->path); 00461 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00462 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00463 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00464 free(sn_grs_stub.expectedInfo); 00465 00466 if( 0 != val ){ 00467 ret = false; 00468 goto end; 00469 } 00470 00471 //test coap content overflow 00472 sn_grs_stub.info2ndRetCounter = 2; 00473 sn_grs_stub.infoRetCounter = 2; 00474 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00475 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00476 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00477 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00478 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00479 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00480 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00481 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00482 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00483 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00484 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = UINT16_MAX - 20; 00485 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00486 sn_grs_stub.expectedInfo->resource_parameters_ptr->coap_content_type = UINT8_MAX; 00487 00488 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00489 sn_grs_stub.expectedInfo->path[0] = 'a'; 00490 sn_grs_stub.expectedInfo->path[1] = '\0'; 00491 sn_grs_stub.expectedInfo->pathlen = 1; 00492 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00493 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00494 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00495 sn_grs_stub.expectedInfo->resourcelen = 1; 00496 sn_grs_stub.expectedInfo->publish_uri = 1; 00497 eptr->binding_and_mode = 0x06; 00498 retCounter = 7; 00499 00500 sn_coap_builder_stub.expectedUint16 = 1; 00501 sn_coap_protocol_stub.expectedInt16 = 1; 00502 //passes 00503 val = sn_nsdl_register_endpoint(handle, eptr); 00504 free(sn_grs_stub.expectedInfo->resource); 00505 free(sn_grs_stub.expectedInfo->path); 00506 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00507 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00508 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00509 free(sn_grs_stub.expectedInfo); 00510 00511 if( 0 != val ){ 00512 ret = false; 00513 goto end; 00514 } 00515 00516 //test observe len overflow 00517 sn_grs_stub.info2ndRetCounter = 2; 00518 sn_grs_stub.infoRetCounter = 2; 00519 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00520 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00521 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00522 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00523 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00524 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00525 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00526 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00527 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00528 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00529 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = UINT16_MAX - 25; 00530 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00531 sn_grs_stub.expectedInfo->resource_parameters_ptr->coap_content_type = 1; 00532 00533 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00534 sn_grs_stub.expectedInfo->path[0] = 'a'; 00535 sn_grs_stub.expectedInfo->path[1] = '\0'; 00536 sn_grs_stub.expectedInfo->pathlen = 1; 00537 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00538 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00539 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00540 sn_grs_stub.expectedInfo->resourcelen = 1; 00541 sn_grs_stub.expectedInfo->publish_uri = 1; 00542 eptr->binding_and_mode = 0x06; 00543 retCounter = 7; 00544 00545 sn_coap_builder_stub.expectedUint16 = 1; 00546 sn_coap_protocol_stub.expectedInt16 = 1; 00547 //passes 00548 val = sn_nsdl_register_endpoint(handle, eptr); 00549 free(sn_grs_stub.expectedInfo->resource); 00550 free(sn_grs_stub.expectedInfo->path); 00551 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00552 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00553 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00554 free(sn_grs_stub.expectedInfo); 00555 00556 if( 0 != val ){ 00557 ret = false; 00558 goto end; 00559 } 00560 00561 //test observe len overflow 00562 sn_grs_stub.info2ndRetCounter = 2; 00563 sn_grs_stub.infoRetCounter = 2; 00564 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00565 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00566 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00567 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00568 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00569 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00570 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00571 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00572 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00573 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00574 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = UINT16_MAX - 28; 00575 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00576 sn_grs_stub.expectedInfo->resource_parameters_ptr->coap_content_type = 1; 00577 00578 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00579 sn_grs_stub.expectedInfo->path[0] = 'a'; 00580 sn_grs_stub.expectedInfo->path[1] = '\0'; 00581 sn_grs_stub.expectedInfo->pathlen = 1; 00582 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00583 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00584 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00585 sn_grs_stub.expectedInfo->resourcelen = 1; 00586 sn_grs_stub.expectedInfo->publish_uri = 1; 00587 eptr->binding_and_mode = 0x06; 00588 retCounter = 7; 00589 00590 sn_coap_builder_stub.expectedUint16 = 1; 00591 sn_coap_protocol_stub.expectedInt16 = 1; 00592 //passes 00593 val = sn_nsdl_register_endpoint(handle, eptr); 00594 free(sn_grs_stub.expectedInfo->resource); 00595 free(sn_grs_stub.expectedInfo->path); 00596 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00597 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00598 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00599 free(sn_grs_stub.expectedInfo); 00600 00601 if( 0 != val ){ 00602 ret = false; 00603 goto end; 00604 } 00605 00606 sn_grs_stub.info2ndRetCounter = 2; 00607 sn_grs_stub.infoRetCounter = 2; 00608 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00609 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00610 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00611 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00612 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00613 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00614 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00615 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00616 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00617 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00618 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00619 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00620 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00621 sn_grs_stub.expectedInfo->path[0] = 'a'; 00622 sn_grs_stub.expectedInfo->path[1] = '\0'; 00623 sn_grs_stub.expectedInfo->pathlen = 1; 00624 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00625 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00626 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00627 sn_grs_stub.expectedInfo->resourcelen = 1; 00628 sn_grs_stub.expectedInfo->publish_uri = 1; 00629 eptr->binding_and_mode = 0x06; 00630 retCounter = 4; 00631 sn_coap_builder_stub.expectedUint16 = 1; 00632 sn_coap_protocol_stub.expectedInt16 = 1; 00633 //set_endpoint_info == -1 00634 val = sn_nsdl_register_endpoint(handle, eptr); 00635 free(sn_grs_stub.expectedInfo->resource); 00636 free(sn_grs_stub.expectedInfo->path); 00637 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00638 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00639 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00640 free(sn_grs_stub.expectedInfo); 00641 00642 if( 0 != val ){ 00643 ret = false; 00644 goto end; 00645 } 00646 00647 end: 00648 free(sn_grs_stub.expectedGrs->coap); 00649 free(eptr->domain_name_ptr); 00650 free(eptr->lifetime_ptr); 00651 free(eptr->type_ptr); 00652 free(eptr->endpoint_name_ptr); 00653 00654 free(eptr); 00655 sn_nsdl_destroy(handle); 00656 return true; 00657 } 00658 00659 bool test_sn_nsdl_unregister_endpoint() 00660 { 00661 if( 0 != sn_nsdl_unregister_endpoint(NULL) ){ 00662 return false; 00663 } 00664 00665 sn_grs_stub.retNull = false; 00666 retCounter = 5; 00667 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00668 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00669 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00670 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 00671 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 00672 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 00673 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 00674 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 00675 00676 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00677 return false; 00678 } 00679 00680 handle->sn_nsdl_endpoint_registered = 1; 00681 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00682 return false; 00683 } 00684 00685 retCounter = 0; 00686 handle->sn_nsdl_endpoint_registered = 1; 00687 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00688 return false; 00689 } 00690 00691 retCounter = 1; 00692 handle->sn_nsdl_endpoint_registered = 1; 00693 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00694 return false; 00695 } 00696 00697 retCounter = 2; 00698 handle->sn_nsdl_endpoint_registered = 1; 00699 sn_coap_builder_stub.expectedUint16 = 0; 00700 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00701 return false; 00702 } 00703 00704 //Following tests will test sn_nsdl_internal_coap_send() + stuff 00705 retCounter = 2; 00706 handle->sn_nsdl_endpoint_registered = 1; 00707 sn_coap_builder_stub.expectedUint16 = 1; 00708 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00709 return false; 00710 } 00711 00712 retCounter = 3; 00713 handle->sn_nsdl_endpoint_registered = 1; 00714 sn_coap_builder_stub.expectedUint16 = 1; 00715 sn_coap_protocol_stub.expectedInt16 = -1; 00716 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00717 return false; 00718 } 00719 00720 retCounter = 3; 00721 handle->sn_nsdl_endpoint_registered = 1; 00722 sn_coap_builder_stub.expectedUint16 = 1; 00723 sn_coap_protocol_stub.expectedInt16 = 1; 00724 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00725 return false; 00726 } 00727 00728 u_int8_t loc[] = {"location"}; 00729 00730 handle->ep_information_ptr->location_ptr = (uint8_t*)malloc(sizeof(loc)); 00731 handle->ep_information_ptr->location_len = (uint8_t)sizeof(loc); 00732 00733 retCounter = 1; 00734 handle->sn_nsdl_endpoint_registered = 1; 00735 sn_coap_builder_stub.expectedUint16 = 1; 00736 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00737 return false; 00738 } 00739 00740 retCounter = 2; 00741 handle->sn_nsdl_endpoint_registered = 1; 00742 sn_coap_builder_stub.expectedUint16 = 1; 00743 sn_coap_protocol_stub.expectedInt16 = -1; 00744 if( 0 != sn_nsdl_unregister_endpoint(handle) ){ 00745 return false; 00746 } 00747 free(sn_grs_stub.expectedGrs->coap); 00748 sn_nsdl_destroy(handle); 00749 return true; 00750 } 00751 00752 bool test_sn_nsdl_update_registration() 00753 { 00754 if( 0 != sn_nsdl_update_registration(NULL, NULL, 0) ){ 00755 return false; 00756 } 00757 00758 sn_grs_stub.retNull = false; 00759 retCounter = 4; 00760 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00761 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00762 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00763 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 00764 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 00765 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 00766 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 00767 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 00768 00769 if( 0 != sn_nsdl_update_registration(handle, NULL, 0) ){ 00770 return false; 00771 } 00772 00773 handle->sn_nsdl_endpoint_registered = 1; 00774 if( 0 != sn_nsdl_update_registration(handle, NULL, 0) ){ 00775 return false; 00776 } 00777 00778 retCounter = 1; 00779 if( 0 != sn_nsdl_update_registration(handle, NULL, 0) ){ 00780 return false; 00781 } 00782 00783 retCounter = 2; 00784 if( 0 != sn_nsdl_update_registration(handle, NULL, 0) ){ 00785 return false; 00786 } 00787 00788 retCounter = 4; 00789 sn_grs_stub.infoRetCounter = 2; 00790 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00791 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00792 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00793 sn_grs_stub.expectedInfo->resource_parameters_ptr->registered = SN_NDSL_RESOURCE_REGISTERED; 00794 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_len = 1; 00795 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr = (uint8_t*)malloc(2); 00796 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[0] = 'a'; 00797 sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr[1] = '\0'; 00798 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr = (uint8_t*)malloc(2); 00799 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[0] = 'a'; 00800 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr[1] = '\0'; 00801 sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_len = 1; 00802 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00803 00804 sn_grs_stub.expectedInfo->path = (uint8_t*)malloc(2); 00805 sn_grs_stub.expectedInfo->path[0] = 'a'; 00806 sn_grs_stub.expectedInfo->path[1] = '\0'; 00807 sn_grs_stub.expectedInfo->pathlen = 1; 00808 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(2); 00809 sn_grs_stub.expectedInfo->resource[0] = 'a'; 00810 sn_grs_stub.expectedInfo->resource[1] = '\0'; 00811 sn_grs_stub.expectedInfo->resourcelen = 1; 00812 sn_grs_stub.expectedInfo->publish_uri = 1; 00813 00814 sn_coap_builder_stub.expectedUint16 = 1; 00815 int8_t val = sn_nsdl_update_registration(handle, NULL, 0); 00816 00817 free(sn_grs_stub.expectedInfo->resource); 00818 free(sn_grs_stub.expectedInfo->path); 00819 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->interface_description_ptr); 00820 free(sn_grs_stub.expectedInfo->resource_parameters_ptr->resource_type_ptr); 00821 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00822 free(sn_grs_stub.expectedInfo); 00823 sn_grs_stub.expectedInfo = NULL; 00824 00825 if( 0 != val ){ 00826 return false; 00827 } 00828 00829 sn_grs_stub.info2ndRetCounter = 1; 00830 sn_grs_stub.infoRetCounter = 1; 00831 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00832 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00833 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00834 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00835 sn_grs_stub.expectedInfo->publish_uri = 1; 00836 retCounter = 3; 00837 //set_endpoint_info == -1 00838 //sn_nsdl_build_registration_body == SN_NSDL_FAILURE 00839 val = sn_nsdl_update_registration(handle, NULL, 0); 00840 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00841 free(sn_grs_stub.expectedInfo); 00842 00843 if( 0 != val ){ 00844 return false; 00845 } 00846 00847 sn_grs_stub.info2ndRetCounter = 2; 00848 sn_grs_stub.infoRetCounter = 2; 00849 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00850 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00851 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00852 memset( sn_grs_stub.expectedInfo->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s)); 00853 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00854 sn_grs_stub.expectedInfo->publish_uri = 1; 00855 retCounter = 4; 00856 sn_grs_stub.expectedInfo->resource_parameters_ptr->registered = SN_NDSL_RESOURCE_REGISTERING; 00857 //set_endpoint_info == -1 00858 val = sn_nsdl_update_registration(handle, NULL, 0); 00859 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00860 free(sn_grs_stub.expectedInfo); 00861 00862 if( 0 != val ){ 00863 return false; 00864 } 00865 00866 u_int8_t loc[] = {"location"}; 00867 00868 handle->ep_information_ptr->location_ptr = (uint8_t*)malloc(sizeof(loc)); 00869 handle->ep_information_ptr->location_len = (uint8_t)sizeof(loc); 00870 00871 sn_grs_stub.info2ndRetCounter = 1; 00872 sn_grs_stub.infoRetCounter = 1; 00873 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00874 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00875 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00876 memset( sn_grs_stub.expectedInfo->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s)); 00877 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00878 sn_grs_stub.expectedInfo->publish_uri = 1; 00879 retCounter = 1; 00880 sn_grs_stub.expectedInfo->resource_parameters_ptr->registered = SN_NDSL_RESOURCE_REGISTERING; 00881 //set_endpoint_info == -1 00882 val = sn_nsdl_update_registration(handle, NULL, 0); 00883 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00884 free(sn_grs_stub.expectedInfo); 00885 00886 if( 0 != val ){ 00887 return false; 00888 } 00889 00890 sn_grs_stub.info2ndRetCounter = 2; 00891 sn_grs_stub.infoRetCounter = 2; 00892 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 00893 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 00894 sn_grs_stub.expectedInfo->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)malloc(sizeof(sn_nsdl_resource_parameters_s)); 00895 memset( sn_grs_stub.expectedInfo->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s)); 00896 sn_grs_stub.expectedInfo->resource_parameters_ptr->observable = 1; 00897 sn_grs_stub.expectedInfo->publish_uri = 1; 00898 retCounter = 2; 00899 sn_grs_stub.expectedInfo->resource_parameters_ptr->registered = SN_NDSL_RESOURCE_REGISTERING; 00900 //set_endpoint_info == -1 00901 val = sn_nsdl_update_registration(handle, NULL, 0); 00902 free(sn_grs_stub.expectedInfo->resource_parameters_ptr); 00903 free(sn_grs_stub.expectedInfo); 00904 00905 if( 0 != val ){ 00906 return false; 00907 } 00908 free(sn_grs_stub.expectedGrs->coap); 00909 sn_nsdl_destroy(handle); 00910 return true; 00911 } 00912 00913 bool test_sn_nsdl_set_endpoint_location() 00914 { 00915 00916 u_int8_t loc[] = {"location"}; 00917 00918 uint8_t* location_ptr = (uint8_t*)malloc(sizeof(loc)); 00919 uint8_t location_len = (uint8_t)sizeof(loc); 00920 00921 sn_grs_stub.retNull = false; 00922 retCounter = 4; 00923 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00924 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00925 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00926 00927 00928 if(sn_nsdl_set_endpoint_location(NULL,location_ptr,location_len) != -1){ 00929 return false; 00930 } 00931 00932 if(sn_nsdl_set_endpoint_location(NULL,NULL,location_len) != -1){ 00933 return false; 00934 } 00935 00936 if(sn_nsdl_set_endpoint_location(handle,NULL,location_len) != -1){ 00937 return false; 00938 } 00939 00940 if(sn_nsdl_set_endpoint_location(handle,location_ptr,0) != -1){ 00941 return false; 00942 } 00943 00944 if(sn_nsdl_set_endpoint_location(NULL,location_ptr,0) != -1){ 00945 return false; 00946 } 00947 00948 retCounter = 1; 00949 00950 if(sn_nsdl_set_endpoint_location(handle,location_ptr,location_len) != 0){ 00951 return false; 00952 } 00953 00954 sn_nsdl_destroy(handle); 00955 free(location_ptr); 00956 00957 return true; 00958 } 00959 00960 bool test_sn_nsdl_nsp_lost() 00961 { 00962 sn_nsdl_nsp_lost(NULL); 00963 00964 sn_grs_stub.retNull = false; 00965 retCounter = 4; 00966 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00967 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00968 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00969 00970 bool ret = true; 00971 sn_nsdl_nsp_lost(handle); 00972 if( SN_NSDL_ENDPOINT_NOT_REGISTERED != handle->sn_nsdl_endpoint_registered ){ 00973 ret = false; 00974 } 00975 sn_nsdl_destroy(handle); 00976 return ret; 00977 } 00978 00979 bool test_sn_nsdl_is_ep_registered() 00980 { 00981 if( SN_NSDL_FAILURE != sn_nsdl_is_ep_registered(NULL)){ 00982 return false; 00983 } 00984 sn_grs_stub.retNull = false; 00985 retCounter = 4; 00986 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 00987 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 00988 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 00989 handle->sn_nsdl_endpoint_registered = 1; 00990 00991 bool ret = sn_nsdl_is_ep_registered(handle) == 1; 00992 00993 sn_nsdl_destroy(handle); 00994 return ret; 00995 } 00996 00997 bool test_sn_nsdl_send_observation_notification() 00998 { 00999 if( 0 != sn_nsdl_send_observation_notification(NULL, NULL, 0,NULL,0,NULL,0,0,0) ){ 01000 return false; 01001 } 01002 sn_grs_stub.retNull = false; 01003 sn_grs_stub.expectedInt8 = SN_NSDL_SUCCESS; 01004 retCounter = 5; 01005 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01006 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01007 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01008 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 01009 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 01010 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 01011 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 01012 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 01013 01014 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,0) ){ 01015 return false; 01016 } 01017 01018 retCounter = 0; 01019 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,0) ){ 01020 return false; 01021 } 01022 01023 retCounter = 1; 01024 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,0) ){ 01025 return false; 01026 } 01027 01028 retCounter = 2; 01029 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,1) ){ 01030 return false; 01031 } 01032 01033 retCounter = 2; 01034 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,1) ){ 01035 return false; 01036 } 01037 01038 retCounter = 2; 01039 sn_grs_stub.int8SuccessCounter = 0; 01040 sn_grs_stub.expectedInt8 = SN_NSDL_FAILURE; 01041 if( 0 != sn_nsdl_send_observation_notification(handle, NULL, 0,NULL,0,NULL,0,0,1) ){ 01042 return false; 01043 } 01044 free(sn_grs_stub.expectedGrs->coap); 01045 sn_nsdl_destroy(handle); 01046 return true; 01047 } 01048 01049 bool test_sn_nsdl_send_observation_notification_with_uri_path() 01050 { 01051 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(NULL, NULL, 0,NULL,0,NULL,0,0,0, NULL,0) ){ 01052 return false; 01053 } 01054 sn_grs_stub.retNull = false; 01055 retCounter = 5; 01056 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01057 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01058 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01059 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 01060 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 01061 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 01062 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 01063 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 01064 01065 u_int8_t path[] = {"13/0/1"}; 01066 uint8_t* uri_path_ptr = (uint8_t*)malloc(sizeof(path)); 01067 uint8_t uri_path_len = (uint8_t)sizeof(path); 01068 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,0,uri_path_ptr,uri_path_len) ){ 01069 return false; 01070 } 01071 01072 retCounter = 0; 01073 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,0,uri_path_ptr,uri_path_len) ){ 01074 return false; 01075 } 01076 01077 retCounter = 1; 01078 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,0,uri_path_ptr,uri_path_len) ){ 01079 return false; 01080 } 01081 01082 retCounter = 2; 01083 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,1,uri_path_ptr,uri_path_len) ){ 01084 return false; 01085 } 01086 01087 retCounter = 2; 01088 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,1,uri_path_ptr,uri_path_len) ){ 01089 return false; 01090 } 01091 01092 retCounter = 2; 01093 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,1,uri_path_ptr,uri_path_len) ){ 01094 return false; 01095 } 01096 01097 retCounter = 2; 01098 sn_grs_stub.int8SuccessCounter = 0; 01099 sn_grs_stub.expectedInt8 = SN_NSDL_FAILURE; 01100 if( 0 != sn_nsdl_send_observation_notification_with_uri_path(handle, NULL, 0,NULL,0,NULL,0,0,1,NULL,0) ){ 01101 return false; 01102 } 01103 free(sn_grs_stub.expectedGrs->coap); 01104 free(uri_path_ptr); 01105 sn_nsdl_destroy(handle); 01106 return true; 01107 } 01108 01109 bool test_sn_nsdl_oma_bootstrap() 01110 { 01111 if( 0 != sn_nsdl_oma_bootstrap(NULL, NULL, NULL, NULL)){ 01112 return false; 01113 } 01114 sn_grs_stub.retNull = false; 01115 retCounter = 5; 01116 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01117 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01118 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01119 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 01120 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 01121 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 01122 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 01123 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 01124 01125 sn_nsdl_addr_s *addr = (sn_nsdl_addr_s*)malloc(sizeof(sn_nsdl_addr_s)); 01126 memset(addr, 0, sizeof(sn_nsdl_addr_s)); 01127 sn_nsdl_ep_parameters_s *param = (sn_nsdl_ep_parameters_s*)malloc(sizeof(sn_nsdl_ep_parameters_s)); 01128 memset(param, 0, sizeof(sn_nsdl_ep_parameters_s)); 01129 sn_nsdl_bs_ep_info_t *info = (sn_nsdl_bs_ep_info_t*)malloc(sizeof(sn_nsdl_bs_ep_info_t)); 01130 memset(info, 0, sizeof(sn_nsdl_bs_ep_info_t)); 01131 01132 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01133 return false; 01134 } 01135 01136 info->device_object = (sn_nsdl_oma_device_t*)malloc(sizeof(sn_nsdl_oma_device_t)); 01137 memset(info->device_object, 0, sizeof(sn_nsdl_oma_device_t)); 01138 01139 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01140 return false; 01141 } 01142 01143 retCounter = 0; 01144 sn_grs_stub.expectedInt8 = -1; 01145 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01146 return false; 01147 } 01148 01149 retCounter = 1; 01150 sn_grs_stub.expectedInt8 = -1; 01151 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01152 return false; 01153 } 01154 01155 retCounter = 1; 01156 sn_grs_stub.expectedInt8 = -1; 01157 sn_grs_stub.int8SuccessCounter = 1; 01158 param->binding_and_mode = 0; 01159 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01160 return false; 01161 } 01162 01163 retCounter = 1; 01164 sn_grs_stub.int8SuccessCounter = 2; 01165 param->binding_and_mode = 3; 01166 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01167 return false; 01168 } 01169 01170 retCounter = 1; 01171 sn_grs_stub.int8SuccessCounter = 3; 01172 param->binding_and_mode = 6; 01173 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01174 return false; 01175 } 01176 01177 retCounter = 2; 01178 sn_grs_stub.int8SuccessCounter = 3; 01179 param->binding_and_mode = 6; 01180 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01181 return false; 01182 } 01183 01184 retCounter = 3; 01185 sn_grs_stub.int8SuccessCounter = 3; 01186 param->binding_and_mode = 6; 01187 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01188 return false; 01189 } 01190 01191 retCounter = 6; 01192 sn_grs_stub.expectedInt8 = 0; 01193 sn_grs_stub.int8SuccessCounter = 3; 01194 param->binding_and_mode = 6; 01195 sn_coap_builder_stub.expectedUint16 = 1; 01196 if( 0 != sn_nsdl_oma_bootstrap(handle, addr, param, info)){ 01197 return false; 01198 } 01199 01200 free(info->device_object); 01201 free(info); 01202 free(param); 01203 free(addr); 01204 free(sn_grs_stub.expectedGrs->coap); 01205 retCounter = 1; 01206 sn_nsdl_destroy(handle); 01207 return true; 01208 } 01209 01210 bool test_sn_nsdl_get_certificates() 01211 { 01212 if( 0 != sn_nsdl_get_certificates(NULL)){ 01213 return false; 01214 } 01215 sn_grs_stub.retNull = false; 01216 retCounter = 4; 01217 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01218 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01219 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01220 01221 if( 0 != sn_nsdl_get_certificates(handle)){ 01222 return false; 01223 } 01224 01225 retCounter = 1; 01226 sn_grs_stub.retNull = true; 01227 if( 0 != sn_nsdl_get_certificates(handle)){ 01228 return false; 01229 } 01230 01231 retCounter = 1; 01232 sn_grs_stub.retNull = false; 01233 sn_grs_stub.infoRetCounter = 1; 01234 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 01235 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 01236 if( 0 != sn_nsdl_get_certificates(handle)){ 01237 return false; 01238 } 01239 01240 retCounter = 1; 01241 sn_grs_stub.retNull = false; 01242 sn_grs_stub.infoRetCounter = 2; 01243 if( 0 != sn_nsdl_get_certificates(handle)){ 01244 return false; 01245 } 01246 01247 retCounter = 1; 01248 sn_grs_stub.retNull = false; 01249 sn_grs_stub.infoRetCounter = 3; 01250 omalw_certificate_list_t* list = sn_nsdl_get_certificates(handle); 01251 if( 0 == list ){ 01252 return false; 01253 } 01254 free(list); 01255 free(sn_grs_stub.expectedInfo); 01256 01257 sn_nsdl_destroy(handle); 01258 return true; 01259 } 01260 01261 bool test_sn_nsdl_update_certificates() 01262 { 01263 if( -1 != sn_nsdl_update_certificates(NULL, NULL, 0) ){ 01264 return false; 01265 } 01266 sn_grs_stub.retNull = false; 01267 retCounter = 4; 01268 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01269 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01270 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01271 01272 omalw_certificate_list_t* list = (omalw_certificate_list_t*)malloc(sizeof(omalw_certificate_list_t)); 01273 memset( list, 0, sizeof(omalw_certificate_list_t)); 01274 01275 sn_grs_stub.retNull = true; 01276 if( -1 != sn_nsdl_update_certificates(handle, list, 0) ){ 01277 return false; 01278 } 01279 01280 sn_grs_stub.retNull = false; 01281 sn_grs_stub.infoRetCounter = 1; 01282 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 01283 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 01284 if( -1 != sn_nsdl_update_certificates(handle, list, 0) ){ 01285 return false; 01286 } 01287 01288 sn_grs_stub.retNull = false; 01289 sn_grs_stub.infoRetCounter = 2; 01290 if( -1 != sn_nsdl_update_certificates(handle, list, 0) ){ 01291 return false; 01292 } 01293 01294 sn_grs_stub.retNull = false; 01295 sn_grs_stub.infoRetCounter = 3; 01296 if( 0 != sn_nsdl_update_certificates(handle, list, 0) ){ 01297 return false; 01298 } 01299 01300 free(sn_grs_stub.expectedInfo); 01301 free(list); 01302 sn_nsdl_destroy(handle); 01303 return true; 01304 } 01305 01306 bool test_sn_nsdl_create_oma_device_object() 01307 { 01308 if( -1 != sn_nsdl_create_oma_device_object(NULL, NULL) ){ 01309 return false; 01310 } 01311 sn_grs_stub.retNull = false; 01312 retCounter = 4; 01313 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01314 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01315 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01316 01317 sn_nsdl_oma_device_t *device = (sn_nsdl_oma_device_t*)malloc(sizeof(sn_nsdl_oma_device_t)); 01318 memset( device, 0, sizeof(sn_nsdl_oma_device_t)); 01319 01320 sn_grs_stub.retNull = true; 01321 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01322 return false; 01323 } 01324 01325 sn_grs_stub.retNull = false; 01326 sn_grs_stub.infoRetCounter = 1; 01327 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 01328 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 01329 01330 sn_grs_stub.useMockedPath = true; 01331 sn_grs_stub.mockedPath[0] = '9'; 01332 sn_grs_stub.mockedPath[1] = '9'; 01333 sn_grs_stub.mockedPath[2] = '9'; 01334 sn_grs_stub.mockedPath[3] = '9'; 01335 sn_grs_stub.mockedPath[4] = '9'; 01336 sn_grs_stub.mockedPath[5] = '9'; 01337 sn_grs_stub.mockedPath[6] = '9'; 01338 sn_grs_stub.mockedPath[7] = '9'; 01339 sn_grs_stub.mockedPathLen = 8; 01340 01341 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01342 return false; 01343 } 01344 01345 sn_grs_stub.infoRetCounter = 1; 01346 sn_grs_stub.useMockedPath = true; 01347 sn_grs_stub.mockedPath[0] = '1'; 01348 sn_grs_stub.mockedPath[1] = '1'; 01349 sn_grs_stub.mockedPath[2] = '1'; 01350 sn_grs_stub.mockedPath[3] = '1'; 01351 sn_grs_stub.mockedPath[4] = '1'; 01352 sn_grs_stub.mockedPath[5] = '1'; 01353 sn_grs_stub.mockedPath[6] = '1'; 01354 sn_grs_stub.mockedPath[7] = '1'; 01355 sn_grs_stub.mockedPathLen = 8; 01356 01357 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01358 return false; 01359 } 01360 01361 sn_grs_stub.useMockedPath = false; 01362 sn_grs_stub.infoRetCounter = 1; 01363 01364 sn_grs_stub.expectedInfo->resource = (uint8_t*)malloc(4); 01365 *sn_grs_stub.expectedInfo->resource = 0; 01366 01367 if( SN_NSDL_SUCCESS != sn_nsdl_create_oma_device_object(handle, device) ){ 01368 return false; 01369 } 01370 01371 sn_grs_stub.infoRetCounter = 1; 01372 *sn_grs_stub.expectedInfo->resource = 1; 01373 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01374 return false; 01375 } 01376 01377 free( sn_grs_stub.expectedInfo->resource ); 01378 01379 retCounter = 1; 01380 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01381 return false; 01382 } 01383 01384 retCounter = 2; 01385 if( -1 != sn_nsdl_create_oma_device_object(handle, device) ){ 01386 return false; 01387 } 01388 01389 retCounter = 3; 01390 if( SN_NSDL_SUCCESS != sn_nsdl_create_oma_device_object(handle, device) ){ 01391 return false; 01392 } 01393 01394 free(sn_grs_stub.expectedInfo); 01395 free(device); 01396 sn_nsdl_destroy(handle); 01397 return true; 01398 } 01399 01400 bool test_sn_nsdl_get_version() 01401 { 01402 char* ret = sn_nsdl_get_version(); 01403 if( strcmp(ret, "0.0.0") != 0 ){ 01404 return false; 01405 } 01406 01407 return true; 01408 } 01409 01410 bool test_sn_nsdl_process_coap() 01411 { 01412 if( -1 != sn_nsdl_process_coap(NULL, NULL, 0, NULL) ){ 01413 return false; 01414 } 01415 sn_grs_stub.retNull = false; 01416 retCounter = 5; 01417 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 01418 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 01419 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 01420 01421 sn_coap_protocol_stub.expectedHeader = NULL; 01422 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01423 return false; 01424 } 01425 01426 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01427 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01428 sn_grs_stub.expectedGrs->coap = (struct coap_s *)malloc(sizeof(struct coap_s)); 01429 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_free = myFree; 01430 sn_grs_stub.expectedGrs->coap->sn_coap_protocol_malloc = myMalloc; 01431 sn_grs_stub.expectedGrs->coap->sn_coap_rx_callback = nsdl_rx_callback; 01432 sn_grs_stub.expectedGrs->coap->sn_coap_tx_callback = nsdl_tx_callback; 01433 01434 sn_coap_protocol_stub.expectedHeader->coap_status = 2; // != 0 && != 6 01435 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01436 return false; 01437 } 01438 01439 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01440 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01441 sn_coap_protocol_stub.expectedHeader->coap_status = 0; 01442 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01443 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01444 sn_coap_protocol_stub.expectedHeader->options_list_ptr->proxy_uri_len = 2; 01445 sn_coap_protocol_stub.expectedHeader->options_list_ptr->proxy_uri_ptr = (uint8_t*)malloc(2); 01446 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr->proxy_uri_ptr, 0, 2); 01447 01448 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01449 return false; 01450 } 01451 01452 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01453 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01454 sn_coap_protocol_stub.expectedHeader->coap_status = 0; 01455 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01456 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01457 sn_coap_protocol_stub.expectedHeader->options_list_ptr->proxy_uri_len = 2; 01458 sn_coap_protocol_stub.expectedHeader->options_list_ptr->proxy_uri_ptr = (uint8_t*)malloc(2); 01459 01460 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01461 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01462 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01463 return false; 01464 } 01465 sn_coap_builder_stub.expectedHeader = NULL; 01466 01467 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01468 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01469 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01470 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01471 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01472 01473 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01474 return false; 01475 } 01476 01477 sn_nsdl_addr_s *addr = (sn_nsdl_addr_s*)malloc(sizeof(sn_nsdl_addr_s)); 01478 memset(addr, 0, sizeof(sn_nsdl_addr_s)); 01479 01480 //Test sn_nsdl_local_rx_function fully here 01481 sn_coap_builder_stub.expectedHeader = NULL; 01482 01483 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01484 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01485 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01486 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01487 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01488 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01489 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CREATED; 01490 handle->register_msg_id = 5; 01491 handle->unregister_msg_id = 5; 01492 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01493 return false; 01494 } 01495 01496 sn_coap_builder_stub.expectedHeader = NULL; 01497 01498 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01499 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01500 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01501 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01502 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01503 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01504 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CREATED; 01505 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01506 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01507 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(2); 01508 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 2; 01509 handle->register_msg_id = 5; 01510 01511 if( 0 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01512 return false; 01513 } 01514 01515 sn_coap_builder_stub.expectedHeader = NULL; 01516 01517 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01518 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01519 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01520 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01521 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01522 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01523 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CREATED; 01524 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01525 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01526 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(3); 01527 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 3; 01528 01529 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[0] = '/'; 01530 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[1] = '/'; 01531 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[2] = '/'; 01532 handle->register_msg_id = 5; 01533 01534 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01535 return false; 01536 } 01537 01538 sn_coap_builder_stub.expectedHeader = NULL; 01539 01540 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01541 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01542 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01543 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01544 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01545 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01546 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CREATED; 01547 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01548 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01549 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(3); 01550 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 3; 01551 01552 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[0] = '/'; 01553 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[1] = '/'; 01554 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[2] = '/'; 01555 handle->register_msg_id = 5; 01556 01557 retCounter = 1; 01558 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01559 return false; 01560 } 01561 01562 sn_coap_builder_stub.expectedHeader = NULL; 01563 01564 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01565 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01566 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01567 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01568 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01569 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01570 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CREATED; 01571 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01572 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01573 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(3); 01574 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 3; 01575 01576 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[0] = '/'; 01577 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[1] = '/'; 01578 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[2] = '/'; 01579 01580 handle->register_msg_id = 5; 01581 retCounter = 2; 01582 if( 0 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01583 return false; 01584 } 01585 free(handle->ep_information_ptr->endpoint_name_ptr); 01586 handle->ep_information_ptr->endpoint_name_ptr = NULL; 01587 free(handle->ep_information_ptr->domain_name_ptr); 01588 handle->ep_information_ptr->domain_name_ptr = NULL; 01589 01590 sn_coap_builder_stub.expectedHeader = NULL; 01591 01592 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01593 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01594 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01595 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01596 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01597 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01598 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; 01599 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01600 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01601 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(3); 01602 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 3; 01603 01604 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[0] = '/'; 01605 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[1] = '/'; 01606 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr[2] = '/'; 01607 01608 handle->register_msg_id = 0; 01609 handle->unregister_msg_id = 0; 01610 handle->update_register_msg_id = 5; 01611 01612 retCounter = 2; 01613 if( 0 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01614 return false; 01615 } 01616 free(handle->ep_information_ptr->endpoint_name_ptr); 01617 handle->ep_information_ptr->endpoint_name_ptr = NULL; 01618 free(handle->ep_information_ptr->domain_name_ptr); 01619 handle->ep_information_ptr->domain_name_ptr = NULL; 01620 01621 sn_coap_builder_stub.expectedHeader = NULL; 01622 01623 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01624 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01625 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01626 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_REQUEST_DELETE + 1; 01627 sn_coap_protocol_stub.expectedHeader->payload_ptr = (uint8_t*)malloc(2); 01628 sn_coap_protocol_stub.expectedHeader->msg_id = 5; 01629 sn_coap_protocol_stub.expectedHeader->msg_code = COAP_MSG_CODE_RESPONSE_DELETED; 01630 sn_coap_protocol_stub.expectedHeader->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 01631 memset(sn_coap_protocol_stub.expectedHeader->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 01632 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_ptr = (uint8_t*)malloc(3); 01633 sn_coap_protocol_stub.expectedHeader->options_list_ptr->location_path_len = 3; 01634 handle->register_msg_id = 5; 01635 handle->unregister_msg_id = 5; 01636 01637 handle->ep_information_ptr->endpoint_name_ptr = (uint8_t*)malloc(2); 01638 handle->ep_information_ptr->domain_name_ptr = (uint8_t*)malloc(2); 01639 01640 if( 0 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01641 return false; 01642 } 01643 01644 // <-- Test sn_nsdl_local_rx_function fully here 01645 01646 sn_coap_builder_stub.expectedHeader = NULL; 01647 01648 01649 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01650 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01651 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01652 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01653 sn_grs_stub.expectedInt8 = -1; 01654 01655 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, NULL) ){ 01656 return false; 01657 } 01658 // sn_coap_protocol_stub.expectedHeader is not deleted 01659 01660 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01661 return false; 01662 } 01663 01664 01665 sn_grs_stub.expectedInt8 = 0; 01666 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01667 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01668 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01669 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01670 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01671 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01672 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 9; 01673 01674 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01675 return false; 01676 } 01677 01678 uint8_t * payload_ptr = (uint8_t*)malloc(40); 01679 memset(payload_ptr, 0, 40); 01680 01681 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01682 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01683 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01684 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01685 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01686 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01687 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01688 01689 payload_ptr[0] = 0x20; 01690 payload_ptr[1] = 0x00; 01691 payload_ptr[2] = 0x01; 01692 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01693 sn_coap_protocol_stub.expectedHeader->payload_len = 3; 01694 01695 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01696 return false; 01697 } 01698 01699 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01700 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01701 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01702 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01703 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01704 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01705 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01706 01707 payload_ptr[0] = 0x18; 01708 payload_ptr[1] = 0x00; 01709 payload_ptr[2] = 0x00; 01710 payload_ptr[3] = 0x01; 01711 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01712 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01713 01714 if( -1 != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01715 return false; 01716 } 01717 01718 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01719 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01720 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01721 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01722 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01723 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01724 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01725 01726 payload_ptr[0] = 0x08; 01727 payload_ptr[1] = 0x01; 01728 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 01729 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01730 01731 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01732 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01733 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01734 return false; 01735 } 01736 sn_coap_builder_stub.expectedHeader = NULL; 01737 01738 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01739 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01740 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01741 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01742 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01743 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01744 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01745 01746 payload_ptr[0] = 0x10; 01747 payload_ptr[1] = 0x00; 01748 payload_ptr[2] = 0x01; 01749 sn_coap_protocol_stub.expectedHeader->payload_len = 3; 01750 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01751 01752 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01753 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01754 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01755 return false; 01756 } 01757 sn_coap_builder_stub.expectedHeader = NULL; 01758 01759 //Test sn_nsdl_process_oma_tlv switches with failing 01760 01761 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01762 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01763 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01764 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01765 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01766 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01767 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01768 01769 payload_ptr[0] = 0xC0; 01770 payload_ptr[1] = 0x00; 01771 payload_ptr[2] = 0xC0; 01772 payload_ptr[3] = 0x00; 01773 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01774 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01775 sn_grs_stub.int8SuccessCounter = 1; 01776 sn_grs_stub.expectedInt8 = -1; 01777 01778 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01779 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01780 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01781 return false; 01782 } 01783 sn_coap_builder_stub.expectedHeader = NULL; 01784 01785 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01786 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01787 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01788 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01789 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01790 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01791 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01792 01793 payload_ptr[0] = 0xC0; 01794 payload_ptr[1] = 0x02; 01795 payload_ptr[2] = 0xC0; 01796 payload_ptr[3] = 0x02; 01797 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01798 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01799 sn_grs_stub.int8SuccessCounter = 1; 01800 sn_grs_stub.expectedInt8 = -1; 01801 01802 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01803 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01804 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01805 return false; 01806 } 01807 sn_coap_builder_stub.expectedHeader = NULL; 01808 01809 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01810 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01811 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01812 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01813 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01814 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01815 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01816 01817 payload_ptr[0] = 0xC0; 01818 payload_ptr[1] = 0x03; 01819 payload_ptr[2] = 0xC0; 01820 payload_ptr[3] = 0x03; 01821 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01822 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01823 sn_grs_stub.int8SuccessCounter = 1; 01824 sn_grs_stub.expectedInt8 = -1; 01825 01826 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01827 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01828 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01829 return false; 01830 } 01831 sn_coap_builder_stub.expectedHeader = NULL; 01832 01833 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01834 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01835 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01836 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01837 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01838 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01839 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01840 01841 payload_ptr[0] = 0xC0; 01842 payload_ptr[1] = 0x04; 01843 payload_ptr[2] = 0xC0; 01844 payload_ptr[3] = 0x04; 01845 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01846 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01847 sn_grs_stub.int8SuccessCounter = 1; 01848 sn_grs_stub.expectedInt8 = -1; 01849 01850 sn_coap_builder_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01851 memset(sn_coap_builder_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01852 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01853 return false; 01854 } 01855 sn_coap_builder_stub.expectedHeader = NULL; 01856 01857 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01858 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01859 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01860 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01861 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01862 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01863 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01864 01865 payload_ptr[0] = 0xC0; 01866 payload_ptr[1] = 0x05; 01867 payload_ptr[2] = 0xC0; 01868 payload_ptr[3] = 0x05; 01869 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 01870 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01871 sn_grs_stub.int8SuccessCounter = 1; 01872 sn_grs_stub.expectedInt8 = -1; 01873 01874 if( SN_NSDL_FAILURE != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01875 return false; 01876 } 01877 01878 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01879 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01880 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01881 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01882 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01883 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01884 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 99; 01885 01886 payload_ptr[0] = 0xC0; 01887 payload_ptr[1] = 0x01; 01888 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 01889 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01890 sn_grs_stub.int8SuccessCounter = 1; 01891 sn_grs_stub.expectedInt8 = -1; 01892 01893 if( SN_NSDL_FAILURE != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01894 return false; 01895 } 01896 01897 // Content type 97 tests 01898 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01899 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01900 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01901 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01902 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01903 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01904 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 01905 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 01906 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '2'; 01907 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 01908 01909 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01910 return false; 01911 } 01912 01913 // --> 01914 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01915 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01916 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01917 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01918 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01919 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01920 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 01921 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 01922 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '2'; 01923 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 01924 sn_grs_stub.infoRetCounter = 3; 01925 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 01926 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 01927 01928 handle->nsp_address_ptr->omalw_address_ptr->type = 1; 01929 01930 payload_ptr[0] = '2'; 01931 payload_ptr[1] = '\0'; 01932 sn_coap_protocol_stub.expectedHeader->payload_len = 1; 01933 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01934 01935 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 01936 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 01937 01938 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01939 return false; 01940 } 01941 01942 free(sn_grs_stub.expectedInfo); 01943 sn_grs_stub.expectedInfo = NULL; 01944 01945 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01946 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01947 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01948 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01949 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01950 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01951 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 01952 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 01953 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '2'; 01954 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 01955 sn_grs_stub.infoRetCounter = 3; 01956 sn_grs_stub.expectedInfo = (sn_nsdl_resource_info_s*)malloc(sizeof(sn_nsdl_resource_info_s)); 01957 memset( sn_grs_stub.expectedInfo, 0, sizeof(sn_nsdl_resource_info_s)); 01958 handle->nsp_address_ptr->omalw_server_security = CERTIFICATE; 01959 handle->nsp_address_ptr->omalw_address_ptr->type = 1; 01960 01961 payload_ptr[0] = 'a'; 01962 payload_ptr[1] = 'F'; 01963 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 01964 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01965 01966 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 01967 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 01968 01969 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01970 return false; 01971 } 01972 01973 free(sn_grs_stub.expectedInfo); 01974 sn_grs_stub.expectedInfo = NULL; 01975 01976 handle->nsp_address_ptr->omalw_server_security = 0; 01977 // <-- 01978 01979 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 01980 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 01981 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 01982 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 01983 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 01984 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 01985 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 01986 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 01987 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 01988 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 01989 01990 payload_ptr[0] = 0xC0; 01991 payload_ptr[1] = 0x01; 01992 sn_coap_protocol_stub.expectedHeader->payload_len = 1; 01993 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 01994 01995 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 01996 return false; 01997 } 01998 01999 //TODO: test rest of sn_nsdl_resolve_lwm2m_address here 02000 02001 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02002 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02003 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02004 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02005 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02006 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02007 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02008 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02009 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02010 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02011 02012 payload_ptr[0] = 0xC0; 02013 payload_ptr[1] = 0x01; 02014 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 02015 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02016 02017 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02018 return false; 02019 } 02020 02021 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02022 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02023 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02024 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02025 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02026 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02027 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02028 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02029 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02030 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02031 02032 payload_ptr[0] = 0xC0; 02033 payload_ptr[1] = 0x01; 02034 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 02035 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02036 02037 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02038 return false; 02039 } 02040 02041 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02042 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02043 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02044 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02045 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02046 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02047 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02048 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02049 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02050 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02051 02052 payload_ptr[0] = '/'; 02053 payload_ptr[1] = '/'; 02054 sn_coap_protocol_stub.expectedHeader->payload_len = 2; 02055 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02056 02057 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02058 return false; 02059 } 02060 02061 // --> Test IPv6 parsing here 02062 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02063 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02064 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02065 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02066 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02067 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02068 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02069 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02070 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02071 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02072 02073 payload_ptr[0] = '/'; 02074 payload_ptr[1] = '/'; 02075 payload_ptr[2] = ':'; 02076 payload_ptr[3] = ':'; 02077 payload_ptr[4] = 'A'; 02078 payload_ptr[5] = ':'; 02079 payload_ptr[6] = 'd'; 02080 payload_ptr[7] = ':'; 02081 payload_ptr[8] = '7'; 02082 sn_coap_protocol_stub.expectedHeader->payload_len = 9; 02083 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02084 02085 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02086 return false; 02087 } 02088 02089 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02090 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02091 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02092 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02093 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02094 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02095 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02096 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02097 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02098 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02099 02100 payload_ptr[0] = '/'; 02101 payload_ptr[1] = '/'; 02102 payload_ptr[2] = '['; 02103 payload_ptr[3] = ':'; 02104 payload_ptr[4] = 'A'; 02105 payload_ptr[5] = ':'; 02106 payload_ptr[6] = 'd'; 02107 payload_ptr[7] = '7'; 02108 payload_ptr[8] = ':'; 02109 payload_ptr[9] = ':'; 02110 payload_ptr[10] = ']'; 02111 sn_coap_protocol_stub.expectedHeader->payload_len = 11; 02112 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02113 02114 retCounter = 1; 02115 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02116 return false; 02117 } 02118 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02119 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02120 02121 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02122 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02123 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02124 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02125 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02126 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02127 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02128 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02129 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02130 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02131 02132 payload_ptr[0] = '/'; 02133 payload_ptr[1] = '/'; 02134 payload_ptr[2] = '['; 02135 payload_ptr[3] = '1'; 02136 payload_ptr[4] = ':'; 02137 payload_ptr[5] = 'A'; 02138 payload_ptr[6] = '7'; 02139 payload_ptr[7] = ':'; 02140 payload_ptr[8] = 'd'; 02141 payload_ptr[9] = '7'; 02142 payload_ptr[10] = '7'; 02143 payload_ptr[11] = ':'; 02144 payload_ptr[12] = 'd'; 02145 payload_ptr[13] = 'E'; 02146 payload_ptr[14] = '7'; 02147 payload_ptr[15] = '7'; 02148 payload_ptr[16] = ':'; 02149 payload_ptr[17] = ':'; 02150 payload_ptr[18] = ']'; 02151 payload_ptr[19] = ':'; 02152 payload_ptr[20] = '3'; 02153 sn_coap_protocol_stub.expectedHeader->payload_len = 21; 02154 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02155 02156 retCounter = 1; 02157 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02158 return false; 02159 } 02160 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02161 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02162 02163 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02164 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02165 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02166 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02167 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02168 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02169 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02170 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02171 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02172 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02173 02174 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(3); 02175 02176 payload_ptr[0] = '/'; 02177 payload_ptr[1] = '/'; 02178 payload_ptr[2] = '['; 02179 payload_ptr[3] = ':'; 02180 payload_ptr[4] = ':'; 02181 payload_ptr[5] = 'A'; 02182 payload_ptr[6] = '7'; 02183 payload_ptr[7] = ':'; 02184 payload_ptr[8] = 'd'; 02185 payload_ptr[9] = '7'; 02186 payload_ptr[10] = '7'; 02187 payload_ptr[11] = ':'; 02188 payload_ptr[12] = 'd'; 02189 payload_ptr[13] = 'E'; 02190 payload_ptr[14] = '7'; 02191 payload_ptr[15] = '7'; 02192 payload_ptr[16] = ':'; 02193 payload_ptr[17] = '1'; 02194 payload_ptr[18] = ']'; 02195 payload_ptr[19] = ':'; 02196 payload_ptr[20] = '3'; 02197 payload_ptr[21] = '/'; 02198 sn_coap_protocol_stub.expectedHeader->payload_len = 22; 02199 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02200 02201 retCounter = 1; 02202 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02203 return false; 02204 } 02205 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02206 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02207 02208 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02209 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02210 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02211 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02212 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02213 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02214 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02215 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02216 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02217 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02218 02219 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(3); 02220 02221 payload_ptr[0] = '/'; 02222 payload_ptr[1] = '/'; 02223 payload_ptr[2] = '['; 02224 payload_ptr[3] = '2'; 02225 payload_ptr[4] = ':'; 02226 payload_ptr[5] = 'A'; 02227 payload_ptr[6] = '7'; 02228 payload_ptr[7] = ':'; 02229 payload_ptr[8] = ':'; 02230 payload_ptr[9] = '7'; 02231 payload_ptr[10] = '7'; 02232 payload_ptr[11] = ':'; 02233 payload_ptr[12] = 'd'; 02234 payload_ptr[13] = 'E'; 02235 payload_ptr[14] = '7'; 02236 payload_ptr[15] = '7'; 02237 payload_ptr[16] = ':'; 02238 payload_ptr[17] = '1'; 02239 payload_ptr[18] = ']'; 02240 payload_ptr[19] = ':'; 02241 payload_ptr[20] = '3'; 02242 payload_ptr[21] = '/'; 02243 sn_coap_protocol_stub.expectedHeader->payload_len = 22; 02244 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02245 02246 retCounter = 1; 02247 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02248 return false; 02249 } 02250 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02251 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02252 02253 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02254 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02255 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02256 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02257 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02258 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02259 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02260 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02261 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02262 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02263 02264 payload_ptr[0] = '/'; 02265 payload_ptr[1] = '/'; 02266 payload_ptr[2] = '['; 02267 payload_ptr[3] = ':'; 02268 payload_ptr[4] = ':'; 02269 payload_ptr[5] = ']'; 02270 payload_ptr[6] = ':'; 02271 payload_ptr[7] = '5'; 02272 payload_ptr[8] = '/'; 02273 sn_coap_protocol_stub.expectedHeader->payload_len = 9; 02274 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02275 02276 retCounter = 1; 02277 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02278 return false; 02279 } 02280 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02281 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02282 // <-- 02283 02284 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02285 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02286 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02287 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02288 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02289 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02290 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02291 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02292 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02293 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02294 02295 payload_ptr[0] = '/'; 02296 payload_ptr[1] = '/'; 02297 payload_ptr[2] = ':'; 02298 sn_coap_protocol_stub.expectedHeader->payload_len = 3; 02299 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02300 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02301 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02302 02303 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(3); 02304 02305 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02306 return false; 02307 } 02308 02309 //Test IPv4 here --> 02310 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02311 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02312 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02313 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02314 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02315 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02316 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02317 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02318 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02319 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02320 02321 payload_ptr[0] = '/'; 02322 payload_ptr[1] = '/'; 02323 payload_ptr[2] = '1'; 02324 payload_ptr[3] = '.'; 02325 payload_ptr[4] = '2'; 02326 payload_ptr[5] = '.'; 02327 payload_ptr[6] = '3'; 02328 payload_ptr[7] = '.'; 02329 payload_ptr[8] = '4'; 02330 payload_ptr[9] = ':'; 02331 payload_ptr[10] = '6'; 02332 sn_coap_protocol_stub.expectedHeader->payload_len = 11; 02333 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02334 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02335 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02336 02337 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02338 return false; 02339 } 02340 02341 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02342 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02343 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02344 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02345 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02346 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02347 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02348 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02349 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02350 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02351 02352 payload_ptr[0] = '/'; 02353 payload_ptr[1] = '/'; 02354 payload_ptr[2] = '1'; 02355 payload_ptr[3] = '.'; 02356 payload_ptr[4] = '2'; 02357 payload_ptr[5] = '.'; 02358 payload_ptr[6] = '3'; 02359 payload_ptr[7] = '.'; 02360 payload_ptr[8] = '4'; 02361 payload_ptr[9] = ':'; 02362 payload_ptr[10] = '6'; 02363 payload_ptr[11] = '6'; 02364 sn_coap_protocol_stub.expectedHeader->payload_len = 12; 02365 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02366 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02367 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02368 02369 02370 retCounter = 1; 02371 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02372 return false; 02373 } 02374 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02375 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02376 02377 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02378 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02379 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02380 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02381 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02382 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02383 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02384 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02385 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02386 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02387 02388 payload_ptr[0] = '/'; 02389 payload_ptr[1] = '/'; 02390 payload_ptr[2] = '1'; 02391 payload_ptr[3] = '.'; 02392 payload_ptr[4] = '2'; 02393 payload_ptr[5] = '.'; 02394 payload_ptr[6] = '3'; 02395 payload_ptr[7] = '.'; 02396 payload_ptr[8] = '4'; 02397 payload_ptr[9] = ':'; 02398 payload_ptr[10] = '6'; 02399 payload_ptr[11] = '6'; 02400 payload_ptr[12] = '/'; 02401 sn_coap_protocol_stub.expectedHeader->payload_len = 13; 02402 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02403 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02404 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02405 02406 retCounter = 1; 02407 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02408 return false; 02409 } 02410 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02411 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02412 02413 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02414 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02415 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02416 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02417 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02418 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02419 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02420 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02421 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02422 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02423 02424 payload_ptr[0] = '/'; 02425 payload_ptr[1] = '/'; 02426 payload_ptr[2] = 's'; 02427 payload_ptr[3] = '.'; 02428 payload_ptr[4] = 't'; 02429 payload_ptr[5] = '.'; 02430 payload_ptr[6] = 'u'; 02431 payload_ptr[7] = '.'; 02432 payload_ptr[8] = 'v'; 02433 payload_ptr[9] = ':'; 02434 payload_ptr[10] = '6'; 02435 sn_coap_protocol_stub.expectedHeader->payload_len = 11; 02436 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02437 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02438 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02439 02440 retCounter = 1; 02441 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02442 return false; 02443 } 02444 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02445 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02446 02447 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02448 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02449 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02450 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02451 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02452 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02453 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02454 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02455 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02456 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02457 02458 payload_ptr[0] = '/'; 02459 payload_ptr[1] = '/'; 02460 payload_ptr[2] = 's'; 02461 payload_ptr[3] = '.'; 02462 payload_ptr[4] = 't'; 02463 payload_ptr[5] = '.'; 02464 payload_ptr[6] = 'u'; 02465 payload_ptr[7] = '.'; 02466 payload_ptr[8] = 'v'; 02467 payload_ptr[9] = ':'; 02468 payload_ptr[10] = '6'; 02469 sn_coap_protocol_stub.expectedHeader->payload_len = 11; 02470 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02471 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02472 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02473 handle->handle_bootstrap_msg = false; 02474 02475 retCounter = 1; 02476 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02477 return false; 02478 } 02479 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02480 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02481 handle->handle_bootstrap_msg = true; 02482 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02483 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02484 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02485 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02486 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02487 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02488 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02489 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02490 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02491 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02492 02493 payload_ptr[0] = '/'; 02494 payload_ptr[1] = '/'; 02495 payload_ptr[2] = 's'; 02496 payload_ptr[3] = '.'; 02497 payload_ptr[4] = 't'; 02498 payload_ptr[5] = '.'; 02499 payload_ptr[6] = 'u'; 02500 payload_ptr[7] = '.'; 02501 payload_ptr[8] = 'v'; 02502 payload_ptr[9] = '.'; 02503 payload_ptr[10] = 'w'; 02504 payload_ptr[11] = ':'; 02505 payload_ptr[12] = '6'; 02506 payload_ptr[13] = '/'; 02507 sn_coap_protocol_stub.expectedHeader->payload_len = 14; 02508 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02509 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02510 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02511 02512 retCounter = 1; 02513 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02514 return false; 02515 } 02516 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02517 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02518 02519 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02520 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02521 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02522 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02523 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02524 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02525 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02526 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02527 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02528 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02529 02530 payload_ptr[0] = '/'; 02531 payload_ptr[1] = '/'; 02532 payload_ptr[2] = 's'; 02533 payload_ptr[3] = '.'; 02534 payload_ptr[4] = 't'; 02535 payload_ptr[5] = '.'; 02536 payload_ptr[6] = 'u'; 02537 payload_ptr[7] = '.'; 02538 payload_ptr[8] = 'v'; 02539 payload_ptr[9] = '.'; 02540 payload_ptr[10] = 'w'; 02541 payload_ptr[11] = ':'; 02542 payload_ptr[12] = '6'; 02543 sn_coap_protocol_stub.expectedHeader->payload_len = 13; 02544 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02545 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02546 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02547 02548 retCounter = 1; 02549 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02550 return false; 02551 } 02552 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02553 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02554 02555 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02556 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02557 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02558 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02559 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02560 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02561 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02562 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02563 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02564 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02565 02566 free( payload_ptr ); 02567 payload_ptr = malloc(276); 02568 memset(payload_ptr, 1, 276); 02569 payload_ptr[0] = '/'; 02570 payload_ptr[1] = '/'; 02571 payload_ptr[2] = 's'; 02572 payload_ptr[3] = '.'; 02573 payload_ptr[4] = 't'; 02574 payload_ptr[5] = '.'; 02575 payload_ptr[6] = 'u'; 02576 payload_ptr[7] = '.'; 02577 payload_ptr[8] = 'v'; 02578 payload_ptr[9] = '.'; 02579 payload_ptr[10] = 'w'; 02580 payload_ptr[11] = ':'; 02581 payload_ptr[12] = '6'; 02582 sn_coap_protocol_stub.expectedHeader->payload_len = 276; 02583 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02584 handle->sn_nsdl_oma_bs_done_cb = myBootstrapCallback; 02585 handle->sn_nsdl_oma_bs_done_cb_handle = myBootstrapCallbackHandle; 02586 02587 retCounter = 1; 02588 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02589 return false; 02590 } 02591 free( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr ); //Investigate why would leak if removed? 02592 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02593 // <-- 02594 02595 sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02596 memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s)); 02597 sn_coap_protocol_stub.expectedHeader->coap_status = 6; 02598 sn_coap_protocol_stub.expectedHeader->msg_code = 0; 02599 sn_coap_protocol_stub.expectedHeader->content_type_len = 1; 02600 sn_coap_protocol_stub.expectedHeader->content_type_ptr = (uint8_t*)malloc(1); 02601 *sn_coap_protocol_stub.expectedHeader->content_type_ptr = 97; 02602 sn_coap_protocol_stub.expectedHeader->uri_path_ptr = (uint8_t*)malloc(1); 02603 sn_coap_protocol_stub.expectedHeader->uri_path_ptr[0] = '0'; 02604 sn_coap_protocol_stub.expectedHeader->uri_path_len = 1; 02605 02606 payload_ptr[0] = '/'; 02607 payload_ptr[1] = '/'; 02608 payload_ptr[2] = ':'; 02609 payload_ptr[3] = ':'; 02610 sn_coap_protocol_stub.expectedHeader->payload_len = 4; 02611 sn_coap_protocol_stub.expectedHeader->payload_ptr = payload_ptr; 02612 02613 if( SN_NSDL_SUCCESS != sn_nsdl_process_coap(handle, NULL, 0, addr) ){ 02614 return false; 02615 } 02616 free(sn_grs_stub.expectedGrs->coap); 02617 free(payload_ptr); 02618 free(addr); 02619 sn_nsdl_destroy(handle); 02620 return true; 02621 } 02622 02623 bool test_sn_nsdl_exec() 02624 { 02625 if( -1 != sn_nsdl_exec(NULL, NULL) ){ 02626 return false; 02627 } 02628 02629 retCounter = 4; 02630 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02631 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02632 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02633 sn_coap_protocol_stub.expectedInt8 = 0; 02634 02635 if( 0 != sn_nsdl_exec(handle,0) ){ 02636 return false; 02637 } 02638 02639 sn_nsdl_destroy(handle); 02640 return true; 02641 } 02642 02643 bool test_sn_nsdl_get_resource() 02644 { 02645 if( NULL != sn_nsdl_get_resource(NULL, 0, NULL) ){ 02646 return false; 02647 } 02648 sn_grs_stub.retNull = false; 02649 retCounter = 4; 02650 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02651 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02652 02653 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02654 02655 sn_nsdl_get_resource(handle, 0, NULL); 02656 02657 sn_nsdl_destroy(handle); 02658 return true; 02659 } 02660 02661 bool test_set_NSP_address() 02662 { 02663 if( SN_NSDL_FAILURE != set_NSP_address(NULL, NULL, 0, SN_NSDL_ADDRESS_TYPE_IPV4) ){ 02664 return false; 02665 } 02666 sn_grs_stub.retNull = false; 02667 retCounter = 4; 02668 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02669 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02670 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02671 02672 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(2); 02673 memset( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr, 0, 2 ); 02674 02675 uint8_t* addr = (uint8_t*)malloc(2); 02676 memset(addr, 0, 2); 02677 02678 if( SN_NSDL_FAILURE != set_NSP_address(handle, addr, 0, SN_NSDL_ADDRESS_TYPE_IPV4) ){ 02679 return false; 02680 } 02681 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02682 02683 retCounter = 1; 02684 if( SN_NSDL_SUCCESS != set_NSP_address(handle, addr, 0, SN_NSDL_ADDRESS_TYPE_IPV4) ){ 02685 return false; 02686 } 02687 free(handle->nsp_address_ptr->omalw_address_ptr->addr_ptr); 02688 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02689 02690 if( SN_NSDL_FAILURE != set_NSP_address(handle, addr, 0, SN_NSDL_ADDRESS_TYPE_IPV6) ){ 02691 return false; 02692 } 02693 02694 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = NULL; 02695 handle->nsp_address_ptr->omalw_address_ptr->addr_ptr = (uint8_t*)malloc(2); 02696 memset( handle->nsp_address_ptr->omalw_address_ptr->addr_ptr, 0, 2 ); 02697 02698 retCounter = 1; 02699 if( SN_NSDL_SUCCESS != set_NSP_address(handle, addr, 0, SN_NSDL_ADDRESS_TYPE_IPV6) ){ 02700 return false; 02701 } 02702 02703 free(addr); 02704 sn_nsdl_destroy(handle); 02705 return true; 02706 } 02707 02708 bool test_sn_nsdl_list_resource() 02709 { 02710 if( NULL != sn_nsdl_list_resource(NULL, 0, NULL) ){ 02711 return false; 02712 } 02713 sn_grs_stub.retNull = false; 02714 retCounter = 4; 02715 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02716 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02717 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02718 02719 if( NULL != sn_nsdl_list_resource(handle, 0, NULL) ){ 02720 return false; 02721 } 02722 02723 sn_nsdl_destroy(handle); 02724 return true; 02725 } 02726 02727 bool test_sn_nsdl_free_resource_list() 02728 { 02729 sn_nsdl_free_resource_list(NULL, NULL); 02730 02731 sn_grs_stub.retNull = false; 02732 retCounter = 4; 02733 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02734 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02735 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02736 02737 sn_grs_resource_list_s* list = (sn_grs_resource_list_s*)malloc(sizeof(sn_grs_resource_list_s)); 02738 sn_nsdl_free_resource_list(handle, list); //mem leak or pass 02739 02740 sn_nsdl_destroy(handle); 02741 return true; 02742 } 02743 02744 bool test_sn_nsdl_update_resource() 02745 { 02746 if( SN_NSDL_FAILURE != sn_nsdl_update_resource(NULL, NULL) ){ 02747 return false; 02748 } 02749 sn_grs_stub.retNull = false; 02750 retCounter = 4; 02751 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02752 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02753 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02754 02755 if( 0 != sn_nsdl_update_resource(handle, NULL) ){ 02756 return false; 02757 } 02758 02759 sn_nsdl_destroy(handle); 02760 return true; 02761 } 02762 02763 bool test_sn_nsdl_send_coap_message() 02764 { 02765 if( SN_NSDL_FAILURE != sn_nsdl_send_coap_message(NULL, NULL, NULL) ){ 02766 return false; 02767 } 02768 sn_grs_stub.retNull = false; 02769 retCounter = 4; 02770 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02771 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02772 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02773 02774 if( 0 != sn_nsdl_send_coap_message(handle, NULL, NULL) ){ 02775 return false; 02776 } 02777 02778 sn_nsdl_destroy(handle); 02779 return true; 02780 } 02781 02782 bool test_sn_nsdl_create_resource() 02783 { 02784 if( SN_NSDL_FAILURE != sn_nsdl_create_resource(NULL, NULL) ){ 02785 return false; 02786 } 02787 sn_grs_stub.retNull = false; 02788 retCounter = 4; 02789 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02790 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02791 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02792 02793 if( 0 != sn_nsdl_create_resource(handle, NULL) ){ 02794 return false; 02795 } 02796 02797 sn_nsdl_destroy(handle); 02798 return true; 02799 } 02800 02801 bool test_sn_nsdl_delete_resource() 02802 { 02803 if( SN_NSDL_FAILURE != sn_nsdl_delete_resource(NULL, 0, NULL) ){ 02804 return false; 02805 } 02806 sn_grs_stub.retNull = false; 02807 retCounter = 4; 02808 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02809 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02810 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02811 02812 if( 0 != sn_nsdl_delete_resource(handle, 0, NULL) ){ 02813 return false; 02814 } 02815 02816 sn_nsdl_destroy(handle); 02817 return true; 02818 } 02819 02820 bool test_sn_nsdl_get_first_resource() 02821 { 02822 if( NULL != sn_nsdl_get_first_resource(NULL) ){ 02823 return false; 02824 } 02825 sn_grs_stub.retNull = false; 02826 retCounter = 4; 02827 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02828 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02829 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02830 02831 if( NULL != sn_nsdl_get_first_resource(handle) ){ 02832 return false; 02833 } 02834 02835 sn_nsdl_destroy(handle); 02836 return true; 02837 } 02838 02839 bool test_sn_nsdl_get_next_resource() 02840 { 02841 if( NULL != sn_nsdl_get_next_resource(NULL, NULL) ){ 02842 return false; 02843 } 02844 sn_grs_stub.retNull = false; 02845 retCounter = 4; 02846 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02847 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02848 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02849 02850 if( NULL != sn_nsdl_get_next_resource(handle, NULL) ){ 02851 return false; 02852 } 02853 02854 sn_nsdl_destroy(handle); 02855 return true; 02856 } 02857 02858 bool test_sn_nsdl_build_response() 02859 { 02860 if( NULL != sn_nsdl_build_response(NULL, NULL, 0) ){ 02861 return false; 02862 } 02863 sn_grs_stub.retNull = false; 02864 retCounter = 4; 02865 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02866 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02867 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02868 02869 if( NULL != sn_nsdl_build_response(handle, NULL, 0) ){ 02870 return false; 02871 } 02872 02873 sn_nsdl_destroy(handle); 02874 return true; 02875 } 02876 02877 bool test_sn_nsdl_release_allocated_coap_msg_mem() 02878 { 02879 sn_nsdl_release_allocated_coap_msg_mem(NULL, NULL); 02880 sn_grs_stub.retNull = false; 02881 retCounter = 4; 02882 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02883 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02884 struct nsdl_s* handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02885 02886 sn_coap_hdr_s* list = (sn_coap_hdr_s*)malloc(sizeof(sn_coap_hdr_s)); 02887 02888 sn_nsdl_release_allocated_coap_msg_mem(handle, list); //mem leak or pass 02889 02890 sn_nsdl_destroy(handle); 02891 return true; 02892 } 02893 02894 bool test_sn_nsdl_set_retransmission_parameters() 02895 { 02896 struct nsdl_s* handle = NULL; 02897 if (sn_nsdl_set_retransmission_parameters(handle, 10, 10) == 0){ 02898 return false; 02899 } 02900 retCounter = 4; 02901 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02902 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02903 handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02904 sn_coap_protocol_stub.expectedInt8 = 0; 02905 02906 if (sn_nsdl_set_retransmission_parameters(handle, 10, 10) != 0){ 02907 return false; 02908 } 02909 sn_nsdl_destroy(handle); 02910 return true; 02911 } 02912 02913 bool test_sn_nsdl_set_retransmission_buffer() 02914 { 02915 struct nsdl_s* handle = NULL; 02916 if (sn_nsdl_set_retransmission_buffer(handle,3,3 ) == 0){ 02917 return false; 02918 } 02919 retCounter = 4; 02920 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02921 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02922 handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02923 sn_coap_protocol_stub.expectedInt8 = 0; 02924 02925 if (sn_nsdl_set_retransmission_buffer(handle,3,3 ) != 0){ 02926 return false; 02927 } 02928 sn_nsdl_destroy(handle); 02929 return true; 02930 } 02931 02932 bool test_sn_nsdl_set_block_size() 02933 { 02934 struct nsdl_s* handle = NULL; 02935 if (sn_nsdl_set_block_size(handle,16) == 0){ 02936 return false; 02937 } 02938 retCounter = 4; 02939 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02940 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02941 handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02942 sn_coap_protocol_stub.expectedInt8 = 0; 02943 02944 if (sn_nsdl_set_block_size(handle,16) != 0){ 02945 return false; 02946 } 02947 sn_nsdl_destroy(handle); 02948 return true; 02949 } 02950 02951 bool test_sn_nsdl_set_duplicate_buffer_size() 02952 { 02953 struct nsdl_s* handle = NULL; 02954 if (sn_nsdl_set_duplicate_buffer_size(handle,999) == 0){ 02955 return false; 02956 } 02957 retCounter = 4; 02958 sn_grs_stub.expectedGrs = (struct grs_s *)malloc(sizeof(struct grs_s)); 02959 memset(sn_grs_stub.expectedGrs,0, sizeof(struct grs_s)); 02960 handle = sn_nsdl_init(&nsdl_tx_callback, &nsdl_rx_callback, &myMalloc, &myFree); 02961 sn_coap_protocol_stub.expectedInt8 = 0; 02962 02963 if (sn_nsdl_set_duplicate_buffer_size(handle,999) != 0){ 02964 return false; 02965 } 02966 sn_nsdl_destroy(handle); 02967 return true; 02968 }
Generated on Tue Jul 12 2022 12:28:55 by
1.7.2
