mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9208 from ARMmbed/release-candidate
Release candidate for mbed-os-5.11.1pull/9634/head mbed-os-5.11.1
commit
c966348d3f
|
@ -24,3 +24,10 @@
|
|||
[ ] Test update
|
||||
[ ] Breaking change
|
||||
|
||||
### Reviewers
|
||||
|
||||
<!--
|
||||
Optional
|
||||
Request additional reviewers with @username
|
||||
-->
|
||||
|
||||
|
|
20
.travis.yml
20
.travis.yml
|
@ -1,3 +1,19 @@
|
|||
# Copyright (c) 2013-2018 Arm Limited. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# 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.
|
||||
|
||||
language: python
|
||||
python: 2.7
|
||||
|
||||
|
@ -30,8 +46,6 @@ before_install:
|
|||
# Setup ppa to make sure arm-none-eabi-gcc is correct version
|
||||
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
|
||||
- sudo add-apt-repository -y ppa:deadsnakes/ppa
|
||||
# import the new keys for rabbitmq (fix for https://github.com/ARMmbed/mbed-os/issues/8945)
|
||||
- curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
|
||||
# Loop until update succeeds (timeouts can occur)
|
||||
- travis_retry $(! sudo apt-get update 2>&1 |grep Failed)
|
||||
|
||||
|
@ -120,7 +134,7 @@ matrix:
|
|||
- env:
|
||||
- NAME=astyle
|
||||
install:
|
||||
- curl -L0 http://mbed-os.s3-eu-west-1.amazonaws.com/builds/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz;
|
||||
- curl -L0 https://mbed-os.s3-eu-west-1.amazonaws.com/builds/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz;
|
||||
mkdir -p BUILD && tar xf astyle.tar.gz -C BUILD;
|
||||
pushd BUILD/astyle/build/gcc;
|
||||
make;
|
||||
|
|
|
@ -59,8 +59,8 @@ void flashiap_program_test()
|
|||
// the one before the last sector in the system
|
||||
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
|
||||
TEST_ASSERT_TRUE(address != 0UL);
|
||||
utest_printf("ROM ends at 0x%lx, test starts at 0x%lx\n", FLASHIAP_ROM_END, address);
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
|
||||
utest_printf("ROM ends at 0x%lx, test starts at 0x%lx\n", FLASHIAP_APP_ROM_END_ADDR, address);
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_APP_ROM_END_ADDR, "Test skipped. Test region overlaps code.");
|
||||
|
||||
ret = flash_device.erase(address, sector_size);
|
||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||
|
@ -128,7 +128,7 @@ void flashiap_cross_sector_program_test()
|
|||
agg_size += sector_size;
|
||||
address -= sector_size;
|
||||
}
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_APP_ROM_END_ADDR, "Test skipped. Test region overlaps code.");
|
||||
ret = flash_device.erase(address, agg_size);
|
||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||
|
||||
|
@ -184,7 +184,7 @@ void flashiap_program_error_test()
|
|||
TEST_ASSERT_TRUE(address != 0UL);
|
||||
|
||||
// unaligned address
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
|
||||
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_APP_ROM_END_ADDR, "Test skipped. Test region overlaps code.");
|
||||
ret = flash_device.erase(address + 1, sector_size);
|
||||
TEST_ASSERT_EQUAL_INT32(-1, ret);
|
||||
if (flash_device.get_page_size() > 1) {
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018-2018 ARM Limited
|
||||
*
|
||||
* 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 MBED_QSPI_FLASH_MX25L51245G_H
|
||||
#define MBED_QSPI_FLASH_MX25L51245G_H
|
||||
|
||||
|
||||
#define QSPI_FLASH_CHIP_STRING "macronix MX25L51245G"
|
||||
|
||||
// Command for reading status register
|
||||
#define QSPI_CMD_RDSR 0x05
|
||||
// Command for reading configuration register
|
||||
#define QSPI_CMD_RDCR0 0x15
|
||||
// Command for writing status/configuration register
|
||||
#define QSPI_CMD_WRSR 0x01
|
||||
// Command for reading security register
|
||||
#define QSPI_CMD_RDSCUR 0x2B
|
||||
|
||||
// Command for setting Reset Enable
|
||||
#define QSPI_CMD_RSTEN 0x66
|
||||
// Command for setting Reset
|
||||
#define QSPI_CMD_RST 0x99
|
||||
|
||||
// Command for setting write enable
|
||||
#define QSPI_CMD_WREN 0x06
|
||||
// Command for setting write disable
|
||||
#define QSPI_CMD_WRDI 0x04
|
||||
|
||||
// WRSR operations max time [us] (datasheet max time + 15%)
|
||||
#define QSPI_WRSR_MAX_TIME 34500 // 30ms
|
||||
// general wait max time [us]
|
||||
#define QSPI_WAIT_MAX_TIME 100000 // 100ms
|
||||
|
||||
|
||||
// Commands for writing (page programming)
|
||||
#define QSPI_CMD_WRITE_1IO 0x02 // 1-1-1 mode
|
||||
#define QSPI_CMD_WRITE_4IO 0x38 // 1-4-4 mode
|
||||
|
||||
// write operations max time [us] (datasheet max time + 15%)
|
||||
#define QSPI_PAGE_PROG_MAX_TIME 11500 // 10ms
|
||||
|
||||
#define QSPI_PAGE_SIZE 256 // 256B
|
||||
#define QSPI_SECTOR_SIZE 4096 // 4kB
|
||||
#define QSPI_SECTOR_COUNT 2048 //
|
||||
|
||||
// Commands for reading
|
||||
#define QSPI_CMD_READ_1IO_FAST 0x0B // 1-1-1 mode
|
||||
#define QSPI_CMD_READ_1IO 0x03 // 1-1-1 mode
|
||||
#define QSPI_CMD_READ_2IO 0xBB // 1-2-2 mode
|
||||
#define QSPI_CMD_READ_1I2O 0x3B // 1-1-2 mode
|
||||
#define QSPI_CMD_READ_4IO 0xEB // 1-4-4 mode
|
||||
#define QSPI_CMD_READ_1I4O 0x6B // 1-1-4 mode
|
||||
|
||||
#define QSPI_READ_1IO_DUMMY_CYCLE 0
|
||||
#define QSPI_READ_FAST_DUMMY_CYCLE 8
|
||||
#define QSPI_READ_2IO_DUMMY_CYCLE 4
|
||||
#define QSPI_READ_1I2O_DUMMY_CYCLE 8
|
||||
#define QSPI_READ_4IO_DUMMY_CYCLE 6
|
||||
#define QSPI_READ_1I4O_DUMMY_CYCLE 8
|
||||
|
||||
// Commands for erasing
|
||||
#define QSPI_CMD_ERASE_SECTOR 0x20 // 4kB
|
||||
#define QSPI_CMD_ERASE_BLOCK_32 0x52 // 32kB
|
||||
#define QSPI_CMD_ERASE_BLOCK_64 0xD8 // 64kB
|
||||
#define QSPI_CMD_ERASE_CHIP 0x60 // or 0xC7
|
||||
|
||||
// erase operations max time [us] (datasheet max time + 15%)
|
||||
#define QSPI_ERASE_SECTOR_MAX_TIME 480000 // 400 ms
|
||||
#define QSPI_ERASE_BLOCK_32_MAX_TIME 1200000 // 1s
|
||||
#define QSPI_ERASE_BLOCK_64_MAX_TIME 2400000 // 2s
|
||||
|
||||
// max frequency for basic rw operation (for fast mode)
|
||||
#define QSPI_COMMON_MAX_FREQUENCY 32000000
|
||||
|
||||
#define QSPI_STATUS_REG_SIZE 1
|
||||
#define QSPI_CONFIG_REG_0_SIZE 2
|
||||
#define QSPI_SECURITY_REG_SIZE 1
|
||||
#define QSPI_MAX_REG_SIZE 2
|
||||
|
||||
// status register
|
||||
#define STATUS_BIT_WIP (1 << 0) // write in progress bit
|
||||
#define STATUS_BIT_WEL (1 << 1) // write enable latch
|
||||
#define STATUS_BIT_BP0 (1 << 2) //
|
||||
#define STATUS_BIT_BP1 (1 << 3) //
|
||||
#define STATUS_BIT_BP2 (1 << 4) //
|
||||
#define STATUS_BIT_BP3 (1 << 5) //
|
||||
#define STATUS_BIT_QE (1 << 6) // Quad Enable
|
||||
#define STATUS_BIT_SRWD (1 << 7) // status register write protect
|
||||
|
||||
// configuration register 0
|
||||
// bit 0, 1, 2, 4, 5, 7 reserved
|
||||
#define CONFIG0_BIT_TB (1 << 3) // Top/Bottom area protect
|
||||
|
||||
#endif // MBED_QSPI_FLASH_MX25L51245G_H
|
|
@ -18,19 +18,45 @@
|
|||
#define MBED_FLASH_CONFIGS_H
|
||||
|
||||
#if defined(TARGET_DISCO_L475VG_IOT01A)
|
||||
#include "STM/DISCO_L475VG_IOT01A/flash_config.h"
|
||||
#include "MX25RXX35F_config.h" // MX25R6435F
|
||||
|
||||
#elif defined(TARGET_DISCO_F413ZH)
|
||||
#include "N25Q128A_config.h" // N25Q128A13EF840F
|
||||
|
||||
#elif defined(TARGET_DISCO_F746NG)
|
||||
#include "N25Q128A_config.h" // N25Q128A13EF840E
|
||||
|
||||
#elif defined(TARGET_DISCO_F469NI)
|
||||
#include "N25Q128A_config.h" // N25Q128A13EF840E
|
||||
|
||||
#elif defined(TARGET_DISCO_F769NI)
|
||||
#include "MX25L51245G_config.h" // MX25L51245G
|
||||
|
||||
#elif defined(TARGET_DISCO_L476VG)
|
||||
#include "N25Q128A_config.h" // N25Q128A13EF840E
|
||||
/* See STM32L476 Errata Sheet, it is not possible to use Dual-/Quad-mode for the command phase */
|
||||
#undef QSPI_CMD_READ_DPI
|
||||
#undef QSPI_CMD_READ_QPI
|
||||
#undef QSPI_CMD_WRITE_DPI
|
||||
#undef QSPI_CMD_WRITE_QPI
|
||||
|
||||
#elif defined(TARGET_DISCO_L496AG)
|
||||
#include "MX25RXX35F_config.h" // MX25R6435F
|
||||
|
||||
#elif defined(TARGET_NRF52840)
|
||||
#include "NORDIC/NRF52840_DK/flash_config.h"
|
||||
#elif defined(TARGET_DISCO_F413ZH)
|
||||
#include "STM/DISCO_F413ZH/flash_config.h"
|
||||
|
||||
#elif defined(TARGET_EFM32GG11_STK3701)
|
||||
#include "SiliconLabs/EFM32GG11_STK3701/flash_config.h"
|
||||
|
||||
#elif defined(TARGET_K82F)
|
||||
#include "NXP/K82F/flash_config.h"
|
||||
|
||||
#elif defined(TARGET_KL82Z)
|
||||
#include "NXP/KL82Z/flash_config.h"
|
||||
|
||||
#elif defined(TARGET_LPC546XX)
|
||||
#include "NXP/LPC546XX/flash_config.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // MBED_FLASH_CONFIGS_H
|
||||
|
|
|
@ -95,7 +95,7 @@ void sleep_usticker_test()
|
|||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
#ifdef DEVICE_LPTICKER
|
||||
#if DEVICE_LPTICKER
|
||||
|
||||
/* Test that wake-up time from sleep should be less than 10 ms and
|
||||
* low power ticker interrupt can wake-up target from sleep. */
|
||||
|
|
|
@ -105,7 +105,7 @@ void us_ticker_isr(const ticker_data_t *const ticker_data)
|
|||
us_ticker_clear_interrupt();
|
||||
}
|
||||
|
||||
#ifdef DEVICE_LPTICKER
|
||||
#if DEVICE_LPTICKER
|
||||
void lp_ticker_isr(const ticker_data_t *const ticker_data)
|
||||
{
|
||||
lp_ticker_clear_interrupt();
|
||||
|
|
|
@ -384,17 +384,15 @@ void test_fprintf_fscanf()
|
|||
|
||||
/** Test fseek and ftell
|
||||
*
|
||||
* Given already opened file is empty
|
||||
*
|
||||
* When set the file position indicator via fseek
|
||||
* Then underneath retargeting layer seek function is called
|
||||
* fseek return with succeed and ftell return already set position
|
||||
* ARM library is quite good at optimising out unnecessary calls to underlying
|
||||
* seek, so only test real non empty files.
|
||||
*
|
||||
* Given already opened file is not empty
|
||||
*
|
||||
* When set the file position indicator via fseek
|
||||
* Then underneath retargeting layer seek function is called
|
||||
* fseek return with succeed and ftell return already set position
|
||||
* Check actual character read or written.
|
||||
*
|
||||
*/
|
||||
void test_fseek_ftell()
|
||||
|
@ -413,19 +411,6 @@ void test_fseek_ftell()
|
|||
ftell_ret = std::ftell(file);
|
||||
TEST_ASSERT_EQUAL(0, ftell_ret);
|
||||
|
||||
TestFile<FS>::resetFunctionCallHistory();
|
||||
fssek_ret = std::fseek(file, 0, SEEK_CUR);
|
||||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
|
||||
TestFile<FS>::resetFunctionCallHistory();
|
||||
fssek_ret = std::fseek(file, 0, SEEK_SET);
|
||||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
|
||||
TestFile<FS>::resetFunctionCallHistory();
|
||||
fssek_ret = std::fseek(file, 0, SEEK_END);
|
||||
TEST_ASSERT_TRUE(TestFile<FS>::functionCalled(TestFile<FS>::fnSeek));
|
||||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
|
||||
const char *str = "Hello world";
|
||||
const std::size_t size = std::strlen(str);
|
||||
|
||||
|
@ -440,19 +425,28 @@ void test_fseek_ftell()
|
|||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
ftell_ret = std::ftell(file);
|
||||
TEST_ASSERT_EQUAL(5, ftell_ret);
|
||||
int c = std::fgetc(file);
|
||||
TEST_ASSERT_TRUE(TestFile<FS>::functionCalled(TestFile<FS>::fnRead));
|
||||
TEST_ASSERT_EQUAL(c, str[5]);
|
||||
|
||||
TestFile<FS>::resetFunctionCallHistory();
|
||||
fssek_ret = std::fseek(file, -5, SEEK_CUR);
|
||||
fssek_ret = std::fseek(file, -6, SEEK_CUR);
|
||||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
ftell_ret = std::ftell(file);
|
||||
TEST_ASSERT_EQUAL(0, ftell_ret);
|
||||
c = std::fgetc(file);
|
||||
TEST_ASSERT_TRUE(TestFile<FS>::functionCalled(TestFile<FS>::fnRead));
|
||||
TEST_ASSERT_EQUAL(c, str[0]);
|
||||
|
||||
TestFile<FS>::resetFunctionCallHistory();
|
||||
fssek_ret = std::fseek(file, 0, SEEK_END);
|
||||
TEST_ASSERT_TRUE(TestFile<FS>::functionCalled(TestFile<FS>::fnSeek));
|
||||
TEST_ASSERT_EQUAL(0, fssek_ret);
|
||||
ftell_ret = std::ftell(file);
|
||||
TEST_ASSERT_EQUAL(size, ftell_ret);
|
||||
c = std::fputc('!', file);
|
||||
TEST_ASSERT_TRUE(TestFile<FS>::functionCalled(TestFile<FS>::fnWrite));
|
||||
TEST_ASSERT_EQUAL(c, '!');
|
||||
TEST_ASSERT_EQUAL(fh.size(), size + 1);
|
||||
|
||||
std::fclose(file);
|
||||
}
|
||||
|
|
|
@ -18,43 +18,196 @@
|
|||
#include "utest/utest.h"
|
||||
#include "unity/unity.h"
|
||||
#include "mbed.h"
|
||||
#include "Stream.h"
|
||||
|
||||
/* This test suite verifies that write/read/write/read sequence can be
|
||||
* successfully executed on the Stream objects.
|
||||
*
|
||||
* A qute from C99 standard, paragraph 7.19.5.3, point 6:
|
||||
*
|
||||
* When a file is opened with update mode ('+' as the second or third character in the
|
||||
* above list of mode argument values), both input and output may be performed on the
|
||||
* associated stream. However, output shall not be directly followed by input without an
|
||||
* intervening call to the fflush function or to a file positioning function (fseek,
|
||||
* fsetpos, or rewind), and input shall not be directly followed by output without an
|
||||
* intervening call to a file positioning function, unless the input operation encounters end-
|
||||
* of-file.
|
||||
*/
|
||||
|
||||
using utest::v1::Case;
|
||||
|
||||
const char FMT[] = "Foo%02ibar.";
|
||||
const size_t FORMATTED_STR_SIZE = 3 + 2 + 4 + 1;
|
||||
// The test Stream instance has to be able to store two printf() output strings.
|
||||
const size_t LOOPBACK_BUFF_SIZE = 2 * FORMATTED_STR_SIZE;
|
||||
|
||||
class Loopback : public Stream {
|
||||
public:
|
||||
Loopback(const char *name = NULL) : Stream(name) {}
|
||||
Loopback(const char *name = NULL) : Stream(name)
|
||||
{
|
||||
// The `fgets()` stops reading after a newline or EOF.
|
||||
// Fill the buffer with newlines to simplify fgets() usage in this test.
|
||||
memset(_buff, '\n', LOOPBACK_BUFF_SIZE);
|
||||
_p_index = 0;
|
||||
_g_index = 0;
|
||||
}
|
||||
|
||||
virtual ~Loopback()
|
||||
{
|
||||
}
|
||||
|
||||
int test_vprintf(const char *fmt, ...)
|
||||
{
|
||||
int rc = -1;
|
||||
std::va_list args;
|
||||
va_start(args, fmt);
|
||||
rc = vprintf(fmt, args);
|
||||
va_end(args);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int test_vscanf(const char *fmt, ...)
|
||||
{
|
||||
int rc = EOF;
|
||||
std::va_list args;
|
||||
va_start(args, fmt);
|
||||
rc = vscanf(fmt, args);
|
||||
va_end(args);
|
||||
return rc;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual int _getc()
|
||||
{
|
||||
return _c;
|
||||
}
|
||||
virtual int _putc(int c)
|
||||
{
|
||||
_c = c;
|
||||
if (_p_index >= LOOPBACK_BUFF_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
_buff[_p_index++] = (int8_t)c;
|
||||
return c;
|
||||
}
|
||||
|
||||
virtual int _getc()
|
||||
{
|
||||
if (_g_index >= LOOPBACK_BUFF_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
return _buff[_g_index++];
|
||||
}
|
||||
|
||||
private:
|
||||
char _c;
|
||||
int8_t _buff[LOOPBACK_BUFF_SIZE];
|
||||
size_t _p_index;
|
||||
size_t _g_index;
|
||||
};
|
||||
|
||||
Loopback loop("loopback");
|
||||
|
||||
/* Test intermixed Stream::putc() / Stream::getc().
|
||||
*
|
||||
* Given a Stream object,
|
||||
* when a write/read/write/read sequence is executed
|
||||
* with the use of Stream::putc() and Stream::getc() methods,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void test_putc_getc()
|
||||
{
|
||||
char char_buff[2] = {'a', 'b'};
|
||||
Loopback loop("loopback");
|
||||
int ret;
|
||||
char char_buf[2] = {'a', 'b'};
|
||||
|
||||
ret = loop.putc(char_buf[0]);
|
||||
TEST_ASSERT_EQUAL_INT(char_buf[0], ret);
|
||||
ret = loop.putc(char_buff[0]);
|
||||
TEST_ASSERT_EQUAL_INT(char_buff[0], ret);
|
||||
ret = loop.getc();
|
||||
TEST_ASSERT_EQUAL_INT(char_buf[0], ret);
|
||||
ret = loop.putc(char_buf[1]);
|
||||
TEST_ASSERT_EQUAL_INT(char_buf[1], ret);
|
||||
TEST_ASSERT_EQUAL_INT(char_buff[0], ret);
|
||||
ret = loop.putc(char_buff[1]);
|
||||
TEST_ASSERT_EQUAL_INT(char_buff[1], ret);
|
||||
ret = loop.getc();
|
||||
TEST_ASSERT_EQUAL_INT(char_buf[1], ret);
|
||||
return;
|
||||
TEST_ASSERT_EQUAL_INT(char_buff[1], ret);
|
||||
}
|
||||
|
||||
/* Test intermixed Stream::puts() / Stream::gets().
|
||||
*
|
||||
* Given a Stream object,
|
||||
* when a write/read/write/read sequence is executed,
|
||||
* with the use of Stream::puts() and Stream::gets() methods,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void test_puts_gets()
|
||||
{
|
||||
const size_t STR_LEN = 3;
|
||||
const size_t STR_SIZE = STR_LEN + 1; // +1 for '\0'
|
||||
char strings[2][STR_SIZE] = {"Foo", "Bar"};
|
||||
const size_t GETS_BUFF_SIZE = STR_LEN + 2; // +1 for '\n' (gets() stops AFTER a '\n'), +1 for '\0'
|
||||
char g_buff[GETS_BUFF_SIZE] = {};
|
||||
Loopback loop("loopback");
|
||||
int p_rc;
|
||||
char *g_rc;
|
||||
|
||||
p_rc = loop.puts(strings[0]);
|
||||
TEST_ASSERT(p_rc >= 0);
|
||||
g_rc = loop.gets(g_buff, GETS_BUFF_SIZE);
|
||||
TEST_ASSERT_EQUAL_PTR(g_buff, g_rc);
|
||||
|
||||
p_rc = loop.puts(strings[1]);
|
||||
TEST_ASSERT(p_rc >= 0);
|
||||
g_rc = loop.gets(g_buff, GETS_BUFF_SIZE);
|
||||
TEST_ASSERT_EQUAL_PTR(g_buff, g_rc);
|
||||
}
|
||||
|
||||
/* Test intermixed Stream::printf() / Stream::scanf().
|
||||
*
|
||||
* Given a Stream object,
|
||||
* when a write/read/write/read sequence is executed,
|
||||
* with the use of Stream::printf() and Stream::scanf() methods,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void test_printf_scanf()
|
||||
{
|
||||
Loopback loop("loopback");
|
||||
int p_val, g_val, rc;
|
||||
|
||||
p_val = 42;
|
||||
g_val = p_val + 1;
|
||||
rc = loop.printf(FMT, p_val);
|
||||
TEST_ASSERT(rc > 0);
|
||||
rc = loop.scanf(FMT, &g_val);
|
||||
TEST_ASSERT(rc == 1);
|
||||
TEST_ASSERT_EQUAL_INT(p_val, g_val);
|
||||
|
||||
p_val += 5;
|
||||
g_val = p_val + 1;
|
||||
rc = loop.printf(FMT, p_val);
|
||||
TEST_ASSERT(rc > 0);
|
||||
rc = loop.scanf(FMT, &g_val);
|
||||
TEST_ASSERT(rc == 1);
|
||||
TEST_ASSERT_EQUAL_INT(p_val, g_val);
|
||||
}
|
||||
|
||||
/* Test intermixed Stream::vprintf() / Stream::vscanf().
|
||||
*
|
||||
* Given a Stream object,
|
||||
* when a write/read/write/read sequence is executed,
|
||||
* with the use of Stream::vprintf() and Stream::vscanf() methods,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void test_vprintf_vscanf()
|
||||
{
|
||||
Loopback loop("loopback");
|
||||
int p_val, g_val, rc;
|
||||
|
||||
p_val = 42;
|
||||
g_val = p_val + 1;
|
||||
rc = loop.test_vprintf(FMT, p_val);
|
||||
TEST_ASSERT(rc > 0);
|
||||
rc = loop.test_vscanf(FMT, &g_val);
|
||||
TEST_ASSERT(rc == 1);
|
||||
TEST_ASSERT_EQUAL_INT(p_val, g_val);
|
||||
|
||||
p_val += 5;
|
||||
g_val = p_val + 1;
|
||||
rc = loop.test_vprintf(FMT, p_val);
|
||||
TEST_ASSERT(rc > 0);
|
||||
rc = loop.test_vscanf(FMT, &g_val);
|
||||
TEST_ASSERT(rc == 1);
|
||||
TEST_ASSERT_EQUAL_INT(p_val, g_val);
|
||||
}
|
||||
|
||||
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
|
@ -64,7 +217,10 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
|
|||
}
|
||||
|
||||
Case cases[] = {
|
||||
Case("Test putc/getc", test_putc_getc)
|
||||
Case("Test putc/getc", test_putc_getc),
|
||||
Case("Test puts/gets", test_puts_gets),
|
||||
Case("Test printf/scanf", test_printf_scanf),
|
||||
Case("Test vprintf/vscanf", test_vprintf_vscanf)
|
||||
};
|
||||
|
||||
utest::v1::Specification specification(test_setup, cases);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "mbed.h"
|
||||
|
||||
#if !defined(MBED_CPU_STATS_ENABLED) || !defined(DEVICE_LPTICKER) || !defined(DEVICE_SLEEP)
|
||||
#if !defined(MBED_CPU_STATS_ENABLED) || !DEVICE_LPTICKER || !DEVICE_SLEEP
|
||||
#error [NOT_SUPPORTED] test not supported
|
||||
#endif
|
||||
|
||||
|
|
|
@ -243,8 +243,7 @@ content at minimum:
|
|||
"help" : "Port of echo server",
|
||||
"value" : "7"
|
||||
}
|
||||
},
|
||||
"macros": ["MBED_EXTENDED_TESTS"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -299,7 +298,6 @@ the `mbed_app.json` might look like this:
|
|||
"value" : "7"
|
||||
}
|
||||
},
|
||||
"macros": ["MBED_EXTENDED_TESTS"],
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"target.network-default-interface-type": "WIFI",
|
||||
|
|
|
@ -34,8 +34,8 @@ void ASYNCHRONOUS_DNS()
|
|||
{
|
||||
do_asynchronous_gethostbyname(dns_test_hosts, 1, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == 1);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(1, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ void ASYNCHRONOUS_DNS_CACHE()
|
|||
|
||||
semaphore.wait();
|
||||
|
||||
TEST_ASSERT(data.result == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);
|
||||
TEST_ASSERT(strlen(data.addr.get_ip_address()) > 1);
|
||||
|
||||
int delay_ms = (ticker_us - started_us) / 1000;
|
||||
|
|
|
@ -57,10 +57,10 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
|
|||
do_asynchronous_gethostbyname(dns_test_hosts, MBED_CONF_NSAPI_DNS_CACHE_SIZE, &result_ok, &result_no_mem,
|
||||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == MBED_CONF_NSAPI_DNS_CACHE_SIZE);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_NSAPI_DNS_CACHE_SIZE, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
|
||||
// Dispatch event queue
|
||||
Thread eventThread(osPriorityNormal, EXTERNAL_THREAD_SIZE);
|
||||
|
@ -73,10 +73,10 @@ void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE()
|
|||
do_asynchronous_gethostbyname(dns_test_hosts_second, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
|
||||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES);
|
||||
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES, result_ok);
|
||||
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
|
||||
// Give event queue time to finalise before destructors
|
||||
wait(2.0);
|
||||
|
|
|
@ -61,8 +61,8 @@ void ASYNCHRONOUS_DNS_INVALID_HOST()
|
|||
do_asynchronous_gethostbyname(dns_test_hosts_new, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
|
||||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == exp_ok);
|
||||
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
|
||||
TEST_ASSERT_EQUAL(exp_ok, result_ok);
|
||||
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
|
||||
TEST_ASSERT(result_dns_failure == exp_dns_failure || result_dns_failure == exp_dns_failure + 1);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
|
|||
|
||||
semaphore.wait(100);
|
||||
|
||||
TEST_ASSERT(data.result == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);
|
||||
|
||||
printf("DNS: query \"%s\" => \"%s\"\n",
|
||||
dns_test_hosts_second[0], data.addr.get_ip_address());
|
||||
|
|
|
@ -35,8 +35,8 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS()
|
|||
do_asynchronous_gethostbyname(dns_test_hosts_second, MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, &result_ok, &result_no_mem,
|
||||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES);
|
||||
TEST_ASSERT(result_no_mem == 1); // last query fails for no memory as expected
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES, result_ok);
|
||||
TEST_ASSERT_EQUAL(1, result_no_mem); // last query fails for no memory as expected
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE()
|
|||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
// Addresses were cached on last step, OK for all
|
||||
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES + 1);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_SIMULT_QUERIES + 1, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ void ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT()
|
|||
// For 1st round can fail to no memory, on other rounds some of the addresses are found from cache
|
||||
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES || result_ok == MBED_CONF_APP_DNS_SIMULT_QUERIES + 1);
|
||||
TEST_ASSERT(result_no_mem == 1 || result_no_mem == 0); // last query fails for 1st round to no memory as expected
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ void ASYNCHRONOUS_DNS_TIMEOUTS()
|
|||
do_asynchronous_gethostbyname(dns_test_hosts, MBED_CONF_NSAPI_DNS_CACHE_SIZE, &result_ok, &result_no_mem,
|
||||
&result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == MBED_CONF_NSAPI_DNS_CACHE_SIZE);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_NSAPI_DNS_CACHE_SIZE, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
|
||||
// Dispatch event queue
|
||||
Thread eventThread(osPriorityNormal, EXTERNAL_THREAD_SIZE);
|
||||
|
|
|
@ -122,7 +122,6 @@ void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_cou
|
|||
SocketAddress address;
|
||||
nsapi_error_t err = net->gethostbyname(hosts[i], &address);
|
||||
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
(*exp_ok)++;
|
||||
printf("DNS: query \"%s\" => \"%s\"\n",
|
||||
|
@ -136,6 +135,9 @@ void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_cou
|
|||
} else if (err == NSAPI_ERROR_NO_MEMORY) {
|
||||
(*exp_no_mem)++;
|
||||
printf("DNS: query \"%s\" => no memory\n", hosts[i]);
|
||||
} else {
|
||||
printf("DNS: query \"%s\" => %d, unexpected answer\n", hosts[i], err);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,9 +175,7 @@ Case cases[] = {
|
|||
Case("ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE", ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE),
|
||||
Case("ASYNCHRONOUS_DNS_INVALID_HOST", ASYNCHRONOUS_DNS_INVALID_HOST),
|
||||
Case("ASYNCHRONOUS_DNS_TIMEOUTS", ASYNCHRONOUS_DNS_TIMEOUTS),
|
||||
#ifdef MBED_EXTENDED_TESTS
|
||||
Case("ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT", ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT),
|
||||
#endif
|
||||
Case("SYNCHRONOUS_DNS", SYNCHRONOUS_DNS),
|
||||
Case("SYNCHRONOUS_DNS_MULTIPLE", SYNCHRONOUS_DNS_MULTIPLE),
|
||||
Case("SYNCHRONOUS_DNS_INVALID", SYNCHRONOUS_DNS_INVALID),
|
||||
|
|
|
@ -34,8 +34,8 @@ void SYNCHRONOUS_DNS()
|
|||
{
|
||||
do_gethostbyname(dns_test_hosts, 1, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == 1);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(1, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ void SYNCHRONOUS_DNS_INVALID()
|
|||
|
||||
do_gethostbyname(dns_test_hosts_new, MBED_CONF_APP_DNS_TEST_HOSTS_NUM, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == expected_successes);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == expected_failures);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(expected_successes, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(expected_failures, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ void SYNCHRONOUS_DNS_MULTIPLE()
|
|||
{
|
||||
do_gethostbyname(dns_test_hosts, MBED_CONF_APP_DNS_TEST_HOSTS_NUM, &result_ok, &result_no_mem, &result_dns_failure, &result_exp_timeout);
|
||||
|
||||
TEST_ASSERT(result_ok == MBED_CONF_APP_DNS_TEST_HOSTS_NUM);
|
||||
TEST_ASSERT(result_no_mem == 0);
|
||||
TEST_ASSERT(result_dns_failure == 0);
|
||||
TEST_ASSERT(result_exp_timeout == 0);
|
||||
TEST_ASSERT_EQUAL(MBED_CONF_APP_DNS_TEST_HOSTS_NUM, result_ok);
|
||||
TEST_ASSERT_EQUAL(0, result_no_mem);
|
||||
TEST_ASSERT_EQUAL(0, result_dns_failure);
|
||||
TEST_ASSERT_EQUAL(0, result_exp_timeout);
|
||||
}
|
||||
|
|
|
@ -149,17 +149,26 @@ Case cases[] = {
|
|||
Case("TCPSOCKET_OPEN_CLOSE_REPEAT", TCPSOCKET_OPEN_CLOSE_REPEAT),
|
||||
Case("TCPSOCKET_OPEN_LIMIT", TCPSOCKET_OPEN_LIMIT),
|
||||
Case("TCPSOCKET_THREAD_PER_SOCKET_SAFETY", TCPSOCKET_THREAD_PER_SOCKET_SAFETY),
|
||||
#ifdef MBED_EXTENDED_TESTS
|
||||
Case("TCPSOCKET_CONNECT_INVALID", TCPSOCKET_CONNECT_INVALID),
|
||||
Case("TCPSOCKET_ECHOTEST_BURST", TCPSOCKET_ECHOTEST_BURST),
|
||||
Case("TCPSOCKET_ECHOTEST_BURST_NONBLOCK", TCPSOCKET_ECHOTEST_BURST_NONBLOCK),
|
||||
Case("TCPSOCKET_OPEN_DESTRUCT", TCPSOCKET_OPEN_DESTRUCT),
|
||||
Case("TCPSOCKET_OPEN_TWICE", TCPSOCKET_OPEN_TWICE),
|
||||
Case("TCPSOCKET_BIND_PORT", TCPSOCKET_BIND_PORT),
|
||||
Case("TCPSOCKET_BIND_PORT_FAIL", TCPSOCKET_BIND_PORT_FAIL),
|
||||
Case("TCPSOCKET_BIND_ADDRESS_PORT", TCPSOCKET_BIND_ADDRESS_PORT),
|
||||
Case("TCPSOCKET_BIND_ADDRESS_NULL", TCPSOCKET_BIND_ADDRESS_NULL),
|
||||
Case("TCPSOCKET_BIND_ADDRESS_INVALID", TCPSOCKET_BIND_ADDRESS_INVALID),
|
||||
Case("TCPSOCKET_BIND_ADDRESS", TCPSOCKET_BIND_ADDRESS),
|
||||
Case("TCPSOCKET_BIND_WRONG_TYPE", TCPSOCKET_BIND_WRONG_TYPE),
|
||||
Case("TCPSOCKET_BIND_UNOPENED", TCPSOCKET_BIND_UNOPENED),
|
||||
Case("TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID", TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID),
|
||||
Case("TCPSOCKET_RECV_100K", TCPSOCKET_RECV_100K),
|
||||
Case("TCPSOCKET_RECV_100K_NONBLOCK", TCPSOCKET_RECV_100K_NONBLOCK),
|
||||
Case("TCPSOCKET_RECV_TIMEOUT", TCPSOCKET_RECV_TIMEOUT),
|
||||
Case("TCPSOCKET_SEND_REPEAT", TCPSOCKET_SEND_REPEAT),
|
||||
Case("TCPSOCKET_SEND_TIMEOUT", TCPSOCKET_SEND_TIMEOUT),
|
||||
Case("TCPSOCKET_ENDPOINT_CLOSE", TCPSOCKET_ENDPOINT_CLOSE),
|
||||
#endif
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
|
||||
|
|
|
@ -54,13 +54,24 @@ void TCPSOCKET_ECHOTEST_NONBLOCK();
|
|||
void TCPSOCKET_ECHOTEST_BURST();
|
||||
void TCPSOCKET_ECHOTEST_BURST_NONBLOCK();
|
||||
void TCPSOCKET_ENDPOINT_CLOSE();
|
||||
void TCPSOCKET_OPEN_DESTRUCT();
|
||||
void TCPSOCKET_OPEN_CLOSE_REPEAT();
|
||||
void TCPSOCKET_OPEN_LIMIT();
|
||||
void TCPSOCKET_OPEN_TWICE();
|
||||
void TCPSOCKET_BIND_PORT();
|
||||
void TCPSOCKET_BIND_PORT_FAIL();
|
||||
void TCPSOCKET_BIND_ADDRESS_PORT();
|
||||
void TCPSOCKET_BIND_ADDRESS_NULL();
|
||||
void TCPSOCKET_BIND_ADDRESS_INVALID();
|
||||
void TCPSOCKET_BIND_ADDRESS();
|
||||
void TCPSOCKET_BIND_WRONG_TYPE();
|
||||
void TCPSOCKET_BIND_UNOPENED();
|
||||
void TCPSOCKET_RECV_100K();
|
||||
void TCPSOCKET_RECV_100K_NONBLOCK();
|
||||
void TCPSOCKET_RECV_TIMEOUT();
|
||||
void TCPSOCKET_SEND_REPEAT();
|
||||
void TCPSOCKET_SEND_TIMEOUT();
|
||||
void TCPSOCKET_THREAD_PER_SOCKET_SAFETY();
|
||||
void TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID();
|
||||
|
||||
#endif //TCP_TESTS_H
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_ADDRESS()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
SocketAddress sockAddr = SocketAddress(get_interface()->get_ip_address(), 80);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(sockAddr));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_ADDRESS_INVALID()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->bind("190.2.3.4", 1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_ADDRESS_NULL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(NULL, 1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_ADDRESS_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(get_interface()->get_ip_address(), 80));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_PORT_FAIL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));
|
||||
|
||||
TCPSocket *sock2 = new TCPSocket;
|
||||
if (!sock2) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock2->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock2->bind(1024));
|
||||
|
||||
delete sock;
|
||||
delete sock2;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_UNOPENED()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_NO_SOCKET, sock->bind(1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_BIND_WRONG_TYPE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
char addr_bytes[16] = {0xfe, 0x80, 0xff, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
SocketAddress sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->bind(sockAddr));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_OPEN_DESTRUCT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
delete sock;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "tcp_tests.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_OPEN_TWICE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
TCPSocket *sock = new TCPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->open(get_interface()));
|
||||
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "mbed.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
#include "tcp_tests.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID()
|
||||
{
|
||||
TCPSocket sock;
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
||||
int32_t seconds = 7200;
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.setsockopt(NSAPI_SOCKET, NSAPI_KEEPALIVE, &seconds, sizeof(int)));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.connect(MBED_CONF_APP_ECHO_SERVER_ADDR, 9));
|
||||
// LWIP stack does not support getsockopt so the part below is commented out
|
||||
// int32_t optval;
|
||||
// unsigned int optlen;
|
||||
// TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.getsockopt(NSAPI_SOCKET, NSAPI_KEEPALIVE, &optval, &optlen));
|
||||
// TEST_ASSERT_EQUAL(optlen, sizeof(seconds));
|
||||
// TEST_ASSERT_EQUAL(optval, seconds);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
|
||||
}
|
|
@ -102,17 +102,26 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
|
|||
}
|
||||
|
||||
Case cases[] = {
|
||||
Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST),
|
||||
Case("UDPSOCKET_ECHOTEST_NONBLOCK", UDPSOCKET_ECHOTEST_NONBLOCK),
|
||||
Case("UDPSOCKET_OPEN_CLOSE_REPEAT", UDPSOCKET_OPEN_CLOSE_REPEAT),
|
||||
Case("UDPSOCKET_OPEN_LIMIT", UDPSOCKET_OPEN_LIMIT),
|
||||
Case("UDPSOCKET_SENDTO_TIMEOUT", UDPSOCKET_SENDTO_TIMEOUT),
|
||||
#ifdef MBED_EXTENDED_TESTS
|
||||
Case("UDPSOCKET_OPEN_DESTRUCT", UDPSOCKET_OPEN_DESTRUCT),
|
||||
Case("UDPSOCKET_OPEN_TWICE", UDPSOCKET_OPEN_TWICE),
|
||||
Case("UDPSOCKET_BIND_PORT", UDPSOCKET_BIND_PORT),
|
||||
Case("UDPSOCKET_BIND_PORT_FAIL", UDPSOCKET_BIND_PORT_FAIL),
|
||||
Case("UDPSOCKET_BIND_ADDRESS_PORT", UDPSOCKET_BIND_ADDRESS_PORT),
|
||||
Case("UDPSOCKET_BIND_ADDRESS_NULL", UDPSOCKET_BIND_ADDRESS_NULL),
|
||||
Case("UDPSOCKET_BIND_ADDRESS_INVALID", UDPSOCKET_BIND_ADDRESS_INVALID),
|
||||
Case("UDPSOCKET_BIND_ADDRESS", UDPSOCKET_BIND_ADDRESS),
|
||||
Case("UDPSOCKET_BIND_WRONG_TYPE", UDPSOCKET_BIND_WRONG_TYPE),
|
||||
Case("UDPSOCKET_BIND_UNOPENED", UDPSOCKET_BIND_UNOPENED),
|
||||
Case("UDPSOCKET_SENDTO_INVALID", UDPSOCKET_SENDTO_INVALID),
|
||||
Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST),
|
||||
Case("UDPSOCKET_ECHOTEST_BURST", UDPSOCKET_ECHOTEST_BURST),
|
||||
Case("UDPSOCKET_ECHOTEST_BURST_NONBLOCK", UDPSOCKET_ECHOTEST_BURST_NONBLOCK),
|
||||
Case("UDPSOCKET_SENDTO_REPEAT", UDPSOCKET_SENDTO_REPEAT),
|
||||
#endif
|
||||
};
|
||||
|
||||
Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
|
||||
|
|
|
@ -35,7 +35,17 @@ void UDPSOCKET_ECHOTEST_NONBLOCK();
|
|||
void UDPSOCKET_ECHOTEST_BURST();
|
||||
void UDPSOCKET_ECHOTEST_BURST_NONBLOCK();
|
||||
void UDPSOCKET_OPEN_CLOSE_REPEAT();
|
||||
void UDPSOCKET_OPEN_DESTRUCT();
|
||||
void UDPSOCKET_OPEN_LIMIT();
|
||||
void UDPSOCKET_OPEN_TWICE();
|
||||
void UDPSOCKET_BIND_PORT();
|
||||
void UDPSOCKET_BIND_PORT_FAIL();
|
||||
void UDPSOCKET_BIND_ADDRESS_PORT();
|
||||
void UDPSOCKET_BIND_ADDRESS_NULL();
|
||||
void UDPSOCKET_BIND_ADDRESS_INVALID();
|
||||
void UDPSOCKET_BIND_ADDRESS();
|
||||
void UDPSOCKET_BIND_WRONG_TYPE();
|
||||
void UDPSOCKET_BIND_UNOPENED();
|
||||
void UDPSOCKET_RECV_TIMEOUT();
|
||||
void UDPSOCKET_SENDTO_INVALID();
|
||||
void UDPSOCKET_SENDTO_REPEAT();
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_ADDRESS()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
SocketAddress sockAddr = SocketAddress(get_interface()->get_ip_address(), 80);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(sockAddr));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_ADDRESS_INVALID()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->bind("190.2.3.4", 1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_ADDRESS_NULL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(NULL, 1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_ADDRESS_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(get_interface()->get_ip_address(), 80));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_PORT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_PORT_FAIL()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->bind(1024));
|
||||
|
||||
UDPSocket *sock2 = new UDPSocket;
|
||||
if (!sock2) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock2->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock2->bind(1024));
|
||||
|
||||
delete sock;
|
||||
delete sock2;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_UNOPENED()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_NO_SOCKET, sock->bind(1024));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_BIND_WRONG_TYPE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
char addr_bytes[16] = {0xfe, 0x80, 0xff, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
SocketAddress sockAddr = SocketAddress(addr_bytes, NSAPI_IPv4, 80);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->bind(sockAddr));
|
||||
|
||||
delete sock;
|
||||
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_OPEN_DESTRUCT()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
delete sock;
|
||||
}
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
* 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 "greentea-client/test_env.h"
|
||||
#include "mbed.h"
|
||||
#include "udp_tests.h"
|
||||
#include "UDPSocket.h"
|
||||
#include "unity/unity.h"
|
||||
#include "utest.h"
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
void UDPSOCKET_OPEN_TWICE()
|
||||
{
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
int count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
UDPSocket *sock = new UDPSocket;
|
||||
if (!sock) {
|
||||
TEST_FAIL();
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->open(get_interface()));
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, sock->open(get_interface()));
|
||||
|
||||
delete sock;
|
||||
#if MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
|
||||
count = fetch_stats();
|
||||
for (int j = 0; j < count; j++) {
|
||||
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -62,32 +62,24 @@ Case cases[] = {
|
|||
Case("WIFI-CONNECT-NOCREDENTIALS", wifi_connect_nocredentials),
|
||||
Case("WIFI-SET-CREDENTIAL", wifi_set_credential),
|
||||
Case("WIFI-SET-CHANNEL", wifi_set_channel),
|
||||
Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null),
|
||||
Case("WIFI-SCAN-NULL", wifi_scan_null),
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) || defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-SCAN", wifi_scan),
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-GET-RSSI", wifi_get_rssi),
|
||||
#endif
|
||||
Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null),
|
||||
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure),
|
||||
Case("WIFI-CONNECT", wifi_connect),
|
||||
Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
||||
Case("WIFI-CONNECT-PARAMS-VALID-SECURE", wifi_connect_params_valid_secure),
|
||||
Case("WIFI-CONNECT-PARAMS-CHANNEL", wifi_connect_params_channel),
|
||||
Case("WIFI-CONNECT-PARAMS-CHANNEL-FAIL", wifi_connect_params_channel_fail),
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-CONNECT", wifi_connect),
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
||||
Case("WIFI-CONNECT-SECURE", wifi_connect_secure),
|
||||
Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail),
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat),
|
||||
#endif
|
||||
Case("WIFI-SCAN-NULL", wifi_scan_null),
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
Case("WIFI-SCAN", wifi_scan),
|
||||
#endif
|
||||
};
|
||||
|
||||
Specification specification(test_setup, cases, greentea_continue_handlers);
|
||||
|
|
|
@ -31,13 +31,13 @@ void wifi_connect_disconnect_repeat(void)
|
|||
nsapi_error_t error;
|
||||
|
||||
error = wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
error = wifi->connect();
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
error = wifi->disconnect();
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,5 +30,5 @@ void wifi_connect_nocredentials(void)
|
|||
error_connect = wifi->connect();
|
||||
error_disconnect = wifi->disconnect();
|
||||
TEST_ASSERT(error_connect == NSAPI_ERROR_NO_SSID || error_connect == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT(error_disconnect == NSAPI_ERROR_NO_CONNECTION);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_NO_CONNECTION, error_disconnect);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ void wifi_connect_params_null(void)
|
|||
WiFiInterface *wifi = get_interface();
|
||||
error = wifi->connect(NULL, NULL);
|
||||
wifi->disconnect();
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
error = wifi->connect("", "");
|
||||
wifi->disconnect();
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
using namespace utest::v1;
|
||||
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
|
||||
void wifi_scan(void)
|
||||
{
|
||||
WiFiInterface *wifi = get_interface();
|
||||
|
@ -33,7 +31,7 @@ void wifi_scan(void)
|
|||
WiFiAccessPoint ap[MBED_CONF_APP_MAX_SCAN_SIZE];
|
||||
|
||||
int size = wifi->scan(ap, MBED_CONF_APP_MAX_SCAN_SIZE);
|
||||
TEST_ASSERT(size >= 2);
|
||||
TEST_ASSERT(size >= 1);
|
||||
|
||||
bool secure_found = false;
|
||||
bool unsecure_found = false;
|
||||
|
@ -49,17 +47,19 @@ void wifi_scan(void)
|
|||
nsapi_security_t security = ap[i].get_security();
|
||||
int8_t rssi = ap[i].get_rssi();
|
||||
TEST_ASSERT_INT8_WITHIN(-10, -100, rssi);
|
||||
#if defined(MBED_CONF_APP_WIFI_SECURE_SSID)
|
||||
if (strcmp(MBED_CONF_APP_WIFI_SECURE_SSID, ssid) == 0) {
|
||||
secure_found = true;
|
||||
TEST_ASSERT_EQUAL_INT(get_security(), security);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
if (strcmp(MBED_CONF_APP_WIFI_UNSECURE_SSID, ssid) == 0) {
|
||||
unsecure_found = true;
|
||||
TEST_ASSERT_EQUAL_INT(NSAPI_SECURITY_NONE, security);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// Finding one SSID is enough
|
||||
TEST_ASSERT_TRUE(secure_found || unsecure_found);
|
||||
}
|
||||
|
||||
#endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID) && defined(MBED_CONF_APP_WIFI_UNSECURE_SSID)
|
||||
|
|
|
@ -26,6 +26,6 @@ using namespace utest::v1;
|
|||
void wifi_scan_null(void)
|
||||
{
|
||||
WiFiInterface *wifi = get_interface();
|
||||
TEST_ASSERT(wifi->scan(NULL, 0) >= 2);
|
||||
TEST_ASSERT(wifi->scan(NULL, 0) >= 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,22 +51,22 @@ void wifi_set_channel(void)
|
|||
|
||||
if (is_2Ghz) {
|
||||
error = wifi->set_channel(0);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
error = wifi->set_channel(1);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
error = wifi->set_channel(13);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK || error == NSAPI_ERROR_PARAMETER);
|
||||
error = wifi->set_channel(15);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
}
|
||||
|
||||
if (is_5Ghz) {
|
||||
error = wifi->set_channel(30);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
error = wifi->set_channel(36);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
error = wifi->set_channel(169);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
}
|
||||
|
||||
wifi->set_channel(0);
|
||||
|
|
|
@ -29,31 +29,31 @@ void wifi_set_credential(void)
|
|||
nsapi_error_t error;
|
||||
|
||||
error = iface->set_credentials(NULL, NULL, NSAPI_SECURITY_NONE);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("", "", NSAPI_SECURITY_NONE);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
error = iface->set_credentials("OK", "", NSAPI_SECURITY_NONE);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WEP);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WEP);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WPA_WPA2);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("OK", "", NSAPI_SECURITY_WPA_WPA2);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
|
||||
error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WEP);
|
||||
TEST_ASSERT((error == NSAPI_ERROR_OK) || (error == NSAPI_ERROR_UNSUPPORTED));
|
||||
|
@ -65,11 +65,11 @@ void wifi_set_credential(void)
|
|||
TEST_ASSERT((error == NSAPI_ERROR_OK) || (error == NSAPI_ERROR_UNSUPPORTED));
|
||||
|
||||
error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA_WPA2);
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
error = iface->set_credentials("OK", "kUjd0PHHeAqaDoyfcDDEOvbyiVbYMpUHDukGoR6EJZnO5iLzWsfwiM9JQqOngni", get_security());
|
||||
TEST_ASSERT(error == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error);
|
||||
|
||||
error = iface->set_credentials("OK", "kUjd0PHHeAqaDoyfcDDEOvbyiVbYMpUHDukGoR6EJZnO5iLzWsfwiM9JQqOngni8", get_security());
|
||||
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
|
||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_PARAMETER, error);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ typedef enum {
|
|||
TERMINATE = 0xFF00
|
||||
} TestCommand_t;
|
||||
|
||||
/* We group the command based on their fist byte to simplify step checking.
|
||||
/* We group the command based on their first byte to simplify step checking.
|
||||
* Individual conditions of a step are checked in the event so this doesn't
|
||||
* sacrifice any correctness checking */
|
||||
const size_t TEST_COMMAND_GROUP_MASK = 0xFF00;
|
||||
|
@ -359,7 +359,7 @@ public:
|
|||
_driver->write_bytes(_address, _operation_data, _operation_size);
|
||||
break;
|
||||
case ERASE_BYTES:
|
||||
_driver->erase_bytes(_address, 4);
|
||||
_driver->erase_bytes(_address, _operation_size);
|
||||
break;
|
||||
case READ_SIZE:
|
||||
_driver->read_size();
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/* Copyright (c) 2017-2018 ARM Limited
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* Template Version 1.0
|
||||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#include "spm_panic.h"
|
||||
#include "spm_internal.h"
|
||||
#include "handles_manager.h"
|
||||
#include "cmsis.h"
|
||||
#include "psa_crypto_srv_partition.h"
|
||||
#include "psa_its_partition.h"
|
||||
|
||||
extern const uint32_t crypto_srv_external_sids[4];
|
||||
|
||||
spm_partition_t g_partitions[2] = {
|
||||
{
|
||||
.partition_id = CRYPTO_SRV_ID,
|
||||
.thread_id = 0,
|
||||
.flags_rot_srv = CRYPTO_SRV_WAIT_ANY_SID_MSK,
|
||||
.flags_interrupts = 0,
|
||||
.rot_services = NULL,
|
||||
.rot_services_count = CRYPTO_SRV_ROT_SRV_COUNT,
|
||||
.extern_sids = crypto_srv_external_sids,
|
||||
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
|
||||
.irq_mapper = NULL,
|
||||
},
|
||||
{
|
||||
.partition_id = ITS_ID,
|
||||
.thread_id = 0,
|
||||
.flags_rot_srv = ITS_WAIT_ANY_SID_MSK,
|
||||
.flags_interrupts = 0,
|
||||
.rot_services = NULL,
|
||||
.rot_services_count = ITS_ROT_SRV_COUNT,
|
||||
.extern_sids = NULL,
|
||||
.extern_sids_count = ITS_EXT_ROT_SRV_COUNT,
|
||||
.irq_mapper = NULL,
|
||||
},
|
||||
};
|
||||
|
||||
/* Check all the defined memory regions for overlapping. */
|
||||
|
||||
/* A list of all the memory regions. */
|
||||
const mem_region_t *mem_regions = NULL;
|
||||
|
||||
const uint32_t mem_region_count = 0;
|
||||
|
||||
// forward declaration of partition initializers
|
||||
void crypto_srv_init(spm_partition_t *partition);
|
||||
void its_init(spm_partition_t *partition);
|
||||
|
||||
uint32_t init_partitions(spm_partition_t **partitions)
|
||||
{
|
||||
if (NULL == partitions) {
|
||||
SPM_PANIC("partitions is NULL!\n");
|
||||
}
|
||||
|
||||
crypto_srv_init(&(g_partitions[0]));
|
||||
its_init(&(g_partitions[1]));
|
||||
|
||||
*partitions = g_partitions;
|
||||
return 2;
|
||||
}
|
||||
|
|
@ -477,6 +477,7 @@ void mac_data_confirm_handler(const mac_api_t *api, const mcps_data_conf_t *data
|
|||
if (data->status == expected_statuses.data_conf) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
}
|
||||
|
@ -501,12 +502,14 @@ void mac_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *da
|
|||
}
|
||||
if (data->msdu_ptr && expected_statuses.data_ind) {
|
||||
if (data->msduLength != expected_statuses.data_ind_len) {
|
||||
cmd_printf("Bad recv length %d != %d!\n", data->msduLength, expected_statuses.data_ind_len);
|
||||
return;
|
||||
}
|
||||
if (strncmp((const char *)data->msdu_ptr, (const char *)expected_statuses.data_ind, expected_statuses.data_ind_len) == 0) {
|
||||
++data_count;
|
||||
cmd_printf("Data count %d\n", data_count);
|
||||
} else {
|
||||
tr_warn("Received unexpected data!");
|
||||
cmd_printf("Received unexpected data!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,6 +524,7 @@ void mac_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
|
|||
if (data->status == expected_statuses.purge_conf) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
}
|
||||
|
@ -547,6 +551,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
|
|||
if (get_data->status == expected_statuses.get_conf) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, status: %hhu (%s)\n", get_data->status, mlme_status_string(get_data->status));
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
break;
|
||||
|
@ -585,6 +590,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
|
|||
if (scan_data->status == expected_statuses.scan_conf || scan_data->status == MLME_LIMIT_REACHED) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, status: %hhu (%s)\n", scan_data->status, mlme_status_string(scan_data->status));
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
break;
|
||||
|
@ -599,24 +605,28 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
|
|||
mlme_poll_conf_t *poll_data = (mlme_poll_conf_t *)data;
|
||||
cmd_printf("MLME-POLL.confirm\n");
|
||||
if (!silent_mode) {
|
||||
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
|
||||
cmd_printf("data_count %u\n", data_count);
|
||||
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
|
||||
cmd_printf("expected status: %hhu (%s)\n", expected_statuses.poll_conf, mlme_status_string(expected_statuses.poll_conf));
|
||||
cmd_printf("data_count %u\n", data_count);
|
||||
}
|
||||
if (expected_statuses.poll_conf == MLME_SUCCESS) {
|
||||
if (data_count == 1 && poll_data->status == MLME_SUCCESS) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, data_count = %u, status:%hhu\n", data_count, poll_data->status);
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
} else if (expected_statuses.poll_conf == poll_data->status) {
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
} else {
|
||||
cmd_printf("CMD failed, data_count = %u, status:%hhu, expected ret:%hhu\n", data_count, poll_data->status, expected_statuses.poll_conf);
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
cmd_ready(CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
cmd_printf("CMD failed, not implemented\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "mac_mcps.h"
|
||||
#include "mac_common_defines.h"
|
||||
#include "mac_filter_api.h"
|
||||
#include "util.h"
|
||||
#include "mac_tester_util.h"
|
||||
|
||||
#define LOOKUP_DESCRIPTOR_TABLE_SIZE 2
|
||||
#define DEVICE_DESCRIPTOR_TABLE_SIZE 2
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "util.h"
|
||||
#include "mac_tester_util.h"
|
||||
|
||||
int string_to_bytes(const char *str, uint8_t *buf, int bytes)
|
||||
{
|
|
@ -18,12 +18,13 @@ limitations under the License.
|
|||
import threading
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "ED_scan",
|
||||
title = "ED scan test",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "smoke",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -54,9 +55,6 @@ class Testcase(Bench):
|
|||
|
||||
def setUp(self):
|
||||
self.channel = 11
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
|
||||
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
|
||||
|
||||
def spam_channel(self, event):
|
||||
while not event.wait(0.1):
|
||||
|
@ -71,8 +69,16 @@ class Testcase(Bench):
|
|||
res = res | ( 1 << ch)
|
||||
return hex(res)
|
||||
|
||||
def case(self):
|
||||
def do_test_iteration(self):
|
||||
self.lock_th = threading.Lock()
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("Second", "mlme-reset")
|
||||
self.command("Third", "mlme-reset")
|
||||
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
|
||||
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
|
||||
|
||||
self.payload = "01234567890123456789012345678901234567890123456789"
|
||||
|
||||
# Start PAN coordinator
|
||||
|
@ -105,6 +111,20 @@ class Testcase(Bench):
|
|||
# Energy detection analysis
|
||||
self.command("Second", "analyze-ed --channel {} --above 100".format(self.channel))
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.command("First", "silent-mode off")
|
||||
self.command("Third", "silent-mode off")
|
||||
|
@ -112,3 +132,4 @@ class Testcase(Bench):
|
|||
self.th.join()
|
||||
del self.th
|
||||
self.reset_dut()
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "address_read_and_write",
|
||||
title = "MAC address and PAN id read/write test",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "smoke",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -52,7 +53,8 @@ class Testcase(Bench):
|
|||
def setUp(self):
|
||||
pass
|
||||
|
||||
def case(self):
|
||||
def do_test_iteration(self):
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("First", "addr")
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("First", "addr --16-bit 0xABCD")
|
||||
|
@ -61,5 +63,20 @@ class Testcase(Bench):
|
|||
self.command("First", "addr")
|
||||
self.verify_trace(1, "MAC64: 01:02:03:00:00:00:00:01")
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.reset_dut()
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "create_and_join_PAN",
|
||||
title = "Create a PAN and have a device join it",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "smoke",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -60,12 +61,16 @@ class Testcase(Bench):
|
|||
def setUp(self):
|
||||
self.channel = 11
|
||||
|
||||
def case(self):
|
||||
def do_test_iteration(self):
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("Second", "mlme-reset")
|
||||
self.command("Third", "mlme-reset")
|
||||
|
||||
# Beacon payload
|
||||
self.command("First", "mlme-set --attr 0x45 --value_ascii mac-tester --value_size 10")
|
||||
# Beacon payload length
|
||||
self.command("First", "mlme-set --attr 0x46 --value_uint8 10 --value_size 1")
|
||||
|
||||
|
||||
self.command("Second", "mlme-set --attr 0x45 --value_ascii second-mac-tester --value_size 17")
|
||||
self.command("Second", "mlme-set --attr 0x46 --value_uint8 17 --value_size 1")
|
||||
|
||||
|
@ -84,5 +89,19 @@ class Testcase(Bench):
|
|||
self.command("Third", "find-beacon --data mac-tester")
|
||||
self.command("Third", "find-beacon --data second-mac-tester")
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.reset_dut()
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "send_data",
|
||||
title = "Simple data transmission test",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "smoke",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -52,10 +53,14 @@ class Testcase(Bench):
|
|||
|
||||
def setUp(self):
|
||||
self.channel = 11
|
||||
|
||||
def do_test_iteration(self):
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("Second", "mlme-reset")
|
||||
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
|
||||
|
||||
def case(self):
|
||||
# Start PAN coordinator
|
||||
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
|
||||
# Start PAN beacon
|
||||
|
@ -65,5 +70,20 @@ class Testcase(Bench):
|
|||
self.command("First", "data --dst_addr 01:02:03:00:00:00:00:02 --msdu_length 5 --msdu abcde")
|
||||
self.command("Second", "data --dst_addr 01:02:03:00:00:00:00:01 --msdu_length 5 --msdu 12345")
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.reset_dut()
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "send_data_indirect",
|
||||
title = "Indirect data transmission test",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "smoke",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -53,11 +54,17 @@ class Testcase(Bench):
|
|||
|
||||
def setUp(self):
|
||||
self.channel = 11
|
||||
|
||||
def do_test_iteration(self):
|
||||
self.channel = 11
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("Second", "mlme-reset")
|
||||
self.command("Third", "mlme-reset")
|
||||
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
|
||||
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
|
||||
|
||||
def case(self):
|
||||
# Start PAN coordinator
|
||||
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
|
||||
# Start PAN beacon
|
||||
|
@ -107,5 +114,21 @@ class Testcase(Bench):
|
|||
self.command("Third", "poll --coord_address 01:02:03:00:00:00:00:01")
|
||||
self.command("*", "silent-mode off")
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.command("*", "silent-mode off")
|
||||
self.reset_dut()
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import os,sys
|
||||
from icetea_lib.bench import Bench
|
||||
from icetea_lib.TestStepError import TestStepFail
|
||||
|
||||
class Testcase(Bench):
|
||||
def __init__(self):
|
||||
Bench.__init__(self, name = "send_large_payloads",
|
||||
title = "Data transmission test with large packets",
|
||||
status = "development",
|
||||
status = "released",
|
||||
type = "reliability",
|
||||
subtype = "",
|
||||
execution = {
|
||||
|
@ -52,10 +53,14 @@ class Testcase(Bench):
|
|||
|
||||
def setUp(self):
|
||||
self.channel = 11
|
||||
|
||||
def do_test_iteration(self):
|
||||
self.command("First", "mlme-reset")
|
||||
self.command("Second", "mlme-reset")
|
||||
|
||||
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
|
||||
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
|
||||
|
||||
def case(self):
|
||||
#104 characters, headers are 2+1+2+8+8+2=23 bytes, resulting in a packet size of 127 (max)
|
||||
large_payload = "0123456789abcdefghjiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZZZZZZZZZ0123456789012345678901234567891234"
|
||||
# Start PAN coordinator
|
||||
|
@ -83,5 +88,20 @@ class Testcase(Bench):
|
|||
self.command("Second", "data")
|
||||
self.command("First", "wait")
|
||||
|
||||
def case(self):
|
||||
# Try tests few times because of potential RF failures
|
||||
loop = 0
|
||||
while loop < 5:
|
||||
try:
|
||||
self.do_test_iteration()
|
||||
break
|
||||
except TestStepFail:
|
||||
self.logger.info("Warning, iteration failed #" + str(loop+1))
|
||||
loop = loop + 1
|
||||
self.delay(5)
|
||||
else:
|
||||
raise TestStepFail("Too many failed iterations!")
|
||||
|
||||
def tearDown(self):
|
||||
self.reset_dut()
|
||||
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
## Unit testing
|
||||
|
||||
This document describes how to write and test unit tests for Arm Mbed OS. To prevent and solve problems, please see the [troubleshooting](#troubleshooting) section.
|
||||
This document describes how to write and use unit tests for Arm Mbed OS.
|
||||
|
||||
### Introduction
|
||||
|
||||
Unit tests test code in small sections on a host machine. Unlike other testing tools, unit testing doesn't require embedded hardware, and it doesn't need to build the full operating system. Because of this, unit testing can result in faster tests than other testing tools. Unit testing takes place in a build environment where we test each C or C++ class or module in isolation. This means we build test suites into separate test binaries and stub all access outside to remove dependencies on any specific embedded hardware or software combination. This allows us to complete the testing using native compilers on the build machine.
|
||||
Unit tests test code in small sections on a host machine. Unlike other testing tools, unit testing doesn't require embedded hardware or need to build a full operating system. Because of this, unit testing can result in faster tests than other tools. Unit testing happens in a build environment where you test each C or C++ class or module in isolation. Build test suites into separate test binaries and stub all access outside to remove dependencies on any specific embedded hardware or software combination. This allows you to complete tests using native compilers on the build machine.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Please install the following dependencies to use Mbed OS unit testing.
|
||||
Please install the following dependencies to use Mbed OS unit testing:
|
||||
|
||||
- GNU toolchains.
|
||||
- GCC 6 or later. We recommend you use MinGW-W64 on Windows, but any Windows port of the above GCC versions works. Default compilers can be used on Mac OS instead of GCC to shorten build times, but code coverage results can then differ.
|
||||
- CMake 3.0 or newer.
|
||||
- Python 2.7.x, 3.5 or newer.
|
||||
- Pip 10.0 or newer.
|
||||
- Gcovr 4.1 or newer.
|
||||
- Arm Mbed CLI 1.8.0 or newer.
|
||||
* GNU toolchains.
|
||||
* GCC 6 or later. We recommend you use MinGW-W64 on Windows, but any Windows port of the above GCC versions works. Default compilers can be used on Mac OS instead of GCC to shorten build times, but code coverage results can differ.
|
||||
* CMake 3.0 or newer.
|
||||
* Python 2.7.x, 3.5 or newer.
|
||||
* Pip 10.0 or newer.
|
||||
* Gcovr 4.1 or newer.
|
||||
* Arm Mbed CLI 1.8.0 or newer.
|
||||
|
||||
Detailed instructions for supported operating systems are below.
|
||||
|
||||
#### Installing dependencies on Debian or Ubuntu
|
||||
|
||||
In a terminal window:
|
||||
|
||||
1. `sudo apt-get -y install build-essential cmake`
|
||||
1. Install Python and Pip with:
|
||||
|
||||
|
@ -34,6 +36,8 @@ Detailed instructions for supported operating systems are below.
|
|||
|
||||
#### Installing dependencies on macOS
|
||||
|
||||
In a terminal window:
|
||||
|
||||
1. Install [Homebrew](https://brew.sh/).
|
||||
1. Install Xcode Command Line Tools with `xcode-select --install`.
|
||||
1. Install CMake with: `brew install cmake`.
|
||||
|
@ -49,7 +53,9 @@ Detailed instructions for supported operating systems are below.
|
|||
|
||||
#### Installing dependencies on Windows
|
||||
|
||||
1. Download and install [MinGW-W64](http://mingw-w64.org/).
|
||||
In a terminal window:
|
||||
|
||||
1. Download and install MinGW-W64 from [SourceForge](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/).
|
||||
1. Download CMake binaries from https://cmake.org/download/, and run the installer.
|
||||
1. Download Python 2.7 or Python 3 from https://www.python.org/getit/, and run the installer.
|
||||
1. Add MinGW, CMake and Python into system PATH.
|
||||
|
@ -57,13 +63,15 @@ Detailed instructions for supported operating systems are below.
|
|||
|
||||
### Test code structure
|
||||
|
||||
Unit tests are located in the Mbed OS repository under the `UNITTESTS` folder. We recommend unit test files use an identical directory path to the file under test. This makes it easier to find unit tests for a particular class or a module. For example, if the file under test is `some/example/path/ClassName.cpp`, then all the test files are in the `UNITTESTS/some/example/path/ClassName` directory. Each test suite needs to have its own `unittest.cmake` file for test configuration.
|
||||
Find unit tests in the Mbed OS repository under the `UNITTESTS` folder. We recommend unit test files use an identical directory path as the file under test. This makes it easier to find unit tests for a particular class or a module. For example, if the file you're testing is `some/example/path/ClassName.cpp`, then all the test files are in the `UNITTESTS/some/example/path/ClassName` directory. Each test suite needs to have its own `unittest.cmake` file for test configuration.
|
||||
|
||||
All the class stubs should be located in the `UNITTESTS/stubs` directory. A single stub class can be used by multiple test suites and should follow the naming convention `ClassName_stub.cpp` for the source file, and `ClassName_stub.h` for the header file. Use the actual header files for the unit tests, and don't stub headers if possible. The stubbed headers reside in the `UNITTESTS/target_h` directory.
|
||||
|
||||
#### Test discovery
|
||||
|
||||
Registering unit tests for running is automatic, and the test runner handles registration. However, test files are not automatically assigned to be built. We build unit tests by using a separate build system, which searches for unit tests under the `UNITTESTS` directory.
|
||||
Registering unit tests to run happens automatically, and the test runner handles registration. However, test files do not automatically build. Build unit tests with a separate system that searches for unit tests under the `UNITTESTS` directory.
|
||||
|
||||
For the build system to find and build any test suite automatically, you must include a unit test configuration file named `unittest.cmake` for each unit test suite. This configuration file contains all the source files required for the build.
|
||||
For the build system to find and build any test suite automatically, include a unit test configuration file named `unittest.cmake` for each unit test suite. This configuration file lists all the source files required for the test build.
|
||||
|
||||
#### Test names
|
||||
|
||||
|
@ -71,20 +79,30 @@ The build system automatically generates names of test suites. The name is const
|
|||
|
||||
### Unit testing with Mbed CLI
|
||||
|
||||
Mbed CLI supports unit tests through `mbed test --unittests` command. For information on using Mbed CLI, please see the [CLI documentation](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html).
|
||||
Mbed CLI supports unit tests through the `mbed test --unittests` command. For information on using Mbed CLI, please see the [CLI documentation](https://os.mbed.com/docs/latest/tools/developing-arm-mbed-cli.html).
|
||||
|
||||
### Writing unit tests
|
||||
|
||||
A unit tests suite consists of one or more test cases. The test cases should cover all the functions in a class under test. All the external dependencies are stubbed including the other classes in the same module. Avoid stubbing header files. Finally, analyze code coverage to ensure all code is tested, and no dead code is found.
|
||||
|
||||
Please see the [documentation for Google Test](https://github.com/google/googletest/blob/master/googletest/docs/primer.md) to learn how to write unit tests using its framework. See the [documentation for Google Mock](https://github.com/google/googletest/blob/master/googlemock/docs/Documentation.md) if you want to write and use C++ mock classes instead of stubs.
|
||||
|
||||
#### Test suite configuration
|
||||
|
||||
Create two files in the test directory for each test suite:
|
||||
|
||||
- Unit test source file (`test_ClassName.cpp`).
|
||||
- Unit test configuration file (`unittest.cmake`).
|
||||
* Unit test source file (`test_ClassName.cpp`).
|
||||
* Unit test configuration file (`unittest.cmake`).
|
||||
|
||||
List all the files required for the build in the `unittest.cmake` file. We recommend you list the file paths relative to the `UNITTESTS` folder. Use the following variables to list the source files and include paths:
|
||||
List all the required files for the build in the `unittest.cmake` file with paths relative to the `UNITTESTS` folder. Use the following variables to list the source files and include paths:
|
||||
|
||||
- **unittest-includes** - List of header include paths. You can use this to extend or overwrite default paths listed in CMakeLists.txt.
|
||||
- **unittest-sources** - List of files under test.
|
||||
- **unittest-test-sources** - List of test sources and stubs.
|
||||
* **unittest-includes**: List of header include paths. You can use this to extend or overwrite default paths listed in `UNITTESTS/CMakeLists.txt`.
|
||||
* **unittest-sources**: List of files under test.
|
||||
* **unittest-test-sources**: List of test sources and stubs.
|
||||
|
||||
You can also set custom compiler flags and other configurations supported by CMake in `unittest.cmake`.
|
||||
|
||||
#### Example
|
||||
|
||||
With the following steps, you can write a simple unit test. In this example, `rtos/Semaphore.cpp` is a class under test.
|
||||
|
||||
|
@ -97,11 +115,13 @@ With the following steps, you can write a simple unit test. In this example, `rt
|
|||
)
|
||||
|
||||
set(unittest-test-sources
|
||||
stubs/mbed_assert.c
|
||||
stubs/mbed_assert_stub.c
|
||||
stubs/Kernel_stub.cpp
|
||||
rtos/Semaphore/test_Semaphore.cpp
|
||||
)
|
||||
```
|
||||
|
||||
1. Stub all external dependencies. Create stubs `UNITTESTS/stubs/mbed_assert_stub.c` and `UNITTESTS/stubs/Kernel_stub.cpp` if they don't already exist.
|
||||
1. Update header stubs with any missing type or function declarations.
|
||||
1. Create a test source file `UNITTESTS/rtos/Semaphore/test_Semaphore.cpp` with the following content:
|
||||
|
||||
```
|
||||
|
@ -163,28 +183,28 @@ Use Mbed CLI to build and run unit tests. For advanced use, you can run CMake an
|
|||
1. Create a build directory `mkdir UNITTESTS/build`.
|
||||
1. Move to the build directory `cd UNITTESTS/build`.
|
||||
1. Run CMake using a relative path to `UNITTESTS` folder as the argument. So from `UNITTESTS/build` use `cmake ..`:
|
||||
- Add `-g [generator]` if generating other than Unix Makefiles such in case of MinGW use `-g "MinGW Makefiles"`.
|
||||
- Add `-DCMAKE_MAKE_PROGRAM=<value>`, `-DCMAKE_CXX_COMPILER=<value>` and `-DCMAKE_C_COMPILER=<value>` to use a specific Make program and compilers.
|
||||
- Add `-DCMAKE_BUILD_TYPE=Debug` to build a debug build.
|
||||
- Add `-DCOVERAGE=True` to add coverage compiler flags.
|
||||
- See the [CMake manual](https://cmake.org/cmake/help/v3.0/manual/cmake.1.html) for more information.
|
||||
1. Run a Make program to build the tests.
|
||||
* Add `-g [generator]` if generating other than Unix Makefiles such in case of MinGW use `-g "MinGW Makefiles"`.
|
||||
* Add `-DCMAKE_MAKE_PROGRAM=<value>`, `-DCMAKE_CXX_COMPILER=<value>` and `-DCMAKE_C_COMPILER=<value>` to use a specific Make program and compilers.
|
||||
* Add `-DCMAKE_BUILD_TYPE=Debug` for a debug build.
|
||||
* Add `-DCOVERAGE=True` to add coverage compiler flags.
|
||||
* See the [CMake manual](https://cmake.org/cmake/help/v3.0/manual/cmake.1.html) for more information.
|
||||
1. Run a Make program to build tests.
|
||||
|
||||
#### Run tests directly with CTest
|
||||
|
||||
Run a test binary in the build directory to run a unit test suite. To run multiple test suites at once, use CTest test runner. Run CTest with `ctest`. Add `-v` to get results for each test case. See the [CTest manual](https://cmake.org/cmake/help/v3.0/manual/ctest.1.html) for more information.
|
||||
Run a test binary in the build directory to run a unit test suite. To run multiple test suites at once, use the CTest test runner. Run CTest with `ctest`. Add `-v` to get results for each test case. See the [CTest manual](https://cmake.org/cmake/help/v3.0/manual/ctest.1.html) for more information.
|
||||
|
||||
#### Run tests with GUI test runner
|
||||
|
||||
1. Install *gtest-runner* using the [documentation](https://github.com/nholthaus/gtest-runner).
|
||||
1. Run *gtest-runner*
|
||||
1. Add test executables into the list.
|
||||
1. Run them.
|
||||
1. Install `gtest-runner` according to the [documentation](https://github.com/nholthaus/gtest-runner).
|
||||
1. Run `gtest-runner`.
|
||||
1. Add test executables into the list and run.
|
||||
|
||||
### Debugging
|
||||
|
||||
1. Use Mbed CLI to build a debug build. For advanced use, run CMake directly with `-DCMAKE_BUILD_TYPE=Debug`, and then run a Make program.
|
||||
1. Run GDB with a test executable as an argument to debug unit tests.
|
||||
1. Run tests with Valgrind to analyze the test memory profile.
|
||||
|
||||
### Get code coverage
|
||||
|
||||
|
@ -200,8 +220,11 @@ Use Mbed CLI to generate code coverage reports. For advanced use, follow these s
|
|||
**Problem:** Generic problems with CMake or with the build process.
|
||||
* **Solution**: Delete the build directory. Make sure that CMake, g++, GCC and a Make program can be found in the path and are correct versions.
|
||||
|
||||
**Problem:** Virus protection identifies files generated by CMake as malicious and quarantines the files on Windows.
|
||||
* **Solution**: Restore the false positive files from the quarantine.
|
||||
**Problem:** (Windows) Virus protection identifies files generated by CMake as malicious and quarantines the files.
|
||||
* **Solution**: Restore false-positive files from the quarantine.
|
||||
|
||||
**Problem:** CMake compiler check fails on Mac OS Mojave when using GCC-8.
|
||||
**Problem:** (Windows) Git with shell installation adds sh.exe to the path and then CMake throws an error: sh.exe was found in your PATH. For MinGW make to work correctly, sh.exe must NOT be in your path.
|
||||
* **Solution**: Remove sh.exe from the system path.
|
||||
|
||||
**Problem:** (Mac OS) CMake compiler check fails on Mac OS Mojave when using GCC-8.
|
||||
* **Solution**: Make sure gnm (binutils) is not installed. Uninstall binutils with `brew uninstall binutils`.
|
||||
|
|
|
@ -53,7 +53,6 @@ protected:
|
|||
ATHandler_stub::bool_value = false;
|
||||
ATHandler_stub::uint8_value = 0;
|
||||
ATHandler_stub::fh_value = NULL;
|
||||
ATHandler_stub::callback = NULL;
|
||||
ATHandler_stub::call_immediately = false;
|
||||
ATHandler_stub::resp_info_true_counter = false;
|
||||
ATHandler_stub::info_elem_true_counter = false;
|
||||
|
@ -63,6 +62,9 @@ protected:
|
|||
ATHandler_stub::read_string_table[kRead_string_table_size];
|
||||
ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
|
||||
CellularDevice_stub::connect_counter = 2;
|
||||
for (int i=0; i < kATHandler_urc_table_max_size; i++) {
|
||||
ATHandler_stub::callback[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
|
|
|
@ -211,6 +211,71 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params)
|
|||
EXPECT_TRUE(reg_params_check._cell_id == -1 && reg_params_check._active_time == -1 && reg_params_check._periodic_tau == -1);
|
||||
}
|
||||
|
||||
static int disconnect_cb_count = 0;
|
||||
static bool disconnect_cb_param_check = false;
|
||||
static void disconnect_cb(nsapi_event_t ev, intptr_t intptr)
|
||||
{
|
||||
disconnect_cb_count++;
|
||||
|
||||
if (disconnect_cb_count == 3 && disconnect_cb_param_check) {
|
||||
EXPECT_TRUE(ev == NSAPI_EVENT_CONNECTION_STATUS_CHANGE);
|
||||
EXPECT_TRUE(intptr == NSAPI_STATUS_DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_registration_status_change)
|
||||
{
|
||||
EventQueue que;
|
||||
FileHandle_stub fh1;
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
AT_CellularNetwork cn(at);
|
||||
|
||||
|
||||
cn.attach(&disconnect_cb);
|
||||
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
ATHandler_stub::process_oob_urc = true;
|
||||
|
||||
ATHandler_stub::read_string_index = 2;
|
||||
ATHandler_stub::read_string_table[2] = "+CREG:";
|
||||
ATHandler_stub::read_string_table[1] = "00C3";
|
||||
ATHandler_stub::read_string_table[0] = "A13F";
|
||||
ATHandler_stub::int_count = 2;
|
||||
//ATHandler_stub::int_valid_count_table[2] = 1; //URC status is skipped
|
||||
ATHandler_stub::int_valid_count_table[1] = 0; //not registered
|
||||
ATHandler_stub::int_valid_count_table[0] = 1;
|
||||
at.process_oob();
|
||||
|
||||
disconnect_cb_count = 0;
|
||||
disconnect_cb_param_check = true;
|
||||
ATHandler_stub::read_string_index = 4;
|
||||
ATHandler_stub::read_string_table[4] = "+CREG:";
|
||||
ATHandler_stub::read_string_table[3] = "00C3";
|
||||
ATHandler_stub::read_string_table[2] = "A13F";
|
||||
ATHandler_stub::read_string_table[1] = "FF";
|
||||
ATHandler_stub::read_string_table[0] = "FF";
|
||||
ATHandler_stub::int_count = 2;
|
||||
//ATHandler_stub::int_valid_count_table[2] = 1; //URC status is skipped
|
||||
ATHandler_stub::int_valid_count_table[1] = 1; //registered, home network
|
||||
ATHandler_stub::int_valid_count_table[0] = 1;
|
||||
at.process_oob();
|
||||
|
||||
ATHandler_stub::read_string_index = 5;
|
||||
ATHandler_stub::int_count = 3;
|
||||
ATHandler_stub::read_string_index = 4;
|
||||
ATHandler_stub::read_string_table[4] = "+CREG:";
|
||||
ATHandler_stub::read_string_table[3] = "00C3";
|
||||
ATHandler_stub::read_string_table[2] = "A13F";
|
||||
ATHandler_stub::read_string_table[1] = "FF";
|
||||
ATHandler_stub::read_string_table[0] = "FF";
|
||||
ATHandler_stub::int_count = 2;
|
||||
//ATHandler_stub::int_valid_count_table[2] = 1; //URC status is skipped
|
||||
ATHandler_stub::int_valid_count_table[1] = 4; //unknown registration status
|
||||
ATHandler_stub::int_valid_count_table[0] = 1;
|
||||
at.process_oob();
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_network_registering_mode)
|
||||
{
|
||||
EventQueue que;
|
||||
|
|
|
@ -37,5 +37,5 @@ set(unittest-test-sources
|
|||
)
|
||||
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH=8 -DMBED_CONF_LORA_DUTY_CYCLE_ON_JOIN=true")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH=8 -DMBED_CONF_LORA_DUTY_CYCLE_ON_JOIN=true")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH=8 -DMBED_CONF_LORA_DUTY_CYCLE_ON_JOIN=true -DMBED_CONF_LORA_WAKEUP_TIME=5")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH=8 -DMBED_CONF_LORA_DUTY_CYCLE_ON_JOIN=true -DMBED_CONF_LORA_WAKEUP_TIME=5")
|
||||
|
|
|
@ -43,16 +43,19 @@ bool ATHandler_stub::bool_value = false;
|
|||
uint8_t ATHandler_stub::uint8_value = 0;
|
||||
FileHandle_stub *ATHandler_stub::fh_value = NULL;
|
||||
device_err_t ATHandler_stub::device_err_value;
|
||||
Callback<void()> ATHandler_stub::callback = NULL;
|
||||
bool ATHandler_stub::call_immediately = false;
|
||||
uint8_t ATHandler_stub::resp_info_true_counter = false;
|
||||
uint8_t ATHandler_stub::info_elem_true_counter = false;
|
||||
int ATHandler_stub::int_valid_count_table[kRead_int_table_size];
|
||||
int ATHandler_stub::int_count = kRead_int_table_size;
|
||||
bool ATHandler_stub::process_oob_urc = false;
|
||||
|
||||
int ATHandler_stub::read_string_index = kRead_string_table_size;
|
||||
const char *ATHandler_stub::read_string_table[kRead_string_table_size];
|
||||
int ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
|
||||
int ATHandler_stub::urc_amount = 0;
|
||||
mbed::Callback<void()> ATHandler_stub::callback[kATHandler_urc_table_max_size];
|
||||
char *ATHandler_stub::urc_string_table[kATHandler_urc_table_max_size];
|
||||
|
||||
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char *output_delimiter, uint16_t send_delay) :
|
||||
_nextATHandler(0),
|
||||
|
@ -60,6 +63,14 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
|
|||
_queue(queue)
|
||||
{
|
||||
ATHandler_stub::ref_count = 1;
|
||||
|
||||
ATHandler_stub::process_oob_urc = false;
|
||||
ATHandler_stub::urc_amount = 0;
|
||||
int i = 0;
|
||||
while (i < kATHandler_urc_table_max_size) {
|
||||
ATHandler_stub::callback[i] = NULL;
|
||||
ATHandler_stub::urc_string_table[i++] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ATHandler::set_debug(bool debug_on)
|
||||
|
@ -70,6 +81,16 @@ void ATHandler::set_debug(bool debug_on)
|
|||
ATHandler::~ATHandler()
|
||||
{
|
||||
ATHandler_stub::ref_count = kATHandler_destructor_ref_ount;
|
||||
|
||||
int i = 0;
|
||||
while (i < kATHandler_urc_table_max_size) {
|
||||
if (ATHandler_stub::urc_string_table[i]) {
|
||||
delete [] ATHandler_stub::urc_string_table[i];
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATHandler::inc_ref_count()
|
||||
|
@ -98,7 +119,18 @@ void ATHandler::set_file_handle(FileHandle *fh)
|
|||
|
||||
nsapi_error_t ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb)
|
||||
{
|
||||
ATHandler_stub::callback = cb;
|
||||
if (ATHandler_stub::urc_amount < kATHandler_urc_table_max_size) {
|
||||
ATHandler_stub::callback[ATHandler_stub::urc_amount] = cb;
|
||||
ATHandler_stub::urc_string_table[ATHandler_stub::urc_amount] = new char[kATHandler_urc_string_max_size];
|
||||
if (urc) {
|
||||
int bytes_to_copy = strlen(urc) < kATHandler_urc_string_max_size ? strlen(urc) : kATHandler_urc_string_max_size;
|
||||
memcpy(ATHandler_stub::urc_string_table[ATHandler_stub::urc_amount], urc, bytes_to_copy);
|
||||
}
|
||||
ATHandler_stub::urc_amount++;
|
||||
} else {
|
||||
ATHandler_stub::callback[0] = cb;
|
||||
MBED_ASSERT("ATHandler URC amount limit reached");
|
||||
}
|
||||
if (ATHandler_stub::call_immediately) {
|
||||
cb();
|
||||
}
|
||||
|
@ -143,6 +175,20 @@ void ATHandler::restore_at_timeout()
|
|||
|
||||
void ATHandler::process_oob()
|
||||
{
|
||||
if (ATHandler_stub::process_oob_urc) {
|
||||
int i = 0;
|
||||
while (i < ATHandler_stub::urc_amount) {
|
||||
if (ATHandler_stub::read_string_index >= 0) {
|
||||
if (!memcmp(ATHandler_stub::urc_string_table[i],
|
||||
ATHandler_stub::read_string_table[ATHandler_stub::read_string_index],
|
||||
strlen(ATHandler_stub::urc_string_table[i]))) {
|
||||
ATHandler_stub::callback[i]();
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATHandler::clear_error()
|
||||
|
|
|
@ -31,6 +31,8 @@ static const int kRead_int_table_size = 100;
|
|||
static const int kResp_stop_count_default = 100;
|
||||
// set reference count to -909 to separate it from zero so we can test that ATHandler is really deleted.
|
||||
static const int kATHandler_destructor_ref_ount = -909;
|
||||
static const int kATHandler_urc_table_max_size = 10;
|
||||
static const int kATHandler_urc_string_max_size = 16;
|
||||
|
||||
namespace ATHandler_stub {
|
||||
extern nsapi_error_t nsapi_error_value;
|
||||
|
@ -50,13 +52,16 @@ extern uint8_t info_elem_true_counter;
|
|||
extern uint8_t uint8_value;
|
||||
extern mbed::FileHandle_stub *fh_value;
|
||||
extern mbed::device_err_t device_err_value;
|
||||
extern mbed::Callback<void()> callback;
|
||||
extern mbed::Callback<void()> callback[kATHandler_urc_table_max_size];
|
||||
extern bool call_immediately;
|
||||
extern const char *read_string_table[kRead_string_table_size];
|
||||
extern int read_string_index;
|
||||
extern int int_valid_count_table[kRead_int_table_size];
|
||||
extern int int_count;
|
||||
extern int resp_stop_success_count;
|
||||
extern bool process_oob_urc;
|
||||
extern int urc_amount;
|
||||
extern char *urc_string_table[kATHandler_urc_table_max_size];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -168,9 +168,10 @@ uint8_t LoRaPHY::verify_link_ADR_req(verify_adr_params_t *verify_params,
|
|||
return LoRaPHY_stub::uint8_value;
|
||||
}
|
||||
|
||||
void LoRaPHY::get_rx_window_params(double t_symb, uint8_t min_rx_symb,
|
||||
uint32_t rx_error, uint32_t wakeup_time,
|
||||
uint32_t *window_timeout, int32_t *window_offset)
|
||||
void LoRaPHY::get_rx_window_params(float t_symbol, uint8_t min_rx_symbols,
|
||||
float rx_error, float wakeup_time,
|
||||
uint32_t *window_length, int32_t *window_offset,
|
||||
uint8_t phy_dr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,13 @@ def execute_program(args, error_msg="An error occurred!", success_msg=None):
|
|||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
# Output is stripped to remove newline character. logging adds its own
|
||||
# so we avoid double newlines.
|
||||
# Because the process can terminate before the loop has read all lines,
|
||||
# we read the output remnant just in case. Otherwise we lose it.
|
||||
while process.poll() is None:
|
||||
logging.info(process.stdout.readline().decode("utf8"))
|
||||
logging.info(process.stdout.readline().decode('utf8').rstrip('\n'))
|
||||
logging.info(process.stdout.read().decode('utf8').rstrip('\n'))
|
||||
|
||||
retcode = process.wait()
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
|
||||
#define __FPU_USED 1U
|
||||
#else
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
|
||||
#define __FPU_USED 1U
|
||||
#else
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
@ -668,7 +668,7 @@ typedef struct
|
|||
#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */
|
||||
|
||||
/* Auxiliary Control Register Definitions */
|
||||
|
||||
#if defined (__CM3_REV) && (__CM3_REV >= 0x200U)
|
||||
#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */
|
||||
#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */
|
||||
|
||||
|
@ -677,6 +677,7 @@ typedef struct
|
|||
|
||||
#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */
|
||||
#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */
|
||||
#endif
|
||||
|
||||
/*@} end of group CMSIS_SCnotSCB */
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined (__ARM_PCS_VFP)
|
||||
#if defined (__ARM_FP)
|
||||
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
|
||||
#define __FPU_USED 1U
|
||||
#else
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
|
||||
#define __FPU_USED 1U
|
||||
#else
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
|
||||
#define __FPU_USED 1U
|
||||
#else
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#if defined __ARM_FP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "device.h"
|
||||
#include "mbed_error.h"
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#define RFF_TX 0x04
|
||||
#define RFF_CCA 0x08
|
||||
|
||||
namespace {
|
||||
|
||||
typedef enum {
|
||||
RF_MODE_NORMAL = 0,
|
||||
RF_MODE_SNIFFER = 1,
|
||||
|
@ -82,6 +84,8 @@ typedef enum {
|
|||
STATE_TRANSITION_IN_PROGRESS = 0x1F
|
||||
} rf_trx_states_t;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
static const uint8_t *rf_tx_data; // Points to Nanostack's buffer
|
||||
static uint8_t rf_tx_length;
|
||||
/*ACK wait duration changes depending on data rate*/
|
||||
|
|
|
@ -65,6 +65,8 @@ extern "C" {
|
|||
#define gXcvrLowPowerState_d gXcvrPwrAutodoze_c
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
/* MCR20A XCVR states */
|
||||
typedef enum xcvrState_tag {
|
||||
gIdle_c,
|
||||
|
@ -106,6 +108,8 @@ typedef enum {
|
|||
TX_ARET_ON = 0x19
|
||||
} rf_trx_states_t;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
/*RF receive buffer*/
|
||||
static uint8_t rf_buffer[RF_BUFFER_SIZE];
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ void rf_conf_calculate_rx_filter_bandwidth_registers(uint32_t rx_bandwidth, uint
|
|||
uint8_t chflt_e_tmp = 0;
|
||||
uint8_t chflt_m_tmp = 0;
|
||||
|
||||
while (rx_bandwidth < 900000 / (2 << chflt_e_tmp)) {
|
||||
while (rx_bandwidth < 900000u / (2 << chflt_e_tmp)) {
|
||||
chflt_e_tmp++;
|
||||
}
|
||||
uint32_t rx_bandwidth_tmp = rx_bandwidth;
|
||||
|
|
|
@ -301,7 +301,11 @@ typedef enum {
|
|||
S2LP_STATE_SYNTH_SETUP = 0x50
|
||||
} s2lp_states_e;
|
||||
|
||||
#if defined __cplusplus && __cplusplus >= 201103
|
||||
typedef enum : uint8_t {
|
||||
#else
|
||||
typedef enum {
|
||||
#endif
|
||||
S2LP_CMD_TX = 0x60,
|
||||
S2LP_CMD_RX,
|
||||
S2LP_CMD_READY,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef DEVICE_FLASH
|
||||
#if DEVICE_FLASH
|
||||
|
||||
#include "FlashIAPBlockDevice.h"
|
||||
#include "mbed_critical.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef MBED_FLASHIAP_BLOCK_DEVICE_H
|
||||
#define MBED_FLASHIAP_BLOCK_DEVICE_H
|
||||
|
||||
#ifdef DEVICE_FLASH
|
||||
#if DEVICE_FLASH
|
||||
|
||||
#include "FlashIAP.h"
|
||||
#include "BlockDevice.h"
|
||||
|
|
|
@ -421,7 +421,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
|
|||
if (_set_write_enable() != 0) {
|
||||
tr_error("QSPI Erase Device not ready - failed");
|
||||
erase_failed = true;
|
||||
status = QSPIF_BD_ERROR_READY_FAILED;
|
||||
status = QSPIF_BD_ERROR_WREN_FAILED;
|
||||
goto exit_point;
|
||||
}
|
||||
|
||||
|
@ -1024,12 +1024,9 @@ int QSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table
|
|||
//_inst_width = QSPI_CFG_BUS_QUAD;
|
||||
_address_width = QSPI_CFG_BUS_QUAD;
|
||||
_data_width = QSPI_CFG_BUS_QUAD;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
is_qpi_mode = false;
|
||||
examined_byte = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_FAST_READ_SUPPORT_BYTE];
|
||||
if (examined_byte & 0x40) {
|
||||
// Fast Read 1-4-4 Supported
|
||||
|
|
|
@ -48,6 +48,10 @@ void basic_erase_program_read_test(QSPIFBlockDevice &blockD, bd_size_t block_siz
|
|||
{
|
||||
int err = 0;
|
||||
_mutex->lock();
|
||||
|
||||
static unsigned block_seed = 1;
|
||||
srand(block_seed++);
|
||||
|
||||
// Find a random block
|
||||
bd_addr_t block = (rand() * block_size) % blockD.size();
|
||||
|
||||
|
|
|
@ -20,9 +20,18 @@
|
|||
"DISCO_L476VG": {
|
||||
"QSPI_FREQ": "80000000"
|
||||
},
|
||||
"DISCO_L496AG": {
|
||||
"QSPI_FREQ": "8000000"
|
||||
},
|
||||
"DISCO_F469NI": {
|
||||
"QSPI_FREQ": "80000000"
|
||||
},
|
||||
"DISCO_F746NG": {
|
||||
"QSPI_FREQ": "80000000"
|
||||
},
|
||||
"DISCO_F769NI": {
|
||||
"QSPI_FREQ": "8000000"
|
||||
},
|
||||
"NRF52840_DK": {
|
||||
"QSPI_FREQ": "32000000"
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue