Skip to content

Commit cef04e5

Browse files
author
Arto Kinnunen
authored
Update unit tests (#26)
Build unit tests in Jenkins when PR created/changed.
1 parent e062233 commit cef04e5

File tree

10 files changed

+135
-224
lines changed

10 files changed

+135
-224
lines changed

test/coap-service/unittest/coap_connection_handler/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST_SRC_FILES = \
1010
main.cpp \
1111
coap_connection_handlertest.cpp \
1212
test_coap_connection_handler.c \
13-
../stub/ns_trace_stub.c \
13+
../stub/mbed_trace_stub.c \
1414
../stub/ns_list_stub.c \
1515
../stub/ns_timer_stub.c \
1616
../stub/timeout_stub.c \

test/coap-service/unittest/coap_message_handler/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ SRC_FILES = \
88

99
TEST_SRC_FILES = \
1010
main.cpp \
11-
coap_message_handlertest.cpp \
12-
test_coap_message_handler.c \
13-
../stub/ns_trace_stub.c \
11+
coap_message_handlertest.cpp \
12+
test_coap_message_handler.c \
13+
../stub/mbed_trace_stub.c \
1414
../stub/sn_coap_protocol_stub.c \
1515
../stub/sn_coap_parser_stub.c \
1616
../stub/sn_coap_builder_stub.c \

test/coap-service/unittest/coap_security_handler/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST_SRC_FILES = \
1010
main.cpp \
1111
coap_security_handlertest.cpp \
1212
test_coap_security_handler.c \
13-
../stub/ns_trace_stub.c \
13+
../stub/mbed_trace_stub.c \
1414
../stub/ns_list_stub.c \
1515
../stub/ns_timer_stub.c \
1616
../stub/mbedtls_stub.c \

test/coap-service/unittest/coap_service_api/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ SRC_FILES = \
88

99
TEST_SRC_FILES = \
1010
main.cpp \
11-
coap_service_apitest.cpp \
12-
test_coap_service_api.c \
13-
../stub/ns_trace_stub.c \
11+
coap_service_apitest.cpp \
12+
test_coap_service_api.c \
13+
../stub/mbed_trace_stub.c \
1414
../stub/ns_list_stub.c \
1515
../stub/system_timer_stub.c \
1616
../stub/nsdynmemLIB_stub.c \

test/coap-service/unittest/coap_service_api/test_coap_service_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,22 +252,22 @@ bool test_coap_callbacks()
252252
addr.addr_len = 2;
253253
addr.port = 4;
254254
addr.addr_ptr = &data;
255-
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(NULL, 0, &addr, NULL))
255+
if( 255 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(NULL, 0, &addr, NULL))
256256
return false;
257257

258258
coap_transaction_t *tr = (coap_transaction_t *)malloc(sizeof(coap_transaction_t));
259259
memset(tr, 0, sizeof(coap_transaction_t));
260260

261-
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
261+
if( 255 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
262262
return false;
263263

264264
tr->service_id = 1;
265265
thread_conn_handler_stub.int_value = -2;
266-
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
266+
if( 255 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 0, &addr, tr))
267267
return false;
268268

269269
nsdynmemlib_stub.returnCounter = 1;
270-
if( 0 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 2, &addr, tr))
270+
if( 255 != coap_message_handler_stub.coap_ptr->sn_coap_tx_callback(&data, 2, &addr, tr))
271271
return false;
272272

273273
free(tr->data_ptr);

test/coap-service/unittest/makefile_defines.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ INCLUDE_DIRS =\
1313
../../../../yotta_modules/mbedtls/ \
1414
../../../../yotta_modules/sal-stack-nanostack/nanostack/ \
1515
../../../../yotta_modules/nanostack-randlib/mbed-client-randlib/ \
16+
../../../../yotta_modules/nanostack-libservice/ \
1617
../../../../yotta_modules/nanostack-libservice/mbed-client-libservice/ \
1718
../../../../yotta_modules/mbed-client-c/nsdl-c/ \
1819
../../../../yotta_modules/mbed-client-c/source/libCoap/src/include/ \
1920
../../../../yotta_modules/sal-stack-nanostack-eventloop/nanostack-event-loop/ \
2021
../../../../yotta_modules/sal-stack-nanostack-eventloop/source/ \
22+
../../../../yotta_modules/mbed-trace/ \
2123
../../../../../nanostack/nanostack/\
2224
../../../../../libService/libService/\
2325
../../../../../nsdl-c/nsdl-c/\

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ int8_t coap_message_handler_destroy(coap_msg_handler_t *handle)
2222
return coap_message_handler_stub.int8_value;
2323
}
2424

25+
coap_transaction_t *coap_message_handler_transaction_valid(coap_transaction_t *tr_ptr)
26+
{
27+
return coap_message_handler_stub.coap_ptr;
28+
}
29+
2530
coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port)
2631
{
2732
return coap_message_handler_stub.coap_tx_ptr;
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the License); you may
5+
* not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include <stdio.h>
17+
#include <string.h>
18+
#include <stdarg.h>
19+
#include <stdlib.h>
20+
21+
#ifndef YOTTA_CFG_MBED_TRACE
22+
#define YOTTA_CFG_MBED_TRACE
23+
#define YOTTA_CFG_MBED_TRACE_FEA_IPV6 1
24+
#endif
25+
26+
#include "mbed-trace/mbed_trace.h"
27+
#if YOTTA_CFG_MBED_TRACE_FEA_IPV6 == 1
28+
#include "mbed-client-libservice/ip6string.h"
29+
#include "mbed-client-libservice/common_functions.h"
30+
#endif
31+
32+
33+
int mbed_trace_init(void)
34+
{
35+
return 0;
36+
}
37+
void mbed_trace_free(void)
38+
{
39+
}
40+
41+
void mbed_trace_buffer_sizes(int lineLength, int tmpLength)
42+
{
43+
}
44+
45+
void mbed_trace_config_set(uint8_t config)
46+
{
47+
}
48+
49+
uint8_t mbed_trace_config_get(void)
50+
{
51+
return 0;
52+
}
53+
54+
void mbed_trace_prefix_function_set(char *(*pref_f)(size_t))
55+
{
56+
}
57+
58+
void mbed_trace_suffix_function_set(char *(*suffix_f)(void))
59+
{
60+
}
61+
62+
void mbed_trace_print_function_set(void (*printf)(const char *))
63+
{
64+
}
65+
66+
void mbed_trace_cmdprint_function_set(void (*printf)(const char *))
67+
{
68+
}
69+
70+
void mbed_trace_exclude_filters_set(char *filters)
71+
{
72+
73+
}
74+
75+
const char *mbed_trace_exclude_filters_get(void)
76+
{
77+
return NULL;
78+
}
79+
80+
const char *mbed_trace_include_filters_get(void)
81+
{
82+
return NULL;
83+
}
84+
85+
void mbed_trace_include_filters_set(char *filters)
86+
{
87+
88+
}
89+
90+
void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...)
91+
{
92+
}
93+
94+
const char *mbed_trace_last(void)
95+
{
96+
return NULL;
97+
}
98+
99+
/* Helping functions */
100+
#define tmp_data_left() m_trace.tmp_data_length-(m_trace.tmp_data_ptr-m_trace.tmp_data)
101+
#if YOTTA_CFG_MBED_TRACE_FEA_IPV6 == 1
102+
char *mbed_trace_ipv6(const void *addr_ptr)
103+
{
104+
return NULL;
105+
}
106+
107+
char *mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len)
108+
{
109+
return NULL;
110+
}
111+
#endif //YOTTA_CFG_MBED_TRACE_FEA_IPV6
112+
113+
char *mbed_trace_array(const uint8_t *buf, uint16_t len)
114+
{
115+
return NULL;
116+
}

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)