Skip to content

Commit b037628

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Fixed unit test and stubs
Fixed missing ws_neighbour_class stub's Fixed mac_neighbour_table function stubs
1 parent 8153fe3 commit b037628

File tree

6 files changed

+124
-5
lines changed

6 files changed

+124
-5
lines changed

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ TEST_SRC_FILES = \
2929
../../stub/mac_ie_lib_stub.c \
3030
../../stub/ws_ie_lib_stub.c \
3131
../../stub/ws_mpx_header_stub.c \
32+
../../stub/ws_neighbour_class_stub.c \
33+
../../stub/mac_neighbor_table_stub.c \
3234
../../stub/iphc_decompress_stub.c \
3335

3436

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/test_ws_llc_data_service.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,27 @@
2828
#include "6LoWPAN/MAC/mpx_api.h"
2929
#include "6LoWPAN/MAC/mac_ie_lib.h"
3030
#include "6LoWPAN/ws/ws_common_defines.h"
31+
#include "6LoWPAN/ws/ws_common.h"
3132
#include "6LoWPAN/ws/ws_ie_lib.h"
3233
#include "6LoWPAN/ws/ws_llc.h"
3334
#include "6LoWPAN/ws/ws_mpx_header.h"
34-
#include "6LoWPAN/lowpan_adaptation_interface.h"
35+
#include "6LoWPAN/ws/ws_neighbour_class.h"
36+
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3537
#include "nsdynmemLIB_stub.h"
3638
#include "mac_ie_lib_stub.h"
3739
#include "ws_mpx_header_stub.h"
40+
#include "ws_mpx_header_stub.h"
41+
#include "mac_neighbor_table_stub.h"
42+
#include "ws_neighbour_class_stub.h"
3843

3944
static mcps_data_indication_ext *data_indication_cb;
4045

4146
static mcps_data_confirm_ext *data_confirmation_cb;
4247

4348
static protocol_interface_info_entry_t interface;
4449

50+
static arm_15_4_mac_parameters_t mac_parameters;
51+
4552

