Skip to content

Release candidate for mbed-os-5.9.2 #7375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 142 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
b60abe1
Update mbed-coap to version 4.4.4
Jun 1, 2018
1fde01c
Add API to read Thread EUI-64
kjbracey Jun 7, 2018
ad016f4
Correct supported check of uvision to include uARM
theotherjimmy Jun 12, 2018
2f12845
Heed default_lib in arm compiler
theotherjimmy Jun 12, 2018
51708bc
Compute ARM_STD and ARM_MICRO labels with target attrs
theotherjimmy Jun 12, 2018
2c4a868
Correct "defalut" typo
theotherjimmy Jun 13, 2018
dc3092f
Support erasing of more than one erase unit in the exhaustible block …
Jun 3, 2018
8cc8b81
Tolerate packet loss up to 30% in udp echo tests
Jun 13, 2018
44bf7d6
Force small lib usage when using uARM tc
theotherjimmy Jun 15, 2018
cecd0c3
NRF52_DK: SLEEP enable
maciejbocianski May 31, 2018
9fdb9a1
Added long echo sequence test to EMAC tests
Jun 13, 2018
fa42c72
LPC54628: Update the ADC clock divider based on the input clock source
mmahadevan108 Jun 12, 2018
8f29bf5
Nordic BLE: Accept connection parameter update
pan- Jun 13, 2018
6e9d1ac
Enable COG boards instruction cache
Jun 18, 2018
de135d7
Enable COG boards flash algo
Jun 18, 2018
322a154
Spelling error in fault handler
janjongboom Jun 18, 2018
4094ebc
Add comments for HAL_InitTick function
bcostm Jun 15, 2018
de5985b
Remove text related to channel2
bcostm Jun 15, 2018
50a79a6
Disabled STM ethernet driver hardware checksum calculation
Jun 15, 2018
a7b8ccc
Rename files to fix warning
Jun 18, 2018
5dcd265
Make MTB_ADV_WISE_1570 respect MBED_APP_START & enable bootloader
Jun 15, 2018
3bc03e3
Changed DNS global class definitions to singletons
Jun 13, 2018
e5c9a09
Enlarge wait time in Greentea test function test_deepsleep
ccli8 Jun 15, 2018
ecef1f5
Fix default interface selection by using correct macro names.
Jun 18, 2018
cfe9225
Fix typo: WifiInterface -> WiFiInterface and add missing return.
Jun 19, 2018
3346180
Cellular: Added power and sim greentea and unit tests.
Jun 6, 2018
2cadd9d
Cellular: fixed unit tests after rebase with latest changes.
Jun 15, 2018
38e8ac4
Rename text region in ARM linker file for a few NXP CPUs
Jun 18, 2018
d10dee1
Adding precise timing for receive delays
Jun 11, 2018
2db1b9a
Queuing the automatic uplink
Jun 11, 2018
6ab0c0b
Adding port in trace & streamlining continuous RX2
Jun 11, 2018
e8f9f4d
Adding valid frequency check for RXParamSetup cmd
Jun 11, 2018
600efe9
Remaining style fixes
Jun 12, 2018
ed43eab
Allow hex BL, SD and application merging
theotherjimmy Jun 19, 2018
41335ad
IAR: Suppress C "bypasses initialization" warning
kjbracey Jun 19, 2018
e858b98
Provide default WiFI interface for REALTEK_RTL8195AM
Jun 19, 2018
0b7e21a
Provide default WiFi interface for Ublox EVK ODIN W2
Jun 19, 2018
3e4076a
Asynchronous DNS greentea tests
May 14, 2018
9d062c0
Non-blocking K64F/K66F ethernet power up
Jun 7, 2018
f1416c7
Added delay to K64F/K66F ethernet TX when all descriptors are in use
Jun 13, 2018
787ea51
K64F, K66F: Update the ENET PHY driver
Jun 15, 2018
9cd91a6
fix hash alignment of F2, F7, L4
bcostm Jun 13, 2018
15553bd
Suppress warning for IAR compiler as well
Jun 19, 2018
207dbb2
STM32: Reduce HAL_deepsleep stack usage
Jun 18, 2018
518ac5a
update pack index
Jun 19, 2018
1b18393
Add binary drivers for MTB_MXCHIP_EMW3166
KariHaapalehto Jun 20, 2018
537afa3
Enable new HAL us_ticker API on fast model MPS2 platform
Jun 8, 2018
e6c3ad4
update us_ticker driver and revert CMSDK headers changes
Jun 11, 2018
341f4b4
add disable interrupt function in us_ticker_free()
Jun 11, 2018
e23bde9
change us_ticker_inited to static
Jun 12, 2018
fa8ceef
add comments about TIMER modes and set TIMER2 off by default
Jun 15, 2018
ae5848e
NRF52_DK: Use 32 bit counter for us ticker (instead 16 bit counter)
mprse May 23, 2018
97b4f65
NRF5x: Remove duplicate lp ticker initialization from I2C, flash, trng.
mprse May 23, 2018
9ecbc5b
common_rtc_set_interrupt: Wrap <ticks_count> before comparisons
mprse May 23, 2018
80b100e
NRF51, NRF52: Implement us_ticker_free() function.
mprse May 24, 2018
d6b7367
Use common us_ticker.c for NRF51 and NRF52 boards
mprse May 25, 2018
1e49e4d
NRF5x: Add bug fix for the first timer read.
mprse May 25, 2018
1f0f9c2
NRF5x: Increase lp us ticker interrupt priority
mprse May 25, 2018
b3de87b
Use common_rtc.h for NRF51 and NRF52 boards
mprse Jun 8, 2018
6b9f91a
Use lp_ticker.c for NRF51 and NRF52 boards
mprse Jun 8, 2018
6048944
us_ticker_set_interrupt: fix bit-shift operation
mprse Jun 19, 2018
79f55ee
Travis: fix mongodb key expired error
0xc0170 Jun 20, 2018
7339fa0
Enlarge wait time for flushing serial buffer in Greentea test code
ccli8 Jun 21, 2018
4affb4d
Update Greentea netsocket and wifi tests
juhaylinen Jun 21, 2018
4a5e6a9
Fix SPI initialization for NRF52 series
Jun 20, 2018
f596556
Fixed broken InterruptIn.mode() in NRF5x target which didn't do anyth…
melvinItude Jun 14, 2018
4d84c03
- Fixed coding style - Set default pull mode to PullNone in gpio_irq_…
melvinItude Jun 19, 2018
a76d7bb
Compiling Cortex-A cores in uVision is not supported. Reference: http…
Jun 21, 2018
9ff9823
Support thread-safety with ARMC6
ccli8 Jun 20, 2018
3618b20
Add comment with RTX_NO_MULTITHREAD_CLIB movement
ccli8 Jun 21, 2018
1720341
Move RTX_NO_MULTITHREAD_CLIB from RTX_Config.h to mbed_rtx_conf.h
ccli8 Jun 21, 2018
27a5e47
adding USTICKER label for C027
aqib-ublox Jun 21, 2018
83fbeea
Cellular: fixed defect where SIM interface was closed too early causi…
Jun 20, 2018
e60566e
Copy edit CellularConnectionFSM.h
Jun 21, 2018
c17c674
add setScanParams overload
paul-szczepanek-arm Jun 19, 2018
338a8fc
use sets to apply limits
paul-szczepanek-arm Jun 19, 2018
a0b2072
reuse existing call
paul-szczepanek-arm Jun 20, 2018
f3207ad
MIMXRT1050: Update to EVK Rev B
mmahadevan108 May 22, 2018
b955eb7
Add binary drivers for MTB_USI_WM_BN_BM_22 and MTB_ADV_WISE_1530
KariHaapalehto Jun 21, 2018
1e92f0e
Add names to idle/timer thread
Jun 21, 2018
a08c3ec
Support Flash iAP for GR-PEACH and GR-LYCHEE
TomoYamanaka May 21, 2018
16f0971
Support Bootloader for GR-PEACH and GR-LYCHEE
TomoYamanaka May 29, 2018
c927369
Update arm pack manager for GR-LYCHEE
TomoYamanaka May 29, 2018
10e9819
Add the process for Cortex-A in mbed_applicaion
TomoYamanaka May 29, 2018
350980a
Fix definitions of IAR exporter for GR-PEACH and GR-LYCHEE
TomoYamanaka May 29, 2018
e2c2e35
Update arm pack manager for GR-PEACH
TomoYamanaka Jun 6, 2018
440c10a
Cellular: added greentea tests for CellularNetwork.
Jun 12, 2018
0e4ca1c
Cellular: Added network unit tests.
Jun 15, 2018
9527ab3
Cellular: fixed unit tests after rebasing with master.
Jun 20, 2018
f3406d2
Updates to configuration flags used in error handling implementation.…
SenRamakri Jun 11, 2018
2512403
Update exception handling code to remove dedicated fault safe printfs…
SenRamakri Jun 13, 2018
06b1ae5
Limit error filename capture to 64 chars, wrapping tests with right c…
SenRamakri Jun 18, 2018
c4ecbfb
Nordic BLE: Improve return of nRF5xn::getGap.
pan- Jun 13, 2018
a6eefdf
Nordic BLE: Add default parameter to get the local instance of nrF5xn
pan- Jun 13, 2018
e8b783b
Nordic BLE: Store locally role for a given connection.
pan- Jun 13, 2018
01f5c45
Nordic BLE: Fix pairing cancellation.
pan- Jun 13, 2018
5711b29
Nordic BLE:
pan- Jun 13, 2018
2d97c91
Nordi BLE: Fix formatting
pan- Jun 22, 2018
a5df917
Nordic BLE: Fix return value verification
pan- Jun 22, 2018
8528353
Modify RAM size definition of ARMCC for GR-LYCHEE
TomoYamanaka Jun 25, 2018
69ed638
Fixed issue with MBR init asserting on bad partition size
geky Jun 21, 2018
8535212
Moved the sourcing of the astyle archive to AWS from SourceForge. SF …
Jun 26, 2018
7e82eb5
Cellular: added more CellularInformation unit tests.
Jun 20, 2018
789a1c1
Cellular: added greentea tests for CellularInformation.
Jun 21, 2018
90f6790
Cellular: review fixes for cellularinformation tests.
Jun 25, 2018
5570782
fix LED_RED mapping on NUCLEO_F429ZI
soramame21 Jun 26, 2018
53083b7
Check version of Mbed CLI compile
theotherjimmy Jun 18, 2018
c17a5d9
Use Non-blocking Error and LooseVersion
theotherjimmy Jun 19, 2018
efcba88
Improve ARM compiler regex
theotherjimmy Jun 25, 2018
6e71c4c
Search all stdout for version regex; check > 1 matches
theotherjimmy Jun 25, 2018
081fc8e
Escape '.' in regex
theotherjimmy Jun 25, 2018
7122a53
Check for no match in version check
theotherjimmy Jun 25, 2018
9f74d64
Test and correct ARMCC version check
theotherjimmy Jun 26, 2018
e36bd9f
Test IAR version check
theotherjimmy Jun 26, 2018
f73f8d5
Test and correct GCC version check
theotherjimmy Jun 26, 2018
8879889
Update mbed-coap to version 4.5.0
Jun 25, 2018
e2ab561
Remove whitespace from NRF52 serial_api.c
Jun 25, 2018
f4aa4ff
Make serial_putc non-blocking for the NRF52 series
Jun 25, 2018
00a0c81
Improve serial performance for NRF52 series
Jun 26, 2018
92eab0f
Cellular: improved observing of disconnect for callbacks.
Jun 27, 2018
f01cd41
Cleaning MTB_USI_WM_BN_BM_22, MTB_ADV_WISE_1530 and MTB_MXCHIP_EMW316…
KariHaapalehto Jun 26, 2018
91c3b4d
TARGET_STM astyle
jeromecoutant Jun 27, 2018
a497022
TARGET_STM32F0 astyle
jeromecoutant Jun 27, 2018
56975a5
TARGET_STM32F1 astyle
jeromecoutant Jun 27, 2018
b3292e2
TARGET_STM32F2 astyle
jeromecoutant Jun 27, 2018
f5830bf
TARGET_STM32F3 astyle
jeromecoutant Jun 27, 2018
b6cbec8
TARGET_STM32F4 astyle
jeromecoutant Jun 27, 2018
7fa433d
TARGET_STM32F7 astyle
jeromecoutant Jun 27, 2018
91e7db0
TARGET_STM32L0 astyle
jeromecoutant Jun 27, 2018
2e54baa
TARGET_STM32L1 astyle
jeromecoutant Jun 27, 2018
77cb1cc
TARGET_STM32L4 astyle
jeromecoutant Jun 27, 2018
66a0998
TARGET_STM mbedtls astyle
jeromecoutant Jun 27, 2018
5612dac
TARGET_STM_EMAC astyle
jeromecoutant Jun 27, 2018
8397a9d
TARGET_STM USB astyle
jeromecoutant Jun 27, 2018
0d2e199
LoRaWAN: Fixing transport of fatal TX timeout event
Jun 27, 2018
bcc532d
build_api script : separate PeripheralPins.o
jeromecoutant Jun 27, 2018
6b5c796
Fix error history related comments
SenRamakri Jun 25, 2018
3df8827
Fix tool crashing when lines end with cr(not crlf)
SenRamakri Jun 27, 2018
6eb564f
STM32 serial RX/TX active patch
jeromecoutant Jun 28, 2018
6bd2258
Remove semicolon at the end of #define
Jun 27, 2018
126bf17
NRF_52840: Fix us ticker counter size
mprse Jun 25, 2018
a2d763f
Update Mbed version block for patch release
adbridge Jun 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ 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
# Fix for "The following signatures were invalid: KEYEXPIRED 1515625755" failed". See https://github.com/travis-ci/travis-ci/issues/9037
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Loop until update succeeds (timeouts can occur)
- travis_retry $(! sudo apt-get update 2>&1 |grep Failed)

Expand Down Expand Up @@ -107,8 +109,8 @@ matrix:
- env:
- NAME=astyle
install:
- wget https://downloads.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz;
mkdir -p BUILD && tar xf astyle_3.1_linux.tar.gz -C BUILD;
- curl -L0 http://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;
export PATH=$PWD/bin:$PATH;
Expand Down
9 changes: 7 additions & 2 deletions TESTS/mbed_drivers/timeout/timeout_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,19 @@ void test_deepsleep(void)
LowPowerTimer timer;

/*
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
* Since deepsleep() may shut down the UART peripheral, we wait for 20ms
* to allow for hardware serial buffers to completely flush.
*
* Take NUMAKER_PFM_NUC472 as an example:
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
* 20ms here for safe.

* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now.
*/
wait_ms(10);
wait_ms(20);

timer.start();
timeout.attach_callback(mbed::callback(sem_callback, &sem), delay_us);
Expand Down
20 changes: 18 additions & 2 deletions TESTS/mbed_hal/sleep/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@

#define US_PER_S 1000000

/* Flush serial buffer before deep sleep
*
* Since deepsleep() may shut down the UART peripheral, we wait for some time
* to allow for hardware serial buffers to completely flush.
*
* Take NUMAKER_PFM_NUC472 as an example:
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
* 20ms here for safe.
*
* This should be replaced with a better function that checks if the
* hardware buffers are empty. However, such an API does not exist now,
* so we'll use the wait_ms() function for now.
*/
#define SERIAL_FLUSH_TIME_MS 20

using namespace utest::v1;

/* The following ticker frequencies are possible:
Expand Down Expand Up @@ -167,7 +183,7 @@ void deepsleep_lpticker_test()
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
wait_ms(10);
wait_ms(SERIAL_FLUSH_TIME_MS);

TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");

Expand Down Expand Up @@ -202,7 +218,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
wait_ms(10);
wait_ms(SERIAL_FLUSH_TIME_MS);

TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");

Expand Down
10 changes: 5 additions & 5 deletions TESTS/mbed_platform/error_handling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ void test_error_context_capture()
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->thread_addr, error_ctx.thread_entry_address);
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->stack_size, error_ctx.thread_stack_size);
TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->stack_mem, error_ctx.thread_stack_mem);
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
#if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED
TEST_ASSERT_EQUAL_STRING(MBED_FILENAME, error_ctx.error_filename);
#endif
}

#ifndef MBED_CONF_ERROR_HIST_DISABLED
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
/** Test error logging functionality
*/
void test_error_logging()
Expand Down Expand Up @@ -261,7 +261,7 @@ void test_error_hook()
TEST_ASSERT(sem_status > 0);
}

#ifdef MBED_TEST_SIM_BLOCKDEVICE
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)

// test configuration
#ifndef MBED_TEST_FILESYSTEM
Expand Down Expand Up @@ -351,12 +351,12 @@ Case cases[] = {
Case("Test error context capture", test_error_context_capture),
#endif //MBED_CONF_RTOS_PRESENT
Case("Test error hook", test_error_hook),
#ifndef MBED_CONF_ERROR_HIST_DISABLED
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
Case("Test error logging", test_error_logging),
#if MBED_CONF_RTOS_PRESENT
Case("Test error handling multi-threaded", test_error_logging_multithread),
#endif //MBED_CONF_RTOS_PRESENT
#ifdef MBED_TEST_SIM_BLOCKDEVICE
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)
Case("Test error save log", test_save_error_log),
#endif //MBED_TEST_SIM_BLOCKDEVICE
#endif //MBED_CONF_ERROR_HIST_DISABLED
Expand Down
41 changes: 41 additions & 0 deletions TESTS/netsocket/dns/asynchronous_dns.cpp
Original file line number Diff line number Diff line change
@@ -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 "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "dns_tests.h"

