-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test support for Mbed OS (#8403)
* Register missing tests: - TestChannel - TestExchangeManager - TestReliableMessageProtocol * Add output name and dir for mdns libraries * Prevent inclusion of main from TestInetLayer in Mbed library * Prevent build of stdio logging on Mbed OS * Add Mbed TLS SHA1 support for Mbed. This is needed by some of the unit tests. * Disable argparser test for Mbed OS getopt behavior with newlib is different from _standard_ on desktop. * Add missing header to QRCodeTLV test * Prevent inclusion of cpp files in payload test. The functions tested are not marked as static but aren't exposed publicly either. Forward declaration is used in tests to import them. * Add Mbed OS test driver. * Add debug and build script for Mbed OS test driver * Improve Mbed OS timing primitive precisions. Base primitive used was the OS tick which changes every ms. Instead use a low power timer to improve the accuracy to the us range. * Proper shutdown of Mbed OS platform manager * Update Mbed OS dependencies. * Platform Manager fixes (#189) * Fix PlatformManagerImple and BLEMangerImpl Add double BLE initialization protection Improve stop and start event loop * Address inet layer test inclusion * Increase number of timer in test to prevent exhaustion. * Add workflow to build mbed os unit test * Move Mbed unit test build script in dedicated folder. This helps when integration tests scripts are added. * Increase Mbed OS unit test stack size. Help coping with SecureSession tests. * Revert changes in TestHelpers.h Revert changes in mdns BUILD.gn files Move function declaration from TestManualCode.cpp to ManualSetupPayloadParser.h Cleanup mbed unit test CMakeLists.txt file * Capitalize ManualSetupPayloadParser functions names Fix TestHelper global variables types Add extractPayload function to header file and capitalize the name * Add unit-test buidling to Build example - Mbed OS workflow Remove Build unit test - Mbed OS workflow * Fix unit tests binary file name * Fix multiple definition of chip::Platform:PersistedStorage::Read/Write * Changes restyle * Fix TestMdnsCache - use usleep intead of sleep * Udpate unit tests app with a new logging approach * Add all flash and debug options for unit tests app in launch.json * Restore setting print_lib in mbed_app.json * Mbed unit tests CHIPProjectConfig.h cleanup * Change files expose from file static to class static * Add detach function to Mbed event timeout class Fix Mbed event queue shutdown in Platform Manager * Fix using SystemLayerSocketsLoop in PlatformManagerImpl * Fix controller tests - not using data_model for mbed platform * Restyle changes * Remove unit test artifacts from mbed-os workflow Co-authored-by: ATmobica <[email protected]> Co-authored-by: ATmobica <[email protected]>
- Loading branch information
1 parent
98568b3
commit d48d754
Showing
42 changed files
with
731 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Copyright (c) 2021 Project CHIP Authors | ||
# | ||
# 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. | ||
# | ||
|
||
cd "$(dirname "$0")/../../.." | ||
CHIP_ROOT="$PWD" | ||
cd "$CHIP_ROOT/src/test_driver/mbed/" | ||
|
||
SUPPORTED_TOOLCHAIN=(GCC_ARM ARM) | ||
SUPPORTED_TARGET_BOARD=(CY8CPROTO_062_4343W) | ||
SUPPORTED_PROFILES=(release develop debug) | ||
SUPPORTED_COMMAND=(build flash build-flash) | ||
|
||
TARGET_BOARD=CY8CPROTO_062_4343W | ||
TOOLCHAIN=GCC_ARM | ||
PROFILE=release | ||
COMMAND=build | ||
|
||
for i in "$@"; do | ||
case $i in | ||
-b=* | --board=*) | ||
TARGET_BOARD="${i#*=}" | ||
shift | ||
;; | ||
-t=* | --toolchain=*) | ||
TOOLCHAIN="${i#*=}" | ||
shift | ||
;; | ||
-p=* | --profile=*) | ||
PROFILE="${i#*=}" | ||
shift | ||
;; | ||
-c=* | --command=*) | ||
COMMAND="${i#*=}" | ||
shift | ||
;; | ||
*) | ||
# unknown option | ||
;; | ||
esac | ||
done | ||
|
||
if [[ ! " ${SUPPORTED_TARGET_BOARD[@]} " =~ " ${TARGET_BOARD} " ]]; then | ||
echo "ERROR: Target $TARGET_BOARD not supported" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! " ${SUPPORTED_TOOLCHAIN[@]} " =~ " ${TOOLCHAIN} " ]]; then | ||
echo "ERROR: Toolchain $TOOLCHAIN not supported" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! " ${SUPPORTED_PROFILES[@]} " =~ " ${PROFILE} " ]]; then | ||
echo "ERROR: Profile $PROFILE not supported" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! " ${SUPPORTED_COMMAND[@]} " =~ " ${COMMAND} " ]]; then | ||
echo "ERROR: Command $COMMAND not supported" | ||
exit 1 | ||
fi | ||
|
||
# Activate Matter environment | ||
source "$CHIP_ROOT"/scripts/activate.sh | ||
|
||
BUILD_DIRECTORY="build-$TARGET_BOARD/$PROFILE/" | ||
|
||
set -e # Exit immediately if a command exits with a non-zero status. | ||
# set -x # Print commands and their arguments as they are executed. | ||
|
||
if [[ "$COMMAND" == *"build"* ]]; then | ||
echo "Build $APP app for $TARGET_BOARD target with $TOOLCHAIN toolchain and $PROFILE profile" | ||
|
||
# Config directory setup | ||
MBED_CONFIG_PATH=./cmake_build/"$TARGET_BOARD"/develop/"$TOOLCHAIN"/ | ||
|
||
# Override Mbed OS path to development directory | ||
MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo | ||
|
||
# Create symlinks to mbed-os submodule | ||
ln -sfTr "$MBED_OS_PATH" "mbed-os" | ||
|
||
# Create symlinks to mbed-os-posix-socket submodule | ||
MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo | ||
ln -sfTr "$MBED_OS_POSIX_SOCKET_PATH" "mbed-os-posix-socket" | ||
|
||
# Generate config file for selected target, toolchain and hardware | ||
mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" | ||
|
||
# Remove old artifacts to force linking | ||
rm -rf "$BUILD_DIRECTORY/chip-"* | ||
|
||
# Create output directory and copy config file there. | ||
mkdir -p "$BUILD_DIRECTORY" | ||
cp -f "$MBED_CONFIG_PATH"/mbed_config.cmake "$BUILD_DIRECTORY"/mbed_config.cmake | ||
|
||
# Build application | ||
cmake -S "./" -B "$BUILD_DIRECTORY" -GNinja -DCMAKE_BUILD_TYPE="$PROFILE" | ||
cmake --build "$BUILD_DIRECTORY" | ||
fi | ||
|
||
if [[ "$COMMAND" == *"flash"* ]]; then | ||
|
||
echo "Flash Unit Tests app to $TARGET_BOARD target [$TOOLCHAIN toolchain, $PROFILE profile]" | ||
|
||
# Flash scripts path setup | ||
MBED_FLASH_SCRIPTS_PATH=$CHIP_ROOT/config/mbed/scripts | ||
|
||
# Flash application | ||
openocd -f "$MBED_FLASH_SCRIPTS_PATH/$TARGET_BOARD".tcl -c "program $BUILD_DIRECTORY/chip-tests verify reset exit" | ||
fi |
Oops, something went wrong.