4653
static uint8_t async_ind_type;
4754
static uint16_t async_data_length;
@@ -111,7 +118,9 @@ static void test_mcps_purge_request(const mac_api_t* api, const mcps_purge_t *da
111118
static void interface_api_init(mac_api_t *api)
112119
{
113120
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
121+
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
114122
interface.mac_api = api;
123+
interface.mac_parameters = &mac_parameters;
115124
api->mcps_purge_req = &test_mcps_purge_request;
116125
api->mcps_data_req_ext = &test_mcps_data_request_ext;
117126
api->mac_mcps_extension_enable = &test_mac_api_enable_mcps_ext;
@@ -378,6 +387,9 @@ bool test_mpx_msg_rx()
378387
ie_ext.payloadIeList = payload_buf;
379388
ie_ext.payloadIeListLength = 100;
380389

390+
ws_neighbor_stub.neigh_entry = NULL;
391+
mac_neighbor_table_stub.test_neigh = NULL;
392+
381393
mac_ie_lib_stub_def.value_uint8 = 0;
382394

383395
data_indication_cb(NULL, &data_ind, &ie_ext);

test/nanostack/unittest/stub/common_functions_stub.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit(const uint8_t data_buf[__st
9797
return common_functions_stub.uint24_value;
9898
}
9999

100+
COMMON_FUNCTIONS_FN uint_fast24_t common_read_24_bit_inverse(const uint8_t data_buf[__static 3])
101+
{
102+
memcpy(common_functions_stub.argument_table, data_buf, 3);
103+
return common_functions_stub.uint24_value;
104+
}
105+
100106
COMMON_FUNCTIONS_FN uint8_t *common_write_24_bit_inverse(uint_fast24_t value, uint8_t ptr[__static 3])
101107
{
102108
return ptr + 3;

test/nanostack/unittest/stub/mac_neighbor_table_stub.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ void mac_neighbor_table_neighbor_remove(mac_neighbor_table_t *table_class, mac_n
6161
}
6262

6363

64-
void neighbor_table_class_neighbor_refresh(mac_neighbor_table_t *table_class, mac_neighbor_table_entry_t *neighbor_entry, uint32_t life_time)
64+
void mac_neighbor_table_neighbor_refresh(mac_neighbor_table_t *table_class, mac_neighbor_table_entry_t *neighbor_entry, uint32_t life_time)
6565
{
6666

6767
}
6868

69-
void neighbor_table_class_neighbor_connected(mac_neighbor_table_t *table_class, mac_neighbor_table_entry_t *neighbor_entry)
69+
void mac_neighbor_table_neighbor_connected(mac_neighbor_table_t *table_class, mac_neighbor_table_entry_t *neighbor_entry)
7070
{
7171

7272
}
@@ -77,12 +77,12 @@ void mac_neighbor_table_trusted_neighbor(mac_neighbor_table_t *table_class, mac_
7777
}
7878

7979

80-
mac_neighbor_table_entry_t *neighbor_table_class_address_discover(mac_neighbor_table_t *table_class, const uint8_t *address, uint8_t address_type)
80+
mac_neighbor_table_entry_t *mac_neighbor_table_address_discover(mac_neighbor_table_t *table_class, const uint8_t *address, uint8_t address_type)
8181
{
8282
return mac_neighbor_table_stub.test_neigh;
8383
}
8484

85-
mac_neighbor_table_entry_t *neighbor_table_class_attribute_discover(mac_neighbor_table_t *table_class, uint8_t index)
85+
mac_neighbor_table_entry_t *mac_neighbor_table_attribute_discover(mac_neighbor_table_t *table_class, uint8_t index)
8686
{
8787
return mac_neighbor_table_stub.test_neigh;
8888
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
/*
18+
* Copyright (c) 2018, Arm Limited and affiliates.
19+
* SPDX-License-Identifier: Apache-2.0
20+
*
21+
* Licensed under the Apache License, Version 2.0 (the "License");
22+
* you may not use this file except in compliance with the License.
23+
* You may obtain a copy of the License at
24+
*
25+
* http://www.apache.org/licenses/LICENSE-2.0
26+
*
27+
* Unless required by applicable law or agreed to in writing, software
28+
* distributed under the License is distributed on an "AS IS" BASIS,
29+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30+
* See the License for the specific language governing permissions and
31+
* limitations under the License.
32+
*/
33+
34+
#include "nsconfig.h"
35+
#include <string.h>
36+
#include "ns_types.h"
37+
#include "ns_list.h"
38+
#include "ns_trace.h"
39+
#include "nsdynmemLIB.h"
40+
#include "6LoWPAN/ws/ws_neighbour_class.h"
41+
#include "ws_neighbour_class_stub.h"
42+
43+
ws_neighbor_stub_def ws_neighbor_stub;
44+
45+
bool ws_neighbour_class_alloc(ws_neighbour_class_t *class_data, uint8_t list_size)
46+
{
47+
return ws_neighbor_stub.bool_value;
48+
}
49+
50+
51+
void ws_neighbour_class_dealloc(ws_neighbour_class_t *class_data)
52+
{
53+
54+
}
55+
56+
ws_neighbour_class_entry_t * ws_neighbour_class_entry_get(ws_neighbour_class_t *class_data, uint8_t attribute_index)
57+
{
58+
return ws_neighbor_stub.neigh_entry;
59+
}
60+
61+
void ws_neighbour_class_entry_remove(ws_neighbour_class_t *class_data, uint8_t attribute_index)
62+
{
63+
64+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef WS_NEIGHBOUR_CLASS_STUB_H_
19+
#define WS_NEIGHBOUR_CLASS_STUB_H_
20+
21+
#include "inttypes.h"
22+
23+
#include "6LoWPAN/ws/ws_neighbour_class.h"
24+
25+
26+
typedef struct {
27+
ws_neighbour_class_entry_t *neigh_entry;
28+
bool bool_value;
29+
} ws_neighbor_stub_def;
30+
31+
extern ws_neighbor_stub_def ws_neighbor_stub;
32+
33+
34+
35+
#endif /* WS_NEIGHBOUR_CLASS_STUB_H_ */

0 commit comments

Comments
 (0)