Skip to content

Commit 07d7222

Browse files
author
Tero Heinonen
authored
Fix unittests (#35)
Adding missing stubs, and added check for nullpointer to coap message process callback.
1 parent 0e4af1a commit 07d7222

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

source/coap_service_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static void service_event_handler(arm_event_s *event)
174174
static int16_t coap_msg_process_callback(int8_t socket_id, sn_coap_hdr_s *coap_message, coap_transaction_t *transaction_ptr)
175175
{
176176
coap_service_t *this;
177-
if( !coap_message ){
177+
if (!coap_message || !transaction_ptr) {
178178
return -1;
179179
}
180180

test/coap-service/unittest/coap_message_handler/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ TEST_SRC_FILES = \
1717
../stub/nsdynmemLIB_stub.c \
1818
../stub/ns_list_stub.c \
1919
../stub/randLIB_stub.c \
20+
../stub/coap_service_api_stub.c
2021

2122
include ../MakefileWorker.mk
2223

test/coap-service/unittest/coap_service_api/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ TEST_SRC_FILES = \
1717
../stub/eventOS_event_stub.c \
1818
../stub/coap_connection_handler_stub.c \
1919
../stub/coap_message_handler_stub.c \
20+
../stub/common_functions_stub.c
2021

2122
include ../MakefileWorker.mk
2223

test/coap-service/unittest/stub/coap_service_api_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ uint32_t coap_service_get_internal_timer_ticks(void)
6262
{
6363
return 1;
6464
}
65+
66+
uint16_t coap_service_id_find_by_socket(int8_t socket_id)
67+
{
68+
return 1;
69+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2016 ARM Limited. All rights reserved.
3+
*/
4+
#include <stdio.h>
5+
#include <stdint.h>
6+
#include <inttypes.h>
7+
8+
#include "ns_types.h"
9+
10+
uint16_t common_read_16_bit(const uint8_t data_buf[__static 2])
11+
{
12+
return 0;
13+
}

0 commit comments

Comments
 (0)