diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce1a276..6b3ed9ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ option(ENABLE_FORMAT_CHECKS "Run format checks during configuration stage and ge option(SKIP_FORMAT_REPORTS "Skip generation of format XML reports in build directory" ON) option(ENABLE_STATIC_CHECKS "Configure a build tree for static code analysis" OFF) option(ENABLE_COVERAGE "Build unit tests with coverage information to use with GCOV and LCOV" ON) +option(ENABLE_INTEGRATION_TESTING "Build for integration tests application" OFF) +option(INTEGRATION_TEST_ENTRY_PATH "Specify which integratin test entry to build default essentials" core/essentials) ## Include config file if it exists include(kiso_defaults.cmake OPTIONAL) @@ -17,14 +19,16 @@ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT ${ENABLE_TESTING}) include(cmake/ArmToolchain.cmake) endif() -message("------------- KISO CONFIG -------------") -message("Building Kiso tests: ${ENABLE_TESTING}") -message(" ... with coverage: ${ENABLE_COVERAGE}") -message("Kiso Board Path: ${KISO_BOARD_PATH}") -message("Kiso OS: ${KISO_OS_LIB}") -message("Kiso Application Path: ${KISO_APPLICATION_PATH}") -message("Project Config Path: ${PROJECT_CONFIG_PATH}") -message("------------- KISO CONFIG -------------") +message("------------- KISO CONFIG --------------------------------") +message("Building Kiso tests: ${ENABLE_TESTING}") +message(" ... with coverage: ${ENABLE_COVERAGE}") +message("Building Kiso integration tests: ${ENABLE_INTEGRATION_TESTING}") +message(" with entry in: ${INTEGRATION_TEST_ENTRY_PATH}") +message("Kiso Board Path: ${KISO_BOARD_PATH}") +message("Kiso OS: ${KISO_OS_LIB}") +message("Kiso Application Path: ${KISO_APPLICATION_PATH}") +message("Project Config Path: ${PROJECT_CONFIG_PATH}") +message("------------- KISO CONFIG --------------------------------") project (Kiso C) @@ -89,7 +93,12 @@ if(${ENABLE_STATIC_CHECKS}) endif() ## Add application code -add_subdirectory(${KISO_APPLICATION_PATH} ${CMAKE_CURRENT_BINARY_DIR}/applications/${KISO_APPLICATION_NAME}) +if(${ENABLE_INTEGRATION_TESTING}) + add_subdirectory(testing/integration/test-executor) + add_subdirectory(${INTEGRATION_TEST_ENTRY_PATH}) +else() + add_subdirectory(${KISO_APPLICATION_PATH} ${CMAKE_CURRENT_BINARY_DIR}/applications/${KISO_APPLICATION_NAME}) +endif() include(KisoLibsConfig) @@ -98,6 +107,9 @@ include(KisoLibsConfig) add_subdirectory(core/essentials) add_subdirectory(core/utils) add_subdirectory(core/connectivity/cellular) +if(${ENABLE_INTEGRATION_TESTING}) + add_subdirectory(core/testing) +endif() ## Add thirdparty libs add_subdirectory(thirdparty) diff --git a/boards/NucleoF767/bsp/source/bsp_api_GenericUart.c b/boards/NucleoF767/bsp/source/bsp_api_GenericUart.c new file mode 100644 index 00000000..619f555c --- /dev/null +++ b/boards/NucleoF767/bsp/source/bsp_api_GenericUart.c @@ -0,0 +1,228 @@ +/******************************************************************************** +* Copyright (c) 2010-2019 Robert Bosch GmbH +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License 2.0 which is available at +* http://www.eclipse.org/legal/epl-2.0. +* +* SPDX-License-Identifier: EPL-2.0 +* +* Contributors: +* Robert Bosch GmbH - initial contribution +* +********************************************************************************/ + +#include "Kiso_BSP_GenericUart.h" + +#if KISO_FEATURE_BSP_GENERIC_UART + +#include "stm32/stm32f7/Kiso_MCU_STM32F7_UART_Handle.h" +#include "Kiso_HAL_Delay.h" +#include "BSP_NucleoF767.h" +#include "protected/gpio.h" + +/*---------------------- MACROS DEFINITION --------------------------------------------------------------------------*/ + +#undef KISO_MODULE_ID +#define KISO_MODULE_ID MODULE_BSP_API_GENERICUART + +#define UART_INT_PRIORITY UINT32_C(10) +#define UART_SUBPRIORITY UINT32_C(1) + +/*---------------------- LOCAL FUNCTIONS DECLARATION ----------------------------------------------------------------*/ + +void USART2_IRQHandler(void); + +/*---------------------- VARIABLES DECLARATION ----------------------------------------------------------------------*/ + +static uint8_t bspState = (uint8_t)BSP_STATE_INIT; /**< BSP State of the cellular module */ + +/** + * Static structure storing the UART handle for Test Interface + */ +static struct MCU_UART_S uartCtrlStruct = + { + .TxMode = KISO_HAL_TRANSFER_MODE_INTERRUPT, + .RxMode = KISO_HAL_TRANSFER_MODE_INTERRUPT, + .Datarate = 115200U, + .huart.Instance = USART2, + .huart.Init.BaudRate = 115200U, + .huart.Init.WordLength = UART_WORDLENGTH_8B, + .huart.Init.StopBits = UART_STOPBITS_1, + .huart.Init.Parity = UART_PARITY_NONE, + .huart.Init.Mode = UART_MODE_TX_RX, + .huart.Init.HwFlowCtl = UART_HWCONTROL_NONE, + .huart.Init.OverSampling = UART_OVERSAMPLING_16, + .huart.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE, + .huart.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT, +}; +/*---------------------- EXPOSED FUNCTIONS IMPLEMENTATION -----------------------------------------------------------*/ + +/** + * See API interface for function documentation + * @retval RETCODE_OK in case of success. + * @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow connecting. + */ +Retcode_T BSP_GenericUart_Connect(uint32_t id) +{ + KISO_UNUSED(id); + Retcode_T retcode = RETCODE_OK; + + if (!(bspState & (uint8_t)BSP_STATE_TO_CONNECTED)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE); + } + if (RETCODE_OK == retcode) + { + /* IOSV bit MUST be set to access GPIO port G[2:15] */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_RCC_LPTIM1_CLK_ENABLE(); + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* UART RX/TX GPIO pin configuration */ + GPIO_OpenClockGate(GPIO_PORT_D, PIND_USART2_TX | PIND_USART2_RX); + + GPIO_InitStruct.Pin = PIND_USART2_TX | PIND_USART2_RX; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + bspState = (uint8_t)BSP_STATE_CONNECTED; + } + return retcode; +} + +/** + * See API interface for function documentation + * @retval RETCODE_OK in case of success. + * @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow enabling. + */ +Retcode_T BSP_GenericUart_Enable(uint32_t id) +{ + KISO_UNUSED(id); + Retcode_T retcode = RETCODE_OK; + + if (!(bspState & (uint8_t)BSP_STATE_TO_ENABLED)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE); + } + if (RETCODE_OK == retcode) + { + __HAL_RCC_USART2_CLK_ENABLE(); + __HAL_RCC_USART2_FORCE_RESET(); + __HAL_RCC_USART2_RELEASE_RESET(); + __GPIOD_CLK_ENABLE(); + /* Configure the UART resource */ + if (HAL_OK != HAL_UART_Init(&uartCtrlStruct.huart)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_INIT_FAILED); + } + } + if (RETCODE_OK == retcode) + { + NVIC_ClearPendingIRQ(USART2_IRQn); + HAL_NVIC_SetPriority(USART2_IRQn, UART_INT_PRIORITY, UART_SUBPRIORITY); + HAL_NVIC_EnableIRQ(USART2_IRQn); + + bspState = (uint8_t)BSP_STATE_ENABLED; + } + return retcode; +} + +/** + * See API interface for function documentation + * @retval RETCODE_OK in case of success. + * @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow disabling. + */ +Retcode_T BSP_GenericUart_Disable(uint32_t id) +{ + KISO_UNUSED(id); + Retcode_T retcode = RETCODE_OK; + + if (!(bspState & (uint8_t)BSP_STATE_TO_DISABLED)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE); + } + if (RETCODE_OK == retcode) + { + /* Disable interrupts and deactivate UART peripheral */ + HAL_NVIC_DisableIRQ(USART2_IRQn); + /* Clear the pending interrupt */ + HAL_NVIC_ClearPendingIRQ(USART2_IRQn); + + if (HAL_OK != HAL_UART_DeInit(&uartCtrlStruct.huart)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_DEINIT_FAILED); + } + } + if (RETCODE_OK == retcode) + { + __USART2_CLK_DISABLE(); + bspState = (uint8_t)BSP_STATE_DISABLED; + } + return retcode; +} + +/** + * See API interface for function documentation + * @retval RETCODE_OK in case of success. + * @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow disconnecting. + */ +Retcode_T BSP_GenericUart_Disconnect(uint32_t id) +{ + KISO_UNUSED(id); + Retcode_T retcode = RETCODE_OK; + if (!(bspState & (uint8_t)BSP_STATE_TO_DISCONNECTED)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE); + } + if (RETCODE_OK == retcode) + { + HAL_GPIO_DeInit(GPIOD, PIND_USART2_TX | PIND_USART2_RX); + GPIO_CloseClockGate(GPIO_PORT_D, PIND_USART2_TX | PIND_USART2_RX); + } + if (RETCODE_OK == retcode) + { + bspState = (uint8_t)BSP_STATE_DISCONNECTED; + } + return retcode; +} + +/** + * See API interface for function documentation + * @return A pointer to the UART control structure + */ +HWHandle_T BSP_GenericUart_GetHandle(uint32_t id) +{ + KISO_UNUSED(id); + return (HWHandle_T)&uartCtrlStruct; +} + +/** + * This function is not in use. + */ +Retcode_T BSP_GenericUart_UserControl(uint32_t control, void *param) +{ + KISO_UNUSED(control); + KISO_UNUSED(param); + + return RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NOT_SUPPORTED); +} + +/*---------------------- LOCAL FUNCTIONS IMPLEMENTATION -------------------------------------------------------------*/ + +/** + * Interrupt Service Routine handling USART2 IRQ. Forwards call to MCU Layer for handling. + */ +void USART2_IRQHandler(void) +{ + if (uartCtrlStruct.IrqCallback) + { + uartCtrlStruct.IrqCallback((UART_T)&uartCtrlStruct); + } +} +#endif /* KISO_FEATURE_BSP_TEST_INTERFACE */ diff --git a/boards/NucleoF767/bsp/source/bsp_api_testif.c b/boards/NucleoF767/bsp/source/bsp_api_testif.c index 1b4bd875..0dd7c2ab 100644 --- a/boards/NucleoF767/bsp/source/bsp_api_testif.c +++ b/boards/NucleoF767/bsp/source/bsp_api_testif.c @@ -77,7 +77,14 @@ Retcode_T BSP_TestInterface_Connect(void) } if (RETCODE_OK == retcode) { - GPIO_InitTypeDef BSP_GPIOInitStruct = {0}; + /* IOSV bit MUST be set to access GPIO port G[2:15] */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_RCC_LPTIM1_CLK_ENABLE(); + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* UART RX/TX GPIO pin configuration */ + GPIO_OpenClockGate(GPIO_PORT_D, PIND_USART3_TX | PIND_USART3_RX); GPIO_OpenClockGate(GPIO_PORT_D, PINB_DBG_TX | PINB_DBG_RX); /* Configure RX TX as alternate function push pull */ @@ -146,7 +153,8 @@ Retcode_T BSP_TestInterface_Disable(void) { /* Disable interrupts and deactivate UART peripheral */ HAL_NVIC_DisableIRQ(USART3_IRQn); - if (HAL_OK != HAL_UART_DeInit(&testIf_UARTStruct.huart)) + + if (HAL_OK != HAL_UART_DeInit(&testIf_UARTStruct.huart)) { retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_DEINIT_FAILED); } @@ -173,8 +181,8 @@ Retcode_T BSP_TestInterface_Disconnect(void) } if (RETCODE_OK == retcode) { - HAL_GPIO_DeInit(GPIOD, PINB_DBG_TX | PINB_DBG_RX); - GPIO_CloseClockGate(GPIO_PORT_D, PINB_DBG_TX | PINB_DBG_RX); + HAL_GPIO_DeInit(GPIOD, PIND_USART3_TX | PIND_USART3_RX); + GPIO_CloseClockGate(GPIO_PORT_D, PIND_USART3_TX | PIND_USART3_RX); } if (RETCODE_OK == retcode) { @@ -206,7 +214,7 @@ Retcode_T BSP_TestInterface_Control(uint32_t command, void *arg) /*---------------------- LOCAL FUNCTIONS IMPLEMENTATION -------------------------------------------------------------*/ /** - * Interrupt Service Routine handling USART1 IRQ. Forwards call to MCU Layer for handling. + * Interrupt Service Routine handling USART3 IRQ. Forwards call to MCU Layer for handling. */ void USART3_IRQHandler(void) { diff --git a/cmake/KisoLibsConfig.cmake b/cmake/KisoLibsConfig.cmake index cba4be35..ad922c92 100644 --- a/cmake/KisoLibsConfig.cmake +++ b/cmake/KisoLibsConfig.cmake @@ -72,7 +72,6 @@ if(NOT KISO_STATIC_CONFIG) configure_file(${ABS_BOARD_CONFIG_PATH}/${HEADER} ${DEST} COPYONLY) endforeach(HEADER ${BOARD_CONF_FILES}) - # Copy app-specific config files in intermediary directory # APP_CONFIG_PATH is not required - only act if present if(NOT APP_CONFIG_PATH) message(STATUS "APP_CONFIG_PATH not set to a valid path. Not using application-specific configuration.") @@ -99,7 +98,7 @@ if(NOT KISO_STATIC_CONFIG) configure_file(${ABS_APP_CONFIG_PATH}/${HEADER} ${DEST} COPYONLY) endforeach(HEADER ${USER_CONF_FILES}) endif(NOT EXISTS ${ABS_APP_CONFIG_PATH}) - endif(NOT APP_CONFIG_PATH) + endif(NOT APP_CONFIG _PATH) endif(NOT KISO_STATIC_CONFIG) -message(STATUS "Configuration headers merged in ${KISO_CONFIG_PATH}.") +message(STATUS "Configuration headers merged in ${KISO_CONFIG_PATH}.") \ No newline at end of file diff --git a/core/essentials/test/integration/CMakeLists.txt b/core/essentials/test/integration/CMakeLists.txt new file mode 100644 index 00000000..81e8d939 --- /dev/null +++ b/core/essentials/test/integration/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.6) + +project ("Essentials integration test entry" C ASM) + +# the checks will be executed as it would be on the desired compile step +if(${ENABLE_STATIC_CHECKS}) + set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY} --extra-arg=--target=arm-none-eabi --extra-arg=-mthumb --extra-arg=--sysroot=${CMAKE_SYSROOT} -checks=-*,readability-*,clang-analyzer-*,-clang-analyzer-cplusplus*) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY} --extra-arg=--target=arm-none-eabi --extra-arg=--sysroot=${CMAKE_SYSROOT} -checks=-*,readability-*,clang-analyzer-*,-clang-analyzer-cplusplus*) +endif() + +## Only compilable for a target +if(${CMAKE_CROSSCOMPILING}) + file(GLOB TEST_ENTRY_SOURCES + source/*.c + ) + add_library(testentry STATIC ${TEST_ENTRY_SOURCES}) + + target_include_directories(testentry + PRIVATE + source + ) + # List of additional libs from board_config.cmake + target_link_libraries(testentry testing essentials ${KISO_BOARD_LIBS}) +endif(${CMAKE_CROSSCOMPILING}) + +# Include the tests for this module +if(${CMAKE_TESTING_ENABLED}) + #add_subdirectory(testentry/test) +endif() + diff --git a/core/essentials/test/integration/readme.md b/core/essentials/test/integration/readme.md new file mode 100644 index 00000000..38315cda --- /dev/null +++ b/core/essentials/test/integration/readme.md @@ -0,0 +1,7 @@ +# Integration Test Framework + +It is composed by the following packages: +* Test-scheduler: Called in the continious integration. Define where the tests should be run. +* Test-coordinator: Coordiante the build and execution of the tests. +* Test-auxiliaries: List of elements that supports more complex tests (example: communication tests between a cloud service and a device) +* Test-executor: Software that will be flashed on the device under test. \ No newline at end of file diff --git a/core/essentials/test/integration/source/TestEntry.c b/core/essentials/test/integration/source/TestEntry.c new file mode 100644 index 00000000..974a9580 --- /dev/null +++ b/core/essentials/test/integration/source/TestEntry.c @@ -0,0 +1,68 @@ +/********************************************************************************************************************** + * Copyright (c) 2010#2019 Robert Bosch GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl#2.0. + * + * SPDX#License#Identifier: EPL#2.0 + * + * Contributors: + * Robert Bosch GmbH # initial contribution + * + **********************************************************************************************************************/ + +/** + * @file + * + * @brief + * Implements the following functionalities specified in template.h + */ +/*###################### INCLUDED HEADERS ############################################################################*/ +#include "Kiso_Testing.h" +#include "TestSuiteUart.h" + +/*###################### MACROS DEFINITION ###########################################################################*/ +#undef KISO_MODULE_ID +#define KISO_MODULE_ID KISO_MODULE_ID_TEST_ENTRY + +#define TEST_ENTRY_ID 1 +/*###################### LOCAL_TYPES DEFINITION ######################################################################*/ + +/*###################### LOCAL FUNCTIONS DECLARATION #################################################################*/ + +Retcode_T TestEntry_Initialize(void *param1, uint32_t param2); +static Retcode_T TestEntry_Setup(CCMsg_T *ccmsg); +static Retcode_T TestEntry_Teardown(CCMsg_T *ccmsg); + +/*###################### VARIABLES DECLARATION #######################################################################*/ + +/*###################### EXPOSED FUNCTIONS IMPLEMENTATION ############################################################*/ + +/*###################### LOCAL FUNCTIONS IMPLEMENTATION ##############################################################*/ + +Retcode_T TestEntry_Initialize(void *param1, uint32_t param2) +{ + KISO_UNUSED(param1); + KISO_UNUSED(param2); + + Retcode_T retcode = RETCODE_OK; + retcode = Tests_Initialize(TEST_ENTRY_ID, TestEntry_Setup, TestEntry_Teardown); + if (RETCODE_OK == retcode) + { + retcode = TestSuiteUart_Initialize((uint8_t)1); + } + return retcode; +} + +static Retcode_T TestEntry_Setup(CCMsg_T *ccmsg) +{ + KISO_UNUSED(ccmsg); + return RETCODE_OK; +} + +static Retcode_T TestEntry_Teardown(CCMsg_T *ccmsg) +{ + KISO_UNUSED(ccmsg); + return RETCODE_OK; +} \ No newline at end of file diff --git a/core/essentials/test/integration/source/TestSuiteUart.c b/core/essentials/test/integration/source/TestSuiteUart.c new file mode 100644 index 00000000..78019fb9 --- /dev/null +++ b/core/essentials/test/integration/source/TestSuiteUart.c @@ -0,0 +1,245 @@ +/********************************************************************************************************************** + * Copyright (c) 2010#2019 Robert Bosch GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl#2.0. + * + * SPDX#License#Identifier: EPL#2.0 + * + * Contributors: + * Robert Bosch GmbH # initial contribution + * + **********************************************************************************************************************/ + +/** + * @file + * + * @brief + * Implements test cases for uart comminication verification + */ +/*###################### INCLUDED HEADERS ############################################################################*/ +#include "Kiso_Testing.h" +#include "Kiso_CmdProcessor.h" +#include "Kiso_MCU_UART.h" +#include "Kiso_BSP_GenericUart.h" +#include "TestSuiteUART.h" +#include +#include "FreeRTOS.h" +#include "semphr.h" +/*###################### MACROS DEFINITION ###########################################################################*/ +#undef KISO_MODULE_ID +#define KISO_MODULE_ID 0 + +#define UART_BUFFER_LEN 5 +#define DATA_TRANSFER_TIMEOUT_MS UINT32_C(1000) +#define UART_DEVICE UINT32_C(1) + +/*###################### LOCAL_TYPES DEFINITION ######################################################################*/ +enum TestSuiteUart_TestCases_E +{ + TEST_CASE_FUNCTIONAL_TEST_ID = 1 +}; +/*###################### LOCAL FUNCTIONS DECLARATION #################################################################*/ + +static Retcode_T TestCase_FctTest_Setup(CCMsg_T *ccmsg); +static void TestCase_FctTest_Run(CCMsg_T *ccmsg); +static Retcode_T TestCase_FctTest_Teardown(CCMsg_T *ccmsg); +static void UartISRCallback(UART_T uart, struct MCU_UART_Event_S event); + +/*###################### VARIABLES DECLARATION #######################################################################*/ + +/*###################### EXPOSED FUNCTIONS IMPLEMENTATION ############################################################*/ + +/*###################### LOCAL FUNCTIONS IMPLEMENTATION ##############################################################*/ + +static UART_T UartHdl = 0; +static xSemaphoreHandle UartLock = 0; + +Retcode_T TestSuiteUart_Initialize(uint8_t sId) +{ + Retcode_T retcode = RETCODE_OK; + + retcode = Tests_RegisterTestSuite(sId, TestCase_FctTest_Setup, TestCase_FctTest_Teardown); + + if (RETCODE_OK == retcode) + { + retcode = Tests_RegisterTestCase(sId, TEST_CASE_FUNCTIONAL_TEST_ID, TestCase_FctTest_Setup, TestCase_FctTest_Run, TestCase_FctTest_TearDown); + } + return retcode; +} + +/** + * @brief Performs the setup operation of the functional test of uart in interrupt mode + * @details This function initializes the uart interface in interrupt mode and creates the necessary + * synchronisation ressources. + */ +static Retcode_T TestCase_FctTest_Setup(CCMsg_T *ccmsg) +{ + KISO_UNUSED(ccmsg); + Retcode_T retcode = RETCODE_OK; + + UartHdl = (UART_T)BSP_GenericUart_GetHandle(UART_DEVICE); + if (NULL == UartHdl) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NULL_POINTER); + } + if (RETCODE_OK == retcode) + { + UartLock = xSemaphoreCreateBinary(); + if (NULL == UartLock) + { + return RETCODE(RETCODE_SEVERITY_FATAL, RETCODE_SEMAPHORE_ERROR); + } + } + if (RETCODE_OK == retcode) + { + retcode = BSP_GenericUart_Connect(UART_DEVICE); + } + if (RETCODE_OK == retcode) + { + retcode = MCU_UART_Initialize(UartHdl, UartISRCallback); + } + if (RETCODE_OK == retcode) + { + retcode = BSP_GenericUart_Enable(UART_DEVICE); + } + return retcode; +} + +/** + * @brief Deinitializes the uart interface + */ +static Retcode_T TestCase_FctTest_Teardown(CCMsg_T *ccmsg) +{ + KISO_UNUSED(ccmsg); + Retcode_T retcode; + + retcode = MCU_UART_Deinitialize(UartHdl); + if (RETCODE_OK == retcode) + { + retcode = BSP_GenericUart_Disable(UART_DEVICE); + } + if (RETCODE_OK == retcode) + { + retcode = BSP_GenericUart_Disconnect(UART_DEVICE); + } + if (RETCODE_OK == retcode) + { + vSemaphoreDelete(UartLock); + } + return retcode; +} + +/** + * This Test will put the uart receiver into receive mode and send data via the transmitter the data will be + * looped back to the receiver at hardware level (e.g. wiring TX line to RX line) + * the test will succede if the transmit operation succeeded and if the received data matches the transmitted data + */ +static void TestCase_FctTest_Run(CCMsg_T *ccmsg) +{ + KISO_UNUSED(ccmsg); + + Retcode_T retcode; + uint8_t dataOut[UART_BUFFER_LEN]; + uint8_t dataIn[UART_BUFFER_LEN] = {0}; + char msg[30] = "SUCCESS"; + + for (uint8_t i = 0; i < UART_BUFFER_LEN; i++) + { + dataOut[i] = i; + } + + retcode = MCU_UART_Receive(UartHdl, dataIn, UART_BUFFER_LEN); + + if (RETCODE_OK == retcode) + { + retcode = MCU_UART_Send(UartHdl, dataOut, UART_BUFFER_LEN); + } + if (RETCODE_OK == retcode) + { + if (pdTRUE != xSemaphoreTake(UartLock, DATA_TRANSFER_TIMEOUT_MS)) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_SEMAPHORE_ERROR); + strcpy(msg, "FAIL"); + } + } + if (RETCODE_OK == retcode) + { + for (uint8_t i = 0; i < UART_BUFFER_LEN; i++) + { + if (dataIn[i] != dataOut[i]) + { + retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_UNEXPECTED_BEHAVIOR); + strcpy(msg, "FAIL"); + } + } + } + Tests_SendReport(Retcode_GetCode(retcode), msg); +} + +static void UartISRCallback(UART_T uart, struct MCU_UART_Event_S event) +{ + KISO_UNUSED(uart); + Retcode_T Rc = RETCODE_OK; + + if (UINT8_C(1) == event.TxComplete) + { + + if (RETCODE_OK == Rc) + { + BaseType_t higherPriorityTaskWoken = pdFALSE; + + if (NULL != UartLock) + { + if (pdTRUE == xSemaphoreGiveFromISR(UartLock, &higherPriorityTaskWoken)) + { + portYIELD_FROM_ISR(higherPriorityTaskWoken); + } + else + { + /* ignore... semaphore has already been given */ + } + } + else + { + Rc = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NULL_POINTER); + } + } + } + + if (UINT8_C(1) == event.RxComplete) + { + + if (RETCODE_OK == Rc) + { + BaseType_t higherPriorityTaskWoken = pdFALSE; + + if (NULL != UartLock) + { + if (pdTRUE == xSemaphoreGiveFromISR(UartLock, &higherPriorityTaskWoken)) + { + portYIELD_FROM_ISR(higherPriorityTaskWoken); + } + else + { + /* ignore... semaphore has already been given */ + } + } + else + { + Rc = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NULL_POINTER); + } + } + } + + if (UINT8_C(1) == event.TxError) + { + Rc = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_FAILURE); + } + + if (RETCODE_OK != Rc) + { + Retcode_RaiseErrorFromIsr(Rc); + } +} diff --git a/core/essentials/test/integration/source/TestSuiteUart.h b/core/essentials/test/integration/source/TestSuiteUart.h new file mode 100644 index 00000000..4319f201 --- /dev/null +++ b/core/essentials/test/integration/source/TestSuiteUart.h @@ -0,0 +1,55 @@ +/********************************************************************************************************************** + * Copyright (c) 2010#2019 Robert Bosch GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl#2.0. + * + * SPDX#License#Identifier: EPL#2.0 + * + * Contributors: + * Robert Bosch GmbH # initial contribution + * + **********************************************************************************************************************/ + +/** + * @file + * @defgroup + * @ingroup + * @{ + * + * @brief Provides an API for the following functionality + * + */ +#ifndef TESTSUITE_UART_H_ +#define TESTSUITE_UART_H_ + +/*###################### INCLUDED HEADERS ############################################################################*/ + +/*###################### MACROS DEFINITION ###########################################################################*/ + +/*###################### TYPE DEFINITIONS ############################################################################*/ + +enum TestSuiteUart_Retcodes_E +{ + TESTSUITE_SETUP_TRIGGERED_SEVERAL_TIMES = RETCODE_FIRST_CUSTOM_CODE, + TESTSUITE_RUN_TRIGGERED_SEVERAL_TIMES, + TestSuite_Teardown_TRIGGERED_SEVERAL_TIMES, +}; + +/*###################### EXPORTED FUNCTIONS PROTOTYPES ###############################################################*/ + +/** + * @brief Initializes the uart test suite + * @details This function will register the uart test suites in the Testing module TestSuites register and will + * also register for execution all the test cases belonging to this test suite + * @param id is the identifier to be given to the test suite it will be used in the communication protocol between + * the test executor and the test controller @see todo: add link to docu + */ +Retcode_T TestSuiteUart_Initialize(uint8_t id); + +/*###################### GLOBAL VARIABLES ###########################################################################*/ + +/** @} */ + +#endif /* TESTSUITE_UART_H_ */ diff --git a/core/essentials/test/integration/specs/I2C_Test_Spec.md b/core/essentials/test/integration/specs/I2C_Test_Spec.md new file mode 100644 index 00000000..2b5a1d83 --- /dev/null +++ b/core/essentials/test/integration/specs/I2C_Test_Spec.md @@ -0,0 +1,283 @@ +# Test Entry 3: "Essentials" + +## Test Suite 3.3: I2C_Selfcontained_Test +### Description + +* Purpose + + Test the I2C transfer functionality + +* Test participants: + - Device under Test (DUT): Stm32 - Bike Sensor Board (BSE) + - Test Coordinator: PC + +### Test Setup +The test setup consists of the test coordinator and 1 test participant + +* Test Coordinator (on PC) +* The DUT is connected to the PC via UART which is the Test Coordination Channel. The embedded C testling code is flashed onto the DUT. +* The DUT is connected to a 12 V power source. +* For this selfcontained test, no external wires are necessary and only BSE-internal Sensors are polled via I2C. + +On the BSE testling, the initialization sequence setups the I2C Clock and the I2C GPIOs: + +* I2C SCL line: GPIO_PIN_14, Bank GPIOG, mode GPIO_PULLUP, GPIO_SPEED_LOW +* I2C SDA line: GPIO_PIN_13, Bank GPIOG, mode GPIO_PULLUP, GPIO_SPEED_LOW +* Alternative function: GPIO_AF4_I2C1 +* I2C Clock: PCLK1 +* enable GPIO bank G clock +* power up GPIO bank G (PWR_CR2_IOSV register) +* IRQs I2Cx_ER_IRQn and I2Cx_EV_IRQn are enabled + +### Teardown + +No special teardown + +### Test Cases + +#### TC 3.3.1 TestCase_I2C_initialize +##### Setup +No separate Test Case Setup required + +##### Run +1. For all present I2C Interfaces: BCDS_I2C1, BCDS_I2C2 + + * Call API: I2C_getVersion(), expect version + * Call API: I2C_getCapabilities(), expect only "address10bit" capability. + * Call API: I2C_initialize(), expect RETCODE_OK + * Call API: I2C_powerControl(PERIPHERALS_POWER_STATE_FULL), expect RETCODE_OK + * Call API: I2C_powerControl(PERIPHERALS_POWER_STATE_OFF), expect RETCODE_OK + * Call API: I2C_powerControl(PERIPHERALS_POWER_STATE_FULL), expect RETCODE_OK + * Call API: I2C_control(BCDS_I2C_BUS_SPEED,BCDS_I2C_BUS_SPEED_STANDARD), expect RETCODE_OK + * Call API: I2C_control(BCDS_I2C_BUS_SPEED,BCDS_I2C_BUS_SPEED_FAST), expect RETCODE_OK + * Call API: I2C_control(BCDS_I2C_BUS_SPEED,BCDS_I2C_BUS_SPEED_FAST_PLUS), expect RETCODE_OK + * Call API: I2C_control(BCDS_I2C_BUS_SPEED,BCDS_I2C_OWN_ADDRESS,0x42), expect RETCODE_OK + * Call API: I2C_getStatus(), expect only flag "Initialized" + * Call API: I2C_uninitialize(), expect RETCODE_OK + +2. If all as expected, return Success. + +##### TearDown +No separate Test Case Tear Down required + +#### TC 3.3.2 TestCase_I2C_master_BMI160 + +On the BSE boardThe inertial measurement unit BMI160 is visible via BCDS_I2C1 on address 0x68. +To read a register, the register ID is first written via I2C to BMI160. +Maximum supported clock frequency is 1000khz, i.e., BCDS_I2C_BUS_SPEED_FAST_PLUS. + +##### Setup +Call API: I2C_initialize(), expect RETCODE_OK + +##### Run +1. Transmit 1 byte value 0 to BMI160 to access the CHIPID register: + + * Call API: I2C_masterTransmit(BCDS_I2C1 ,0x68, 0, 1, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. +2. Read 1 byte CHIPID value from BMI160: + + * Call API: I2C_masterReceive(BCDS_I2C1 ,0x68, &chipid, 1, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. + * Expect CHIPID to be ( 0b11010001 = 0xD1 ) +3. Transmit 1 byte value 0x04 to BMI160 to access the DATA registers: + + * Call API: I2C_masterTransmit(BCDS_I2C1 ,0x68, 0x04, 1, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. +4. Read 20 byte DATA register values from BMI160: + + * Call API: I2C_masterReceive(BCDS_I2C1 ,0x68, datareg, 20, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. + * Expect at least one DATA registers values to contain values different from 0 +5. If all as expected, return Success. + +##### TearDown +Call API: I2C_uninitialize(), expect RETCODE_OK + +## Test Suite 3.4: I2C_Arduino_Test +### Description + +1. Purpose: + + * Test the I2C transfer functionality with an Arduino counterpart that allows precise master AND slave communication tests. + +2. Test participants: + + * Test Coordinator: PC + * Device under Test (DUT): Stm32 - Bike Sensor Board (BSE) + * Arduino Due - the arduino code is contained in the Peripherals/test/integration/Testling/Tests/testSuiteI2c/Arduino_I2C_final_Testing_Code folder. + +### Setup +The test setup consists of the test coordinator and 2 test participants + +1. Test Coordinator (on PC) +2. The DUT is connected to the PC via UART which is the Test Coordination Channel. The embedded C testling code is flashed onto the DUT. +3. The DUT is connected to a 12 V power source. +4. The Arduino is connected to the PC via UART to flash and power the Arduino board. +5. The Arduino testling code is flashed onto the Arduino. +6. The I2C bus I2C1 of the BSE board is led out and connected to the Arduino Due board such that: + + * BSE-PG14/C6 SCL line is connected to Arduino GPIO pin 21 + * BSE-PG13/C7 SDA line is connected to Arduino GPIO pin 20 + * a common ground line between the BSE board and the Arduino board is connected + +On the BSE testling, the initialization sequence setups the I2C Clock and the I2C GPIOs: + +7. I2C SCL line: GPIO_PIN_14, Bank GPIOG, mode GPIO_PULLUP, GPIO_SPEED_LOW +8. I2C SDA line: GPIO_PIN_13, Bank GPIOG, mode GPIO_PULLUP, GPIO_SPEED_LOW +9. Alternative function: GPIO_AF4_I2C1 +10. I2C Clock: PCLK1 +11. Enable GPIO bank G clock +12. Power up GPIO bank G (PWR_CR2_IOSV register) +13. IRQs I2Cx_ER_IRQn and I2Cx_EV_IRQn are enabled + +### Teardown +No special teardown + +### Test Cases + +#### TC 3.4.1 TestCase_I2C_master + +The arduino wire library has a maximum i2c buffer size of 32 bytes - so larger data streams cannot be tested. + +##### Setup +1. Call API: I2C_initialize(), expect RETCODE_OK +2. Send testcase ID (1) to arduino and expect acknowledge byte (1) + + * Call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, 1, 1, 0); + * Call API: I2C_masterRecieve (BCDS_I2C1, ARDUINO_I2C_ADDRESS, &arduinoAcknowledges, 1, 0); + * Expect arduinoAcknowledges == 1 +3. Call API: I2C_uninitialize(), expect RETCODE_OK +4. Call API: I2C_initialize(), expect RETCODE_OK + +##### Run +1. In Master mode send 1 byte to Arduino and receive it back: + + * Call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, TESTBYTE, 1, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. + * Call API: I2C_masterReceive(BCDS_I2C1, ARDUINO_I2C_ADDRESS, &receiveBuffer, 1, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. + * Verify (receiveBuffer == TESTBYTE) +2. In Master mode send 32 bytes to Arduino and receive them back + + * uint8_t TEST32BYTES[] = {42, 43, ..., 73 }; + * Call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, TEST32BYTES, 32, 0); + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. +3. Call API: I2C_masterReceive(BCDS_I2C1, ARDUINO_I2C_ADDRESS, receiveBuffer32, 32, 0); + + * Expect RETCODE_OK; + * Expect "TransferDone" Callback. +4. Verify (receiveBuffer32 identical to TEST32BYTES) +5. Return Success. + +##### TearDown +Call API: I2C_uninitialize(), expect RETCODE_OK + +#### TC 3.4.2 TestCase_I2C_slave_woCallback + +##### Setup +1. Call API: I2C_initialize(), expect RETCODE_OK +2. Send testcase ID (2) to arduino and expect acknowledge byte (1) + + * Byte to call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, 2, 1, 0); + * Byte to call API: I2C_masterRecieve (BCDS_I2C1, ARDUINO_I2C_ADDRESS, &arduinoAcknowledges, 1, 0); + * Expect arduinoAcknowledges == 1 +3. Call API: I2C_uninitialize(), expect RETCODE_OK +4. Call API: I2C_initialize(), expect RETCODE_OK +5. Set own slave address to 0x42 + +##### Run + +1. In Slave mode, wait for Arduino to request 1 byte, then wait until Arduino sends it back + + * Call API: I2C_slaveTransmit(BCDS_I2C1, TESTBYTE, 1); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Call API: I2C_slaveReceive(BCDS_I2C1, &receiveBuffer, 1); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Verify (receiveBuffer == TESTBYTE) +2. In Slave mode send 32 bytes to Arduino and receive them back + + * uint8_t TEST32BYTES[] = {42, 43, ..., 73 }; + * Call API: I2C_slaveTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, TEST32BYTES, 32); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Call API: I2C_slaveReceive(BCDS_I2C1, ARDUINO_I2C_ADDRESS, receiveBuffer32, 32); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Verify (receiveBuffer32 identical to TEST32BYTES) +3. Return Success. + +##### TearDown + +Call API: I2C_uninitialize(), expect RETCODE_OK + +#### TC 3.4.3 TestCase_I2C_slave_callbackDriven + +##### Setup +1. Call API: I2C_initialize(), expect RETCODE_OK +2. Send testcase ID (3) to arduino and expect acknowledge byte (1) + + * Call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, 3, 1, 0); + * Call API: I2C_masterRecieve (BCDS_I2C1, ARDUINO_I2C_ADDRESS, &arduinoAcknowledges, 1, 0); + * Expect arduinoAcknowledges == 1 +3. Call API: I2C_uninitialize(), expect RETCODE_OK + +##### Run +1. Define uint8_t TEST32BYTES[] = {42, 43, ..., 73 }; +2. Call API: I2C_initialize(), expect RETCODE_OK +3. Set own slave address to 0x42 +4. Register new callback event handler that: + + * Answers a SlaveTransmit request with: I2C_slaveTransmit(BCDS_I2C1, TEST32BYTES, 32); + * expect RETCODE_OK; + * Answers a SlaveReceive request with: I2C_slaveReceive(BCDS_I2C1, receiveBuffer32, 32); + * expect RETCODE_OK; + * Updates 4-state-variable from waitForSlaveTransmit(0) to waitForSlaveReceive(1) to done(2) or alternatively error(3) +5. Wait with timeout until 4-state-variable goes through the states + + * WaitForSlaveTransmit(0) + * WaitForSlaveReceive(1) + * Done(2) +6. Make sure error(3) is not reached or return error-report. +7. When state done(2) is reached, verify (receiveBuffer32 identical to TEST32BYTES) +8. Return Success. + +##### TearDown + +Call API: I2C_uninitialize(), expect RETCODE_OK + +#### TC 3.4.4 TestCase_I2C_higherSpeeds + +##### Setup +1. Call API: I2C_initialize(), expect RETCODE_OK +2. Send testcase ID (4) to arduino and expect acknowledge byte (1) + + * Call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, 4, 1, 0); + * Call API: I2C_masterRecieve (BCDS_I2C1, ARDUINO_I2C_ADDRESS, &arduinoAcknowledges, 1, 0); + * Expect arduinoAcknowledges == 1 +3. Call API: I2C_uninitialize(), expect RETCODE_OK +4. Call API: I2C_initialize(), expect RETCODE_OK + +##### Run +1. uint8_t TEST32BYTES[] = {42, 43, ..., 73 }; +2. Set the bus speeds [Standard Speed (100kHz), Fast Speed (400kHz), Fast+ Speed (1MHz)] try: + + * In Master mode send 32 bytes to Arduino and receive them back + * call API: I2C_masterTransmit(BCDS_I2C1, ARDUINO_I2C_ADDRESS, TEST32BYTES, 32, 0); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Call API: I2C_masterReceive(BCDS_I2C1, ARDUINO_I2C_ADDRESS, receiveBuffer32, 32, 0); + * expect RETCODE_OK; + * expect "TransferDone" Callback. + * Verify (receiveBuffer32 identical to TEST32BYTES) +3. Return Success. + +##### TearDown +Call API: I2C_uninitialize(), expect RETCODE_OK diff --git a/core/essentials/test/integration/specs/SPI_Test_Spec.md b/core/essentials/test/integration/specs/SPI_Test_Spec.md new file mode 100644 index 00000000..0542dfdb --- /dev/null +++ b/core/essentials/test/integration/specs/SPI_Test_Spec.md @@ -0,0 +1,207 @@ +Integration Test Specification for SPI + +# Test Suite 2: "Test Specification of SPI" + +## Description + +* Purpose + * Test the Peripheral SPI functionality +* Test participants which are involved + * Test participant :- BSE +* Test environment and setup + * BSE device be connected to the PC via USB Cable. + * A PC has a test coordinator. +* Setup for Flashing-Manual. + * SPI IntegrationTestApp binary file into BSE device + * once the flashing is done + * It automatically reset the device and IntegrationTestApps Boots-up + +## Setup +The test setup consists of the test coordinator and 2 test participants: + +* test coordinator (on PC) +* The test device BSE with the embedded C test participant + +The test device is connected to the test coordinator on the PC via UART as a Test Coordination Channel. + + +### Parameters +No special parameters + +## Teardown +* Deinitialize the SPI Port with SPI_deinitialize. + +## Test Suite 1.2: Non initialized - error test +### Description +* Test the SPI error cases for non initialized case + +### Setup +* No required separate Test Suite Setup for this example. + +### Teardown +* Not required separate Test Suite Tear Down for this example. + +### Test Cases + +#### TC 1.1.1 TestCase_SPI_Control_Error_unitialized +* Test case Setup + * Deinitialize the SPI. +* Test Case Run + * Parameter passed: valid handle, valid control, valid argument + * Run SPI_Control API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.1.2 TestCase_SPI_Send_Error_unitialized +* Test case Setup + * Deinitialize the SPI. +* Test Case Run + * Parameter passed: valid handle, valid sendValue, valid bufferSize + * Run SPI_Send API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.1.3 TestCase_SPI_Receive_Error_unitialized +* Test case Setup + * Deinitialize the SPI. +* Test Case Run + * Parameter passed: valid handle, valid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * No required separate Test Case Tear Down for this example. + +#### TC 1.1.4 TestCase_SPI_Transfer_Error_unitialized +* Test case Setup + * Deinitialize the SPI. +* Test Case Run + * Parameter passed: valid handle, valid sendValue, valid receiveValue, valid bufferSize + * Run SPI_Transfer API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * No required separate Test Case Tear Down for this example. + +################################################################################################################################## + + +#### TC 1.1.5 TestCase_SPI_Send_Error_invalidPort +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: invalid port, valid sendValue, valid bufferSize + * Run SPI_Send API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * No required separate Test Case Tear Down for this example. + +#### TC 1.1.6 TestCase_SPI_Send_Error_invalidSendValue +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, invalid sendValue, valid bufferSize + * Run SPI_Send API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.3 TestCase_SPI_Send_Error_invalidBufferSize +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, valid sendValue, invalid bufferSize + * Run SPI_Send API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.4 TestCase_SPI_Receive_Error_invalidPort +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: invalid port, valid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.5 TestCase_SPI_Receive_Error_invalidReceiveValue +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, invalid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.6 TestCase_SPI_Receive_Error_invalidReceiveValue +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, invalid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.7 TestCase_SPI_Transfer_Error_invalidPort +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: invalid port, valid sendValue, valid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.8 TestCase_SPI_Transfer_Error_invalidSendValue +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, invalid sendValue, valid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.9 TestCase_SPI_Transfer_Error_invalidReceiveValue +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, valid sendValue, invalid receiveValue, valid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +#### TC 1.2.10 TestCase_SPI_Transfer_Error_invalidBufferSize +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid port, valid sendValue, valid receiveValue, invalid bufferSize + * Run SPI_Receive API +* Expected return value from the API: RETCODE_FAILURE +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + + #### TC 1.2.11 TestCase_SPI_Control_Error_invalidParameter +* Test case Setup + * Initialize the SPI Port. +* Test Case Run + * Parameter passed: valid handle, invalid control, invalid argument + * Run SPI_Control API + * Expected return value from the API: RETCODE_NOT_SUPPORTED +* Test case Tear Down + * Not required separate Test Case Tear Down for this example. + +################################################################################################################################## + +## Test Suite 1.3: functional tests +### Description +* Currently it is not possible to have functional SPI tests, because there is neither implemented bus +partner for testing nor a possibility to test the GPIO pins. Instead, the (positive tests) +functionality will be tested by testing the external flash which is connected via SPI. +That means, if flash is working, SPI is working too. But that also means, if flash does not work, +its unclear if the error is in the flash driver or in the SPI driver. diff --git a/core/essentials/test/integration/specs/UART_Test_Spec.md b/core/essentials/test/integration/specs/UART_Test_Spec.md new file mode 100644 index 00000000..818e8a36 --- /dev/null +++ b/core/essentials/test/integration/specs/UART_Test_Spec.md @@ -0,0 +1,212 @@ +# Test Entry 3: "Essentials" +## Test Suite 3.1: UART +### Description +* This suite aims at testing the basic functionality of the UART APIs + +### Setup +The test setup consists of the test coordinator and 1 test participant + +* Test Coordinator (on PC) +* The DUT is connected to the PC via UART which is the Test Coordination Channel. The embedded C testling code is flashed onto the DUT. + +### TearDown + +No special teardown + +### Test Cases + +#### TC 3.1.1:TestCase_Uart_getStatus +##### Setup +No special setup + +##### Run +1. Invoke the Uart_getStatus API +2. Expected return value from the API: HAL_UART_STATE_READY + +##### TearDown +No special teardown + +#### TC 3.1.2:TestCase_Uart_getVersion +##### Setup +No special setup + +##### Run +1. Invoke the Uart_getVersion API +2. API should return the version number of the UART + +##### TearDown +No special teardown + +#### TC 3.1.3:TestCase_Uart_getCapabilities +##### Setup +No special setup + +##### Run +1. Invoke the Uart_getCapabilities API +2. API should return the capabilities supported by the UART + +##### TearDown +No special teardown + + +#### TC 3.1.4:TestCase_Uart_initialize +##### Setup +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 | BCDS_UART_FLOW_CONTROL_NONE + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_initialize API +2. Expected return value from the API: RETCODE_SUCCESS + +##### TearDown +1. Invoke the Uart_uninitialize API +2. Expected return value from the API: RETCODE_SUCCESS + +#### TC 3.1.5:TestCase_Uart_control +##### Setup +No special setup + +##### Run +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS + +##### TearDown +No special teardown + + +#### TC 3.1.6:TestCase_Uart_send +##### Setup +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 | BCDS_UART_FLOW_CONTROL_NONE + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS +3. Invoke the Uart_initialize API +4. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_send API and send the data "BikeSensor" +2. Expected return value from the API: RETCODE_SUCCESS + +##### TearDown +1. Invoke the Uart_uninitialize API +2. Expected return value from the API: RETCODE_SUCCESS + +#### TC 3.1.7:TestCase_Uart_receive +##### Setup +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS +3. Invoke the Uart_initialize API +4. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_receive API +2. Expected return value from the API: RETCODE_FAILURE + +/* @todo: Expectation is a failure because no device is sending data to the DUT UART. Beaglebone has to be integrated for validating this test case */ + +##### TearDown +1. Invoke the Uart_uninitialize API +2. Expected return value from the API: RETCODE_SUCCESS + + +#### TC 3.1.8:TestCase_Uart_uninitialize +##### Setup +1. Invoke the Uart_control API with the following parameters + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_9 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 + * 9600 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS +3. Invoke the Uart_initialize API +4. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_uninitialize API +2. Expected return value from the API: RETCODE_SUCCESS + +##### TearDown +No special teardown + +#### TC 3.1.9:TestCase_Uart_powerControl_full +##### Setup +No special setup + +##### Run +1. Invoke the Uart_powerControl API with the following parameter + + * PERIPHERALS_POWER_STATE_FULL +2. Expected return value from the API: RETCODE_SUCCESS + +##### TearDown +No special teardown + +#### TC 3.1.10:TestCase_Uart_powerControl_low +##### Setup +No special setup + +##### Run +1. Invoke the Uart_powerControl API with the following parameter + + * PERIPHERALS_POWER_STATE_LOW +2. Expected return value from the API: RETCODE_FAILURE + +##### TearDown +No special teardown + +#### TC 3.1.11:Testcase_Uart_initialize_without_control +##### Setup +No special setup + +##### Run +1. Invoke the Uart_initialize API +2. Expected return value from the API:RETCODE_SUCCESS + +##### TearDown +1. Invoke the Uart_uninitialize API +2. Expected return value from the API: RETCODE_SUCCESS + +#### TC 3.1.12:Testcase_Uart_send_without_initialize +##### Setup +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 | BCDS_UART_FLOW_CONTROL_NONE + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_send API and send the data "Integration testing" +2. Expected return value from the API: RETCODE_FAILURE + +##### TearDown +No special teardown + +#### TC 3.1.13:Testcase_Uart_receive_without_initialize +##### Setup +1. Invoke the Uart_control API with the following parameters, + + * BCDS_Uart1 + * BCDS_UART_MODE_ASYNCHRONOUS | BCDS_UART_DATA_BITS_8 | BCDS_UART_PARITY_NONE | BCDS_UART_STOP_BITS_1 | BCDS_UART_FLOW_CONTROL_NONE + * 115200 (Baud rate) +2. Expected return value from the API: RETCODE_SUCCESS + +##### Run +1. Invoke the Uart_receive API +2. Expected return value from the API: RETCODE_FAILURE + +##### TearDown +No special teardown \ No newline at end of file diff --git a/core/essentials/test/integration/test-protocol.txt b/core/essentials/test/integration/test-protocol.txt new file mode 100644 index 00000000..e69de29b diff --git a/testing/integration/readme.md b/testing/integration/readme.md new file mode 100644 index 00000000..38315cda --- /dev/null +++ b/testing/integration/readme.md @@ -0,0 +1,7 @@ +# Integration Test Framework + +It is composed by the following packages: +* Test-scheduler: Called in the continious integration. Define where the tests should be run. +* Test-coordinator: Coordiante the build and execution of the tests. +* Test-auxiliaries: List of elements that supports more complex tests (example: communication tests between a cloud service and a device) +* Test-executor: Software that will be flashed on the device under test. \ No newline at end of file diff --git a/testing/integration/test-auxiliary/readme.md b/testing/integration/test-auxiliary/readme.md new file mode 100644 index 00000000..32b88c56 --- /dev/null +++ b/testing/integration/test-auxiliary/readme.md @@ -0,0 +1,3 @@ +# Test Auxiliary + +It contains different entities that will support the device under test to execute and verify the tests. \ No newline at end of file diff --git a/testing/integration/test-coordinator/readme.md b/testing/integration/test-coordinator/readme.md new file mode 100644 index 00000000..ed3dcf7b --- /dev/null +++ b/testing/integration/test-coordinator/readme.md @@ -0,0 +1,4 @@ +# Test Coordinator + +It is: +* TBD \ No newline at end of file diff --git a/testing/integration/test-executor/CMakeLists.txt b/testing/integration/test-executor/CMakeLists.txt new file mode 100644 index 00000000..156f4488 --- /dev/null +++ b/testing/integration/test-executor/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.6) +project ("Kiso Integration Test Executor" C) + +if(${CMAKE_CROSSCOMPILING}) + set(APP_CONFIG_PATH ${CMAKE_CURRENT_LIST_DIR}/config PARENT_SCOPE) + add_executable(TestExecutor + source/main.c + ) + + target_include_directories(TestExecutor PRIVATE source) + target_link_libraries(TestExecutor bsp essentials testing utils ${KISO_OS_LIB} ${KISO_BOARD_LIBS}) + + add_custom_target(TestExecutor.bin ALL + COMMAND ${CMAKE_OBJCOPY} -O binary -R .usrpg $ ${CMAKE_CURRENT_BINARY_DIR}/TestExecutor.bin + COMMENT "Creating flashable binary ${CMAKE_CURRENT_BINARY_DIR}/TestExecutor.bin" + ) + add_dependencies(TestExecutor.bin TestExecutor) + + include(FlashTarget) + CREATE_FLASH_TARGET_JLINK(TestExecutor) +endif() \ No newline at end of file diff --git a/testing/integration/test-executor/readme.md b/testing/integration/test-executor/readme.md new file mode 100644 index 00000000..e48be8f1 --- /dev/null +++ b/testing/integration/test-executor/readme.md @@ -0,0 +1,4 @@ +# Test Executor + +It is: +* TBD \ No newline at end of file diff --git a/testing/integration/test-executor/testapp/config/AppConfig.cmake b/testing/integration/test-executor/testapp/config/AppConfig.cmake new file mode 100644 index 00000000..87fc8a60 --- /dev/null +++ b/testing/integration/test-executor/testapp/config/AppConfig.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.6) + +set(APP_CMDPROCESSOR_MAIN_PRIORITY 1 CACHE STRING "Main CmdProcessor task priority") +set(APP_CMDPROCESSOR_MAIN_STACKSIZE 1024 CACHE STRING "Main CmdProcessor stack-size") +set(APP_CMDPROCESSOR_MAIN_QLEN 10 CACHE STRING "Main CmdProcessor queue length") + +set(APP_TASK_APP_PRIORITY 2 CACHE STRING "App task priority") +set(APP_TASK_APP_STACKSIZE 1024 CACHE STRING "App stack-size") + +configure_file(${APP_CONFIG_DIR}/AppConfig.h.in ${CURRENT_CONFIG_DIR}/AppConfig.h) \ No newline at end of file diff --git a/testing/integration/test-executor/testapp/config/AppConfig.h.in b/testing/integration/test-executor/testapp/config/AppConfig.h.in new file mode 100644 index 00000000..7d7b8c6a --- /dev/null +++ b/testing/integration/test-executor/testapp/config/AppConfig.h.in @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2010-2019 Robert Bosch GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * + ******************************************************************************/ + +/** + * @brief App config header + * + * @details + * ``` + * ______ _____ _ _ _____ _____ ___ ______________ _____________ __ + * | _ \ _ | | \ | | _ |_ _| | \/ | _ | _ \_ _| ___\ \ / / + * | | | | | | | | \| | | | | | | | . . | | | | | | | | | | |_ \ V / + * | | | | | | | | . ` | | | | | | | |\/| | | | | | | | | | | _| \ / + * | |/ /\ \_/ / | |\ \ \_/ / | | | | | \ \_/ / |/ / _| |_| | | | + * |___/ \___/ \_| \_/\___/ \_/ \_| |_/\___/|___/ \___/\_| \_/ + * + * + * _____ _ _ _____ _____ _ _ _____ ___ ______ ___________ _ + * |_ _| | | |_ _/ ___| | | | || ___|/ _ \| _ \ ___| ___ \ | + * | | | |_| | | | \ `--. | |_| || |__ / /_\ \ | | | |__ | |_/ / | + * | | | _ | | | `--. \ | _ || __|| _ | | | | __|| /| | + * | | | | | |_| |_/\__/ / | | | || |___| | | | |/ /| |___| |\ \|_| + * \_/ \_| |_/\___/\____/ \_| |_/\____/\_| |_/___/ \____/\_| \_(_) + * ``` + * + * This file is managed through cmake! The .h.in file acts as the + * template for generating the "real" header during cmakes' configure stage. + * This generated header will be placed in your CMAKE_CURRENT_BINARY_DIR and + * included during building. + * + * In the template we refer to cmake variables through ${XYZ} or @XYZ@ notation. + * Any such occurrence will be populated by cmake with the coresponding variable + * value. + * + * The intended way of modifying values in this header is: + * A) Through the .cmake file located either in either the boards' + * or the apps' config folder. + * B) Through command line options such as: + * `$ cmake --build -D =` + * Where is the name of a cmake variable and it's associated + * value. + */ + +#ifndef APPCONFIG_H_ +#define APPCONFIG_H_ + +// clang-format off +#define APP_CMDPROCESSOR_MAIN_PRIORITY (UINT32_C(${APP_CMDPROCESSOR_MAIN_PRIORITY})) +#define APP_CMDPROCESSOR_MAIN_STACKSIZE (UINT16_C(${APP_CMDPROCESSOR_MAIN_STACKSIZE})) +#define APP_CMDPROCESSOR_MAIN_QLEN (UINT32_C(${APP_CMDPROCESSOR_MAIN_QLEN})) + +#define APP_TASK_APP_PRIORITY (UINT32_C(${APP_TASK_APP_PRIORITY})) +#define APP_TASK_APP_STACKSIZE (UINT16_C(${APP_TASK_APP_STACKSIZE})) + +// clang-format on + +#endif diff --git a/testing/integration/test-executor/testapp/config/Utils/Kiso_UtilsConfig.cmake b/testing/integration/test-executor/testapp/config/Utils/Kiso_UtilsConfig.cmake new file mode 100644 index 00000000..c3e005a3 --- /dev/null +++ b/testing/integration/test-executor/testapp/config/Utils/Kiso_UtilsConfig.cmake @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.6) + +if(${ENABLE_ALL_FEATURES}) + set(CFG_KISO_FEATURE_CMDLINEDEBUGGER "1" CACHE STRING "Enable Kiso Command Line Debugger module") + set(CFG_KISO_FEATURE_CMDPROCESSOR "1" CACHE STRING "Enable Kiso Command Processor module") + set(CFG_KISO_FEATURE_CRC "1" CACHE STRING "Enable Kiso CRC module") + set(CFG_KISO_FEATURE_EVENTHUB "1" CACHE STRING "Enable Kiso Event Hub module") + set(CFG_KISO_FEATURE_GUARDEDTASK "1" CACHE STRING "Enable Kiso Guarded Task module") + set(CFG_KISO_FEATURE_ERRORLOGGER "1" CACHE STRING "Enable Kiso Error Logger module") + set(CFG_KISO_FEATURE_LOGGING "1" CACHE STRING "Enable Kiso Logging module") + set(CFG_KISO_FEATURE_QUEUE "1" CACHE STRING "Enable Kiso Queue module") + set(CFG_KISO_FEATURE_RINGBUFFER "1" CACHE STRING "Enable Kiso Ring Buffer module") + set(CFG_KISO_FEATURE_SLEEPCONTROL "1" CACHE STRING "Enable Kiso Sleep Control module") + set(CFG_KISO_FEATURE_TASKMONITOR "1" CACHE STRING "Enable Kiso Task Monitor module") + set(CFG_KISO_TASKMONITOR_MAX_TASKS "10" CACHE STRING "Number of Task Monitors to allocate") + set(CFG_KISO_FEATURE_UARTTRANSCEIVER "1" CACHE STRING "Enable Kiso UART Transceiver module") + set(CFG_KISO_FEATURE_I2CTRANSCEIVER "1" CACHE STRING "Enable Kiso I2C Transceiver module") + set(CFG_KISO_FEATURE_XPROTOCOL "1" CACHE STRING "Enable Kiso XProtocol module") + set(CFG_KISO_FEATURE_PIPEANDFILTER "1" CACHE STRING "Enable Kiso Pipe & Filter module") +else() + set(CFG_KISO_FEATURE_CMDLINEDEBUGGER "1" CACHE STRING "Enable Kiso Command Line Debugger module") + set(CFG_KISO_FEATURE_CMDPROCESSOR "1" CACHE STRING "Enable Kiso Command Processor module") + set(CFG_KISO_FEATURE_CRC "1" CACHE STRING "Enable Kiso CRC module") + set(CFG_KISO_FEATURE_EVENTHUB "1" CACHE STRING "Enable Kiso Event Hub module") + set(CFG_KISO_FEATURE_GUARDEDTASK "1" CACHE STRING "Enable Kiso Guarded Task module") + set(CFG_KISO_FEATURE_ERRORLOGGER "1" CACHE STRING "Enable Kiso Error Logger module") + set(CFG_KISO_FEATURE_LOGGING "1" CACHE STRING "Enable Kiso Logging module") + set(CFG_KISO_FEATURE_QUEUE "1" CACHE STRING "Enable Kiso Queue module") + set(CFG_KISO_FEATURE_RINGBUFFER "1" CACHE STRING "Enable Kiso Ring Buffer module") + set(CFG_KISO_FEATURE_SLEEPCONTROL "0" CACHE STRING "Enable Kiso Sleep Control module") + set(CFG_KISO_FEATURE_TASKMONITOR "1" CACHE STRING "Enable Kiso Task Monitor module") + set(CFG_KISO_TASKMONITOR_MAX_TASKS "10" CACHE STRING "Number of Task Monitors to allocate") + set(CFG_KISO_FEATURE_UARTTRANSCEIVER "1" CACHE STRING "Enable Kiso UART Transceiver module") + set(CFG_KISO_FEATURE_I2CTRANSCEIVER "1" CACHE STRING "Enable Kiso I2C Transceiver module") + set(CFG_KISO_FEATURE_XPROTOCOL "1" CACHE STRING "Enable Kiso XProtocol module") + set(CFG_KISO_FEATURE_PIPEANDFILTER "1" CACHE STRING "Enable Kiso Pipe & Filter module") +endif() + +configure_file(${KISO_CENTRAL_CONFIG_DIR}/Utils/Kiso_UtilsConfig.h.in ${CURRENT_CONFIG_DIR}/Utils/Kiso_UtilsConfig.h) \ No newline at end of file diff --git a/testing/integration/test-executor/testapp/source/AppModules.h b/testing/integration/test-executor/testapp/source/AppModules.h new file mode 100644 index 00000000..cbd2681a --- /dev/null +++ b/testing/integration/test-executor/testapp/source/AppModules.h @@ -0,0 +1,17 @@ + +#ifndef APPMODULES_H_ +#define APPMODULES_H_ + +/** + * @brief Enumerates application modules which are reporting error codes according to RETCODE specification. + * @info usage: + * #undef KISO_APP_MODULE_ID + * #define KISO_APP_MODULE_ID APP_MODULE_ID_xxx + */ +enum App_ModuleID_E +{ + APP_MODULE_ID_MAIN = 1, + /* Define next module ID here and assign a value to it! */ +}; + +#endif diff --git a/testing/integration/test-executor/testapp/source/BSP_Proxy.h b/testing/integration/test-executor/testapp/source/BSP_Proxy.h new file mode 100644 index 00000000..fa849d27 --- /dev/null +++ b/testing/integration/test-executor/testapp/source/BSP_Proxy.h @@ -0,0 +1,61 @@ +/********************************************************************************************************************** + * Copyright (c) 2010#2019 Robert Bosch GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl#2.0. + * + * SPDX#License#Identifier: EPL#2.0 + * + * Contributors: + * Robert Bosch GmbH # initial contribution + * + **********************************************************************************************************************/ + +/** + * @file + * @defgroup + * @ingroup + * @{ + * + * @brief Provides conversion from the bsp board interface to the testapp expected interface + * + */ + +/*###################### INCLUDED HEADERS ############################################################################*/ +#if defined(CommonGateway) +#include "BSP_CommonGateway.h" +#elif defined(NucleoL4R5ZI) +#include "BSP_NucleoL4R5ZI.h" +#endif + +/*###################### MACROS DEFINITION ###########################################################################*/ + +#if defined(CommonGateway) + +#define TEST_BOARD_LED_ALL COMMONGATEWAY_LED_ALL +#define TEST_BOARD_LED_PASS COMMONGATEWAY_LED_GREEN_ID +#define TEST_BOARD_LED_FAIL COMMONGATEWAY_LED_BLUE_ID +#define TEST_BOARD_LED_PANIC COMMONGATEWAY_LED_RED_ID +#define TEST_BOARD_LED_COMMAND_ON COMMONGATEWAY_LED_COMMAND_ON +#define TEST_BOARD_LED_COMMAND_OFF COMMONGATEWAY_LED_COMMAND_OFF +#define TEST_BOARD_LED_COMMAND_TOGGLE COMMONGATEWAY_LED_COMMAND_TOGGLE + +#elif defined(NucleoL4R5ZI) + +#define TEST_BOARD_LED_ALL NUCLEOL4R5ZI_LED_ALL +#define TEST_BOARD_LED_PASS NUCLEOL4R5ZI_LED_GREEN_ID +#define TEST_BOARD_LED_FAIL NUCLEOL4R5ZI_LED_BLUE_ID +#define TEST_BOARD_LED_PANIC NUCLEOL4R5ZI_LED_RED_ID +#define TEST_BOARD_LED_COMMAND_ON NUCLEOL4R5ZI_LED_COMMAND_ON +#define TEST_BOARD_LED_COMMAND_OFF NUCLEOL4R5ZI_LED_COMMAND_OFF +#define TEST_BOARD_LED_COMMAND_TOGGLE NUCLEOL4R5ZI_LED_COMMAND_TOGGLE +#endif + +/*###################### TYPE DEFINITIONS ############################################################################*/ + +/*###################### EXPORTED FUNCTIONS PROTOTYPES ###############################################################*/ + +/*###################### GLOBAL VARIABLES ###########################################################################*/ + +/** @} */ \ No newline at end of file diff --git a/testing/integration/test-executor/testapp/source/main.c b/testing/integration/test-executor/testapp/source/main.c new file mode 100644 index 00000000..11d0fe5a --- /dev/null +++ b/testing/integration/test-executor/testapp/source/main.c @@ -0,0 +1,266 @@ +/********************************************************************************************************************** +* Copyright (c) 2010-2019 Robert Bosch GmbH +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License 2.0 which is available at +* http://www.eclipse.org/legal/epl-2.0. +* +* SPDX-License-Identifier: EPL-2.0 +* +* Contributors: +* Robert Bosch GmbH - initial contribution +* +**********************************************************************************************************************/ + +/** + * @brief This file implements the main() of the test executor software. After initializing the test board and + * starting the OS scheduler, it shall call the function in the feature integration tests responsible for initializing + * and starting the tests (e.g. TestEntry_Initialize() under /core/essentials/test/integration/source/TestEntry.c) + * + * @file +**/ + +/*###################### INCLUDED HEADERS ############################################################################*/ + +#include "AppModules.h" +#include "BSP_Proxy.h" +#include "Kiso_Retcode.h" +#include "Kiso_BSP_LED.h" +#include "Kiso_BSP_Board.h" +#include "Kiso_Basics.h" +#include "Kiso_CmdProcessor.h" +#include "FreeRTOS.h" +#include "task.h" +#include + +/*###################### MACROS DEFINITION ###########################################################################*/ + +#undef KISO_MODULE_ID +#define KISO_MODULE_ID KISO_APP_MODULE_MAIN + +#define TASK_PRIO_MAIN_CMD_PROCESSOR (UINT32_C(1)) +#define TASK_STACK_SIZE_MAIN_CMD_PROCESSOR (UINT16_C(700)) +#define TASK_Q_LEN_MAIN_CMD_PROCESSOR (UINT32_C(10)) + +/*###################### FUNCTIONS DECLARATION #######################################################################*/ + +extern void xPortSysTickHandler(void); /*link-time function to be provided by the freertos library */ +extern Retcode_T TestEntry_Initialize(void *param1, uint32_t param2); /* link-time function to be provided by the library implementing the feature integration tests*/ + +static Retcode_T systemStartup(void); +static void systemInit(void *param1, uint32_t param2); +static void ErrorHandler(Retcode_T error, bool isfromIsr); +static void assertIndicationMapping(const unsigned long line, const unsigned char *const file); +static void SysTickPreCallback(void); + +#if configSUPPORT_STATIC_ALLOCATION +void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, + StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize); +#endif +#if configSUPPORT_STATIC_ALLOCATION && configUSE_TIMERS +void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, + StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize); +#endif + +/*###################### VARIABLES DECLARATIONS ######################################################################*/ + +static CmdProcessor_T MainCmdProcessor; + +/*###################### EXPOSED FUNCTIONS IMPLEMENTATION ############################################################*/ + +int main(void) +{ + /* Mapping Default Error Handling function */ + Retcode_T retcode = Retcode_Initialize(ErrorHandler); + +#ifndef NDEBUG + if (RETCODE_OK == retcode) + { + retcode = Assert_Initialize(assertIndicationMapping); + } +#endif /*NDEBUG*/ + if (RETCODE_OK == retcode) + { + retcode = systemStartup(); + } + if (RETCODE_OK == retcode) + { + retcode = CmdProcessor_Initialize(&MainCmdProcessor, + (char *)"MainCmdProcessor", + TASK_PRIO_MAIN_CMD_PROCESSOR, + TASK_STACK_SIZE_MAIN_CMD_PROCESSOR, + TASK_Q_LEN_MAIN_CMD_PROCESSOR); + } + if (RETCODE_OK == retcode) + { + /* Here we enqueue the application initialization into the command + * processor, such that the initialization function will be invoked + * once the RTOS scheduler is started below. + */ + retcode = CmdProcessor_Enqueue(&MainCmdProcessor, + systemInit, + &MainCmdProcessor, + UINT32_C(0)); + } + + if (RETCODE_OK != retcode) + { + printf("System Startup failed"); + assert(false); + } + /* start scheduler */ + vTaskStartScheduler(); +} + +/*###################### LOCAL FUNCTIONS IMPLEMENTATION ##############################################################*/ +/** + * @brief Starts the system up. + * @details This function will execute before the scheduler starts and it is intended to make the target board + * ready for operation. + * @return Returns RETCODE_OK in case of success, error code otherwise. + */ +Retcode_T systemStartup(void) +{ + Retcode_T retcode = RETCODE_OK; + uint32_t param1 = 0; + void *param2 = NULL; + + /* Initialize the callbacks for the system tick */ + BSP_Board_OSTickInitialize(SysTickPreCallback, NULL); + retcode = BSP_Board_Initialize(param1, param2); + if (RETCODE_OK == retcode) + { + retcode = BSP_LED_Connect(); + } + if (RETCODE_OK == retcode) + { + retcode = BSP_LED_Enable(TEST_BOARD_LED_ALL); + } + if (RETCODE_OK == retcode) + { + retcode = BSP_LED_Switch(TEST_BOARD_LED_ALL, TEST_BOARD_LED_COMMAND_ON); + } + return retcode; +} + +void systemInit(void *param1, uint32_t param2) +{ + KISO_UNUSED(param1); + KISO_UNUSED(param2); + Retcode_T retcode = TestEntry_Initialize(NULL, 0U); + if (RETCODE_OK != retcode) + { + Retcode_RaiseError(retcode); + } +} + +/** + * @brief Error handler function. + * @details This function is called when Retcode_RaiseError() function is invoked, it is used to report the error to + * the user. + * @param[in] error: Error code raised. + * @param[in] isfromIsr: if true then the ErrorHandler is being executed from an ISR context and not all the services + * are available. + */ +void ErrorHandler(Retcode_T error, bool isfromIsr) +{ + if (!isfromIsr) + { + /** \todo: ERROR HANDLING SHOULD BE DONE FOR THE ERRORS RAISED FROM PLATFORM */ + uint32_t PackageID = Retcode_GetPackage(error); + uint32_t ErrorCode = Retcode_GetCode(error); + uint32_t ModuleID = Retcode_GetModuleId(error); + Retcode_Severity_T SeverityCode = Retcode_GetSeverity(error); + + if (RETCODE_SEVERITY_FATAL == SeverityCode) + { + printf("Fatal Error:[%u] from Module:[%u] in Package:[%u]\r\n", + (unsigned int)ErrorCode, + (unsigned int)ModuleID, + (unsigned int)PackageID); + } + else if (RETCODE_SEVERITY_ERROR == SeverityCode) + { + printf("Severe Error:[%u] from Module:[%u] in Package:[%u]\r\n", + (unsigned int)ErrorCode, + (unsigned int)ModuleID, + (unsigned int)PackageID); + } + BSP_LED_Switch(TEST_BOARD_LED_ALL, TEST_BOARD_LED_COMMAND_OFF); + BSP_LED_Switch(TEST_BOARD_LED_PANIC, TEST_BOARD_LED_COMMAND_ON); + } + else + { + + BSP_LED_Switch(TEST_BOARD_LED_ALL, TEST_BOARD_LED_COMMAND_OFF); + BSP_LED_Switch(TEST_BOARD_LED_PANIC, TEST_BOARD_LED_COMMAND_ON); + } +} + +#ifndef NDEBUG +/** + * @brief This API is called when function enters an assert + * @param[in] line : line number where asserted. + * @param[in] file : file name which is asserted. + */ +void assertIndicationMapping(const unsigned long line, const unsigned char *const file) +{ + (void)BSP_LED_Switch(TEST_BOARD_LED_ALL, TEST_BOARD_LED_COMMAND_ON); + printf("asserted at Filename %s , line no %ld \n\r", file, line); +} +#endif /* NDEBUG */ + +/** + * @brief This function is a hook from FreeRTOS to systick. + * @details This function is called when ever the Systick IRQ is hit. This is a temporary implementation where the + * SysTick_Handler() is not directly mapped to xPortSysTickHandler(). Instead it is only called if the + * scheduler has started. + */ +static void SysTickPreCallback(void) +{ + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { + xPortSysTickHandler(); + } +} + +#if configSUPPORT_STATIC_ALLOCATION + +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[IDLE_TASK_SIZE]; + +/** + * @brief If static allocation is supported then the application must provide the following callback function + * @details Enables the application to optionally provide the memory that will be used by the idle task as the + * task's stack and TCB. + */ +void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, + StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = IDLE_TASK_SIZE; +} +#endif + +#if configSUPPORT_STATIC_ALLOCATION && configUSE_TIMERS +static StaticTask_t xTimerTaskTCBBuffer; +static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; + +/** + * @brief If static allocation and timers are supported then the application must provide the following callback function + * @details Enables the application to optionally provide the memory that will be used by the timer task as the + * task's stack and TCB. + */ +void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, + StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize) +{ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; + *ppxTimerTaskStackBuffer = &xTimerStack[0]; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} +#endif diff --git a/testing/integration/test-scheduler/readme.md b/testing/integration/test-scheduler/readme.md new file mode 100644 index 00000000..7f4c27ca --- /dev/null +++ b/testing/integration/test-scheduler/readme.md @@ -0,0 +1,4 @@ +# Test Scheduler + +It is scheduling which tests should be executed where. +It is tide link to our continious integration setup and Jenkins. \ No newline at end of file