using namespace utest::v1;

namespace {
int result_ok;
int result_no_mem;
int result_dns_failure;
int result_exp_timeout;
}

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);
}
65 changes: 65 additions & 0 deletions TESTS/netsocket/dns/asynchronous_dns_cache.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "dns_tests.h"

using namespace utest::v1;

namespace {
int ticker_us = 0;
}

static void test_dns_query_ticker(void)
{
ticker_us += 100;
}

void ASYNCHRONOUS_DNS_CACHE()
{
rtos::Semaphore semaphore;
dns_application_data data;
data.semaphore = &semaphore;

Ticker ticker;
ticker.attach_us(&test_dns_query_ticker, 100);

for (unsigned int i = 0; i < 5; i++) {
int started_us = ticker_us;

nsapi_error_t err = get_interface()->gethostbyname_async(dns_test_hosts[0],
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data));
TEST_ASSERT(err >= 0);

semaphore.wait();

TEST_ASSERT(data.result == NSAPI_ERROR_OK);
TEST_ASSERT(strlen(data.addr.get_ip_address()) > 1);

int delay_ms = (ticker_us - started_us) / 1000;

static int delay_first = delay_ms / 2;
// Check that cached accesses are at least twice as fast as the first one
TEST_ASSERT_FALSE(i != 0 && delay_ms > delay_first);

printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
dns_test_hosts[0], data.addr.get_ip_address(), delay_ms);
}
}
84 changes: 84 additions & 0 deletions TESTS/netsocket/dns/asynchronous_dns_cancel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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 "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "dns_tests.h"

