mirror of https://github.com/ARMmbed/mbed-os.git
Merge commit '041b6fa73681061072f970e9cf11ff4d422fa04b' into nanostack_release_v704
* commit '041b6fa73681061072f970e9cf11ff4d422fa04b': Squashed 'features/nanostack/FEATURE_NANOSTACK/sal-stack-nanostack/' changes from 0697d9a..c9bf20fpull/5602/head
commit
32abfcfe77
|
@ -1,102 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:output encoding="UTF-8" indent="yes" method="html"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:variable name="list"
|
||||
select="document('index.xml')/list" />
|
||||
|
||||
<xsl:template match="/">
|
||||
<h1>
|
||||
Unittest report
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
<b>
|
||||
Total tests run <xsl:value-of select="sum(document($list/entry/@name)/testsuite/@tests)"/>, failures: <xsl:value-of select="sum(document($list/entry/@name)/testsuite/@failures) + sum(document($list/entry/@name)/testsuite/@errors)"/>
|
||||
|
||||
</b>
|
||||
|
||||
|
||||
<xsl:for-each select="document($list/entry/@name)" >
|
||||
<xsl:apply-templates select="testsuite"/>
|
||||
</xsl:for-each>
|
||||
</p>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="testsuite">
|
||||
<h2>
|
||||
<xsl:value-of select="@name" />
|
||||
</h2>
|
||||
<table border="1" cellSpacing="0" cellPadding="10" >
|
||||
<tr>
|
||||
<th>Tests run</th>
|
||||
<th>Tests fail</th>
|
||||
<th>Other errors</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><xsl:value-of select="@tests"/></td>
|
||||
<td><xsl:value-of select="@failures"/></td>
|
||||
<td><xsl:value-of select="@errors"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
<table border="1" cellSpacing="0" cellPadding="10" >
|
||||
<tr>
|
||||
<th>Tests name</th>
|
||||
<th>PASS/FAIL</th>
|
||||
<th>Failing case</th>
|
||||
<th>Reason</th>
|
||||
</tr>
|
||||
<xsl:apply-templates select="testcase"/>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="testcase">
|
||||
<xsl:choose>
|
||||
<xsl:when test="failure">
|
||||
<tr><td><font color="#FF0000"><xsl:value-of select="@name" /></font></td><xsl:apply-templates select="failure"/></tr>
|
||||
</xsl:when>
|
||||
<xsl:when test="error">
|
||||
<tr><td><font color="#FF0000"><xsl:value-of select="@name" /></font></td><xsl:apply-templates select="error"/></tr>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<tr><td><xsl:value-of select="@name" /></td><td><font color="#00FF00">PASS</font></td><td></td><td></td></tr>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="failure">
|
||||
<td>
|
||||
<b><font color="#FF0000">FAILED</font></b>
|
||||
</td>
|
||||
<td>
|
||||
<font color="#ff0000">
|
||||
<xsl:value-of select="@message" />
|
||||
</font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="#ff0000">
|
||||
<xsl:value-of select="@type" />
|
||||
</font>
|
||||
</td>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="error">
|
||||
<td>
|
||||
<b><font color="#FF0000">FAILED</font></b>
|
||||
</td>
|
||||
<td>
|
||||
<font color="#ff0000">
|
||||
<xsl:value-of select="@message" />
|
||||
</font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="#ff0000">
|
||||
<xsl:value-of select="@type" />
|
||||
</font>
|
||||
</td>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) 2015-2017, Arm Limited and affiliates.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
make test
|
|
@ -1,19 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = 6lowpan_mesh_unit
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Mesh/mesh.c \
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
test_mesh.cpp \
|
||||
mesh_test.cpp \
|
||||
../../stub/6lowpan_mesh_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mesh.h"
|
||||
|
||||
TEST_GROUP(6lowpan_mesh)
|
||||
{
|
||||
test_6lowpan_mesh *unit = NULL;
|
||||
|
||||
void setup() {
|
||||
unit = new test_6lowpan_mesh();
|
||||
}
|
||||
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(6lowpan_mesh, Create)
|
||||
{
|
||||
CHECK(unit != NULL);
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_supports_multicast)
|
||||
{
|
||||
unit->test_mesh_supports_multicast();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_short_address_is_multicast)
|
||||
{
|
||||
unit->test_mesh_short_address_is_multicast();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_short_address_is_broadcast_or_multicast)
|
||||
{
|
||||
unit->test_mesh_short_address_is_broadcast_or_multicast();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_up)
|
||||
{
|
||||
unit->test_mesh_up();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_forwardable_address)
|
||||
{
|
||||
unit->test_mesh_forwardable_address();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_address_map)
|
||||
{
|
||||
unit->test_mesh_address_map();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_header_needed)
|
||||
{
|
||||
unit->test_mesh_header_needed();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_header_size)
|
||||
{
|
||||
unit->test_mesh_header_size();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_header_len_from_type_byte)
|
||||
{
|
||||
unit->test_mesh_header_len_from_type_byte();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_header_len_from_buffer_type_byte)
|
||||
{
|
||||
unit->test_mesh_header_len_from_buffer_type_byte();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_rewrite_bc0_header)
|
||||
{
|
||||
unit->test_mesh_rewrite_bc0_header();
|
||||
}
|
||||
|
||||
TEST(6lowpan_mesh, test_mesh_down)
|
||||
{
|
||||
unit->test_mesh_down();
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mesh.h"
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include "Core/include/ns_buffer.h"
|
||||
|
||||
test_6lowpan_mesh::test_6lowpan_mesh()
|
||||
{
|
||||
}
|
||||
|
||||
test_6lowpan_mesh::~test_6lowpan_mesh()
|
||||
{
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_supports_multicast()
|
||||
{
|
||||
bool supports = false;
|
||||
mesh_all_addresses_unicast(supports);
|
||||
CHECK(mesh_supports_multicast() != supports);
|
||||
supports = true;
|
||||
mesh_all_addresses_unicast(supports);
|
||||
CHECK(mesh_supports_multicast() != supports);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_short_address_is_multicast()
|
||||
{
|
||||
mesh_all_addresses_unicast(true);
|
||||
//CHECK(mesh_short_address_is_multicast(0)==false);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_short_address_is_broadcast_or_multicast()
|
||||
{
|
||||
mesh_all_addresses_unicast(true);
|
||||
//CHECK(mesh_short_address_is_broadcast_or_multicast(0)==false);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_up()
|
||||
{
|
||||
buffer_t buf = {};
|
||||
CHECK(mesh_up(&buf) == NULL);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_forwardable_address()
|
||||
{
|
||||
protocol_interface_info_entry_t et = {};
|
||||
addrtype_t addr;
|
||||
uint8_t some = 2;
|
||||
CHECK(mesh_forwardable_address(&et, addr, &some) == false);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_address_map()
|
||||
{
|
||||
protocol_interface_info_entry_t et = {};
|
||||
addrtype_t addr;
|
||||
uint8_t some = 2;
|
||||
CHECK(mesh_address_map(&et, &addr, &some) == true);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_header_needed()
|
||||
{
|
||||
buffer_t buf = {};
|
||||
CHECK(mesh_header_needed(&buf) == false);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_header_size()
|
||||
{
|
||||
buffer_t buf = {};
|
||||
CHECK(mesh_header_size(&buf) == 0);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_header_len_from_type_byte()
|
||||
{
|
||||
CHECK(mesh_header_len_from_type_byte(0) == 0);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_header_len_from_buffer_type_byte()
|
||||
{
|
||||
buffer_t buf = {};
|
||||
CHECK(mesh_header_len_from_buffer_type_byte(&buf) == 0);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_rewrite_bc0_header()
|
||||
{
|
||||
uint8_t val = 0;
|
||||
mesh_rewrite_bc0_header(&val);
|
||||
}
|
||||
|
||||
void test_6lowpan_mesh::test_mesh_down()
|
||||
{
|
||||
buffer_t buf = {};
|
||||
CHECK(mesh_down(&buf) == NULL);
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_6LOWPAN_MESH_H
|
||||
#define TEST_6LOWPAN_MESH_H
|
||||
|
||||
#include "nsconfig.h"
|
||||
#include <string.h>
|
||||
#include <ns_list.h>
|
||||
#include "common_functions.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "NWK_INTERFACE/Include/protocol_stats.h"
|
||||
#include "6LoWPAN/IPHC_Decode/cipv6.h"
|
||||
#include "mesh.h"
|
||||
|
||||
|
||||
class test_6lowpan_mesh
|
||||
{
|
||||
public:
|
||||
test_6lowpan_mesh();
|
||||
virtual ~test_6lowpan_mesh();
|
||||
void test_mesh_supports_multicast();
|
||||
void test_mesh_short_address_is_multicast();
|
||||
void test_mesh_short_address_is_broadcast_or_multicast();
|
||||
void test_mesh_up();
|
||||
void test_mesh_forwardable_address();
|
||||
void test_mesh_address_map();
|
||||
void test_mesh_header_needed();
|
||||
void test_mesh_header_size();
|
||||
void test_mesh_header_len_from_type_byte();
|
||||
void test_mesh_header_len_from_buffer_type_byte();
|
||||
void test_mesh_rewrite_bc0_header();
|
||||
void test_mesh_down();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = nwk_nvm_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/NVM/nwk_nvm.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
nwk_nvmtest.cpp \
|
||||
test_nwk_nvm.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_service_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/platform_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/etx_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/mesh_stub.c \
|
||||
../../stub/iphc_decompress_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(nwk_nvm);
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_nwk_nvm.h"
|
||||
|
||||
TEST_GROUP(nwk_nvm)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(nwk_nvm, test_net_nvm_wpan_params_storage_enable)
|
||||
{
|
||||
CHECK(test_net_nvm_wpan_params_storage_enable());
|
||||
}
|
||||
|
||||
TEST(nwk_nvm, test_net_nvm_wpan_params_storage_disable)
|
||||
{
|
||||
CHECK(test_net_nvm_wpan_params_storage_disable());
|
||||
}
|
||||
|
||||
TEST(nwk_nvm, test_net_nvm_wpan_params_storage_reset)
|
||||
{
|
||||
CHECK(test_net_nvm_wpan_params_storage_reset());
|
||||
}
|
||||
|
||||
TEST(nwk_nvm, test_net_nvm_usage)
|
||||
{
|
||||
CHECK(test_net_nvm_usage());
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_nwk_nvm.h"
|
||||
#include <string.h>
|
||||
#include "ns_types.h"
|
||||
#include "eventOS_event.h"
|
||||
#include "ns_trace.h"
|
||||
#include "string.h"
|
||||
#include "randLIB.h"
|
||||
#include "nsdynmemLIB.h"
|
||||
#include "net_nvm_api.h"
|
||||
#include "Core/include/socket.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "6LoWPAN/MAC/mac_helper.h"
|
||||
#include "6LoWPAN/NVM/nwk_nvm.h"
|
||||
#include "Service_Libs/mle_service/mle_service_api.h"
|
||||
|
||||
#include "address_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "mesh_stub.h"
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "buffer_dyn_stub.h"
|
||||
#include "common_functions_stub.h"
|
||||
|
||||
#define C_CHECK(condition) \
|
||||
do { if (!(condition)) { printf("ERROR: %s at file %s on line %d\n", #condition, __FILE__, __LINE__); return false; } } while(0)
|
||||
|
||||
//Stubbed test data
|
||||
wpan_nvm_params_t test_params;
|
||||
|
||||
|
||||
static void test_wpan_params_updated(wpan_nvm_params_t *parameters)
|
||||
{
|
||||
test_params = *parameters;
|
||||
}
|
||||
|
||||
static bool test_wpan_params_get(wpan_nvm_params_t *parameters)
|
||||
{
|
||||
if (parameters->pan_id == test_params.pan_id) {
|
||||
*parameters = test_params;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void test_params_set(uint16_t pan_id, uint32_t mac_counter, uint32_t mle_counter)
|
||||
{
|
||||
test_params.pan_id = pan_id;
|
||||
test_params.mac_security_frame_counter = mac_counter;
|
||||
test_params.mle_securit_counter = mle_counter;
|
||||
}
|
||||
|
||||
bool test_net_nvm_wpan_params_storage_enable(void)
|
||||
{
|
||||
protocol_interface_info_entry_t interface;
|
||||
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
|
||||
protocol_core_stub.entry_ptr = &interface;
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
int8_t ret = net_nvm_wpan_params_storage_enable(0, NULL, NULL);
|
||||
C_CHECK( ret == -1 );
|
||||
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
ret = net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
C_CHECK( ret == -1 );
|
||||
protocol_core_stub.entry_ptr = &interface;
|
||||
ret = net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
C_CHECK( ret == -2 );
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
ret = net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
C_CHECK( ret == 0 );
|
||||
|
||||
ret = net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
C_CHECK( ret == 0 );
|
||||
|
||||
net_nvm_wpan_params_storage_disable(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_net_nvm_wpan_params_storage_disable(void)
|
||||
{
|
||||
protocol_interface_info_entry_t interface;
|
||||
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
int8_t ret = net_nvm_wpan_params_storage_disable(0);
|
||||
|
||||
protocol_core_stub.entry_ptr = &interface;
|
||||
ret = net_nvm_wpan_params_storage_disable(0);
|
||||
C_CHECK( ret == -1 );
|
||||
net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
ret = net_nvm_wpan_params_storage_disable(0);
|
||||
C_CHECK( ret == 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_net_nvm_wpan_params_storage_reset(void)
|
||||
{
|
||||
protocol_interface_info_entry_t interface;
|
||||
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
int8_t ret = net_nvm_wpan_params_storage_reset(0);
|
||||
C_CHECK( ret == -1 );
|
||||
protocol_core_stub.entry_ptr = &interface;
|
||||
ret = net_nvm_wpan_params_storage_reset(0);
|
||||
C_CHECK( ret == -1 );
|
||||
|
||||
net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
ret = net_nvm_wpan_params_storage_reset(0);
|
||||
C_CHECK( ret == 0 );
|
||||
|
||||
net_nvm_wpan_params_storage_disable(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_net_nvm_usage(void)
|
||||
{
|
||||
protocol_interface_info_entry_t interface;
|
||||
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
protocol_core_stub.entry_ptr = &interface;
|
||||
net_nvm_wpan_params_storage_enable(0, test_wpan_params_updated, test_wpan_params_get);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api);
|
||||
//Now lets start using and testing from stack and APP function callbacks
|
||||
//Test GET all possible
|
||||
test_params_set(0xface, 100, 101);
|
||||
|
||||
interface.nwk_wpan_nvm_api->nvm_params_update_cb(interface.nwk_wpan_nvm_api, false);
|
||||
|
||||
//Test that we load from NVM and start using updated frame counters
|
||||
wpan_nvm_params_t *result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api,0xface);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (100+1000));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (101+1000));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (100+1000));
|
||||
C_CHECK( test_params.mle_securit_counter == (101+1000));
|
||||
|
||||
result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api, 0xbabe);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (0));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (0));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (0));
|
||||
C_CHECK( test_params.mle_securit_counter == (0));
|
||||
|
||||
|
||||
mac_helper_link_frame_counter_set(0,900);
|
||||
|
||||
interface.nwk_wpan_nvm_api->nvm_params_update_cb(interface.nwk_wpan_nvm_api, false);
|
||||
result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api, 0xbabe);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (0));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (0));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (0));
|
||||
C_CHECK( test_params.mle_securit_counter == (0));
|
||||
mac_helper_link_frame_counter_set(0, 951);
|
||||
interface.nwk_wpan_nvm_api->nvm_params_update_cb(interface.nwk_wpan_nvm_api, false);
|
||||
result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api, 0xbabe);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (951));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (0));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (951));
|
||||
C_CHECK( test_params.mle_securit_counter == (0));
|
||||
mac_helper_link_frame_counter_set(0, 1030);
|
||||
interface.nwk_wpan_nvm_api->nvm_params_update_cb(interface.nwk_wpan_nvm_api, true);
|
||||
result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api, 0xbabe);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (1030));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (0));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (951));
|
||||
C_CHECK( test_params.mle_securit_counter == (0));
|
||||
net_nvm_wpan_params_storage_reset(0);
|
||||
result = interface.nwk_wpan_nvm_api->nvm_params_get_cb(interface.nwk_wpan_nvm_api, 0xbabe);
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mac_security_frame_counter == (1951));
|
||||
C_CHECK( interface.nwk_wpan_nvm_api->params.mle_securit_counter == (1000));
|
||||
C_CHECK( test_params.mac_security_frame_counter == (1951));
|
||||
C_CHECK( test_params.mle_securit_counter == (1000));
|
||||
|
||||
net_nvm_wpan_params_storage_disable(0);
|
||||
return true;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_NWK_NVM_H
|
||||
#define TEST_NWK_NVM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_net_nvm_wpan_params_storage_enable(void);
|
||||
bool test_net_nvm_wpan_params_storage_disable(void);
|
||||
bool test_net_nvm_wpan_params_storage_reset(void);
|
||||
bool test_net_nvm_usage(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = adaptation_interface_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/adaptation_interface.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
adaptation_interfacetest.cpp \
|
||||
test_adaptation_interface.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/platform_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/etx_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/mesh_stub.c \
|
||||
../../stub/iphc_decompress_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_adaptation_interface.h"
|
||||
|
||||
TEST_GROUP(adaptation_interface)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_interface_init)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_interface_init());
|
||||
}
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_interface_free)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_interface_free());
|
||||
}
|
||||
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_interface_reset)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_interface_reset());
|
||||
}
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adapatation_data_process_tx_preprocess)
|
||||
{
|
||||
CHECK(test_lowpan_adapatation_data_process_tx_preprocess());
|
||||
}
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_indirect_purge)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_indirect_purge());
|
||||
}
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_interface_tx)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_interface_tx());
|
||||
}
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_interface_tx_confirm)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_interface_tx_confirm());
|
||||
}
|
||||
|
||||
|
||||
TEST(adaptation_interface, test_lowpan_adaptation_tx_active)
|
||||
{
|
||||
CHECK(test_lowpan_adaptation_tx_active());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(adaptation_interface);
|
||||
|
|
@ -1,920 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_adaptation_interface.h"
|
||||
#include <string.h>
|
||||
#include "6LoWPAN/lowpan_adaptation_interface.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "MAC/rf_driver_storage.h"
|
||||
#include "ns_error_types.h"
|
||||
#include "mle.h"
|
||||
#include "mlme.h"
|
||||
#include "mac_api.h"
|
||||
|
||||
#include "address_stub.h"
|
||||
#include "mle_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "socket_stub.h"
|
||||
#include "mesh_stub.h"
|
||||
#include "rpl_data_stub.h"
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "buffer_dyn_stub.h"
|
||||
#include "common_functions_stub.h"
|
||||
|
||||
static void mcps_data_req_cb(const mac_api_t* api, const mcps_data_req_t *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_interface_init()
|
||||
{
|
||||
if (-2 != lowpan_adaptation_interface_init(0, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_init(0, 127)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_init(0, 127)) {
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (-1 != lowpan_adaptation_interface_init(0, 127)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_init(0, 127)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_init(0, 127)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lowpan_adaptation_interface_free(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_interface_free()
|
||||
{
|
||||
if (-1 != lowpan_adaptation_interface_free(0)) {
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_free(1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != lowpan_adaptation_interface_free(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_interface_reset()
|
||||
{
|
||||
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
buffer_dyn_stub.buffer_ptr = NULL;
|
||||
|
||||
buffer_t buf;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buffer_dyn_stub.buffer_ptr = &buf;
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buf.buf_ptr = 10;
|
||||
buf.buf_end = 80;
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_reset(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
|
||||
//Set 2 direct and 2 indirect buffer
|
||||
buf.link_specific.ieee802_15_4.indirectTxProcess = false;
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
buf.link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
|
||||
if (0 != lowpan_adaptation_interface_reset(0)) {
|
||||
return false;
|
||||
}
|
||||
lowpan_adaptation_interface_free(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_lowpan_adapatation_data_process_tx_preprocess()
|
||||
{
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
buffer_t buf;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buf.dst_sa.addr_type = ADDR_NONE;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buffer_dyn_stub.buffer_ptr = &buf;
|
||||
buf.buf_ptr = 10;
|
||||
buf.buf_end = 80;
|
||||
socket_stub.buffer_ptr = NULL;
|
||||
if (lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mle_neigh_table_entry_t mle;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle;
|
||||
mle.mode = 8;
|
||||
mle.handshakeReady = false;
|
||||
mle.thread_commission = false;
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
buf.options.ll_security_bypass_tx = false;
|
||||
socket_stub.buffer_ptr = &buf;
|
||||
if (lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test Broadcast
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
mle.handshakeReady = true;
|
||||
address_stub.uint8_value = 0;
|
||||
if (!lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf.link_specific.ieee802_15_4.indirectTxProcess
|
||||
|| buf.link_specific.ieee802_15_4.requestAck) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
address_stub.uint8_value = 2;
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_LONG;
|
||||
buf.link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_MODE_DEFAULT;
|
||||
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
if (!lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf.link_specific.ieee802_15_4.indirectTxProcess
|
||||
|| !buf.link_specific.ieee802_15_4.requestAck
|
||||
|| buf.link_specific.ieee802_15_4.key_id_mode
|
||||
== B_SECURITY_KEY_ID_MODE_DEFAULT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle;
|
||||
|
||||
if (!lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf.link_specific.ieee802_15_4.indirectTxProcess
|
||||
|| !buf.link_specific.ieee802_15_4.requestAck
|
||||
|| !buf.link_specific.ieee802_15_4.key_id_mode
|
||||
== B_SECURITY_KEY_ID_MODE_DEFAULT) {
|
||||
return false;
|
||||
}
|
||||
mle.mode = 0;
|
||||
|
||||
if (!lowpan_adaptation_data_process_tx_preprocess(&entry, &buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!buf.link_specific.ieee802_15_4.indirectTxProcess
|
||||
|| !buf.link_specific.ieee802_15_4.requestAck
|
||||
|| !buf.link_specific.ieee802_15_4.key_id_mode
|
||||
== B_SECURITY_KEY_ID_MODE_DEFAULT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void tester_mcps_purge_request(const mac_api_t* api,
|
||||
const mcps_purge_t *data)
|
||||
{
|
||||
(void) api;
|
||||
(void) data;
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_indirect_purge()
|
||||
{
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
params.mac_channel = 11;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
api.mcps_purge_req = &tester_mcps_purge_request;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
buffer_t *test_buf = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf, 0, sizeof(buffer_t));
|
||||
|
||||
test_buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
test_buf->buf_ptr = 10;
|
||||
test_buf->buf_end = 70;
|
||||
|
||||
socket_stub.buffer_ptr = test_buf;
|
||||
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
|
||||
//Test Indirect data allocation fail
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_t *test_buf2 = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf2, 0, sizeof(buffer_t));
|
||||
test_buf2->buf_ptr = 10;
|
||||
test_buf2->buf_end = 70;
|
||||
|
||||
test_buf2->dst_sa.addr_type = ADDR_802_15_4_LONG;
|
||||
test_buf2->link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf2)) {
|
||||
return false;
|
||||
}
|
||||
entry.id = 2;
|
||||
if (-1
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf->dst_sa.address,
|
||||
test_buf->dst_sa.addr_type)) {
|
||||
return false;
|
||||
}
|
||||
entry.id = 0;
|
||||
if (-0
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf->dst_sa.address,
|
||||
test_buf->dst_sa.addr_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-0
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf2->dst_sa.address, ADDR_NONE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// purge with addr none
|
||||
test_buf2->dst_sa.addr_type = ADDR_NONE;
|
||||
if (-0
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf2->dst_sa.address, ADDR_NONE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf2->dst_sa.addr_type = ADDR_802_15_4_LONG;
|
||||
|
||||
test_buf2->dst_sa.address[2] = 2;
|
||||
if (-0
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf2->dst_sa.address,
|
||||
test_buf2->dst_sa.addr_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf2->dst_sa.address[2] = 0;
|
||||
|
||||
if (-0
|
||||
!= lowpan_adaptation_indirect_free_messages_from_queues_by_address(
|
||||
&entry, test_buf2->dst_sa.address,
|
||||
test_buf2->dst_sa.addr_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lowpan_adaptation_interface_free(0);
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_interface_tx()
|
||||
{
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
params.mac_channel = 11;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
api.mcps_purge_req = &tester_mcps_purge_request;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
buffer_t *test_buf = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf, 0, sizeof(buffer_t) + 2100);
|
||||
|
||||
test_buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
test_buf->buf_ptr = 10;
|
||||
test_buf->buf_end = 70;
|
||||
|
||||
socket_stub.buffer_ptr = NULL;
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx(NULL, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.mac_api = NULL;
|
||||
socket_stub.buffer_ptr = test_buf;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.mac_api = &api;
|
||||
api.mcps_data_req = NULL;
|
||||
socket_stub.buffer_ptr = NULL;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test Indirect data allocation fail
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
|
||||
if (0 != lowpan_adaptation_indirect_queue_params_set(&entry, 106, 1, 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->buf_end = 2100;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
test_buf->link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
//Fragmented
|
||||
mac_helper_stub.uint16_value = 69;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->buf_end = 300;
|
||||
|
||||
uint8_t *ptr = test_buf->buf + test_buf->buf_ptr;
|
||||
*ptr = 0x80;
|
||||
ptr += 4;
|
||||
*ptr = 0x50;
|
||||
mesh_stub.uint8_value = 66;
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (-1 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mesh_stub.uint8_value = 4;
|
||||
|
||||
test_buf->buf_ptr = 10;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (test_buf->buf_ptr != 16) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check force security on fragmented packets
|
||||
test_buf->options.ll_security_bypass_tx = true;
|
||||
test_buf->options.ll_sec_bypass_frag_deny = true;
|
||||
test_buf->buf_end = 300;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
if (test_buf->options.ll_security_bypass_tx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Not fragmented
|
||||
test_buf->link_specific.ieee802_15_4.requestAck = true;
|
||||
mac_helper_stub.uint16_value = 110;
|
||||
test_buf->buf_end = 90;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mac_helper_stub.uint8_value = 4;
|
||||
test_buf->link_specific.ieee802_15_4.key_id_mode =
|
||||
B_SECURITY_KEY_ID_IMPLICIT;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.key_id_mode =
|
||||
B_SECURITY_KEY_ID_MODE_DEFAULT;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_2;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.useDefaultPanId = false;
|
||||
test_buf->link_specific.ieee802_15_4.dstPanId = 0xffff;
|
||||
test_buf->link_specific.ieee802_15_4.requestAck = false;
|
||||
test_buf->link_specific.ieee802_15_4.indirectTxProcess = false;
|
||||
test_buf->link_specific.ieee802_15_4.rf_channel_switch = true;
|
||||
test_buf->link_specific.ieee802_15_4.selected_channel = 12;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)
|
||||
&& test_buf->link_specific.ieee802_15_4.selected_channel == 12) {
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf->link_specific.ieee802_15_4.useDefaultPanId = true;
|
||||
test_buf->link_specific.ieee802_15_4.requestAck = true;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_t *test_buf2 = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf2, 0, sizeof(buffer_t));
|
||||
|
||||
test_buf2->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
|
||||
test_buf2->link_specific.ieee802_15_4.useDefaultPanId = true;
|
||||
test_buf2->link_specific.ieee802_15_4.requestAck = true;
|
||||
test_buf2->link_specific.ieee802_15_4.indirectTxProcess = false;
|
||||
test_buf2->link_specific.ieee802_15_4.rf_channel_switch = true;
|
||||
test_buf2->link_specific.ieee802_15_4.selected_channel = 12;
|
||||
test_buf2->buf_end = 90;
|
||||
test_buf2->priority = QOS_HIGH;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_t *test_buf3 = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf3, 0, sizeof(buffer_t) + 2100);
|
||||
|
||||
test_buf3->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
|
||||
test_buf3->link_specific.ieee802_15_4.requestAck = true;
|
||||
test_buf3->buf_end = 90;
|
||||
test_buf3->priority = QOS_HIGH;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx(&entry, test_buf3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lowpan_adaptation_interface_free(0);
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_interface_tx_confirm()
|
||||
{
|
||||
mac_api_t api;
|
||||
mcps_data_conf_t data_confirm;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
params.mac_channel = 11;
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
mac_helper_stub.uint16_value = 110;
|
||||
mac_helper_stub.uint8_value = 4;
|
||||
|
||||
memset(&data_confirm, 0, sizeof(mcps_data_conf_t));
|
||||
|
||||
buffer_t *test_buf = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf, 0, sizeof(buffer_t) + 2100);
|
||||
|
||||
entry.mac_parameters->mac_in_direct_entry_timeout = 14000;
|
||||
test_buf->link_specific.ieee802_15_4.useDefaultPanId = true;
|
||||
test_buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
test_buf->buf_ptr = 10;
|
||||
test_buf->buf_end = 70;
|
||||
test_buf->link_specific.ieee802_15_4.requestAck = true;
|
||||
test_buf->link_specific.ieee802_15_4.key_id_mode =
|
||||
B_SECURITY_KEY_ID_MODE_DEFAULT;
|
||||
test_buf->link_specific.ieee802_15_4.rf_channel_switch = true;
|
||||
test_buf->link_specific.ieee802_15_4.selected_channel = 11;
|
||||
|
||||
buffer_t *test_buf2 = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf2, 0, sizeof(buffer_t) + 2100);
|
||||
test_buf2->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
test_buf2->buf_ptr = 10;
|
||||
test_buf2->buf_end = 70;
|
||||
test_buf2->link_specific.ieee802_15_4.requestAck = true;
|
||||
test_buf2->link_specific.ieee802_15_4.rf_channel_switch = true;
|
||||
test_buf2->link_specific.ieee802_15_4.selected_channel = 12;
|
||||
|
||||
buffer_t *test_buf3 = malloc(sizeof(buffer_t) + 2100);
|
||||
memset(test_buf3, 0, sizeof(buffer_t) + 2100);
|
||||
test_buf3->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
test_buf3->buf_ptr = 10;
|
||||
test_buf3->buf_end = 70;
|
||||
test_buf3->link_specific.ieee802_15_4.requestAck = true;
|
||||
test_buf3->link_specific.ieee802_15_4.indirectTxProcess = true;
|
||||
|
||||
entry.mac_api = &api;
|
||||
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(NULL, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(&entry, NULL)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
test_buf2->ip_routed_up = true;
|
||||
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf);
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf2);
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf3);
|
||||
|
||||
data_confirm.msduHandle = 10;
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_confirm.msduHandle = test_buf->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_confirm.msduHandle = test_buf2->seq;
|
||||
data_confirm.status = MLME_BUSY_CHAN;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_confirm.msduHandle = test_buf2->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_confirm.msduHandle = test_buf3->seq;
|
||||
data_confirm.status = MLME_TRANSACTION_EXPIRED;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
data_confirm.msduHandle = test_buf3->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
buffer_routing_info_t buf_route;
|
||||
test_buf2->route = &buf_route;
|
||||
rpl_data_stub.bool_value = true;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf2);
|
||||
data_confirm.msduHandle = test_buf2->seq;
|
||||
data_confirm.status = MLME_TX_NO_ACK;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
test_buf2->buf_end = 200;
|
||||
test_buf2->ip_routed_up = false;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf2);
|
||||
data_confirm.msduHandle = test_buf2->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (test_buf2->buf_end != test_buf2->buf_ptr) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
//Test Fragmentation fail
|
||||
test_buf2->buf_ptr = 10;
|
||||
test_buf2->buf_end = 200;
|
||||
socket_stub.buffer_ptr = test_buf2;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf2);
|
||||
data_confirm.msduHandle = test_buf2->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
data_confirm.status = MLME_TX_NO_ACK;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
socket_stub.buffer_ptr = NULL;
|
||||
|
||||
test_buf3->buf_end = 300;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf3);
|
||||
data_confirm.msduHandle = test_buf3->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
data_confirm.status = MLME_BUSY_CHAN;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check route_up with fragmentation
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
test_buf3->buf_end += 200;
|
||||
test_buf3->ip_routed_up = true;
|
||||
lowpan_adaptation_interface_tx(&entry, test_buf3);
|
||||
data_confirm.msduHandle = test_buf3->seq;
|
||||
data_confirm.status = MLME_SUCCESS;
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
if (0 != lowpan_adaptation_interface_tx_confirm(&entry, &data_confirm)) {
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return false;
|
||||
}
|
||||
|
||||
lowpan_adaptation_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static buffer_t * test_fragment_first_96(buffer_t *buf, uint8_t index)
|
||||
{
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 232;
|
||||
common_functions_stub.uint16_value_queue[0] = 100 + index;
|
||||
buf->buf_ptr = 0;
|
||||
buf->buf_end = 100;
|
||||
|
||||
uint8_t *ptr = buf->buf + buf->buf_ptr;
|
||||
*ptr = 0xc0; //first sequency
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
static buffer_t * test_fragment_last_96(buffer_t *buf, uint8_t index)
|
||||
{
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 232;
|
||||
common_functions_stub.uint16_value_queue[0] = 100 + index;
|
||||
buf->buf_ptr = 0;
|
||||
buf->buf_end = 101;
|
||||
|
||||
uint8_t *ptr = buf->buf + buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
bool test_lowpan_adaptation_tx_active()
|
||||
{
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
entry.id = 0;
|
||||
api.mcps_data_req = &mcps_data_req_cb;
|
||||
if (lowpan_adaptation_tx_active(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
lowpan_adaptation_interface_init(0, 127);
|
||||
if (lowpan_adaptation_tx_active(0)) {
|
||||
return false;
|
||||
}
|
||||
buffer_t buf;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buffer_dyn_stub.buffer_ptr = &buf;
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
buf.buf_ptr = 10;
|
||||
buf.buf_end = 80;
|
||||
buf.link_specific.ieee802_15_4.indirectTxProcess = false;
|
||||
lowpan_adaptation_interface_tx(&entry, &buf);
|
||||
if (!lowpan_adaptation_tx_active(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lowpan_adaptation_interface_free(0);
|
||||
return true;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_ADAPTATION_INTERFACE_H
|
||||
#define TEST_ADAPTATION_INTERFACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_lowpan_adaptation_interface_init();
|
||||
|
||||
bool test_lowpan_adaptation_interface_free();
|
||||
|
||||
bool test_lowpan_adaptation_interface_reset();
|
||||
|
||||
bool test_lowpan_adapatation_data_process_tx_preprocess();
|
||||
|
||||
bool test_lowpan_adaptation_interface_tx();
|
||||
|
||||
bool test_lowpan_adaptation_interface_tx_confirm();
|
||||
|
||||
bool test_lowpan_adaptation_tx_active();
|
||||
|
||||
bool test_lowpan_adaptation_indirect_purge();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_ADAPTATION_INTERFACE_H
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = nd_router_object_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/ND/nd_router_object.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
nd_router_objecttest.cpp \
|
||||
test_nd_router_object.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/protocol_6lowpan_bootstrap_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/icmpv6_radv_stub.c \
|
||||
../../stub/icmpv6_prefix_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/mac_data_poll_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/whiteboard_stub.c \
|
||||
../../stub/lowpan_context_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
../../stub/border_router_stub.c \
|
||||
../../stub/pan_blacklist_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT -DHAVE_6LOWPAN_ND
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(nd_router_object);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_nd_router_object.h"
|
||||
|
||||
TEST_GROUP(nd_router_object)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(nd_router_object, test_icmp_nd_routers_init)
|
||||
{
|
||||
CHECK(test_icmp_nd_routers_init());
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_nd_router_object.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
bool test_icmp_nd_routers_init()
|
||||
{
|
||||
icmp_nd_routers_init();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_ND_ROUTER_OBJECT_H
|
||||
#define TEST_ND_ROUTER_OBJECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_icmp_nd_routers_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_ND_ROUTER_OBJECT_H
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = reassembly_interface_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Fragmentation/cipv6_fragmenter.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
reassembly_interfacetest.cpp \
|
||||
test_cipv6_reassembly_interface.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/platform_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/etx_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/mesh_stub.c \
|
||||
../../stub/iphc_decompress_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(reassembly_interface);
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_cipv6_reassembly_interface.h"
|
||||
|
||||
TEST_GROUP(reassembly_interface)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(reassembly_interface, test_reassembly_interface_init)
|
||||
{
|
||||
CHECK(test_reassembly_interface_init());
|
||||
}
|
||||
|
||||
TEST(reassembly_interface, test_reassembly_interface_reset)
|
||||
{
|
||||
CHECK(test_reassembly_interface_reset());
|
||||
}
|
||||
|
||||
TEST(reassembly_interface, test_reassembly_interface_free)
|
||||
{
|
||||
CHECK(test_reassembly_interface_free());
|
||||
}
|
||||
|
||||
TEST(reassembly_interface, test_cipv6_frag_timer)
|
||||
{
|
||||
CHECK(test_cipv6_frag_timer());
|
||||
}
|
||||
|
||||
TEST(reassembly_interface, test_cipv6_frag_reassembly)
|
||||
{
|
||||
CHECK(test_cipv6_frag_reassembly());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,623 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include <string.h>
|
||||
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "MAC/rf_driver_storage.h"
|
||||
#include "ns_error_types.h"
|
||||
#include "mle.h"
|
||||
#include "mlme.h"
|
||||
#include "mac_api.h"
|
||||
|
||||
#include "address_stub.h"
|
||||
#include "mle_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "socket_stub.h"
|
||||
#include "mesh_stub.h"
|
||||
#include "rpl_data_stub.h"
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "buffer_dyn_stub.h"
|
||||
#include "common_functions_stub.h"
|
||||
|
||||
|
||||
bool test_reassembly_interface_init()
|
||||
{
|
||||
|
||||
if (-2 != reassembly_interface_init(0, 0, 5) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-2 != reassembly_interface_init(0, 8, 0) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
|
||||
if (-1 != reassembly_interface_init(0, 8, 5) ) {
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (-1 != reassembly_interface_init(0, 8, 5) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != reassembly_interface_init(0, 8, 5) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (0 != reassembly_interface_init(0, 8, 5) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_interface_free(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_reassembly_interface_free()
|
||||
{
|
||||
if (-1 != reassembly_interface_free(0) ) {
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
reassembly_interface_init(0, 8, 5);
|
||||
|
||||
if (-1 != reassembly_interface_free(1) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != reassembly_interface_free(0) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static buffer_t * test_fragment_first_96(buffer_t *buf, uint8_t index)
|
||||
{
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 232;
|
||||
common_functions_stub.uint16_value_queue[0] = 100 + index;
|
||||
buf->buf_ptr = 0;
|
||||
buf->buf_end = 100;
|
||||
|
||||
uint8_t *ptr = buf->buf + buf->buf_ptr;
|
||||
*ptr = 0xc0; //first sequency
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static buffer_t * test_fragment_last_96(buffer_t *buf, uint8_t index)
|
||||
{
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 232;
|
||||
common_functions_stub.uint16_value_queue[0] = 100 + index;
|
||||
buf->buf_ptr = 0;
|
||||
buf->buf_end = 101;
|
||||
|
||||
uint8_t *ptr = buf->buf + buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
static buffer_t *test_buffer_get(uint16_t size)
|
||||
{
|
||||
buffer_t *buf = malloc(sizeof (buffer_t) + size);
|
||||
memset(buf, 0, sizeof(buffer_t));
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool test_reassembly_interface_reset()
|
||||
{
|
||||
|
||||
if (-1 != reassembly_interface_reset(0) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
reassembly_interface_init(0, 8, 5);
|
||||
buffer_t *reassembly_buf = test_buffer_get(127);
|
||||
buffer_t *test_buf = test_buffer_get(1500);
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 0);
|
||||
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 1);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
if (0 != reassembly_interface_reset(0) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_interface_free(0);
|
||||
free(test_buf);
|
||||
free(reassembly_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool test_cipv6_frag_reassembly()
|
||||
{
|
||||
|
||||
|
||||
buffer_t *reassembly_buf = test_buffer_get(127);
|
||||
buffer_t *test_buf = test_buffer_get(1500);
|
||||
buffer_t *test_buf2 = test_buffer_get(1500);
|
||||
buffer_t *test_buf3 = test_buffer_get(1500);
|
||||
buffer_t *test_buf4 = test_buffer_get(1500);
|
||||
buffer_t *test_buf5 = test_buffer_get(1500);
|
||||
buffer_t *test_buf6 = test_buffer_get(1500);
|
||||
buffer_t *test_buf7 = test_buffer_get(1500);
|
||||
buffer_t *test_buf8 = test_buffer_get(1500);
|
||||
buffer_t *test_buf9 = test_buffer_get(1500);
|
||||
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
reassembly_interface_init(0, 8, 5);
|
||||
common_functions_stub.readuint16_from_queue = 0;
|
||||
common_functions_stub.uint16_value = 0;
|
||||
|
||||
|
||||
//Test Size zero drop
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_buf->buf_end = 96;
|
||||
//Test buffer allocation fail
|
||||
buffer_dyn_stub.buffer_ptr = NULL;
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 200;
|
||||
common_functions_stub.uint16_value_queue[0] = 100;
|
||||
|
||||
uint8_t *ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
|
||||
*ptr = 0xc0; //First fragment
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test frag out of range
|
||||
address_stub.uint8_value = 2;
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 96;
|
||||
//Test buffer allocation fail
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 160;
|
||||
common_functions_stub.uint16_value_queue[0] = 100;
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 96;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = 96 / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
common_functions_stub.uint16_value_queue[1] = 160;
|
||||
common_functions_stub.uint16_value_queue[0] = 100;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_interface_reset(0);
|
||||
|
||||
|
||||
//Test succesfully fragment push
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 0);
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_buf = test_fragment_last_96(reassembly_buf, 0);
|
||||
|
||||
buffer_t *reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Receive inversr order
|
||||
|
||||
reassembly_buf = test_fragment_last_96(reassembly_buf, 0);
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 0);
|
||||
reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Receive 2., 3. & 1.
|
||||
common_functions_stub.uint16_value_queue[1] = 328;
|
||||
common_functions_stub.uint16_value_queue[0] = 100;
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //sub sequency
|
||||
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192 + 96) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//First , last, middle 1., 3. 2.
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //sub sequency
|
||||
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency Last
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192 + 96) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//3., 2., 1.
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency Last
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //sub sequency
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192 + 96) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Test 2., 1. and 3.
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //first sequency
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
reassemled_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (!reassemled_buffer || (reassemled_buffer->buf_end - reassemled_buffer->buf_ptr) != 192 + 96) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test overlap last
|
||||
common_functions_stub.uint16_value_queue[1] = 328;
|
||||
common_functions_stub.uint16_value_queue[0] = 101;
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //first sequency
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 102;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Overflow first fragment
|
||||
common_functions_stub.uint16_value_queue[1] = 328;
|
||||
common_functions_stub.uint16_value_queue[0] = 102;
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency Last
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //sub sequency
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Overflow middle of
|
||||
common_functions_stub.uint16_value_queue[1] = 328;
|
||||
common_functions_stub.uint16_value_queue[0] = 103;
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 100;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0xc0; //first sequency
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 101;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40 + 96) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_buf->buf_ptr = 0;
|
||||
reassembly_buf->buf_end = 102;
|
||||
ptr = reassembly_buf->buf + reassembly_buf->buf_ptr;
|
||||
*ptr = 0x20; //sub sequency
|
||||
ptr += 4;
|
||||
*ptr = (96 + 40) / 8; //Set offset
|
||||
common_functions_stub.readuint16_from_queue = 2;
|
||||
if (cipv6_frag_reassembly(0, reassembly_buf) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reassembly_interface_reset(0);
|
||||
|
||||
//Test reassembly overflow start 9 tx proces which 1 should fail and 8 other success
|
||||
memset(test_buf, 0, sizeof(buffer_t));
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 0);
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf2;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 1);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf3;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 2);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf4;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 3);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf5;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 4);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf6;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 5);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf7;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 6);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf8;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 7);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf9;
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 8);
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
//Start testing
|
||||
for (uint8_t i= 0; i< 9;i++) {
|
||||
reassembly_buf = test_fragment_last_96(reassembly_buf, i);
|
||||
buffer_t *fully_buffer = cipv6_frag_reassembly(0, reassembly_buf);
|
||||
if (i == 8) {
|
||||
if (fully_buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!fully_buffer || (fully_buffer->buf_end - fully_buffer->buf_ptr) != 192) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reassembly_interface_free(0);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
free(test_buf3);
|
||||
free(test_buf4);
|
||||
free(test_buf5);
|
||||
free(test_buf6);
|
||||
free(test_buf7);
|
||||
free(test_buf8);
|
||||
free(test_buf9);
|
||||
free(reassembly_buf);
|
||||
common_functions_stub.readuint16_from_queue = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_cipv6_frag_timer()
|
||||
{
|
||||
buffer_t *reassembly_buf = test_buffer_get(127);
|
||||
buffer_t *test_buf = test_buffer_get(1500);
|
||||
buffer_t *test_buf2 = test_buffer_get(1500);
|
||||
|
||||
reassembly_buf->dst_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
|
||||
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 0);
|
||||
|
||||
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
reassembly_interface_init(0, 8, 5);
|
||||
|
||||
address_stub.uint8_value = 2;
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
cipv6_frag_timer(1);
|
||||
reassembly_buf = test_fragment_first_96(reassembly_buf, 1);
|
||||
buffer_dyn_stub.buffer_ptr = test_buf2;
|
||||
cipv6_frag_reassembly(0, reassembly_buf);
|
||||
|
||||
|
||||
//Push 2 buffer to queue and time out them
|
||||
buffer_dyn_stub.buffer_ptr = test_buf;
|
||||
cipv6_frag_timer(4);
|
||||
buffer_dyn_stub.buffer_ptr = test_buf2;
|
||||
socket_stub.buffer_ptr = test_buf2;
|
||||
cipv6_frag_timer(4);
|
||||
reassembly_interface_free(0);
|
||||
free(reassembly_buf);
|
||||
free(test_buf);
|
||||
free(test_buf2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_CIPV6_REASSEMBLY_INTERFACE_H
|
||||
#define TEST_CIPV6_REASSEMBLY_INTERFACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_reassembly_interface_init();
|
||||
|
||||
bool test_reassembly_interface_reset();
|
||||
|
||||
bool test_reassembly_interface_free();
|
||||
|
||||
bool test_cipv6_frag_reassembly();
|
||||
|
||||
bool test_cipv6_frag_timer();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_CIPV6_REASSEMBLY_INTERFACE_H
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = beacon_handler_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/MAC/beacon_handler.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
beacon_handlertest.cpp \
|
||||
test_beacon_handler.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/pan_blacklist_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_beacon_handler.h"
|
||||
|
||||
TEST_GROUP(beacon_handler)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(beacon_handler, test_beacon_received)
|
||||
{
|
||||
CHECK(test_beacon_received());
|
||||
}
|
||||
|
||||
TEST(beacon_handler, test_mac_beacon_link_beacon_compare_rx_callback_set)
|
||||
{
|
||||
CHECK(test_mac_beacon_link_beacon_compare_rx_callback_set());
|
||||
}
|
||||
|
||||
TEST(beacon_handler, test_beacon_join_priority_update)
|
||||
{
|
||||
CHECK(test_beacon_join_priority_update());
|
||||
}
|
||||
|
||||
TEST(beacon_handler, test_mac_beacon_link_beacon_join_priority_tx_callback_set)
|
||||
{
|
||||
CHECK(test_mac_beacon_link_beacon_join_priority_tx_callback_set());
|
||||
}
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(beacon_handler);
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_beacon_handler.h"
|
||||
#include "beacon_handler.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "6LoWPAN/Bootstraps/protocol_6lowpan.h"
|
||||
|
||||
#include "protocol_core_stub.h"
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "protocol_6lowpan_stub.h"
|
||||
#include "load_balance_api.h"
|
||||
|
||||
uint8_t *beacon_optional_tlv_field_get(uint8_t len, uint8_t *ptr, uint8_t offset, uint8_t type);
|
||||
|
||||
static uint8_t *beacon_ind_cb(uint8_t *ptr, uint8_t len, protocol_interface_info_entry_t *cur)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t compare_cb(int8_t interface_id, uint8_t join_priority, uint8_t link_quality)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void lb_beac_notify(const load_balance_api_t* api, const struct mlme_beacon_ind_s *beacon_ind, uint8_t priority)
|
||||
{
|
||||
(void)api;
|
||||
(void)beacon_ind;
|
||||
(void)priority;
|
||||
}
|
||||
|
||||
uint8_t beac_ind(uint8_t *ptr, uint8_t len, protocol_interface_info_entry_t *cur)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool test_beacon_received()
|
||||
{
|
||||
//These test cases just confirms that there are no crashes or mem leaks.
|
||||
beacon_received(0, NULL);
|
||||
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
mlme_beacon_ind_t ind;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
struct load_balance_api api;
|
||||
memset(&api, 0, sizeof(struct load_balance_api));
|
||||
api.lb_beacon_notify = &lb_beac_notify;
|
||||
entry.lb_api = &api;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
memset(¶ms, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
params.beacon_ind = &beac_ind;
|
||||
entry.mac_parameters = ¶ms;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
uint8_t beacon_data_in_3[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0x05};
|
||||
ind.beacon_data = malloc(20);
|
||||
memcpy(ind.beacon_data, beacon_data_in_3, sizeof(beacon_data_in_3));
|
||||
ind.beacon_data_length = 20;
|
||||
|
||||
ind.PANDescriptor.CoordPANId = 6;
|
||||
|
||||
beacon_received(0, &ind);
|
||||
|
||||
free(ind.beacon_data);
|
||||
ind.beacon_data = NULL;
|
||||
|
||||
entry.lb_api = NULL;
|
||||
|
||||
params.nwk_scan_params.active_scan_active = true;
|
||||
params.nwk_filter_params.net_pan_id_filter = 1;
|
||||
ind.beacon_data_length = 40;
|
||||
ind.PANDescriptor.CoordPANId = 2;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
ind.PANDescriptor.CoordPANId = 1;
|
||||
params.nwk_filter_params.nwk_active_scan_level = 1;
|
||||
entry.mac_parameters->beacon_ind = &beacon_ind_cb;
|
||||
ind.beacon_data_length = 1;
|
||||
|
||||
beacon_received(0, &ind);
|
||||
|
||||
ind.beacon_data_length = 0;
|
||||
|
||||
beacon_received(0, &ind);
|
||||
|
||||
params.nwk_filter_params.nwk_active_scan_level = 0;
|
||||
|
||||
beacon_received(0, &ind); //ns_dyn_mem_alloc fails
|
||||
|
||||
//Test beacon_join_priority_tlv_val_get here -->
|
||||
params.beacon_compare_rx_cb_ptr = &compare_cb;
|
||||
ind.beacon_data_length = PLAIN_BEACON_PAYLOAD_SIZE+6;
|
||||
uint8_t dat[PLAIN_BEACON_PAYLOAD_SIZE+6];
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE] = 0x00;
|
||||
|
||||
ind.beacon_data = &dat;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
|
||||
//Test scan_params->nwk_response_info ==NULL here -->
|
||||
//Test beacon_optional_tlv_field_get here -->
|
||||
beacon_received(0, &ind); //just end delimiter
|
||||
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE] = 0x01; //len
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE+1] = 0x08; //val
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE+2] = (BEACON_OPTION_JOIN_PRIORITY_TYPE << 4 & 0xf0) +2;
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
beacon_received(0, &ind); //BEACON_OPTION_JOIN_PRIORITY_TYPE
|
||||
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE+2] = (BEACON_OPTION_JOIN_PRIORITY_TYPE << 4 & 0xf0) + 12;
|
||||
|
||||
//Test duplicate_pan_descriptor here -->
|
||||
nsdynmemlib_stub.returnCounter = 3;
|
||||
beacon_received(0, &ind); //BEACON_OPTION_JOIN_PRIORITY_TYPE
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 4;
|
||||
beacon_received(0, &ind); //BEACON_OPTION_JOIN_PRIORITY_TYPE
|
||||
|
||||
ns_dyn_mem_free(params.nwk_scan_params.nwk_response_info->pan_descriptor);
|
||||
ns_dyn_mem_free(params.nwk_scan_params.nwk_response_info->beacon_payload);
|
||||
ns_dyn_mem_free(params.nwk_scan_params.nwk_response_info);
|
||||
//<-- Test duplicate_pan_descriptor here
|
||||
//<-- Test beacon_optional_tlv_field_get here
|
||||
//<-- Test beacon_join_priority_tlv_val_get here
|
||||
//<--Test scan_params->nwk_response_info ==NULL here
|
||||
|
||||
//Test scan_params->nwk_response_info != NULL here -->
|
||||
dat[PLAIN_BEACON_PAYLOAD_SIZE] = 0x00;
|
||||
|
||||
nwk_pan_descriptor_t info;
|
||||
memset(&info, 0, sizeof(nwk_pan_descriptor_t));
|
||||
mlme_pan_descriptor_t pan;
|
||||
info.pan_descriptor = &pan;
|
||||
pan.LogicalChannel = 1;
|
||||
ind.PANDescriptor.LogicalChannel = 2;
|
||||
|
||||
params.nwk_scan_params.nwk_response_info = &info;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 3;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 4;
|
||||
beacon_received(0, &ind);
|
||||
ns_dyn_mem_free(info.next->pan_descriptor);
|
||||
ns_dyn_mem_free(info.next->beacon_payload);
|
||||
ns_dyn_mem_free(info.next);
|
||||
|
||||
mlme_pan_descriptor_t pan2;
|
||||
nwk_pan_descriptor_t info2;
|
||||
info2.pan_descriptor = &pan2;
|
||||
pan2.LogicalChannel = 2;
|
||||
pan2.CoordPANId = 2;
|
||||
ind.PANDescriptor.CoordPANId = 2;
|
||||
info2.pan_descriptor->LinkQuality = 110;
|
||||
info2.alternative_parent.CoordAddrMode = MAC_ADDR_MODE_NONE;
|
||||
info.next = &info2;
|
||||
|
||||
mlme_pan_descriptor_t pan3;
|
||||
nwk_pan_descriptor_t info3;
|
||||
info3.pan_descriptor = &pan3;
|
||||
pan3.LogicalChannel = 3;
|
||||
info2.next = &info3;
|
||||
info3.next = NULL;
|
||||
|
||||
info2.beacon_length = 0;
|
||||
info2.beacon_payload = NULL;
|
||||
|
||||
ind.beacon_data_length = 0;
|
||||
params.nwk_filter_params.net_pan_id_filter = 2;
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
ind.PANDescriptor.LinkQuality = 0;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
info2.pan_descriptor->LinkQuality = 0;
|
||||
ind.PANDescriptor.LinkQuality = 10;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
info2.beacon_payload = ns_dyn_mem_alloc(2);
|
||||
info2.beacon_length = 2;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
info2.pan_descriptor->LinkQuality = 0;
|
||||
ind.beacon_data_length = PLAIN_BEACON_PAYLOAD_SIZE+6;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
beacon_received(0, &ind);
|
||||
|
||||
info2.pan_descriptor->LinkQuality = 0;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
beacon_received(0, &ind);
|
||||
ns_dyn_mem_free( info2.beacon_payload );
|
||||
|
||||
//<--Test scan_params->nwk_response_info != NULL here
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_beacon_link_beacon_compare_rx_callback_set()
|
||||
{
|
||||
if( -1 != mac_beacon_link_beacon_compare_rx_callback_set(0, NULL) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
memset(¶ms, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
entry.mac_parameters = ¶ms;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
//It is okay to set NULL for callback
|
||||
if( 0 != mac_beacon_link_beacon_compare_rx_callback_set(0, NULL) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
|
||||
}
|
||||
|
||||
bool test_beacon_join_priority_update()
|
||||
{
|
||||
//These test cases just confirms that there are no crashes or mem leaks.
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
mlme_beacon_ind_t ind;
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
memset(¶ms, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
entry.mac_parameters = ¶ms;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Uses real storing of beacon payload data
|
||||
mac_helper_stub.enable_storing = true;
|
||||
|
||||
// Sets join priority
|
||||
protocol_6lowpan_stub.uint8_value = 0xe1;
|
||||
entry.mac_parameters->beacon_join_priority_tx_cb_ptr = protocol_6lowpan_beacon_join_priority_tx;
|
||||
|
||||
|
||||
// Test: TLV does not exists.
|
||||
|
||||
// Sets input data
|
||||
uint8_t beacon_data_in_1[18] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
|
||||
entry.mac_parameters->mac_beacon_payload = malloc(18);
|
||||
memcpy(entry.mac_parameters->mac_beacon_payload, beacon_data_in_1, sizeof(beacon_data_in_1));
|
||||
entry.mac_parameters->mac_beacon_payload_size = 18;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Check output data
|
||||
if (entry.mac_parameters->mac_beacon_payload_size != 20) {
|
||||
return false;
|
||||
}
|
||||
uint8_t beacon_data_out_1[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0xe1};
|
||||
if (memcmp(entry.mac_parameters->mac_beacon_payload, beacon_data_out_1, 20) != 0) {
|
||||
return false;
|
||||
}
|
||||
free(entry.mac_parameters->mac_beacon_payload);
|
||||
|
||||
|
||||
// Test: TLV does not exists. Delimiter 0x00 in the end of the beacon.
|
||||
|
||||
uint8_t beacon_data_in_2[19] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0x00};
|
||||
entry.mac_parameters->mac_beacon_payload = malloc(19);
|
||||
memcpy(entry.mac_parameters->mac_beacon_payload, beacon_data_in_2, sizeof(beacon_data_in_2));
|
||||
entry.mac_parameters->mac_beacon_payload_size = 19;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Check output data
|
||||
if (entry.mac_parameters->mac_beacon_payload_size != 21) {
|
||||
return false;
|
||||
}
|
||||
uint8_t beacon_data_out_2[21] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0xe1,0x00};
|
||||
if (memcmp(entry.mac_parameters->mac_beacon_payload, beacon_data_out_2, 21) != 0) {
|
||||
return false;
|
||||
}
|
||||
free(entry.mac_parameters->mac_beacon_payload);
|
||||
|
||||
|
||||
// Test: join priority TLV in the end of the beacon.
|
||||
|
||||
uint8_t beacon_data_in_3[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0x05};
|
||||
entry.mac_parameters->mac_beacon_payload = malloc(20);
|
||||
memcpy(entry.mac_parameters->mac_beacon_payload, beacon_data_in_3, sizeof(beacon_data_in_3));
|
||||
entry.mac_parameters->mac_beacon_payload_size = 20;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Check output data
|
||||
if (entry.mac_parameters->mac_beacon_payload_size != 20) {
|
||||
return false;
|
||||
}
|
||||
uint8_t beacon_data_out_3[21] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0xe1};
|
||||
if (memcmp(entry.mac_parameters->mac_beacon_payload, beacon_data_out_3, 20) != 0) {
|
||||
return false;
|
||||
}
|
||||
free(entry.mac_parameters->mac_beacon_payload);
|
||||
|
||||
|
||||
// Test: two TLVs and after that delimiter and data in the end of the beacon. Second TLV is join priority.
|
||||
|
||||
uint8_t beacon_data_in_4[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xa2,0x03,0x04,0xc1,0x05,0x00,1,2,3};
|
||||
entry.mac_parameters->mac_beacon_payload = malloc(27);
|
||||
memcpy(entry.mac_parameters->mac_beacon_payload, beacon_data_in_4, sizeof(beacon_data_in_4));
|
||||
entry.mac_parameters->mac_beacon_payload_size = 27;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Check output data
|
||||
if (entry.mac_parameters->mac_beacon_payload_size != 27) {
|
||||
return false;
|
||||
}
|
||||
uint8_t beacon_data_out_4[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xa2,0x03,0x04,0xc1,0xe1,0x00,1,2,3};
|
||||
if (memcmp(entry.mac_parameters->mac_beacon_payload, beacon_data_out_4, 27) != 0) {
|
||||
return false;
|
||||
}
|
||||
free(entry.mac_parameters->mac_beacon_payload);
|
||||
|
||||
|
||||
// Test: TLV in the end of the beacon. TLV length is too long.
|
||||
|
||||
uint8_t beacon_data_in_5[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc2,0x05};
|
||||
entry.mac_parameters->mac_beacon_payload = malloc(20);
|
||||
memcpy(entry.mac_parameters->mac_beacon_payload, beacon_data_in_5, sizeof(beacon_data_in_5));
|
||||
entry.mac_parameters->mac_beacon_payload_size = 20;
|
||||
|
||||
beacon_join_priority_update(0x00);
|
||||
|
||||
// Check output data
|
||||
if (entry.mac_parameters->mac_beacon_payload_size != 22) {
|
||||
return false;
|
||||
}
|
||||
uint8_t beacon_data_out_5[22] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,0xc1,0xe1,0xc2,0x05};
|
||||
if (memcmp(entry.mac_parameters->mac_beacon_payload, beacon_data_out_5, 22) != 0) {
|
||||
return false;
|
||||
}
|
||||
free(entry.mac_parameters->mac_beacon_payload);
|
||||
|
||||
|
||||
|
||||
// Reset stub values
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
protocol_6lowpan_stub.uint8_value = 0;
|
||||
mac_helper_stub.enable_storing = false;
|
||||
mac_helper_stub.uint8_ptr = 0;
|
||||
mac_helper_stub.uint8_value = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static uint8_t tester_beacon_join_priority_tx_cb(int8_t interface_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool test_mac_beacon_link_beacon_join_priority_tx_callback_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
memset(¶ms, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
|
||||
|
||||
if (mac_beacon_link_beacon_join_priority_tx_callback_set(0,&tester_beacon_join_priority_tx_cb) != -1) {
|
||||
return false;
|
||||
}
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
if (mac_beacon_link_beacon_join_priority_tx_callback_set(0,&tester_beacon_join_priority_tx_cb) != -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.mac_parameters = ¶ms;
|
||||
if (mac_beacon_link_beacon_join_priority_tx_callback_set(0,&tester_beacon_join_priority_tx_cb) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!entry.mac_parameters->beacon_join_priority_tx_cb_ptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset stub values
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
protocol_6lowpan_stub.uint8_value = 0;
|
||||
mac_helper_stub.enable_storing = false;
|
||||
mac_helper_stub.uint8_ptr = 0;
|
||||
mac_helper_stub.uint8_value = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_BEACON_HANDLER_H
|
||||
#define TEST_BEACON_HANDLER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_beacon_received();
|
||||
|
||||
bool test_mac_beacon_link_beacon_compare_rx_callback_set();
|
||||
|
||||
bool test_beacon_join_priority_update();
|
||||
|
||||
bool test_mac_beacon_link_beacon_join_priority_tx_callback_set();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_BEACON_HANDLER_H
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = mac_data_poll_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/MAC/mac_data_poll.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
mac_data_polltest.cpp \
|
||||
test_mac_data_poll.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/system_timer_stub.c \
|
||||
../../stub/protocol_6lowpan_bootstrap_stub.c \
|
||||
../../stub/thread_bootstrap_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/network_lib_stub.c \
|
||||
../../stub/event_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT -DHAVE_THREAD -DHAVE_6LOWPAN_ND
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mac_data_poll.h"
|
||||
|
||||
TEST_GROUP(mac_data_poll)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(mac_data_poll, test_mac_poll_timer_trig)
|
||||
{
|
||||
CHECK(test_mac_poll_timer_trig());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_mlme_poll_confirm)
|
||||
{
|
||||
CHECK(test_mac_mlme_poll_confirm());
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_disable)
|
||||
{
|
||||
CHECK(test_mac_data_poll_disable());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_init_protocol_poll)
|
||||
{
|
||||
CHECK(test_mac_data_poll_init_protocol_poll());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_host_poll_time_max)
|
||||
{
|
||||
CHECK(test_mac_data_poll_host_poll_time_max());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_host_timeout)
|
||||
{
|
||||
CHECK(test_mac_data_poll_host_timeout());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_protocol_poll_mode_decrement)
|
||||
{
|
||||
CHECK(test_mac_data_poll_protocol_poll_mode_decrement());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_protocol_poll_mode_disable)
|
||||
{
|
||||
CHECK(test_mac_data_poll_protocol_poll_mode_disable());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_enable_check)
|
||||
{
|
||||
CHECK(test_mac_data_poll_enable_check());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_host_mode_get)
|
||||
{
|
||||
CHECK(test_mac_data_poll_host_mode_get());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_host_mode_set)
|
||||
{
|
||||
CHECK(test_mac_data_poll_host_mode_set());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_init)
|
||||
{
|
||||
CHECK(test_mac_data_poll_init());
|
||||
}
|
||||
|
||||
TEST(mac_data_poll, test_mac_data_poll_get_max_sleep_period)
|
||||
{
|
||||
CHECK(test_mac_data_poll_get_max_sleep_period());
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(mac_data_poll);
|
||||
|
|
@ -1,456 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_mac_data_poll.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "mac_data_poll.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "6LoWPAN/Thread/thread_common.h"
|
||||
#include "mac_api.h"
|
||||
|
||||
#include "system_timer_stub.h"
|
||||
#include "protocol_6lowpan_bootstrap_stub.h"
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "event_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
|
||||
bool visited = false;
|
||||
|
||||
void poll_fail(int8_t nwk_interface_id)
|
||||
{
|
||||
visited = true;
|
||||
}
|
||||
|
||||
void buffer_handler(buffer_t *a)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void mlme_req_cb(const mac_api_t* api, mlme_primitive id, const void *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_disable()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
mac_data_poll_disable(NULL);
|
||||
|
||||
mac_data_poll_disable(&entry);
|
||||
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
rf_ptr.protocol_poll = 2;
|
||||
mac_data_poll_disable(&entry);
|
||||
if (rf_ptr.protocol_poll) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_poll_timer_trig()
|
||||
{
|
||||
//void mac_poll_timer_trig(uint32_t poll_time, protocol_interface_info_entry_t *cur)
|
||||
mac_poll_timer_trig(0, NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
|
||||
entry.lowpan_info = 64;
|
||||
system_timer_stub.int8_value = -1;
|
||||
|
||||
mac_poll_timer_trig(100, &entry);
|
||||
|
||||
mac_poll_timer_trig(10, &entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_mlme_poll_confirm()
|
||||
{
|
||||
mac_mlme_poll_confirm(NULL, NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
mlme_poll_conf_t conf;
|
||||
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
|
||||
conf.status = MLME_SUCCESS;
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
|
||||
conf.status = MLME_NO_DATA;
|
||||
rf_ptr.protocol_poll = 0;
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
|
||||
rf_ptr.protocol_poll = 1;
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
|
||||
conf.status = MLME_INVALID_ADDRESS;
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
|
||||
visited = false;
|
||||
rf_ptr.pollFailCb = poll_fail;
|
||||
rf_ptr.nwk_parent_poll_fail = 5;
|
||||
mac_mlme_poll_confirm(&entry, &conf);
|
||||
if( !visited ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_init_protocol_poll()
|
||||
{
|
||||
|
||||
mac_data_poll_init_protocol_poll(NULL);
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.lowpan_info = 64;
|
||||
|
||||
rf_ptr.protocol_poll = 0;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
rf_ptr.pollActive = false;
|
||||
mac_data_poll_init_protocol_poll(&entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_host_poll_time_max()
|
||||
{
|
||||
if( 0 != mac_data_poll_host_poll_time_max(NULL) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s info;
|
||||
info.slow_poll_rate_seconds = 2;
|
||||
entry.rfd_poll_info = &info;
|
||||
if( 2 != mac_data_poll_host_poll_time_max(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_host_timeout()
|
||||
{
|
||||
if( 0 != mac_data_poll_host_timeout(NULL) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
rf_ptr.timeOutInSeconds = 6;
|
||||
|
||||
if( 6 != mac_data_poll_host_timeout(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_protocol_poll_mode_decrement()
|
||||
{
|
||||
mac_data_poll_protocol_poll_mode_decrement(NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.lowpan_info = 1;
|
||||
mac_data_poll_protocol_poll_mode_decrement(&entry);
|
||||
|
||||
//Test mac_data_poll_protocol_poll_internal_cancel here -->
|
||||
entry.lowpan_info = 64;
|
||||
mac_data_poll_protocol_poll_mode_decrement(&entry);
|
||||
|
||||
rf_ptr.protocol_poll = 0;
|
||||
mac_data_poll_protocol_poll_mode_decrement(&entry);
|
||||
|
||||
rf_ptr.protocol_poll = 1;
|
||||
rf_ptr.pollActive = false;
|
||||
rf_ptr.nwk_app_poll_time = 1;
|
||||
mac_data_poll_protocol_poll_mode_decrement(&entry);
|
||||
|
||||
rf_ptr.protocol_poll = 1;
|
||||
rf_ptr.pollActive = false;
|
||||
rf_ptr.nwk_app_poll_time = 0;
|
||||
mac_data_poll_protocol_poll_mode_decrement(&entry);
|
||||
// <-- Test mac_data_poll_protocol_poll_internal_cancel here
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_protocol_poll_mode_disable()
|
||||
{
|
||||
mac_data_poll_protocol_poll_mode_disable(NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.lowpan_info = 1;
|
||||
mac_data_poll_protocol_poll_mode_disable(&entry);
|
||||
|
||||
entry.lowpan_info = 64;
|
||||
mac_data_poll_protocol_poll_mode_disable(&entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_enable_check()
|
||||
{
|
||||
mac_data_poll_enable_check(NULL);
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.lowpan_info = 1;
|
||||
mac_data_poll_enable_check(&entry);
|
||||
|
||||
//Test mac_data_poll_protocol_internal here -->
|
||||
entry.lowpan_info = 64;
|
||||
rf_ptr.protocol_poll = 0;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
rf_ptr.pollActive = false;
|
||||
mac_data_poll_enable_check(&entry);
|
||||
|
||||
//<-- Test mac_data_poll_protocol_internal here
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_host_mode_get()
|
||||
{
|
||||
mac_data_poll_host_mode_get(NULL, NULL);
|
||||
net_host_mode_t mode;
|
||||
protocol_interface_info_entry_t entry;
|
||||
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.rfd_poll_info->host_mode = NET_HOST_MODE_NOT_ACTIVE;
|
||||
|
||||
mac_data_poll_host_mode_get(&entry, &mode);
|
||||
if( NET_HOST_MODE_NOT_ACTIVE != mode ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_host_mode_set()
|
||||
{
|
||||
if( -1 != mac_data_poll_host_mode_set(NULL, 0, 0) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t mac;
|
||||
memset(&mac, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
entry.mac_parameters = &mac;
|
||||
if( -1 != mac_data_poll_host_mode_set(&entry, 0, 0) ){
|
||||
return false;
|
||||
}
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
|
||||
entry.lowpan_info = INTERFACE_NWK_ROUTER_DEVICE;
|
||||
if( -3 != mac_data_poll_host_mode_set(&entry, 0, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.lowpan_info = 8;
|
||||
|
||||
if( -2 != mac_data_poll_host_mode_set(&entry, NET_HOST_SLOW_POLL_MODE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
rf_ptr.host_mode = NET_HOST_RX_ON_IDLE;
|
||||
if( 0 != mac_data_poll_host_mode_set(&entry, NET_HOST_SLOW_POLL_MODE, 1) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
protocol_6lowpan_bootstrap_stub.int_value = -1;
|
||||
rf_ptr.host_mode = NET_HOST_RX_ON_IDLE;
|
||||
if( -3 != mac_data_poll_host_mode_set(&entry, NET_HOST_SLOW_POLL_MODE, 1) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
rf_ptr.host_mode = NET_HOST_RX_ON_IDLE;
|
||||
protocol_6lowpan_bootstrap_stub.int_value = 0;
|
||||
if( 0 != mac_data_poll_host_mode_set(&entry, NET_HOST_FAST_POLL_MODE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
rf_ptr.host_mode = NET_HOST_RX_ON_IDLE;
|
||||
protocol_6lowpan_bootstrap_stub.int_value = -1;
|
||||
if( -3 != mac_data_poll_host_mode_set(&entry, NET_HOST_FAST_POLL_MODE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test host_link_configuration rx_on_idle == true here -->
|
||||
protocol_6lowpan_bootstrap_stub.int_value = -1;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
if( -3 != mac_data_poll_host_mode_set(&entry, NET_HOST_RX_ON_IDLE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
mac.RxOnWhenIdle = true;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
if( -3 != mac_data_poll_host_mode_set(&entry, NET_HOST_RX_ON_IDLE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
thread_info_t info;
|
||||
entry.thread_info = &info;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
mac.RxOnWhenIdle = false;
|
||||
if( 0 != mac_data_poll_host_mode_set(&entry, NET_HOST_RX_ON_IDLE, 0) ){
|
||||
return false;
|
||||
}
|
||||
mac.RxOnWhenIdle = true;
|
||||
|
||||
entry.thread_info = NULL;
|
||||
protocol_6lowpan_bootstrap_stub.int_value = 0;
|
||||
rf_ptr.host_mode = NET_HOST_SLOW_POLL_MODE;
|
||||
if( 0 != mac_data_poll_host_mode_set(&entry, NET_HOST_RX_ON_IDLE, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
// <-- Test host_link_configuration here
|
||||
|
||||
//default case:
|
||||
if( -1 != mac_data_poll_host_mode_set(&entry, 50, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_data_poll_init()
|
||||
{
|
||||
mac_data_poll_init(NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t mac;
|
||||
memset(&mac, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
entry.mac_parameters = &mac;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
nwk_rfd_poll_setups_s *rf_ptr = ns_dyn_mem_alloc(sizeof(nwk_rfd_poll_setups_s));
|
||||
memset(rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = rf_ptr;
|
||||
|
||||
entry.lowpan_info = INTERFACE_NWK_ROUTER_DEVICE;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
entry.lowpan_info = 1; //!INTERFACE_NWK_ROUTER_DEVICE
|
||||
entry.rfd_poll_info = NULL;
|
||||
event_stub.int8_value = -1;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
event_stub.int8_value = 0;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
//Test mac_data_poll_cb here -->
|
||||
if( event_stub.func_ptr ){
|
||||
arm_event_s event;
|
||||
//Test mac_data_poll_cb_run here -->
|
||||
event.event_type = 1;
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
event_stub.func_ptr(&event);
|
||||
protocol_interface_info_entry_t entry2;
|
||||
memset(&entry2, 0, sizeof(protocol_interface_info_entry_t));
|
||||
protocol_core_stub.entry_ptr = &entry2;
|
||||
event_stub.func_ptr(&event);
|
||||
|
||||
nwk_rfd_poll_setups_s rf_ptr2;
|
||||
memset(&rf_ptr2, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry2.rfd_poll_info = &rf_ptr2;
|
||||
mac_helper_stub.uint8_value = MAC_ADDR_MODE_NONE;
|
||||
event_stub.func_ptr(&event);
|
||||
|
||||
mac_helper_stub.uint8_value = MAC_ADDR_MODE_16_BIT;
|
||||
event_stub.func_ptr(&event);
|
||||
|
||||
mac_api_t api;
|
||||
memset(&api, 0, sizeof(mac_api_t) );
|
||||
entry2.mac_api = &api;
|
||||
api.mlme_req = &mlme_req_cb;
|
||||
event_stub.func_ptr(&event);
|
||||
//<-- Test mac_data_poll_cb_run here
|
||||
|
||||
event.event_type = 3;
|
||||
event_stub.func_ptr(&event);
|
||||
}
|
||||
|
||||
//<-- Test mac_data_poll_cb here
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
mac.RxOnWhenIdle = true;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
mac.RxOnWhenIdle = false;
|
||||
mac_data_poll_init(&entry);
|
||||
|
||||
ns_dyn_mem_free(entry.rfd_poll_info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool test_mac_data_poll_get_max_sleep_period()
|
||||
{
|
||||
if( 0 != mac_data_poll_get_max_sleep_period(NULL) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
nwk_rfd_poll_setups_s rf_ptr;
|
||||
memset(&rf_ptr, 0, sizeof(nwk_rfd_poll_setups_s));
|
||||
entry.rfd_poll_info = &rf_ptr;
|
||||
entry.if_stack_buffer_handler = &buffer_handler;
|
||||
rf_ptr.pollActive = false;
|
||||
rf_ptr.protocol_poll = 1;
|
||||
if( 300 != mac_data_poll_get_max_sleep_period(&entry) ){
|
||||
return false;
|
||||
}
|
||||
rf_ptr.protocol_poll = 0;
|
||||
rf_ptr.nwk_app_poll_time = 400;
|
||||
if( 400 != mac_data_poll_get_max_sleep_period(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_MAC_DATA_POLL_H
|
||||
#define TEST_MAC_DATA_POLL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_mac_poll_timer_trig();
|
||||
|
||||
bool test_mac_mlme_poll_confirm();
|
||||
|
||||
bool test_mac_data_poll_disable();
|
||||
|
||||
bool test_mac_data_poll_init_protocol_poll();
|
||||
|
||||
bool test_mac_data_poll_host_poll_time_max();
|
||||
|
||||
bool test_mac_data_poll_host_timeout();
|
||||
|
||||
bool test_mac_data_poll_protocol_poll_mode_decrement();
|
||||
|
||||
bool test_mac_data_poll_protocol_poll_mode_disable();
|
||||
|
||||
bool test_mac_data_poll_enable_check();
|
||||
|
||||
bool test_mac_data_poll_host_mode_get();
|
||||
|
||||
bool test_mac_data_poll_host_mode_set();
|
||||
|
||||
bool test_mac_data_poll_init();
|
||||
|
||||
bool test_mac_data_poll_get_max_sleep_period();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_MAC_DATA_POLL_H
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = mac_helper_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/MAC/mac_helper.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
mac_helpertest.cpp \
|
||||
test_mac_helper.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mac_helper.h"
|
||||
|
||||
TEST_GROUP(mac_helper)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(mac_helper, test_mac_create_scan_request)
|
||||
{
|
||||
CHECK(test_mac_create_scan_request());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_select_best_lqi)
|
||||
{
|
||||
CHECK(test_mac_helper_select_best_lqi());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_drop_selected_from_the_scanresult)
|
||||
{
|
||||
CHECK(test_mac_helper_drop_selected_from_the_scanresult());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_free_scan_confirm)
|
||||
{
|
||||
CHECK(test_mac_helper_free_scan_confirm());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_free_pan_descriptions)
|
||||
{
|
||||
CHECK(test_mac_helper_free_pan_descriptions());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_nwk_id_filter_set)
|
||||
{
|
||||
CHECK(test_mac_helper_nwk_id_filter_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_panid_set)
|
||||
{
|
||||
CHECK(test_mac_helper_panid_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_mac16_address_set)
|
||||
{
|
||||
CHECK(test_mac_helper_mac16_address_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_mac16_address_get)
|
||||
{
|
||||
CHECK(test_mac_helper_mac16_address_get());
|
||||
}
|
||||
|
||||
|
||||
TEST(mac_helper, test_mac_helper_panid_get)
|
||||
{
|
||||
CHECK(test_mac_helper_panid_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_set_default_key_source)
|
||||
{
|
||||
CHECK(test_mac_helper_set_default_key_source());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_security_level_set)
|
||||
{
|
||||
CHECK(test_mac_helper_default_security_level_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_security_level_get)
|
||||
{
|
||||
CHECK(test_mac_helper_default_security_level_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_security_key_id_mode_set)
|
||||
{
|
||||
CHECK(test_mac_helper_default_security_key_id_mode_set());
|
||||
}
|
||||
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_security_key_id_mode_get)
|
||||
{
|
||||
CHECK(test_mac_helper_default_security_key_id_mode_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_key_index_set)
|
||||
{
|
||||
CHECK(test_mac_helper_default_key_index_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_default_key_index_get)
|
||||
{
|
||||
CHECK(test_mac_helper_default_key_index_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_default_key_set)
|
||||
{
|
||||
CHECK(test_mac_helper_security_default_key_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_pairwisekey_set)
|
||||
{
|
||||
CHECK(test_mac_helper_security_pairwisekey_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_next_key_set)
|
||||
{
|
||||
CHECK(test_mac_helper_security_next_key_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_prev_key_set)
|
||||
{
|
||||
CHECK(test_mac_helper_security_prev_key_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_key_swap_next_to_default)
|
||||
{
|
||||
CHECK(test_mac_helper_security_key_swap_next_to_default());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_security_key_clean)
|
||||
{
|
||||
CHECK(test_mac_helper_security_key_clean());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_coordinator_address_set)
|
||||
{
|
||||
CHECK(test_mac_helper_coordinator_address_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_coordinator_address_get)
|
||||
{
|
||||
CHECK(test_mac_helper_coordinator_address_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_beacon_payload_reallocate)
|
||||
{
|
||||
CHECK(test_mac_helper_beacon_payload_reallocate());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_beacon_payload_register)
|
||||
{
|
||||
CHECK(test_mac_helper_beacon_payload_register());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_beacon_payload_pointer_get)
|
||||
{
|
||||
CHECK(test_mac_helper_beacon_payload_pointer_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_beacon_payload_length_get)
|
||||
{
|
||||
CHECK(test_mac_helper_beacon_payload_length_get());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_pib_boolean_set)
|
||||
{
|
||||
CHECK(test_mac_helper_pib_boolean_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_mac_channel_set)
|
||||
{
|
||||
CHECK(test_mac_helper_mac_channel_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_write_our_addr)
|
||||
{
|
||||
CHECK(test_mac_helper_write_our_addr());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_mac64_set)
|
||||
{
|
||||
CHECK(test_mac_helper_mac64_set());
|
||||
}
|
||||
|
||||
|
||||
TEST(mac_helper, test_mac_helper_max_payload_size)
|
||||
{
|
||||
CHECK(test_mac_helper_max_payload_size());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_frame_overhead)
|
||||
{
|
||||
CHECK(test_mac_helper_frame_overhead());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_link_frame_counter_read)
|
||||
{
|
||||
CHECK(test_mac_helper_link_frame_counter_read());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_link_frame_counter_set)
|
||||
{
|
||||
CHECK(test_mac_helper_link_frame_counter_set());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_mac_mlme_max_retry_set)
|
||||
{
|
||||
CHECK(test_mac_helper_mac_mlme_max_retry_set());
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(mac_helper, test_mac_helper_devicetable_remove)
|
||||
{
|
||||
CHECK(test_mac_helper_devicetable_remove());
|
||||
}
|
||||
|
||||
TEST(mac_helper, test_mac_helper_devicetable_set)
|
||||
{
|
||||
CHECK(test_mac_helper_devicetable_set());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(mac_helper);
|
||||
|
|
@ -1,869 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_mac_helper.h"
|
||||
#include "mac_helper.h"
|
||||
#include <string.h>
|
||||
#include "mlme.h"
|
||||
#include "mac_api.h"
|
||||
#include "mac_common_defines.h"
|
||||
#include "net_nwk_scan.h"
|
||||
#include "MLE/mle.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
|
||||
static void mlme_req(const mac_api_t* api, mlme_primitive id, const void *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int8_t mac_set( const mac_api_t* api, const uint8_t *mac64)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int8_t mac_get( const mac_api_t* api, mac_extended_address_type type, uint8_t *mac64_buf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool test_mac_create_scan_request()
|
||||
{
|
||||
mac_create_scan_request(0, NULL, 0, NULL);
|
||||
mlme_scan_t scan;
|
||||
channel_list_s list;
|
||||
|
||||
mac_create_scan_request(0, &list, 0, &scan);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_select_best_lqi()
|
||||
{
|
||||
if( mac_helper_select_best_lqi(NULL) ){
|
||||
return false;
|
||||
}
|
||||
nwk_pan_descriptor_t pan;
|
||||
mlme_pan_descriptor_t desc;
|
||||
pan.pan_descriptor = &desc;
|
||||
nwk_pan_descriptor_t pan2;
|
||||
mlme_pan_descriptor_t desc2;
|
||||
pan2.pan_descriptor = &desc2;
|
||||
desc.LinkQuality = 10;
|
||||
desc2.LinkQuality = 100;
|
||||
pan.next = &pan2;
|
||||
pan2.next = NULL;
|
||||
|
||||
if( !mac_helper_select_best_lqi(&pan) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_drop_selected_from_the_scanresult()
|
||||
{
|
||||
mac_helper_drop_selected_from_the_scanresult(NULL, NULL);
|
||||
nwk_scan_params_t scan;
|
||||
nwk_pan_descriptor_t pan;
|
||||
nwk_pan_descriptor_t pan2;
|
||||
|
||||
scan.nwk_response_info = NULL;
|
||||
mac_helper_drop_selected_from_the_scanresult(&scan, &pan);
|
||||
|
||||
pan.next = NULL;
|
||||
scan.nwk_response_info = &pan;
|
||||
mac_helper_drop_selected_from_the_scanresult(&scan, &pan);
|
||||
|
||||
pan.next = &pan2;
|
||||
pan2.next = NULL;
|
||||
scan.nwk_response_info = &pan;
|
||||
scan.nwk_scan_res_size = 2;
|
||||
mac_helper_drop_selected_from_the_scanresult(&scan, &pan2);
|
||||
if( 1 != scan.nwk_scan_res_size ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_free_scan_confirm()
|
||||
{
|
||||
mac_helper_free_scan_confirm(NULL);
|
||||
nwk_scan_params_t scan;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
nwk_pan_descriptor_t *pan = ns_dyn_mem_alloc(sizeof(nwk_pan_descriptor_t));
|
||||
memset(pan, 0, sizeof(nwk_pan_descriptor_t));
|
||||
pan->next = NULL;
|
||||
scan.nwk_response_info = pan;
|
||||
scan.nwk_scan_res_size = 1;
|
||||
scan.nwk_cur_active = NULL;
|
||||
mac_helper_free_scan_confirm(&scan);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_free_pan_descriptions()
|
||||
{
|
||||
if( mac_helper_free_pan_descriptions(NULL) ){
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
nwk_pan_descriptor_t *pan = ns_dyn_mem_alloc(sizeof(nwk_pan_descriptor_t));
|
||||
memset(pan, 0, sizeof(nwk_pan_descriptor_t));
|
||||
pan->next = NULL;
|
||||
if( mac_helper_free_pan_descriptions(pan) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_nwk_id_filter_set()
|
||||
{
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
if( -1 != mac_helper_nwk_id_filter_set(NULL, NULL) ){
|
||||
return false;
|
||||
}
|
||||
nwk_filter_params_s filt;
|
||||
filt.beacon_nwk_id_filter = NULL;
|
||||
if( 0 != mac_helper_nwk_id_filter_set(NULL, &filt) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t data[16];
|
||||
if( -1 != mac_helper_nwk_id_filter_set(&data, &filt) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if( 0 != mac_helper_nwk_id_filter_set(&data, &filt) ){
|
||||
return false;
|
||||
}
|
||||
ns_dyn_mem_free(filt.beacon_nwk_id_filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_panid_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
mac_helper_panid_set(&entry, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_mac16_address_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
mac_helper_mac16_address_set(&entry, 0);
|
||||
|
||||
mac_helper_mac16_address_set(&entry, 0xffff);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_mac16_address_get()
|
||||
{
|
||||
uint16_t check = 0xfffe;
|
||||
if( check != mac_helper_mac16_address_get(NULL)){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.mac_short_address = 3;
|
||||
|
||||
if( 3 != mac_helper_mac16_address_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_panid_get()
|
||||
{
|
||||
uint16_t check = 0xffff;
|
||||
if( check != mac_helper_panid_get(NULL)){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.pan_id = 3;
|
||||
|
||||
if( 3 != mac_helper_panid_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_set_default_key_source()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
mac_helper_set_default_key_source(&entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_security_level_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
mac_helper_default_security_level_set(&entry, 0);
|
||||
|
||||
mac_helper_default_security_level_set(&entry, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_security_level_get()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_security_level = 5;
|
||||
entry.mac_parameters = ¶ms;
|
||||
if( 5 != mac_helper_default_security_level_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_security_key_id_mode_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
mac_helper_default_security_key_id_mode_set(&entry, 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_security_key_id_mode_get()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
params.mac_key_id_mode = 2;
|
||||
|
||||
if( 2 != mac_helper_default_security_key_id_mode_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_key_index_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
mac_helper_default_key_index_set(&entry, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_default_key_index_get()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.mac_default_key_index = 4;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( 4 != mac_helper_default_key_index_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_default_key_set()
|
||||
{
|
||||
uint8_t key[16];
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( -1 != mac_helper_security_default_key_set(&entry, &key, 0, 1)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_security_default_key_set(&entry, &key, 1, 1)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_pairwisekey_set()
|
||||
{
|
||||
uint8_t key;
|
||||
uint8_t mac;
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
|
||||
//test mac_helper_keytable_pairwise_descriptor_set here -->
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( -1 != mac_helper_security_pairwisekey_set(&entry, &key, NULL, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_security_pairwisekey_set(&entry, &key, &mac, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_security_pairwisekey_set(&entry, NULL, &mac, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
//<-- test mac_helper_keytable_pairwise_descriptor_set here
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_next_key_set()
|
||||
{
|
||||
|
||||
uint8_t key[16];
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
if( -1 != mac_helper_security_next_key_set(&entry, &key, 0, 1)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( 0 != mac_helper_security_next_key_set(&entry, &key, 1, 1)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_prev_key_set()
|
||||
{
|
||||
|
||||
uint8_t key[16];
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
if( -1 != mac_helper_security_prev_key_set(&entry, &key, 0, 1)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_security_prev_key_set(&entry, &key, 1, 1)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_key_swap_next_to_default()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
mac_helper_security_key_swap_next_to_default(&entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_security_key_clean()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
mac_helper_security_key_clean(&entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_coordinator_address_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
uint8_t buf[8];
|
||||
mac_helper_coordinator_address_set(&entry, ADDR_802_15_4_SHORT, &buf);
|
||||
|
||||
mac_helper_coordinator_address_set(&entry, ADDR_802_15_4_LONG, &buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_coordinator_address_get()
|
||||
{
|
||||
if( 0 != mac_helper_coordinator_address_get(NULL, NULL) ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
uint8_t buf[8];
|
||||
params.mac_cordinator_info.cord_adr_mode = MAC_ADDR_MODE_16_BIT;
|
||||
if( ADDR_802_15_4_SHORT != mac_helper_coordinator_address_get(&entry, &buf) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.mac_cordinator_info.cord_adr_mode = MAC_ADDR_MODE_64_BIT;
|
||||
if( ADDR_802_15_4_LONG != mac_helper_coordinator_address_get(&entry, &buf) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_beacon_payload_reallocate()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
params.mac_beacon_payload_size = 0;
|
||||
params.mac_beacon_payload = NULL;
|
||||
if( mac_helper_beacon_payload_reallocate(&entry, 0) ){
|
||||
return false;
|
||||
}
|
||||
params.mac_beacon_payload_size = 5;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
params.mac_beacon_payload = ns_dyn_mem_alloc(5);
|
||||
if( mac_helper_beacon_payload_reallocate(&entry, 0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.mac_beacon_payload_size = 5;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
params.mac_beacon_payload = ns_dyn_mem_alloc(5);
|
||||
if( mac_helper_beacon_payload_reallocate(&entry, 15) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if( !mac_helper_beacon_payload_reallocate(&entry, 15) ){
|
||||
return false;
|
||||
}
|
||||
ns_dyn_mem_free(params.mac_beacon_payload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_beacon_payload_register()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( 0 != mac_helper_beacon_payload_register(&entry) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_beacon_payload_pointer_get()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
uint8_t buf[4];
|
||||
params.mac_beacon_payload = &buf;
|
||||
if( !mac_helper_beacon_payload_pointer_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_beacon_payload_length_get()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.mac_beacon_payload_size = 5;
|
||||
if( 5 != mac_helper_beacon_payload_length_get(&entry) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_pib_boolean_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macSecurityEnabled, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macRxOnWhenIdle, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macPromiscuousMode, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macGTSPermit, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macAssociationPermit, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macAssociatedPANCoord, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macTimestampSupported, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macBattLifeExt, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macAutoRequest, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( 0 != mac_helper_pib_boolean_set(&entry, macThreadForceLongAddressForBeacon, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( -1 != mac_helper_pib_boolean_set(&entry, 0xfd, false) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_mac_channel_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
if( 0 != mac_helper_mac_channel_set(&entry, 8) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_write_our_addr()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
sockaddr_t addr;
|
||||
addr.addr_type = ADDR_NONE;
|
||||
params.shortAdressValid = false;
|
||||
|
||||
if( !mac_helper_write_our_addr(&entry, &addr) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.shortAdressValid = true;
|
||||
addr.addr_type = ADDR_NONE;
|
||||
if( !mac_helper_write_our_addr(&entry, &addr) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_mac64_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mac64_set = &mac_set;
|
||||
entry.mac_api = &api;
|
||||
|
||||
uint8_t buf[8];
|
||||
if( 0 != mac_helper_mac64_set(&entry, &buf) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_max_payload_size()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
mac_api_t api;
|
||||
api.mac64_set = &mac_set;
|
||||
entry.mac_api = &api;
|
||||
api.phyMTU = MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.MacUnsusecured_2003_cab = true;
|
||||
|
||||
if( MAC_IEEE_802_15_4_MAX_MAC_SAFE_PAYLOAD_SIZE != mac_helper_max_payload_size(&entry, 1) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.MacUnsusecured_2003_cab = false;
|
||||
if( MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE - 13 != mac_helper_max_payload_size(&entry, 13) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_frame_overhead()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
params.mac_security_level = 1;
|
||||
params.shortAdressValid = true;
|
||||
params.mac_key_id_mode = MAC_KEY_ID_MODE_SRC8_IDX;
|
||||
uint8_t ret;
|
||||
|
||||
buffer_t buf;
|
||||
memset(&buf, 0, sizeof(buffer_t));
|
||||
buf.src_sa.addr_type = ADDR_NONE;
|
||||
buf.dst_sa.addr_type = ADDR_802_15_4_LONG; //17
|
||||
buf.options.ll_security_bypass_tx = false;
|
||||
|
||||
ret = mac_helper_frame_overhead(&entry, &buf); // +14 + 4
|
||||
if( 35 != ret ){
|
||||
return false;
|
||||
}
|
||||
|
||||
buf.src_sa.addr_type = ADDR_802_15_4_SHORT;
|
||||
buf.dst_sa.addr_type = ADDR_BROADCAST; //11
|
||||
params.mac_key_id_mode = 0;
|
||||
params.mac_security_level = 2;
|
||||
ret = mac_helper_frame_overhead(&entry, &buf); // +5 +8
|
||||
if( 24 != ret ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.mac_security_level = 3;
|
||||
ret = mac_helper_frame_overhead(&entry, &buf); // +5 +16
|
||||
if( 32 != ret ){
|
||||
return false;
|
||||
}
|
||||
|
||||
params.mac_security_level = 4;
|
||||
ret = mac_helper_frame_overhead(&entry, &buf); // +5 +0
|
||||
if( 16 != ret ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_link_frame_counter_read()
|
||||
{
|
||||
if( -1 != mac_helper_link_frame_counter_read(0, NULL) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
uint32_t buf;
|
||||
if( 0 != mac_helper_link_frame_counter_read(0, &buf) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_link_frame_counter_set()
|
||||
{
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
int8_t ret = mac_helper_link_frame_counter_set(0, 0);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
ret = mac_helper_link_frame_counter_set(0, 0);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_mac_mlme_max_retry_set()
|
||||
{
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
int8_t ret = mac_helper_mac_mlme_max_retry_set(0, 4);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
protocol_interface_info_entry_t entry;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
|
||||
ret = mac_helper_mac_mlme_max_retry_set(0, 4);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_devicetable_remove()
|
||||
{
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
|
||||
mac_helper_devicetable_remove(NULL, 0);
|
||||
|
||||
mac_helper_devicetable_remove(&api, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_helper_devicetable_set()
|
||||
{
|
||||
protocol_interface_info_entry_t entry;
|
||||
mle_neigh_table_entry_t entry_temp;
|
||||
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
mac_api_t api;
|
||||
api.mlme_req = &mlme_req;
|
||||
entry.mac_api = &api;
|
||||
|
||||
entry.mac_parameters->SecurityEnabled = false;
|
||||
|
||||
mac_helper_devicetable_set(&entry_temp, &entry, 10, 1);
|
||||
|
||||
entry.mac_parameters->SecurityEnabled = true;
|
||||
entry.mac_parameters->mac_default_key_index = 2;
|
||||
|
||||
mac_helper_devicetable_set(&entry_temp, &entry, 10, 1);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_MAC_HELPER_H
|
||||
#define TEST_MAC_HELPER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_mac_create_scan_request();
|
||||
|
||||
bool test_mac_helper_select_best_lqi();
|
||||
|
||||
bool test_mac_helper_drop_selected_from_the_scanresult();
|
||||
|
||||
bool test_mac_helper_free_scan_confirm();
|
||||
|
||||
bool test_mac_helper_free_pan_descriptions();
|
||||
|
||||
bool test_mac_helper_nwk_id_filter_set();
|
||||
|
||||
bool test_mac_helper_panid_set();
|
||||
|
||||
bool test_mac_helper_mac16_address_set();
|
||||
|
||||
bool test_mac_helper_mac16_address_get();
|
||||
|
||||
bool test_mac_helper_panid_get();
|
||||
|
||||
bool test_mac_helper_set_default_key_source();
|
||||
|
||||
bool test_mac_helper_default_security_level_set();
|
||||
|
||||
bool test_mac_helper_default_security_level_get();
|
||||
|
||||
bool test_mac_helper_default_security_key_id_mode_set();
|
||||
|
||||
bool test_mac_helper_default_security_key_id_mode_get();
|
||||
|
||||
bool test_mac_helper_default_key_index_set();
|
||||
|
||||
bool test_mac_helper_default_key_index_get();
|
||||
|
||||
bool test_mac_helper_security_default_key_set();
|
||||
|
||||
bool test_mac_helper_security_pairwisekey_set();
|
||||
|
||||
bool test_mac_helper_security_next_key_set();
|
||||
|
||||
bool test_mac_helper_security_prev_key_set();
|
||||
|
||||
bool test_mac_helper_security_key_swap_next_to_default();
|
||||
|
||||
bool test_mac_helper_security_key_clean();
|
||||
|
||||
bool test_mac_helper_coordinator_address_set();
|
||||
|
||||
bool test_mac_helper_coordinator_address_get();
|
||||
|
||||
bool test_mac_helper_beacon_payload_reallocate();
|
||||
|
||||
bool test_mac_helper_beacon_payload_register();
|
||||
|
||||
bool test_mac_helper_beacon_payload_pointer_get();
|
||||
|
||||
bool test_mac_helper_beacon_payload_length_get();
|
||||
|
||||
bool test_mac_helper_pib_boolean_set();
|
||||
|
||||
bool test_mac_helper_mac_channel_set();
|
||||
|
||||
bool test_mac_helper_write_our_addr();
|
||||
|
||||
bool test_mac_helper_mac64_set();
|
||||
|
||||
bool test_mac_helper_max_payload_size();
|
||||
|
||||
bool test_mac_helper_frame_overhead();
|
||||
|
||||
bool test_mac_helper_link_frame_counter_read();
|
||||
|
||||
bool test_mac_helper_link_frame_counter_set();
|
||||
|
||||
bool test_mac_helper_devicetable_remove();
|
||||
|
||||
bool test_mac_helper_devicetable_set();
|
||||
|
||||
bool test_mac_helper_mac_mlme_max_retry_set();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_MAC_HELPER_H
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = mac_pairwise_key_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/MAC/mac_pairwise_key.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
mac_pairwise_keytest.cpp \
|
||||
test_mac_pairwise_key.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mac_pairwise_key.h"
|
||||
|
||||
TEST_GROUP(mac_pairwise_key)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(mac_pairwise_key, test_mac_pairwise_key_add)
|
||||
{
|
||||
CHECK(test_mac_pairwise_key_add());
|
||||
}
|
||||
|
||||
TEST(mac_pairwise_key, test_mac_pairwise_key_del)
|
||||
{
|
||||
CHECK(test_mac_pairwise_key_del());
|
||||
}
|
||||
|
||||
TEST(mac_pairwise_key, test_mac_pairwise_key_flush_list)
|
||||
{
|
||||
CHECK(test_mac_pairwise_key_flush_list());
|
||||
}
|
||||
|
||||
TEST(mac_pairwise_key, test_mac_pairwise_key_interface_unregister)
|
||||
{
|
||||
CHECK(test_mac_pairwise_key_interface_unregister());
|
||||
}
|
||||
|
||||
TEST(mac_pairwise_key, test_mac_pairwise_key_interface_register)
|
||||
{
|
||||
CHECK(test_mac_pairwise_key_interface_register());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(mac_pairwise_key);
|
||||
|
|
@ -1,376 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "mac_api.h"
|
||||
#include "test_mac_pairwise_key.h"
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "MLE/mle.h"
|
||||
#include "6LoWPAN/MAC/mac_pairwise_key.h"
|
||||
#include "6LoWPAN/MAC/mac_helper.h"
|
||||
#include "MAC/rf_driver_storage.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nsdynmemLIB_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "mle_stub.h"
|
||||
#include "mac_common_defines.h"
|
||||
|
||||
bool test_mac_pairwise_key_add()
|
||||
{
|
||||
protocol_interface_info_entry_t info_entry;
|
||||
mle_neigh_table_entry_t mle_neigh_table_entry;
|
||||
arm_15_4_mac_parameters_t mac_parameters;
|
||||
uint8_t eui64[8];
|
||||
uint8_t key[16];
|
||||
|
||||
memset(&info_entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
memset(&mle_neigh_table_entry, 0, sizeof(mle_neigh_table_entry_t));
|
||||
memset(eui64, 0, 8);
|
||||
mac_api_t api;
|
||||
memset(&api, 0, sizeof(mac_api_t));
|
||||
info_entry.mac_api = &api;
|
||||
info_entry.mac_parameters = &mac_parameters;
|
||||
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
//Register first interface!!!
|
||||
int ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_interface_register(0, 6, 3);
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Delete
|
||||
mac_pairwise_key_del(0, eui64);
|
||||
|
||||
//mac_pairwise_key_flush_list(0);
|
||||
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
mac_helper_stub.int8_value = -1;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
mac_helper_stub.int8_value = 0;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
eui64[0] = 1;
|
||||
mle_neigh_table_entry.attribute_index = 1;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
eui64[0] = 2;
|
||||
mle_neigh_table_entry.attribute_index = 2;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Test write same key
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != 0 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
//This Should Fail
|
||||
eui64[0] = 3;
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
mle_neigh_table_entry.attribute_index = 3;
|
||||
ret = mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( ret != -1 ){
|
||||
return false;
|
||||
}
|
||||
|
||||
eui64[0] = 0;
|
||||
mle_neigh_table_entry.attribute_index = 0;
|
||||
mac_pairwise_key_del(0, eui64);
|
||||
eui64[0] = 1;
|
||||
mle_neigh_table_entry.attribute_index = 1;
|
||||
mac_pairwise_key_del(0, eui64);
|
||||
eui64[0] = 2;
|
||||
mle_neigh_table_entry.attribute_index = 2;
|
||||
mac_pairwise_key_del(0, eui64);
|
||||
|
||||
|
||||
mac_pairwise_key_interface_unregister(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_pairwise_key_del()
|
||||
{
|
||||
protocol_interface_info_entry_t info_entry;
|
||||
mle_neigh_table_entry_t mle_neigh_table_entry;
|
||||
arm_15_4_mac_parameters_t mac_parameters;
|
||||
uint8_t eui64[8];
|
||||
uint8_t key[16];
|
||||
|
||||
memset(&info_entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
memset(&mle_neigh_table_entry, 0, sizeof(mle_neigh_table_entry_t));
|
||||
memset(eui64, 0, 8);
|
||||
mac_api_t api;
|
||||
memset(&api, 0, sizeof(mac_api_t));
|
||||
info_entry.mac_api = &api;
|
||||
info_entry.mac_parameters = &mac_parameters;
|
||||
|
||||
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
if( -1 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Register first interface!!!
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_interface_register(0, 6, 3);
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
if( -1 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_helper_stub.int8_value = 0;
|
||||
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
|
||||
if( -1 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
mac_pairwise_key_add(0, 0, eui64, key);
|
||||
|
||||
//
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
|
||||
|
||||
if( -1 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
|
||||
mle_neigh_table_entry.attribute_index = 1;
|
||||
if( -1 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
mle_neigh_table_entry.attribute_index = 0;
|
||||
|
||||
if( 0 != mac_pairwise_key_del(0, eui64) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_interface_register(1, 6, 3);
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_add(1, 0, eui64, key);
|
||||
if( 0 != mac_pairwise_key_del(1, eui64) ){
|
||||
return false;
|
||||
}
|
||||
mac_pairwise_key_interface_unregister(0);
|
||||
mac_pairwise_key_interface_unregister(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_pairwise_key_flush_list()
|
||||
{
|
||||
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
if( -1 != mac_pairwise_key_flush_list(0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
protocol_interface_info_entry_t info_entry;
|
||||
mle_neigh_table_entry_t mle_neigh_table_entry;
|
||||
arm_15_4_mac_parameters_t mac_parameters;
|
||||
uint8_t eui64[8];
|
||||
uint8_t key[16];
|
||||
|
||||
memset(&info_entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
memset(&mle_neigh_table_entry, 0, sizeof(mle_neigh_table_entry_t));
|
||||
memset(eui64, 0, 8);
|
||||
info_entry.mac_parameters = &mac_parameters;
|
||||
info_entry.id = 1;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_helper_stub.int8_value = 0;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
|
||||
//Register interface here
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_interface_register(0, 6, 3);
|
||||
|
||||
if( 0 != mac_pairwise_key_flush_list(0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_add(0, 0, eui64, key);
|
||||
if( 0 != mac_pairwise_key_flush_list(0) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( -1 != mac_pairwise_key_flush_list(1) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
mac_pairwise_key_interface_unregister(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_pairwise_key_interface_register() {
|
||||
|
||||
protocol_interface_info_entry_t info_entry;
|
||||
mle_neigh_table_entry_t mle_neigh_table_entry;
|
||||
arm_15_4_mac_parameters_t mac_parameters;
|
||||
uint8_t eui64[8];
|
||||
uint8_t key[16];
|
||||
|
||||
memset(&info_entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
memset(&mle_neigh_table_entry, 0, sizeof(mle_neigh_table_entry_t));
|
||||
memset(eui64, 0, 8);
|
||||
info_entry.mac_parameters = &mac_parameters;
|
||||
info_entry.id = 1;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_helper_stub.int8_value = 0;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
|
||||
|
||||
|
||||
if (mac_pairwise_key_interface_register(0, 0, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mac_pairwise_key_interface_register(0, 3, 0) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mac_pairwise_key_interface_register(0, 1, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mac_pairwise_key_interface_register(0, 3, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
nsdynmemlib_stub.returnCounter = 0;
|
||||
if (mac_pairwise_key_interface_register(0, 3, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 1;
|
||||
if (mac_pairwise_key_interface_register(0, 6, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
if (mac_pairwise_key_interface_register(0, 6, 3) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mac_pairwise_key_interface_register(0, 3, 3) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mac_pairwise_key_interface_unregister(0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_mac_pairwise_key_interface_unregister() {
|
||||
|
||||
protocol_interface_info_entry_t info_entry;
|
||||
mle_neigh_table_entry_t mle_neigh_table_entry;
|
||||
arm_15_4_mac_parameters_t mac_parameters;
|
||||
uint8_t eui64[8];
|
||||
uint8_t key[16];
|
||||
|
||||
memset(&info_entry, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
memset(&mle_neigh_table_entry, 0, sizeof(mle_neigh_table_entry_t));
|
||||
memset(eui64, 0, 8);
|
||||
info_entry.mac_parameters = &mac_parameters;
|
||||
info_entry.id = 1;
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_helper_stub.int8_value = 0;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &mle_neigh_table_entry;
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
|
||||
|
||||
if (mac_pairwise_key_interface_unregister(0) != -1) {
|
||||
return false;
|
||||
}
|
||||
protocol_core_stub.entry_ptr = &info_entry;
|
||||
if (mac_pairwise_key_interface_unregister(0) != -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsdynmemlib_stub.returnCounter = 2;
|
||||
mac_pairwise_key_interface_register(0, 6, 3);
|
||||
if (mac_pairwise_key_interface_unregister(0) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_MAC_PAIRWISE_KEY_H
|
||||
#define TEST_MAC_PAIRWISE_KEY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_mac_pairwise_key_add();
|
||||
|
||||
bool test_mac_pairwise_key_del();
|
||||
|
||||
bool test_mac_pairwise_key_flush_list();
|
||||
|
||||
bool test_mac_pairwise_key_interface_register();
|
||||
|
||||
bool test_mac_pairwise_key_interface_unregister();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_MAC_PAIRWISE_KEY_H
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = mac_response_handler_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/MAC/mac_response_handler.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
mac_response_handlertest.cpp \
|
||||
test_mac_response_handler.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_timer_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/mle_service_stub.c \
|
||||
../../stub/mac_data_poll_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/thread_common_stub.c \
|
||||
../../stub/thread_management_if_stub.c \
|
||||
../../stub/adaptation_interface_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT -DHAVE_THREAD
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_mac_response_handler.h"
|
||||
|
||||
TEST_GROUP(mac_response_handler)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(mac_response_handler, test_mcps_data_confirm_handler)
|
||||
{
|
||||
CHECK(test_mcps_data_confirm_handler());
|
||||
}
|
||||
|
||||
TEST(mac_response_handler, test_mcps_data_indication_handler)
|
||||
{
|
||||
CHECK(test_mcps_data_indication_handler());
|
||||
}
|
||||
|
||||
TEST(mac_response_handler, test_mlme_confirm_handler)
|
||||
{
|
||||
CHECK(test_mlme_confirm_handler());
|
||||
}
|
||||
|
||||
TEST(mac_response_handler, test_mlme_indication_handler)
|
||||
{
|
||||
CHECK(test_mlme_indication_handler());
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(mac_response_handler);
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_mac_response_handler.h"
|
||||
#include "mac_api.h"
|
||||
#include <string.h>
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
#include "Core/include/ns_buffer.h"
|
||||
|
||||
#include "mle.h"
|
||||
#include "mle_stub.h"
|
||||
#include "mac_helper_stub.h"
|
||||
#include "buffer_dyn_stub.h"
|
||||
#include "common_functions_stub.h"
|
||||
#include "protocol_core_stub.h"
|
||||
#include "thread_common_stub.h"
|
||||
|
||||
bool visited = false;
|
||||
|
||||
bool test_mcps_data_confirm_handler()
|
||||
{
|
||||
mac_api_t api;
|
||||
|
||||
mcps_data_confirm_handler(&api, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void mac_security_key_update_cb(protocol_interface_info_entry_t *cur, const mlme_security_t *security_params)
|
||||
{
|
||||
(void) cur;
|
||||
(void) security_params;
|
||||
}
|
||||
|
||||
bool test_mcps_data_indication_handler()
|
||||
{
|
||||
mac_api_t api;
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
params.mac_next_key_index = 1;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_security_key_usage_update_cb = mac_security_key_update_cb;
|
||||
mcps_data_ind_t data_ind;
|
||||
buffer_dyn_stub.buffer_ptr = NULL;
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
|
||||
buffer_t buf;
|
||||
buffer_dyn_stub.buffer_ptr = &buf;
|
||||
uint8_t ubuf[8];
|
||||
common_functions_stub.uint8_ptr = &ubuf;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
data_ind.DstAddrMode = ADDR_802_15_4_SHORT;
|
||||
buf.dst_sa.address[2] = 0xff;
|
||||
buf.dst_sa.address[3] = 0xff;
|
||||
|
||||
data_ind.Key.SecurityLevel = 1;
|
||||
data_ind.Key.KeyIndex = 1;
|
||||
thread_info_t info;
|
||||
thread_stub.info_ptr = &info;
|
||||
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
|
||||
data_ind.DstAddrMode = ADDR_802_15_4_LONG;
|
||||
buf.dst_sa.address[0] = 0xff;
|
||||
buf.dst_sa.address[1] = 0xff;
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
|
||||
data_ind.Key.SecurityLevel = 0;
|
||||
mac_helper_stub.uint8_value = 1;
|
||||
mle_neigh_table_entry_t tent;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &tent;
|
||||
tent.handshakeReady = 1;
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
if (!buf.options.ll_security_bypass_rx ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mac_helper_stub.uint8_value = 0;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
if (!buf.options.ll_security_bypass_rx ) {
|
||||
return false;
|
||||
}
|
||||
buf.options.ll_security_bypass_rx = false;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &tent;
|
||||
mcps_data_indication_handler( &api, &data_ind );
|
||||
if (buf.options.ll_security_bypass_rx ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void scan_callback(int8_t if_id, const mlme_scan_conf_t* conf)
|
||||
{
|
||||
visited = true;
|
||||
}
|
||||
|
||||
void mlme_test_req(const mac_api_t* api, mlme_primitive id, const void *data)
|
||||
{
|
||||
visited = true;
|
||||
}
|
||||
|
||||
bool test_mlme_confirm_handler()
|
||||
{
|
||||
mac_api_t api;
|
||||
api.mlme_req = mlme_test_req;
|
||||
protocol_core_stub.entry_ptr = NULL;
|
||||
mlme_confirm_handler(&api, 0, NULL);
|
||||
protocol_interface_info_entry_t entry;
|
||||
arm_15_4_mac_parameters_t params;
|
||||
entry.mac_parameters = ¶ms;
|
||||
entry.mac_api = &api;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
mlme_confirm_handler(&api, MLME_ASSOCIATE, NULL);
|
||||
mlme_confirm_handler(&api, MLME_DISASSOCIATE, NULL);
|
||||
|
||||
mlme_get_conf_t dat;
|
||||
dat.attr = 254;
|
||||
mlme_confirm_handler(&api, MLME_GET, NULL);
|
||||
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
|
||||
dat.attr = macDeviceTable;
|
||||
dat.value_size = sizeof(mlme_device_descriptor_t) - 4;
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
|
||||
mlme_device_descriptor_t desc;
|
||||
dat.value_pointer = &desc;
|
||||
dat.value_size = sizeof(mlme_device_descriptor_t);
|
||||
dat.status = MLME_SUCCESS;
|
||||
mle_stub.mle_neigh_table_entry_ptr = NULL;
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
|
||||
mle_neigh_table_entry_t tent;
|
||||
mle_stub.mle_neigh_table_entry_ptr = &tent;
|
||||
desc.ShortAddress = 14;
|
||||
tent.short_adr = 15;
|
||||
visited = false;
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
if( !visited ){
|
||||
return false;
|
||||
}
|
||||
|
||||
dat.attr = macFrameCounter;
|
||||
dat.value_size = 3;
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
|
||||
dat.value_size = 4;
|
||||
mlme_confirm_handler(&api, MLME_GET, &dat);
|
||||
|
||||
mlme_confirm_handler(&api, MLME_GTS, NULL);
|
||||
mlme_confirm_handler(&api, MLME_RESET, NULL);
|
||||
mlme_confirm_handler(&api, MLME_RX_ENABLE, NULL);
|
||||
|
||||
visited = false;
|
||||
entry.scan_cb = &scan_callback;
|
||||
mlme_confirm_handler(&api, MLME_SCAN, NULL);
|
||||
if( !visited ){
|
||||
return false;
|
||||
}
|
||||
|
||||
mlme_confirm_handler(&api, MLME_SET, NULL);
|
||||
mlme_confirm_handler(&api, MLME_START, NULL);
|
||||
|
||||
mlme_confirm_handler(&api, MLME_POLL, NULL);
|
||||
|
||||
mlme_confirm_handler(&api, MLME_BEACON_NOTIFY, NULL);
|
||||
mlme_confirm_handler(&api, MLME_ORPHAN, NULL);
|
||||
mlme_confirm_handler(&api, MLME_COMM_STATUS, NULL);
|
||||
mlme_confirm_handler(&api, MLME_SYNC, NULL);
|
||||
mlme_confirm_handler(&api, MLME_SYNC_LOSS, NULL);
|
||||
mlme_confirm_handler(&api, 254, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void beacon_ind_cb(int8_t if_id, const mlme_beacon_ind_t* conf)
|
||||
{
|
||||
visited = true;
|
||||
}
|
||||
|
||||
void comm_status_cb(int8_t if_id, const mlme_comm_status_t* status)
|
||||
{
|
||||
visited = true;
|
||||
}
|
||||
|
||||
bool test_mlme_indication_handler()
|
||||
{
|
||||
mlme_indication_handler(NULL, MLME_ASSOCIATE, NULL);
|
||||
mlme_indication_handler(NULL, MLME_DISASSOCIATE, NULL);
|
||||
|
||||
mac_api_t api;
|
||||
visited = false;
|
||||
protocol_interface_info_entry_t entry;
|
||||
entry.beacon_cb = beacon_ind_cb;
|
||||
protocol_core_stub.entry_ptr = &entry;
|
||||
mlme_indication_handler(&api, MLME_BEACON_NOTIFY, NULL);
|
||||
if( !visited ){
|
||||
return false;
|
||||
}
|
||||
|
||||
mlme_indication_handler(NULL, MLME_GTS, NULL);
|
||||
mlme_indication_handler(NULL, MLME_ORPHAN, NULL);
|
||||
|
||||
mlme_comm_status_t data;
|
||||
visited = false;
|
||||
entry.comm_status_ind_cb = &comm_status_cb;
|
||||
mlme_indication_handler(&api, MLME_COMM_STATUS, &data);
|
||||
if( !visited ){
|
||||
return false;
|
||||
}
|
||||
|
||||
const mlme_sync_loss_t sync_loss = {
|
||||
.LossReason = BEACON_LOST
|
||||
};
|
||||
mlme_indication_handler(&api, MLME_SYNC_LOSS, &sync_loss);
|
||||
mlme_indication_handler(NULL, MLME_GET, NULL);
|
||||
mlme_indication_handler(NULL, MLME_RESET, NULL);
|
||||
mlme_indication_handler(NULL, MLME_RX_ENABLE, NULL);
|
||||
mlme_indication_handler(NULL, MLME_SCAN, NULL);
|
||||
mlme_indication_handler(NULL, MLME_SET, NULL);
|
||||
mlme_indication_handler(NULL, MLME_START, NULL);
|
||||
mlme_indication_handler(NULL, MLME_SYNC, NULL);
|
||||
mlme_indication_handler(NULL, MLME_POLL, NULL);
|
||||
mlme_indication_handler(NULL, 254, NULL);
|
||||
return true;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_MAC_RESPONSE_HANDLER_H
|
||||
#define TEST_MAC_RESPONSE_HANDLER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_mcps_data_confirm_handler();
|
||||
|
||||
bool test_mcps_data_indication_handler();
|
||||
|
||||
bool test_mlme_confirm_handler();
|
||||
|
||||
bool test_mlme_indication_handler();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_MAC_RESPONSE_HANDLER_H
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = network_lib_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Bootstraps/Generic/network_lib.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
network_libtest.cpp \
|
||||
test_network_lib.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/thread_common_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/thread_bootstrap_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(network_lib);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_network_lib.h"
|
||||
|
||||
TEST_GROUP(network_lib)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(network_lib, test_nwk_ready)
|
||||
{
|
||||
CHECK(test_nwk_ready());
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_network_lib.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
bool test_nwk_ready()
|
||||
{
|
||||
nwk_ready(0);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_NETWORK_LIB_H
|
||||
#define TEST_NETWORK_LIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_nwk_ready();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_NETWORK_LIB_H
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = protocol_6lowpan_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
protocol_6lowpantest.cpp \
|
||||
test_protocol_6lowpan.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/net_rpl_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/thread_common_stub.c \
|
||||
../../stub/thread_nd_stub.c \
|
||||
../../stub/protocol_6lowpan_bootstrap_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/mac_data_poll_stub.c \
|
||||
../../stub/border_router_stub.c \
|
||||
../../stub/cipv6_fragmenter_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/ipv6_stub.c \
|
||||
../../stub/tcp_stub.c \
|
||||
../../stub/udp_stub.c \
|
||||
../../stub/mesh_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/6lowpan_iphc_stub.c \
|
||||
../../stub/adaptation_interface_stub.c \
|
||||
../../stub/security_lib_stub.c \
|
||||
../../stub/net_load_balance_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(protocol_6lowpan);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_protocol_6lowpan.h"
|
||||
|
||||
TEST_GROUP(protocol_6lowpan)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(protocol_6lowpan, test_protocol_init)
|
||||
{
|
||||
CHECK(test_protocol_init());
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_protocol_6lowpan.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
bool test_protocol_init()
|
||||
{
|
||||
protocol_init();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_PROTOCOL_6LOWPAN_H
|
||||
#define TEST_PROTOCOL_6LOWPAN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_protocol_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_PROTOCOL_6LOWPAN_H
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = protocol_6lowpan_bootstrap_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
protocol_6lowpan_bootstraptest.cpp \
|
||||
test_protocol_6lowpan_bootstrap.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/mle_tlv_stub.c \
|
||||
../../stub/mle_service_stub.c \
|
||||
../../stub/mle_service_buffer_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/protocol_6lowpan_interface_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/beacon_handler_stub.c \
|
||||
../../stub/border_router_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/net_stub.c \
|
||||
../../stub/net_mle_stub.c \
|
||||
../../stub/blacklist_stub.c \
|
||||
../../stub/mac_data_poll_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/icmpv6_radv_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/thread_common_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/etx_stub.c \
|
||||
../../stub/event_stub.c \
|
||||
../../stub/pana_stub.c \
|
||||
../../stub/pana_client_stub.c \
|
||||
../../stub/net_load_balance_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT -DHAVE_6LOWPAN_ND
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(protocol_6lowpan_bootstrap);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_protocol_6lowpan_bootstrap.h"
|
||||
|
||||
TEST_GROUP(protocol_6lowpan_bootstrap)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(protocol_6lowpan_bootstrap, test_protocol_6lowpan_mle_blacklist_clear)
|
||||
{
|
||||
CHECK(test_protocol_6lowpan_mle_blacklist_clear());
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_protocol_6lowpan_bootstrap.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
bool test_protocol_6lowpan_mle_blacklist_clear()
|
||||
{
|
||||
blacklist_clear();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_PROTOCOL_6LOWPAN_BOOTSTRAP_H
|
||||
#define TEST_PROTOCOL_6LOWPAN_BOOTSTRAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_protocol_6lowpan_mle_blacklist_clear();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_PROTOCOL_6LOWPAN_BOOTSTRAP_H
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = protocol_6lowpan_interface_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
protocol_6lowpan_interfacetest.cpp \
|
||||
test_protocol_6lowpan_interface.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/event_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/blacklist_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/neighbor_cache_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/protocol_6lowpan_bootstrap_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/adaptation_interface_stub.c \
|
||||
../../stub/cipv6_fragmenter_stub.c \
|
||||
../../stub/pana_stub.c \
|
||||
../../stub/net_load_balance_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(protocol_6lowpan_interface);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_protocol_6lowpan_interface.h"
|
||||
|
||||
TEST_GROUP(protocol_6lowpan_interface)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(protocol_6lowpan_interface, test_nwk_6lowpan_up)
|
||||
{
|
||||
CHECK(test_nwk_6lowpan_up());
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_protocol_6lowpan_interface.h"
|
||||
#include <string.h>
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
|
||||
|
||||
bool test_nwk_6lowpan_up()
|
||||
{
|
||||
protocol_interface_info_entry_t info;
|
||||
arm_15_4_mac_parameters_t mac_params;
|
||||
memset(&info, 0, sizeof(protocol_interface_info_entry_t));
|
||||
memset(&mac_params, 0, sizeof(arm_15_4_mac_parameters_t));
|
||||
info.mac_parameters = &mac_params;
|
||||
nwk_6lowpan_up(&info);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_PROTOCOL_6LOWPAN_INTERFACE_H
|
||||
#define TEST_PROTOCOL_6LOWPAN_INTERFACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_nwk_6lowpan_up();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_PROTOCOL_6LOWPAN_INTERFACE_H
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = border_router_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/BorderRouter/border_router.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
border_routertest.cpp \
|
||||
test_border_router.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/whiteboard_stub.c \
|
||||
../../stub/mac_helper_stub.c \
|
||||
../../stub/ipv6_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/icmpv6_radv_stub.c \
|
||||
../../stub/icmpv6_prefix_stub.c \
|
||||
../../stub/neighbor_cache_stub.c \
|
||||
../../stub/thread_common_stub.c \
|
||||
../../stub/blacklist_stub.c \
|
||||
../../stub/thread_bootstrap_stub.c \
|
||||
../../stub/protocol_6lowpan_bootstrap_stub.c \
|
||||
../../stub/adaptation_interface_stub.c \
|
||||
../../stub/cipv6_fragmenter_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/protocol_ipv6_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_timer_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/lowpan_context_stub.c \
|
||||
../../stub/mle_stub.c \
|
||||
../../stub/mle_service_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/nd_proxy_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/beacon_handler_stub.c \
|
||||
../../stub/pana_stub.c \
|
||||
../../stub/pana_server_stub.c \
|
||||
../../stub/net_load_balance_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_border_router.h"
|
||||
|
||||
TEST_GROUP(border_router)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(border_router, test_arm_nwk_6lowpan_borderrouter_data_free)
|
||||
{
|
||||
CHECK(test_arm_nwk_6lowpan_borderrouter_data_free());
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(border_router);
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_border_router.h"
|
||||
#include <string.h>
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
|
||||
bool test_arm_nwk_6lowpan_borderrouter_data_free()
|
||||
{
|
||||
protocol_interface_info_entry_t info;
|
||||
info.border_router_setup = NULL;
|
||||
arm_nwk_6lowpan_borderrouter_data_free(&info);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_BORDER_ROUTER_H
|
||||
#define TEST_BORDER_ROUTER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_arm_nwk_6lowpan_borderrouter_data_free();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_BORDER_ROUTER_H
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = icmpv6_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/Common_Protocols/icmpv6.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
icmpv6test.cpp \
|
||||
test_icmpv6.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/ipv6_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/mpl_stub.c \
|
||||
../../stub/mld_stub.c \
|
||||
../../stub/nd_proxy_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
../../stub/icmpv6_radv_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/protocol_ipv6_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_icmpv6.h"
|
||||
|
||||
TEST_GROUP(icmpv6)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(icmpv6, test_icmpv6_something)
|
||||
{
|
||||
CHECK(test_icmpv6_something());
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(icmpv6);
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_icmpv6.h"
|
||||
#include <string.h>
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
|
||||
bool test_icmpv6_something()
|
||||
{
|
||||
protocol_interface_info_entry_t info;
|
||||
info.recv_ra_routes = false;
|
||||
icmpv6_recv_ra_routes(&info, false);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_ICMPV6_H
|
||||
#define TEST_ICMPV6_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_icmpv6_something();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_ICMPV6_H
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = icmpv6_prefix_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/Common_Protocols/icmpv6_prefix.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
icmpv6_prefixtest.cpp \
|
||||
test_icmpv6_prefix.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_icmpv6_prefix.h"
|
||||
|
||||
TEST_GROUP(icmpv6_prefix)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(icmpv6_prefix, test_icmpv6_prefix_list_free)
|
||||
{
|
||||
CHECK(test_icmpv6_prefix_list_free());
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(icmpv6_prefix);
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_icmpv6_prefix.h"
|
||||
#include <string.h>
|
||||
#include "icmpv6_prefix.h"
|
||||
|
||||
bool test_icmpv6_prefix_list_free()
|
||||
{
|
||||
prefix_list_t list;
|
||||
ns_list_init(&list);
|
||||
icmpv6_prefix_list_free(&list);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_ICMPV6_PREFIX_H
|
||||
#define TEST_ICMPV6_PREFIX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_icmpv6_prefix_list_free();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_ICMPV6_PREFIX_H
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = icmpv6_radv_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/Common_Protocols/icmpv6_radv.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
icmpv6_radvtest.cpp \
|
||||
test_icmpv6_radv.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/protocol_ipv6_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_icmpv6_radv.h"
|
||||
|
||||
TEST_GROUP(icmpv6_radv)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(icmpv6_radv, test_icmpv6_radv_init)
|
||||
{
|
||||
CHECK(test_icmpv6_radv_init());
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(icmpv6_radv);
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "nsconfig.h"
|
||||
#include "test_icmpv6_radv.h"
|
||||
#include <string.h>
|
||||
#include "NWK_INTERFACE/Include/protocol.h"
|
||||
|
||||
|
||||
bool test_icmpv6_radv_init()
|
||||
{
|
||||
protocol_interface_info_entry_t info;
|
||||
icmpv6_radv_init(&info);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_ICMPV6_RADV_H
|
||||
#define TEST_ICMPV6_RADV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool test_icmpv6_radv_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_ICMPV6_RADV_H
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = ipv6_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/Common_Protocols/ipv6.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
ipv6test.cpp \
|
||||
test_ipv6.c \
|
||||
../../stub/ns_list_stub.c \
|
||||
../../stub/buffer_dyn_stub.c \
|
||||
../../stub/mbed_trace_stub.c \
|
||||
../../stub/nsdynmemLIB_stub.c \
|
||||
../../stub/common_functions_stub.c \
|
||||
../../stub/address_stub.c \
|
||||
../../stub/protocol_core_stub.c \
|
||||
../../stub/protocol_stats_stub.c \
|
||||
../../stub/ipv6_resolution_stub.c \
|
||||
../../stub/ipv6_fragmentation_stub.c \
|
||||
../../stub/ipv6_flow_stub.c \
|
||||
../../stub/ipv6_routing_table_stub.c \
|
||||
../../stub/nd_router_object_stub.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/rpl_control_stub.c \
|
||||
../../stub/nd_proxy_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
../../stub/icmpv6_radv_stub.c \
|
||||
../../stub/icmpv6_stub.c \
|
||||
../../stub/protocol_6lowpan_stub.c \
|
||||
../../stub/protocol_ipv6_stub.c \
|
||||
../../stub/socket_stub.c \
|
||||
../../stub/rpl_data_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_ipv6.h"
|
||||
|
||||
TEST_GROUP(ipv6)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(ipv6);
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test_ipv6.h"
|
||||
#include <string.h>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef TEST_IPV6_H
|
||||
#define TEST_IPV6_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_IPV6_H
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
include ../../makefile_defines.txt
|
||||
|
||||
COMPONENT_NAME = ipv6_flow_unit
|
||||
|
||||
#This must be changed manually
|
||||
SRC_FILES = \
|
||||
../../../../../source/Common_Protocols/ipv6_flow.c
|
||||
|
||||
TEST_SRC_FILES = \
|
||||
main.cpp \
|
||||
ipv6_flowtest.cpp \
|
||||
test_ipv6_flow.c \
|
||||
../../stub/randLIB_stub.c \
|
||||
../../stub/fnv_hash_stub.c \
|
||||
|
||||
include ../../MakefileWorker.mk
|
||||
|
||||
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "test_ipv6_flow.h"
|
||||
|
||||
TEST_GROUP(ipv6_flow)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(ipv6_flow, test_ipv6_flow_random)
|
||||
{
|
||||
CHECK(test_ipv6_flow_random());
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
||||
IMPORT_TEST_GROUP(ipv6_flow);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue