Skip to content

Commit

Permalink
Fix unittests (#35)
Browse files Browse the repository at this point in the history
Adding missing stubs, and added check for nullpointer to coap message
process callback.
  • Loading branch information
Tero Heinonen authored Oct 5, 2016
1 parent 0e4af1a commit 07d7222
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/coap_service_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void service_event_handler(arm_event_s *event)
static int16_t coap_msg_process_callback(int8_t socket_id, sn_coap_hdr_s *coap_message, coap_transaction_t *transaction_ptr)
{
coap_service_t *this;
if( !coap_message ){
if (!coap_message || !transaction_ptr) {
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions test/coap-service/unittest/coap_message_handler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TEST_SRC_FILES = \
../stub/nsdynmemLIB_stub.c \
../stub/ns_list_stub.c \
../stub/randLIB_stub.c \
../stub/coap_service_api_stub.c

include ../MakefileWorker.mk

Expand Down
1 change: 1 addition & 0 deletions test/coap-service/unittest/coap_service_api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TEST_SRC_FILES = \
../stub/eventOS_event_stub.c \
../stub/coap_connection_handler_stub.c \
../stub/coap_message_handler_stub.c \
../stub/common_functions_stub.c

include ../MakefileWorker.mk

Expand Down
5 changes: 5 additions & 0 deletions test/coap-service/unittest/stub/coap_service_api_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ uint32_t coap_service_get_internal_timer_ticks(void)
{
return 1;
}

uint16_t coap_service_id_find_by_socket(int8_t socket_id)
{
return 1;
}
13 changes: 13 additions & 0 deletions test/coap-service/unittest/stub/common_functions_stub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2016 ARM Limited. All rights reserved.
*/
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

#include "ns_types.h"

uint16_t common_read_16_bit(const uint8_t data_buf[__static 2])
{
return 0;
}

0 comments on commit 07d7222

Please sign in to comment.