Skip to content

Commit

Permalink
Merge branch 'master' into fix/sx126x-select-pins
Browse files Browse the repository at this point in the history
  • Loading branch information
evandavey committed Jun 26, 2021
2 parents 89789f2 + de7e326 commit f5ed5d9
Show file tree
Hide file tree
Showing 383 changed files with 17,558 additions and 7,940 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
repository: ARMmbed/mbed-os-ci-scripts
token: ${{ secrets.ISSUE_TRIAGING_PERMS }}
path: scripts
ref: triage_test
ref: master

- name: Run the script
run: |
Expand Down
27 changes: 27 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
path_classifiers:
docs:
- docs
test:
- "**/TESTS"
- "**/UNITTESTS"
tools:
- tools

extraction:
cpp:
prepare:
packages:
- ninja-build
- python-pip
after_prepare:
- pip install --user cmake
- ls ~/.local/bin
- export PATH=~/.local/bin:$PATH
- cmake --version
configure:
command:
- cmake -S . -B __build -GNinja -DBUILD_TESTING=ON -DCOVERAGE=OFF -DCMAKE_BUILD_TYPE=Debug
index:
build_command:
- cmake --build __build
- cmake --build __build --target test
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ endif()
project(mbed-os)

# Add all paths to the list files within Mbed OS
list(APPEND CMAKE_MODULE_PATH
list(APPEND CMAKE_MODULE_PATH
"${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"
)

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

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
include(CTest)
include(CTest)
add_subdirectory(UNITTESTS)
endif()

Expand Down Expand Up @@ -68,19 +68,19 @@ if(${CMAKE_CROSSCOMPILING})
"Invalid printf library type '${MBED_PRINTF_LIB}'. Possible values:\n ${MBED_PRINTF_LIB_TYPES}"
)
endif()

mbed_set_cpu_core_definitions(mbed-core)
if(${MBED_TOOLCHAIN_FILE_USED})
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})

target_compile_features(mbed-core
INTERFACE
c_std_11
cxx_std_14
)

endif()

target_compile_definitions(mbed-core
Expand All @@ -98,7 +98,7 @@ if(${CMAKE_CROSSCOMPILING})
endif()

# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
# script, because of path le ngth limitations on Windows. We set the response file and bind the path
# script, because of path length limitations on Windows. We set the response file and bind the path
# to a global property here. The MBED_TARGET being built queries this global property when it sets
# the linker script.
#
Expand All @@ -110,7 +110,7 @@ if(${CMAKE_CROSSCOMPILING})
# using response files or global properties.
mbed_generate_options_for_linker(mbed-core RESPONSE_FILE_PATH)
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${RESPONSE_FILE_PATH})

# Add compile definitions for backward compatibility with the toolchain
# supported. New source files should instead check for __GNUC__ and __clang__
# for the GCC_ARM and ARM toolchains respectively.
Expand Down Expand Up @@ -164,7 +164,7 @@ if(${CMAKE_CROSSCOMPILING})
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED)
string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED})
string(PREPEND MBED_TARGET_CONVERTED "mbed-")

target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED})
endif()

Expand Down
7 changes: 7 additions & 0 deletions TESTS/configs/mbedtls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"macros": [
"MBEDTLS_SELF_TEST",
"MBEDTLS_TIMING_C",
"MBEDTLS_TIMING_ALT"
]
}
4 changes: 3 additions & 1 deletion UNITTESTS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
# Download and unpack googletest
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
GIT_TAG master
)
FetchContent_MakeAvailable(googletest)

Expand Down Expand Up @@ -58,3 +58,5 @@ if (VALGRIND)
endif(VALGRIND)

add_subdirectory(stubs)
add_subdirectory(fakes)

5 changes: 5 additions & 0 deletions UNITTESTS/fakes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(events)
add_subdirectory(ble)
163 changes: 163 additions & 0 deletions UNITTESTS/fakes/ble/BLE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/* mbed Microcontroller Library
* Copyright (c) 2020 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.
*/

#include "ble/BLE.h"
#include "GattServerImpl_mock.h"
#include "GattClientImpl_mock.h"
#include "GapImpl_mock.h"
#include "SecurityManagerImpl_mock.h"
#include "ble/GattClient.h"
#include "ble/GattServer.h"
#include "ble/SecurityManager.h"
#include "ble/Gap.h"
#include "ble_mocks.h"

namespace ble {

static GapMock *gap_impl = nullptr;
static GattServerMock *gatt_server_impl = nullptr;
static GattClientMock *gatt_client_impl = nullptr;
static SecurityManagerMock *security_manager_impl = nullptr;

static Gap *gap = nullptr;
static GattServer *gatt_server = nullptr;
static GattClient *gatt_client = nullptr;
static SecurityManager *security_manager = nullptr;

GapMock& gap_mock() {
return *ble::gap_impl;
}

GattServerMock& gatt_server_mock() {
return *ble::gatt_server_impl;
}

GattClientMock& gatt_client_mock() {
return *ble::gatt_client_impl;
}

SecurityManagerMock& security_manager_mock() {
return *ble::security_manager_impl;
}

void init_mocks() {
if (gap_impl) {
/* we are already initialised */
return;
}

/* mocks */
gap_impl = new GapMock();
gatt_server_impl = new GattServerMock();
gatt_client_impl = new GattClientMock();
security_manager_impl = new SecurityManagerMock();
/* user APIS */
gap = new Gap(gap_impl);
gatt_server = new GattServer(gatt_server_impl);
gatt_client = new GattClient(gatt_client_impl);
security_manager = new SecurityManager(security_manager_impl);
}

void delete_mocks() {
delete gap;
delete gap_impl;
delete gatt_server;
delete gatt_server_impl;
delete gatt_client;
delete gatt_client_impl;
delete security_manager;
delete security_manager_impl;

gap = nullptr;
gap_impl = nullptr;
gatt_server = nullptr;
gatt_server_impl = nullptr;
gatt_client = nullptr;
gatt_client_impl = nullptr;
security_manager = nullptr;
security_manager_impl = nullptr;
}

class BLEInstanceBase {
};

BLE::BLE(ble::BLEInstanceBase &transport) : transport(transport)
{
}

BLE& BLE::Instance()
{
static ble::BLEInstanceBase transport;
static BLE instance(transport);
init_mocks();
return instance;
}

ble::Gap &BLE::gap()
{
init_mocks();
return *ble::gap;
}

ble::GattServer &BLE::gattServer()
{
init_mocks();
return *ble::gatt_server;
}

ble::GattClient &BLE::gattClient()
{
init_mocks();
return *ble::gatt_client;
}

ble::SecurityManager &BLE::securityManager()
{
init_mocks();
return *ble::security_manager;
}

const ble::Gap &BLE::gap() const
{
auto &self = const_cast<BLE &>(*this);
return const_cast<const ble::Gap &>(self.gap());
}

const ble::GattServer &BLE::gattServer() const
{
auto &self = const_cast<BLE &>(*this);
return const_cast<const ble::GattServer &>(self.gattServer());
}

const ble::GattClient &BLE::gattClient() const
{
auto &self = const_cast<BLE &>(*this);
return const_cast<const ble::GattClient &>(self.gattClient());
}

const ble::SecurityManager &BLE::securityManager() const
{
auto &self = const_cast<BLE &>(*this);
return const_cast<const ble::SecurityManager &>(self.securityManager());
}

void BLE::processEvents()
{

}

}
41 changes: 41 additions & 0 deletions UNITTESTS/fakes/ble/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_library(mbed-fakes-ble)

target_include_directories(mbed-fakes-ble
PUBLIC
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/include/ble
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source
PRIVATE
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
)

target_sources(mbed-fakes-ble
PRIVATE
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/AdvertisingDataBuilder.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/AdvertisingParameters.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gap/ConnectionParameters.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/gatt/DiscoveredCharacteristic.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/Gap.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/GattClient.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/GattServer.cpp
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/source/SecurityManager.cpp
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/BLE.cpp
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/source/GattServerImpl_mock.cpp
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/ble_mocks.h
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GapImpl_mock.h
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GattClientImpl_mock.h
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/GattServerImpl_mock.h
${mbed-os_SOURCE_DIR}/UNITTESTS/fakes/ble/SecurityManagerImpl_mock.h
)

target_link_libraries(mbed-fakes-ble
PRIVATE
mbed-headers
mbed-stubs-headers
gcov
)
Loading

0 comments on commit f5ed5d9

Please sign in to comment.