Skip to content

Commit f5ed5d9

Browse files
committed
Merge branch 'master' into fix/sx126x-select-pins
2 parents 89789f2 + de7e326 commit f5ed5d9

File tree

383 files changed

+17558
-7940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+17558
-7940
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
repository: ARMmbed/mbed-os-ci-scripts
2222
token: ${{ secrets.ISSUE_TRIAGING_PERMS }}
2323
path: scripts
24-
ref: triage_test
24+
ref: master
2525

2626
- name: Run the script
2727
run: |

.lgtm.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
path_classifiers:
2+
docs:
3+
- docs
4+
test:
5+
- "**/TESTS"
6+
- "**/UNITTESTS"
7+
tools:
8+
- tools
9+
10+
extraction:
11+
cpp:
12+
prepare:
13+
packages:
14+
- ninja-build
15+
- python-pip
16+
after_prepare:
17+
- pip install --user cmake
18+
- ls ~/.local/bin
19+
- export PATH=~/.local/bin:$PATH
20+
- cmake --version
21+
configure:
22+
command:
23+
- cmake -S . -B __build -GNinja -DBUILD_TESTING=ON -DCOVERAGE=OFF -DCMAKE_BUILD_TYPE=Debug
24+
index:
25+
build_command:
26+
- cmake --build __build
27+
- cmake --build __build --target test

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ endif()
1313
project(mbed-os)
1414

1515
# Add all paths to the list files within Mbed OS
16-
list(APPEND CMAKE_MODULE_PATH
16+
list(APPEND CMAKE_MODULE_PATH
1717
"${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts"
1818
)
1919

2020
option(BUILD_TESTING "Run unit tests only." OFF)
2121

2222
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
23-
include(CTest)
23+
include(CTest)
2424
add_subdirectory(UNITTESTS)
2525
endif()
2626

@@ -68,19 +68,19 @@ if(${CMAKE_CROSSCOMPILING})
6868
"Invalid printf library type '${MBED_PRINTF_LIB}'. Possible values:\n ${MBED_PRINTF_LIB_TYPES}"
6969
)
7070
endif()
71-
71+
7272
mbed_set_cpu_core_definitions(mbed-core)
7373
if(${MBED_TOOLCHAIN_FILE_USED})
7474
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
7575
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
7676
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
77-
77+
7878
target_compile_features(mbed-core
7979
INTERFACE
8080
c_std_11
8181
cxx_std_14
8282
)
83-
83+
8484
endif()
8585

8686
target_compile_definitions(mbed-core
@@ -98,7 +98,7 @@ if(${CMAKE_CROSSCOMPILING})
9898
endif()
9999

100100
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
101-
# script, because of path le ngth limitations on Windows. We set the response file and bind the path
101+
# script, because of path length limitations on Windows. We set the response file and bind the path
102102
# to a global property here. The MBED_TARGET being built queries this global property when it sets
103103
# the linker script.
104104
#
@@ -110,7 +110,7 @@ if(${CMAKE_CROSSCOMPILING})
110110
# using response files or global properties.
111111
mbed_generate_options_for_linker(mbed-core RESPONSE_FILE_PATH)
112112
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${RESPONSE_FILE_PATH})
113-
113+
114114
# Add compile definitions for backward compatibility with the toolchain
115115
# supported. New source files should instead check for __GNUC__ and __clang__
116116
# for the GCC_ARM and ARM toolchains respectively.
@@ -164,7 +164,7 @@ if(${CMAKE_CROSSCOMPILING})
164164
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED)
165165
string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED})
166166
string(PREPEND MBED_TARGET_CONVERTED "mbed-")
167-
167+
168168
target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED})
169169
endif()
170170

TESTS/configs/mbedtls.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"macros": [
3+
"MBEDTLS_SELF_TEST",
4+
"MBEDTLS_TIMING_C",
5+
"MBEDTLS_TIMING_ALT"
6+
]
7+
}

UNITTESTS/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include(FetchContent)
1919
# Download and unpack googletest
2020
FetchContent_Declare(googletest
2121
GIT_REPOSITORY https://github.com/google/googletest.git
22-
GIT_TAG release-1.10.0
22+
GIT_TAG master
2323
)
2424
FetchContent_MakeAvailable(googletest)
2525

@@ -58,3 +58,5 @@ if (VALGRIND)
5858
endif(VALGRIND)
5959

6060
add_subdirectory(stubs)
61+
add_subdirectory(fakes)
62+

UNITTESTS/fakes/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(events)
5+
add_subdirectory(ble)