using namespace utest::v1;

void ASYNCHRONOUS_DNS_CANCEL()
{
rtos::Semaphore semaphore;
dns_application_data *data = new dns_application_data[MBED_CONF_APP_DNS_TEST_HOSTS_NUM];

int count = 0;

for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
data[i].value_set = false;
data[i].semaphore = &semaphore;
data[i].req_result = get_interface()->gethostbyname_async(dns_test_hosts[i],
mbed::Callback<void(nsapi_error_t, SocketAddress *)>(hostbyname_cb, (void *) &data[i]));
TEST_ASSERT(data[i].req_result >= 0 || data[i].req_result == NSAPI_ERROR_NO_MEMORY);

if (data[i].req_result >= 0) {
// Callback will be called
count++;
} else {
// No memory to initiate DNS query, callback will not be called
data[i].result = NSAPI_ERROR_NO_MEMORY;
data[i].value_set = true;
}
}

for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
if (data[i].req_result > 0) {
if (get_interface()->gethostbyname_async_cancel(data[i].req_result) == NSAPI_ERROR_OK) {
count--;
}
}
}

// Wait for callback(s) to complete
for (int i = 0; i < count; i++) {
semaphore.wait();
}

for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
if (!data[i].value_set) {
printf("DNS: query \"%s\" => cancel\n", dns_test_hosts[i]);
continue;
}
TEST_ASSERT(data[i].result == NSAPI_ERROR_OK || data[i].result == NSAPI_ERROR_NO_MEMORY || data[i].result == NSAPI_ERROR_DNS_FAILURE || data[i].result == NSAPI_ERROR_TIMEOUT);
if (data[i].result == NSAPI_ERROR_OK) {
printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts[i], data[i].addr.get_ip_address());
} else if (data[i].result == NSAPI_ERROR_DNS_FAILURE) {
printf("DNS: query \"%s\" => DNS failure\n", dns_test_hosts[i]);
} else if (data[i].result == NSAPI_ERROR_TIMEOUT) {
printf("DNS: query \"%s\" => timeout\n", dns_test_hosts[i]);
} else if (data[i].result == NSAPI_ERROR_NO_MEMORY) {
printf("DNS: query \"%s\" => no memory\n", dns_test_hosts[i]);
}
}

delete[] data;

wait(5.0);
}
Loading