UNITTESTS/fakes/ble/BLE.cpp

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2020 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "ble/BLE.h"
19+
#include "GattServerImpl_mock.h"
20+
#include "GattClientImpl_mock.h"
21+
#include "GapImpl_mock.h"
22+
#include "SecurityManagerImpl_mock.h"
23+
#include "ble/GattClient.h"
24+
#include "ble/GattServer.h"
25+
#include "ble/SecurityManager.h"
26+
#include "ble/Gap.h"
27+
#include "ble_mocks.h"
28+
29+
namespace ble {
30+
31+
static GapMock *gap_impl = nullptr;
32+
static GattServerMock *gatt_server_impl = nullptr;
33+
static GattClientMock *gatt_client_impl = nullptr;
34+
static SecurityManagerMock *security_manager_impl = nullptr;
35+
36+
static Gap *gap = nullptr;
37+
static GattServer *gatt_server = nullptr;
38+
static GattClient *gatt_client = nullptr;
39+
static SecurityManager *security_manager = nullptr;
40+
41+
GapMock& gap_mock() {
42+
return *ble::gap_impl;
43+
}
44+
45+
GattServerMock& gatt_server_mock() {
46+
return *ble::gatt_server_impl;
47+
}
48+
49+
GattClientMock& gatt_client_mock() {
50+
return *ble::gatt_client_impl;
51+
}
52+
53+
SecurityManagerMock& security_manager_mock() {
54+
return *ble::security_manager_impl;
55+
}
56+
57+
void init_mocks() {
58+
if (gap_impl) {
59+
/* we are already initialised */
60+
return;
61+
}
62+
63+
/* mocks */
64+
gap_impl = new GapMock();
65+
gatt_server_impl = new GattServerMock();
66+
gatt_client_impl = new GattClientMock();
67+
security_manager_impl = new SecurityManagerMock();
68+
/* user APIS */
69+
gap = new Gap(gap_impl);
70+
gatt_server = new GattServer(gatt_server_impl);
71+
gatt_client = new GattClient(gatt_client_impl);
72+
security_manager = new SecurityManager(security_manager_impl);
73+
}
74+
75+
void delete_mocks() {
76+
delete gap;
77+
delete gap_impl;
78+
delete gatt_server;
79+
delete gatt_server_impl;
80+
delete gatt_client;
81+
delete gatt_client_impl;
82+
delete security_manager;
83+
delete security_manager_impl;
84+
85+
gap = nullptr;
86+
gap_impl = nullptr;
87+
gatt_server = nullptr;
88+
gatt_server_impl = nullptr;
89+
gatt_client = nullptr;
90+
gatt_client_impl = nullptr;
91+
security_manager = nullptr;
92+
security_manager_impl = nullptr;
93+
}
94+
95+
class BLEInstanceBase {
96+
};
97+
98+
BLE::BLE(ble::BLEInstanceBase &transport) : transport(transport)
99+
{
100+
}
101+
102+
BLE& BLE::Instance()
103+
{
104+
static ble::BLEInstanceBase transport;
105+
static BLE instance(transport);
106+
init_mocks();
107+
return instance;
108+
}
109+
110+
ble::Gap &BLE::gap()
111+
{
112+
init_mocks();
113+
return *ble::gap;
114+
}
115+
116+
ble::GattServer &BLE::gattServer()
117+
{
118+
init_mocks();
119+
return *ble::gatt_server;
120+
}
121+
122+
ble::GattClient &BLE::gattClient()
123+
{
124+
init_mocks();
125+
return *ble::gatt_client;
126+
}
127+
128+
ble::SecurityManager &BLE::securityManager()
129+
{
130+
init_mocks();
131+
return *ble::security_manager;
132+
}
133+
134+
const ble::Gap &BLE::gap() const
135+
{
136+
auto &self = const_cast<BLE &>(*this);
137+
return const_cast<const ble::Gap &>(self.gap());
138+
}
139+
140+
const ble::GattServer &BLE::gattServer() const
141+
{
142+
auto &self = const_cast<BLE &>(*this);
143+
return const_cast<const ble::GattServer &>(self.gattServer());
144+
}
145+
146+
const ble::GattClient &BLE::gattClient() const
147+
{
148+
auto &self = const_cast<BLE &>(*this);
149+
return const_cast<const ble::GattClient &>(self.gattClient());
150+
}
151+
152+
const ble::SecurityManager &BLE::securityManager() const
153+
{
154+
auto &self = const_cast<BLE &>(*this);
155+
return const_cast<const ble::SecurityManager &>(self.securityManager());
156+
}
157+
158+
void BLE::processEvents()
159+
{
160+
161+
}
162+
163+
}

UNITTESTS/fakes/ble/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(mbed-fakes-ble)
5+
6+
target_include_directories(mbed-fakes-ble
7+
PUBLIC
8+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/
9+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include
10+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include/ble
11+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source
12+
PRIVATE
13+
${gtest_SOURCE_DIR}/include
14+
${gmock_SOURCE_DIR}/include
15+
)
16+
17+
target_sources(mbed-fakes-ble
18+
PRIVATE
19+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/AdvertisingDataBuilder.cpp
20+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/AdvertisingParameters.cpp
21+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/ConnectionParameters.cpp
22+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gatt/DiscoveredCharacteristic.cpp
23+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/Gap.cpp
24+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/GattClient.cpp
25+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/GattServer.cpp
26+
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/SecurityManager.cpp
27+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/BLE.cpp
28+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/source/GattServerImpl_mock.cpp
29+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/ble_mocks.h
30+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GapImpl_mock.h
31+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GattClientImpl_mock.h
32+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GattServerImpl_mock.h
33+
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/SecurityManagerImpl_mock.h
34+
)
35+
36+
target_link_libraries(mbed-fakes-ble
37+
PRIVATE
38+
mbed-headers
39+
mbed-stubs-headers
40+
gcov
41+
)

0 commit comments

Comments
 (0)