From 73ea4310c9b814ca601999ec85624933461533eb Mon Sep 17 00:00:00 2001 From: Sourabh Mehta Date: Tue, 9 Apr 2024 14:02:03 +0200 Subject: [PATCH 1/5] Run Robot tests on CI --- .github/workflows/robot-tests.yml | 89 +++++ test/README.md | 0 test/configs/requirements.txt | 2 + test/configs/vcpkg-configuration.json | 20 + test/data/Hello/Board_IO/retarget_stdio.c | 109 ++++++ .../Hello/Board_IO/vio_V2M-MPS3-SSE-300.c | 354 ++++++++++++++++++ test/data/Hello/Hello.cproject.yml | 32 ++ test/data/Hello/Hello.csolution.yml | 26 ++ test/data/Hello/README.md | 49 +++ test/data/Hello/hello.c | 50 +++ test/data/Hello/main.c | 45 +++ test/data/Hello/main.h | 27 ++ test/data/MyProject/CM3/MyMain.c | 7 + .../MyProject/CM3/MyProject_CM3.cproject.yml | 14 + test/data/MyProject/MyProject.csolution.yml | 20 + test/resources/utils.resource | 16 + test/src/test.robot | 24 ++ 17 files changed, 884 insertions(+) create mode 100644 .github/workflows/robot-tests.yml create mode 100644 test/README.md create mode 100644 test/configs/requirements.txt create mode 100644 test/configs/vcpkg-configuration.json create mode 100644 test/data/Hello/Board_IO/retarget_stdio.c create mode 100644 test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c create mode 100644 test/data/Hello/Hello.cproject.yml create mode 100644 test/data/Hello/Hello.csolution.yml create mode 100644 test/data/Hello/README.md create mode 100644 test/data/Hello/hello.c create mode 100644 test/data/Hello/main.c create mode 100644 test/data/Hello/main.h create mode 100644 test/data/MyProject/CM3/MyMain.c create mode 100644 test/data/MyProject/CM3/MyProject_CM3.cproject.yml create mode 100644 test/data/MyProject/MyProject.csolution.yml create mode 100644 test/resources/utils.resource create mode 100644 test/src/test.robot diff --git a/.github/workflows/robot-tests.yml b/.github/workflows/robot-tests.yml new file mode 100644 index 00000000..3d24e699 --- /dev/null +++ b/.github/workflows/robot-tests.yml @@ -0,0 +1,89 @@ +name: Robot Tests + +on: + pull_request: + paths: + - '.github/workflows/robot-tests.yml' + - 'test/**' + - '!test/README.md' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + validate: + runs-on: ubuntu-latest + env: + CMSIS_PACK_ROOT: /home/runner/.cache/arm/packs + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install pip dependencies + run: | + pip install --upgrade pip + pip install -r test/configs/requirements.txt + + - name: Cache vcpkg + uses: actions/cache@v4 + with: + key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }} + restore-keys: | + vcpkg-${{ runner.os }}-${{ runner.arch }}- + path: /home/runner/.vcpkg + + - name: Prepare vcpkg env + working-directory: ./e2e-validation + run: | + . <(curl https://aka.ms/vcpkg-init.sh -L) + vcpkg x-update-registry --all + vcpkg activate + + - name: Activate Arm tool license + working-directory: ./e2e-validation + run: | + . /home/runner/.vcpkg/vcpkg-init + vcpkg activate + armlm activate --server https://mdk-preview.keil.arm.com --product KEMDK-COM0 + + - name: Run Test + run: | + python -m robot --outputdir results testcases/functional_tests + + - name: Run Test and create report + run: python -m robot -d reports -x junit-report.xml "testcases/functional_tests" + + - name: Run Robot Framework tests and generate report + run: | + echo "ROBOT_RC=$?" >> "$GITHUB_ENV" + + - name: Publish test results + uses: actions/upload-artifact@v4 + with: + name: reports + path: results + + generate_report: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download reports + uses: actions/download-artifact@v4 + with: + name: reports + + - name: Send report to commit + uses: joonvena/robotframework-reporter-action@v2 + with: + gh_access_token: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..e69de29b diff --git a/test/configs/requirements.txt b/test/configs/requirements.txt new file mode 100644 index 00000000..6f4ba2fa --- /dev/null +++ b/test/configs/requirements.txt @@ -0,0 +1,2 @@ +# Requirements needed +robotframework >= 7.0 \ No newline at end of file diff --git a/test/configs/vcpkg-configuration.json b/test/configs/vcpkg-configuration.json new file mode 100644 index 00000000..80746868 --- /dev/null +++ b/test/configs/vcpkg-configuration.json @@ -0,0 +1,20 @@ +{ + "registries": [ + { + "kind": "artifact", + "location": "https://aka.ms/vcpkg-ce-default", + "name": "microsoft" + }, + { + "kind": "artifact", + "location": "https://artifacts.tools.arm.com/vcpkg-ce-registry/registry.zip", + "name": "arm" + } + ], + "requires": { + "microsoft:cmake": "^3.25.2", + "microsoft:ninja": "^1.10.2", + "arm:compilers/arm/armclang":"^6.20.0", + "arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.0.0-0", + } +} diff --git a/test/data/Hello/Board_IO/retarget_stdio.c b/test/data/Hello/Board_IO/retarget_stdio.c new file mode 100644 index 00000000..d1a8ad4a --- /dev/null +++ b/test/data/Hello/Board_IO/retarget_stdio.c @@ -0,0 +1,109 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + * + * Name: retarget_stdio.c + * Purpose: Retarget stdio to USART + * + *---------------------------------------------------------------------------*/ + +#include "Driver_USART.h" + +#define USART_DRV_NUM 0 +#define USART_BAUDRATE 115200 + +#define _USART_Driver_(n) Driver_USART##n +#define USART_Driver_(n) _USART_Driver_(n) + +extern ARM_DRIVER_USART USART_Driver_(USART_DRV_NUM); +#define ptrUSART (&USART_Driver_(USART_DRV_NUM)) + +/** + Initialize stdio + + \return 0 on success, or -1 on error. +*/ +int stdio_init (void) { + int32_t status; + + status = ptrUSART->Initialize(NULL); + if (status != ARM_DRIVER_OK) return (-1); + + status = ptrUSART->PowerControl(ARM_POWER_FULL); + if (status != ARM_DRIVER_OK) return (-1); + + status = ptrUSART->Control(ARM_USART_MODE_ASYNCHRONOUS | + ARM_USART_DATA_BITS_8 | + ARM_USART_PARITY_NONE | + ARM_USART_STOP_BITS_1 | + ARM_USART_FLOW_CONTROL_NONE, + USART_BAUDRATE); + if (status != ARM_DRIVER_OK) return (-1); + + status = ptrUSART->Control(ARM_USART_CONTROL_RX, 1); + if (status != ARM_DRIVER_OK) return (-1); + + return (0); +} + +/** + Put a character to the stderr + + \param[in] ch Character to output + \return The character written, or -1 on write error. +*/ +int stderr_putchar (int ch) { + uint8_t buf[1]; + + buf[0] = ch; + if (ptrUSART->Send(buf, 1) != ARM_DRIVER_OK) { + return (-1); + } + while (ptrUSART->GetTxCount() != 1); + return (ch); +} + +/** + Put a character to the stdout + + \param[in] ch Character to output + \return The character written, or -1 on write error. +*/ +int stdout_putchar (int ch) { + uint8_t buf[1]; + + buf[0] = ch; + if (ptrUSART->Send(buf, 1) != ARM_DRIVER_OK) { + return (-1); + } + while (ptrUSART->GetTxCount() != 1); + return (ch); +} + +/** + Get a character from the stdio + + \return The next character from the input, or -1 on read error. +*/ +int stdin_getchar (void) { + uint8_t buf[1]; + + if (ptrUSART->Receive(buf, 1) != ARM_DRIVER_OK) { + return (-1); + } + while (ptrUSART->GetRxCount() != 1); + return (buf[0]); +} diff --git a/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c b/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c new file mode 100644 index 00000000..5ce50811 --- /dev/null +++ b/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c @@ -0,0 +1,354 @@ +/****************************************************************************** + * @file vio.c + * @brief Virtual I/O implementation template + * @version V1.0.0 + * @date 23. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2019-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + */ + +/*! \page vio_V2M-MPS3-SSE-300 Physical I/O Mapping +The table below lists the physical I/O mapping of this CMSIS-Driver VIO implementation. +Virtual Resource | Variable | Physical Resource on V2M-MPS3-SSE-300 | +:-----------------|:---------------|:-----------------------------------------------| +vioBUTTON0 | vioSignalIn.0 | User Button PB1 | +vioBUTTON1 | vioSignalIn.1 | User Button PB1 | +vioLED0 | vioSignalOut.0 | User LED UL0 | +vioLED1 | vioSignalOut.1 | User LED UL1 | +vioLED2 | vioSignalOut.2 | User LED UL2 | +vioLED3 | vioSignalOut.3 | User LED UL3 | +vioLED4 | vioSignalOut.4 | User LED UL4 | +vioLED5 | vioSignalOut.5 | User LED UL5 | +vioLED6 | vioSignalOut.6 | User LED UL6 | +vioLED7 | vioSignalOut.7 | User LED UL7 | +*/ + +#include +#include +#include +#include "cmsis_vio.h" + +#include "RTE_Components.h" // Component selection +#include CMSIS_device_header + +#if !defined CMSIS_VOUT || !defined CMSIS_VIN +#include "arm_mps3_io_drv.h" +#include "device_cfg.h" +#include "device_definition.h" +#endif + +// VIO input, output definitions +#define VIO_PRINT_MAX_SIZE 64U // maximum size of print memory +#define VIO_PRINTMEM_NUM 4U // number of print memories +#define VIO_VALUE_NUM 3U // number of values +#define VIO_VALUEXYZ_NUM 3U // number of XYZ values +#define VIO_IPV4_ADDRESS_NUM 2U // number of IPv4 addresses +#define VIO_IPV6_ADDRESS_NUM 2U // number of IPv6 addresses + +// VIO input, output variables +__USED uint32_t vioSignalIn; // Memory for incoming signal +__USED uint32_t vioSignalOut; // Memory for outgoing signal +__USED char vioPrintMem[VIO_PRINTMEM_NUM][VIO_PRINT_MAX_SIZE]; // Memory for the last value for each level +__USED int32_t vioValue [VIO_VALUE_NUM]; // Memory for value used in vioGetValue/vioSetValue +__USED vioValueXYZ_t vioValueXYZ[VIO_VALUEXYZ_NUM]; // Memory for XYZ value for 3-D vector +__USED vioAddrIPv4_t vioAddrIPv4[VIO_IPV4_ADDRESS_NUM]; // Memory for IPv4 address value used in vioSetIPv4/vioGetIPv4 +__USED vioAddrIPv6_t vioAddrIPv6[VIO_IPV6_ADDRESS_NUM]; // Memory for IPv6 address value used in vioSetIPv6/vioGetIPv6 + +#if !defined CMSIS_VOUT +// Add global user types, variables, functions here: + +#endif + +#if !defined CMSIS_VIN +// Add global user types, variables, functions here: + +#endif + +// Initialize test input, output. +void vioInit (void) { +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + + vioSignalIn = 0U; + vioSignalOut = 0U; + + memset (vioPrintMem, 0, sizeof(vioPrintMem)); + memset (vioValue, 0, sizeof(vioValue)); + memset (vioValueXYZ, 0, sizeof(vioValueXYZ)); + memset (vioAddrIPv4, 0, sizeof(vioAddrIPv4)); + memset (vioAddrIPv6, 0, sizeof(vioAddrIPv6)); + +#if !defined CMSIS_VOUT + // Turn off all LEDs + arm_mps3_io_write_leds(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PORT, 0U, 0U); +#endif + +#if !defined CMSIS_VIN +// Add user code here: + +#endif +} + +// Print formated string to test terminal. +int32_t vioPrint (uint32_t level, const char *format, ...) { + va_list args; + int32_t ret; +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif + + if (level > vioLevelError) { + return (-1); + } + + if (level > VIO_PRINTMEM_NUM) { + return (-1); + } + + va_start(args, format); + + ret = vsnprintf((char *)vioPrintMem[level], sizeof(vioPrintMem[level]), format, args); + + va_end(args); + +#if !defined CMSIS_VOUT +// Add user code here: + +#endif + + return (ret); +} + +// Set signal output. +void vioSetSignal (uint32_t mask, uint32_t signal) { +#if !defined CMSIS_VOUT + uint32_t n; +#endif + + vioSignalOut &= ~mask; + vioSignalOut |= mask & signal; + +#if !defined CMSIS_VOUT + for (n = 0U; n < 8U; n++) { + if (mask & (1U << n)) { + arm_mps3_io_write_leds(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PIN, n, signal & (1U << n)); + } + } +#endif +} + +// Get signal input. +uint32_t vioGetSignal (uint32_t mask) { + uint32_t signal; +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + +#if !defined CMSIS_VIN + vioSignalIn = arm_mps3_io_read_buttons(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PORT, 0); +#endif + + signal = vioSignalIn; + + return (signal & mask); +} + +// Set value output. +void vioSetValue (uint32_t id, int32_t value) { + uint32_t index = id; +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif + + if (index >= VIO_VALUE_NUM) { + return; /* return in case of out-of-range index */ + } + + vioValue[index] = value; + +#if !defined CMSIS_VOUT +// Add user code here: + +#endif +} + +// Get value input. +int32_t vioGetValue (uint32_t id) { + uint32_t index = id; + int32_t value = 0; +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + + if (index >= VIO_VALUE_NUM) { + return value; /* return default in case of out-of-range index */ + } + +#if !defined CMSIS_VIN +// Add user code here: + +// vioValue[index] = ...; +#endif + + value = vioValue[index]; + + return value; +} + +// Set XYZ value output. +void vioSetXYZ (uint32_t id, vioValueXYZ_t valueXYZ) { + uint32_t index = id; +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif + + if (index >= VIO_VALUEXYZ_NUM) { + return; /* return in case of out-of-range index */ + } + + vioValueXYZ[index] = valueXYZ; + +#if !defined CMSIS_VOUT +// Add user code here: + +#endif +} + +// Get XYZ value input. +vioValueXYZ_t vioGetXYZ (uint32_t id) { + uint32_t index = id; + vioValueXYZ_t valueXYZ = {0, 0, 0}; +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + + if (index >= VIO_VALUEXYZ_NUM) { + return valueXYZ; /* return default in case of out-of-range index */ + } + +#if !defined CMSIS_VIN +// Add user code here: + +// vioValueXYZ[index] = ...; +#endif + + valueXYZ = vioValueXYZ[index]; + + return valueXYZ; +} + +// Set IPv4 address output. +void vioSetIPv4 (uint32_t id, vioAddrIPv4_t addrIPv4) { + uint32_t index = id; +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif + + if (index >= VIO_IPV4_ADDRESS_NUM) { + return; /* return in case of out-of-range index */ + } + + vioAddrIPv4[index] = addrIPv4; + +#if !defined CMSIS_VOUT +// Add user code here: + +#endif +} + +// Get IPv4 address input. +vioAddrIPv4_t vioGetIPv4 (uint32_t id) { + uint32_t index = id; + vioAddrIPv4_t addrIPv4 = {0U, 0U, 0U, 0U}; +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + + if (index >= VIO_IPV4_ADDRESS_NUM) { + return addrIPv4; /* return default in case of out-of-range index */ + } + +#if !defined CMSIS_VIN +// Add user code here: + +// vioAddrIPv4[index] = ...; +#endif + + addrIPv4 = vioAddrIPv4[index]; + + return addrIPv4; +} + +// Set IPv6 address output. +void vioSetIPv6 (uint32_t id, vioAddrIPv6_t addrIPv6) { + uint32_t index = id; +#if !defined CMSIS_VOUT +// Add user variables here: + +#endif + + if (index >= VIO_IPV6_ADDRESS_NUM) { + return; /* return in case of out-of-range index */ + } + + vioAddrIPv6[index] = addrIPv6; + +#if !defined CMSIS_VOUT +// Add user code here: + +#endif +} + +// Get IPv6 address input. +vioAddrIPv6_t vioGetIPv6 (uint32_t id) { + uint32_t index = id; + vioAddrIPv6_t addrIPv6 = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, + 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U}; +#if !defined CMSIS_VIN +// Add user variables here: + +#endif + + if (index >= VIO_IPV6_ADDRESS_NUM) { + return addrIPv6; /* return default in case of out-of-range index */ + } + +#if !defined CMSIS_VIN +// Add user code here: + +// vioAddrIPv6[index] = ...; +#endif + + addrIPv6 = vioAddrIPv6[index]; + + return addrIPv6; +} diff --git a/test/data/Hello/Hello.cproject.yml b/test/data/Hello/Hello.cproject.yml new file mode 100644 index 00000000..d5ab83da --- /dev/null +++ b/test/data/Hello/Hello.cproject.yml @@ -0,0 +1,32 @@ +project: + +# it is recommended to list the packs that contain the components in the cproject.yml file. + packs: + - pack: ARM::V2M_MPS3_SSE_300_BSP@1.2.0 # optional packs can specify a version + - pack: Keil::ARM_Compiler # for retargeting stdout to UART + + groups: + - group: Documentation + files: + - file: ./README.md + - group: Main + files: + - file: ./main.c + - group: App + files: + - file: ./hello.c + - group: Board IO + files: + - file: ./Board_IO/retarget_stdio.c + + components: + - component: CMSIS:CORE # short form, vendor selected from available packs + - component: ARM::CMSIS:RTOS2:Keil RTX5&Source # long form, vendor explicitly stated + - component: CMSIS Driver:USART + - component: ARM::Native Driver:IO + - component: ARM::Native Driver:UART + - component: Compiler:I/O:STDERR&User + - component: Compiler:I/O:STDIN&User + - component: Compiler:I/O:STDOUT&User + - component: Device:Definition + - component: Device:Startup&Baremetal diff --git a/test/data/Hello/Hello.csolution.yml b/test/data/Hello/Hello.csolution.yml new file mode 100644 index 00000000..4a0e123a --- /dev/null +++ b/test/data/Hello/Hello.csolution.yml @@ -0,0 +1,26 @@ +solution: + created-for: CMSIS-Toolbox@2.0.0 + description: Print Hello World and a counter value via UART + cdefault: + compiler: AC6 # currently required for components Compiler:I/O + +# it is recommended to list the pack or packs that define the device or board used in the csolution.yml file + packs: + - pack: ARM::CMSIS@5.9.0 + + target-types: + - type: AVH # runs on Arm Virtual Hardware + device: ARM::SSE-300-MPS3 + # add more hardware targets (don't forget to add the required packs) + + build-types: # defines toolchain options for 'debug' and 'release' + - type: Release + debug: off + optimize: balanced + + - type: Debug + debug: on + optimize: none + + projects: # list related projects + - project: ./Hello.cproject.yml diff --git a/test/data/Hello/README.md b/test/data/Hello/README.md new file mode 100644 index 00000000..1922d8b8 --- /dev/null +++ b/test/data/Hello/README.md @@ -0,0 +1,49 @@ +# Hello project + +This project prints "Hello World" and a counter value via the UART output. It is configured for Arm Virtual Hardware, but other target hardware that provides a CMSIS Driver:USART can be easily added. + +## Prerequisites + +### Tools + +- [CMSIS-Toolbox 2.0.0](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/releases) or higher +- [Keil MDK 5.37](https://www2.keil.com/mdk5/) + - Arm Compiler 6.18 (part of MDK, Eval Version sufficient for compilation) + - Arm Virtual Hardware for Corstone-300 v11.18.1 (requires MDK - Professional) + +>**Note:** later versions will also compiler with GCC. + +### Packs + +- Required packs are listed in the file [`Hello.csolution.yml`](./Hello.csolution.yml) and [`Hello.cproject.yml`](./Hello.cproject.yml) + +## Project Structure + +The project is generated using the [CMSIS-Toolbox](https://github.com/Open-CMSIS-Pack/devtools/blob/main/tools/projmgr/docs/Manual/Overview.md) and is defined in [`csolution`](https://github.com/Open-CMSIS-Pack/devtools/blob/main/tools/projmgr/docs/Manual/YML-Format.md) format: + +- [`Hello.csolution.yml`](./Hello.csolution.yml) lists the required packs and defines the hardware target and build-types (along with the compiler). +- [`Hello.cproject.yml`](./Hello.cproject.yml) defines the source files and the software components. + +## Generated Project + +```txt +> cbuild Hello.csolution.yml --packs +``` + +>**Note:** During the build process required packs may be downloaded. + +## Execute Project + +The project is configured for execution on Arm Virtual Hardware which removes the requirement for a physical hardware board. + +- When using MDK-Professional, you may execute it with the command: + + ```txt + > C:/Keil_v5/ARM/VHT/VHT_Corstone_SSE-300_Ethos-U55 -f vht-config.txt -a ./out/Hello/AVH/Debug/Debug+AVH.axf + ``` + +- [Keil Studio Cloud](https://studio.keil.arm.com/) integrates also the Arm Virtual Hardware VHT_Corstone_SSE-300_Ethos-U55 model. The steps to use the example are: + - Start [Keil Studio Cloud](https://studio.keil.arm.com/) and login to the system using your account. + - Use **File - Clone** and enter the URL: (https://github.com/Open-CMSIS-Pack/csolution-examples). Add + - Select from the drop-down *Target hardware*: **Corstone SSE-300 (Cortex-M55, Ethos-U55)** + - Click **Run project** which executes the project build step and then starts running on Arm Virtual Hardware. diff --git a/test/data/Hello/hello.c b/test/data/Hello/hello.c new file mode 100644 index 00000000..9b4bbfd3 --- /dev/null +++ b/test/data/Hello/hello.c @@ -0,0 +1,50 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2020 Arm Limited (or its affiliates). All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + * + * Name: Hello.c + * Purpose: Hello World based on RTX + * + *---------------------------------------------------------------------------*/ + +#include "main.h" +#include +#include "cmsis_os2.h" // ::CMSIS:RTOS2 + + +/*--------------------------------------------------------------------------- + * Application main thread + *---------------------------------------------------------------------------*/ + +static int count = 0; + +static void app_main (void *argument) { + (void)argument; + + while (1) { + printf ("Hello World %d\r\n", count); + if (count > 100) printf ("\x04"); // EOT (0x04) stops simulation + count++; + osDelay (1000); + } +} + +/*--------------------------------------------------------------------------- + * Application initialization + *---------------------------------------------------------------------------*/ +void app_initialize (void) { + osThreadNew(app_main, NULL, NULL); +} diff --git a/test/data/Hello/main.c b/test/data/Hello/main.c new file mode 100644 index 00000000..51e09afa --- /dev/null +++ b/test/data/Hello/main.c @@ -0,0 +1,45 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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 "RTE_Components.h" +#include CMSIS_device_header +#include "cmsis_os2.h" +#ifdef RTE_Compiler_EventRecorder +#include "EventRecorder.h" +#endif + +#include "main.h" + +extern int stdio_init (void); + +int main (void) { + stdio_init(); // Initialize stdio + + +#if defined(RTE_Compiler_EventRecorder) && \ + (defined(__MICROLIB) || \ + !(defined(RTE_CMSIS_RTOS2_RTX5) || defined(RTE_CMSIS_RTOS2_FreeRTOS))) + EventRecorderInitialize(EventRecordAll, 1U); +#endif + + osKernelInitialize(); // Initialize CMSIS-RTOS2 + app_initialize(); // Initialize application + osKernelStart(); // Start thread execution + + for (;;) {} +} diff --git a/test/data/Hello/main.h b/test/data/Hello/main.h new file mode 100644 index 00000000..f0d25f99 --- /dev/null +++ b/test/data/Hello/main.h @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2020-2021 Arm Limited (or its affiliates). + * All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + *---------------------------------------------------------------------------*/ + +#ifndef MAIN_H__ +#define MAIN_H__ + +#include + +/* Prototypes */ +extern void app_initialize (void); + +#endif diff --git a/test/data/MyProject/CM3/MyMain.c b/test/data/MyProject/CM3/MyMain.c new file mode 100644 index 00000000..1c44aa3a --- /dev/null +++ b/test/data/MyProject/CM3/MyMain.c @@ -0,0 +1,7 @@ + +#include "RTE_Components.h" +#include CMSIS_device_header + +int main (void) { + return 1; +} diff --git a/test/data/MyProject/CM3/MyProject_CM3.cproject.yml b/test/data/MyProject/CM3/MyProject_CM3.cproject.yml new file mode 100644 index 00000000..eff8cf44 --- /dev/null +++ b/test/data/MyProject/CM3/MyProject_CM3.cproject.yml @@ -0,0 +1,14 @@ +project: + + packs: + - pack: ARM::CMSIS@5.9.0 + + groups: + - group: Main + files: + - file: ./MyMain.c + + components: + - component: CMSIS:CORE + - component: Device:Startup&C Startup + - component: CMSIS:RTOS:Keil RTX diff --git a/test/data/MyProject/MyProject.csolution.yml b/test/data/MyProject/MyProject.csolution.yml new file mode 100644 index 00000000..4ed99522 --- /dev/null +++ b/test/data/MyProject/MyProject.csolution.yml @@ -0,0 +1,20 @@ +solution: + created-for: CMSIS-Toolbox@2.3.0 + cdefault: + compiler: GCC + + target-types: + - type: CM3 + device: ARMCM3 + + build-types: + - type: Release + debug: off + optimize: balanced + + - type: Debug + debug: on + optimize: none + + projects: + - project: ./CM3/MyProject_CM3.cproject.yml diff --git a/test/resources/utils.resource b/test/resources/utils.resource new file mode 100644 index 00000000..7ab3dd09 --- /dev/null +++ b/test/resources/utils.resource @@ -0,0 +1,16 @@ +*** Settings *** +Documentation A resource file with reusable keywords and variables. +Library Process + +*** Keywords *** +Run Program + [Documentation] Run specified executable with arguments + [Arguments] ${exe_path} ${input_File} @{args} ${expected_ret_code}=0 + ${result} Run Process ${exe_path} ${input_File} @{args} shell=True stdout=${CURDIR}/stdout.txt stderr=STDOUT + Run Keyword If '${result.rc}' != '${expected_ret_code}' Log Many Output: ${result.stdout} Return Code: ${result.rc} + Should Be Equal '${result.rc}' '${expected_ret_code}' + +Run csolution + [Documentation] Run csolution example with specified arguments + [Arguments] ${input_file} @{args} + Run Program cbuild.exe ${input_file} @{args} \ No newline at end of file diff --git a/test/src/test.robot b/test/src/test.robot new file mode 100644 index 00000000..ea872508 --- /dev/null +++ b/test/src/test.robot @@ -0,0 +1,24 @@ +*** Settings *** +Documentation Test to execute csolution example +Suite Setup Suite Setup +Resource ${RESOURCES}/utils.resource +Library Process +Test Template Run csolution examples + + +*** Variables *** +${RESOURCES} ../resources + + +*** Test Cases *** ${input_file} ${args} +Run MyProject example ${testDataDir}/MyProject${/}MyProject.csolution.yml --context=MyProject_CM3.Debug+CM3 -r --update-rte +Run Hello example ${testDataDir}/Hello${/}Hello.csolution.yml -r --update-rte + + +*** Keywords *** +Run csolution examples + [Arguments] ${input_file} @{args} + Run csolution ${input_file} @{args} + +Suite Setup + Set Global Variable ${testDataDir} ${CURDIR}${/}..${/}data${/} From bb8131e28a74eb413e89e9dd17619346667c2fe5 Mon Sep 17 00:00:00 2001 From: Sourabh Mehta Date: Tue, 9 Apr 2024 14:13:05 +0200 Subject: [PATCH 2/5] stop redundant workflows --- .github/workflows/robot-tests.yml | 29 +- .github/workflows/toolbox.yml | 2 + .../MyProject/CM3/MyProject_CM3.cproject.yml | 14 - test/data/MyProject/MyProject.csolution.yml | 20 - test/data/build-asm/project/AC6/AsmArm.s | 16 + test/data/build-asm/project/AC6/Auto.s | 9 + test/data/build-asm/project/AC6/GnuSyntax.s | 10 + .../data/build-asm/project/AC6/PreProcessed.S | 9 + test/data/build-asm/project/GCC/GAS.s | 9 + .../build-asm/project/GCC/NonPreProcessed.s | 13 + .../data/build-asm/project/GCC/PreProcessed.S | 9 + test/data/build-asm/project/IAR/Asm.s | 15 + .../CM3/MyMain.c => build-asm/project/main.c} | 5 +- .../build-asm/project/project.cproject.yml | 53 +++ test/data/build-asm/solution.csolution.yml | 27 ++ test/data/build-c/project/main.c | 6 + .../data/build-c/project/project.cproject.yml | 10 + test/data/build-c/solution.csolution.yml | 31 ++ test/data/build-cpp/project/main.cpp | 8 + .../build-cpp/project/project.cproject.yml | 10 + test/data/build-cpp/solution.csolution.yml | 27 ++ test/data/include-define/project/inc1/inc.h | 1 + test/data/include-define/project/inc2/inc.h | 1 + test/data/include-define/project/main.c | 6 + .../project/project.cproject.yml | 50 +++ test/data/include-define/project/source1.c | 13 + test/data/include-define/project/source2.c | 21 + .../include-define/solution.csolution.yml | 27 ++ .../Device/ARMCM0/ac6_linker_script.sct.src | 109 +++++ .../Device/ARMCM0/clang_linker_script.ld.src | 374 ++++++++++++++++++ .../Device/ARMCM0/gcc_linker_script.ld.src | 308 +++++++++++++++ .../Device/ARMCM0/iar_linker_script.icf.src | 94 +++++ .../RTE/Device/ARMCM0/regions_ARMCM0.h | 60 +++ .../data/linker-pre-processing/project/main.c | 6 + .../project/project.cproject.yml | 14 + .../solution.csolution.yml | 35 ++ .../pack/ARM.PreIncludeTestPack.pdsc | 56 +++ .../pre-include/pack/Files/config-header1.h | 1 + .../pre-include/pack/Files/config-header2.h | 1 + test/data/pre-include/pack/Files/header1.h | 1 + test/data/pre-include/pack/Files/header2.h | 1 + test/data/pre-include/pack/Files/test1.c | 13 + test/data/pre-include/pack/Files/test2.c | 13 + test/data/pre-include/project/main.c | 6 + .../pre-include/project/project.cproject.yml | 12 + test/data/pre-include/solution.csolution.yml | 29 ++ test/resources/utils.resource | 2 +- test/src/test.robot | 3 +- test/{configs => }/vcpkg-configuration.json | 0 49 files changed, 1538 insertions(+), 51 deletions(-) delete mode 100644 test/data/MyProject/CM3/MyProject_CM3.cproject.yml delete mode 100644 test/data/MyProject/MyProject.csolution.yml create mode 100644 test/data/build-asm/project/AC6/AsmArm.s create mode 100644 test/data/build-asm/project/AC6/Auto.s create mode 100644 test/data/build-asm/project/AC6/GnuSyntax.s create mode 100644 test/data/build-asm/project/AC6/PreProcessed.S create mode 100644 test/data/build-asm/project/GCC/GAS.s create mode 100644 test/data/build-asm/project/GCC/NonPreProcessed.s create mode 100644 test/data/build-asm/project/GCC/PreProcessed.S create mode 100644 test/data/build-asm/project/IAR/Asm.s rename test/data/{MyProject/CM3/MyMain.c => build-asm/project/main.c} (65%) create mode 100644 test/data/build-asm/project/project.cproject.yml create mode 100644 test/data/build-asm/solution.csolution.yml create mode 100644 test/data/build-c/project/main.c create mode 100644 test/data/build-c/project/project.cproject.yml create mode 100644 test/data/build-c/solution.csolution.yml create mode 100644 test/data/build-cpp/project/main.cpp create mode 100644 test/data/build-cpp/project/project.cproject.yml create mode 100644 test/data/build-cpp/solution.csolution.yml create mode 100644 test/data/include-define/project/inc1/inc.h create mode 100644 test/data/include-define/project/inc2/inc.h create mode 100644 test/data/include-define/project/main.c create mode 100644 test/data/include-define/project/project.cproject.yml create mode 100644 test/data/include-define/project/source1.c create mode 100644 test/data/include-define/project/source2.c create mode 100644 test/data/include-define/solution.csolution.yml create mode 100644 test/data/linker-pre-processing/project/RTE/Device/ARMCM0/ac6_linker_script.sct.src create mode 100644 test/data/linker-pre-processing/project/RTE/Device/ARMCM0/clang_linker_script.ld.src create mode 100644 test/data/linker-pre-processing/project/RTE/Device/ARMCM0/gcc_linker_script.ld.src create mode 100644 test/data/linker-pre-processing/project/RTE/Device/ARMCM0/iar_linker_script.icf.src create mode 100644 test/data/linker-pre-processing/project/RTE/Device/ARMCM0/regions_ARMCM0.h create mode 100644 test/data/linker-pre-processing/project/main.c create mode 100644 test/data/linker-pre-processing/project/project.cproject.yml create mode 100644 test/data/linker-pre-processing/solution.csolution.yml create mode 100644 test/data/pre-include/pack/ARM.PreIncludeTestPack.pdsc create mode 100644 test/data/pre-include/pack/Files/config-header1.h create mode 100644 test/data/pre-include/pack/Files/config-header2.h create mode 100644 test/data/pre-include/pack/Files/header1.h create mode 100644 test/data/pre-include/pack/Files/header2.h create mode 100644 test/data/pre-include/pack/Files/test1.c create mode 100644 test/data/pre-include/pack/Files/test2.c create mode 100644 test/data/pre-include/project/main.c create mode 100644 test/data/pre-include/project/project.cproject.yml create mode 100644 test/data/pre-include/solution.csolution.yml rename test/{configs => }/vcpkg-configuration.json (100%) diff --git a/.github/workflows/robot-tests.yml b/.github/workflows/robot-tests.yml index 3d24e699..17c5e18f 100644 --- a/.github/workflows/robot-tests.yml +++ b/.github/workflows/robot-tests.yml @@ -14,7 +14,7 @@ concurrency: jobs: - validate: + robot-tests: runs-on: ubuntu-latest env: CMSIS_PACK_ROOT: /home/runner/.cache/arm/packs @@ -42,48 +42,55 @@ jobs: path: /home/runner/.vcpkg - name: Prepare vcpkg env - working-directory: ./e2e-validation + working-directory: ./test run: | . <(curl https://aka.ms/vcpkg-init.sh -L) vcpkg x-update-registry --all vcpkg activate - name: Activate Arm tool license - working-directory: ./e2e-validation + working-directory: ./test run: | . /home/runner/.vcpkg/vcpkg-init vcpkg activate armlm activate --server https://mdk-preview.keil.arm.com --product KEMDK-COM0 - name: Run Test + working-directory: ./test run: | - python -m robot --outputdir results testcases/functional_tests + . /home/runner/.vcpkg/vcpkg-init + vcpkg activate + python -m robot --outputdir reports src/test.robot - - name: Run Test and create report - run: python -m robot -d reports -x junit-report.xml "testcases/functional_tests" + # - name: Run Test and create report + # working-directory: ./test + # run: | + # python -m robot -d reports -x junit-report.xml "src/test.robot" - name: Run Robot Framework tests and generate report + if: always() run: | - echo "ROBOT_RC=$?" >> "$GITHUB_ENV" + echo "ROBOT_RC=$?" >> "$GITHUB_ENV" - name: Publish test results + if: always() uses: actions/upload-artifact@v4 with: name: reports - path: results + path: ./test/reports generate_report: runs-on: ubuntu-latest + needs: robot-tests steps: - - uses: actions/checkout@v4 - - name: Download reports uses: actions/download-artifact@v4 with: name: reports + path: reports - name: Send report to commit - uses: joonvena/robotframework-reporter-action@v2 + uses: joonvena/robotframework-reporter-action@v2.4 with: gh_access_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/toolbox.yml b/.github/workflows/toolbox.yml index 63195be6..846287c9 100644 --- a/.github/workflows/toolbox.yml +++ b/.github/workflows/toolbox.yml @@ -8,11 +8,13 @@ on: - '**' - '!docs/**' - '!README.md' + - '!test/**' pull_request: paths: - '.github/workflows/toolbox.yml' - '**' - '!docs/**' + - '!test/**' release: types: [published] diff --git a/test/data/MyProject/CM3/MyProject_CM3.cproject.yml b/test/data/MyProject/CM3/MyProject_CM3.cproject.yml deleted file mode 100644 index eff8cf44..00000000 --- a/test/data/MyProject/CM3/MyProject_CM3.cproject.yml +++ /dev/null @@ -1,14 +0,0 @@ -project: - - packs: - - pack: ARM::CMSIS@5.9.0 - - groups: - - group: Main - files: - - file: ./MyMain.c - - components: - - component: CMSIS:CORE - - component: Device:Startup&C Startup - - component: CMSIS:RTOS:Keil RTX diff --git a/test/data/MyProject/MyProject.csolution.yml b/test/data/MyProject/MyProject.csolution.yml deleted file mode 100644 index 4ed99522..00000000 --- a/test/data/MyProject/MyProject.csolution.yml +++ /dev/null @@ -1,20 +0,0 @@ -solution: - created-for: CMSIS-Toolbox@2.3.0 - cdefault: - compiler: GCC - - target-types: - - type: CM3 - device: ARMCM3 - - build-types: - - type: Release - debug: off - optimize: balanced - - - type: Debug - debug: on - optimize: none - - projects: - - project: ./CM3/MyProject_CM3.cproject.yml diff --git a/test/data/build-asm/project/AC6/AsmArm.s b/test/data/build-asm/project/AC6/AsmArm.s new file mode 100644 index 00000000..a20db509 --- /dev/null +++ b/test/data/build-asm/project/AC6/AsmArm.s @@ -0,0 +1,16 @@ + + AREA DATA + + IF HEXADECIMAL_TEST != 11259375 ; 0xABCDEF + INFO 1, "HEXADECIMAL_TEST failed!" + ENDIF + + IF DECIMAL_TEST != 1234567890 + INFO 1, "DECIMAL_TEST failed!" + ENDIF + + IF STRING_TEST != "String0" + INFO 1, "STRING_TEST failed!" + ENDIF + + END diff --git a/test/data/build-asm/project/AC6/Auto.s b/test/data/build-asm/project/AC6/Auto.s new file mode 100644 index 00000000..28048d60 --- /dev/null +++ b/test/data/build-asm/project/AC6/Auto.s @@ -0,0 +1,9 @@ + + AREA DATA + + IF :LNOT::DEF:AUTO_DEF + INFO 1, "AUTO_DEF is not defined!" + ENDIF + + END + \ No newline at end of file diff --git a/test/data/build-asm/project/AC6/GnuSyntax.s b/test/data/build-asm/project/AC6/GnuSyntax.s new file mode 100644 index 00000000..02ca75f2 --- /dev/null +++ b/test/data/build-asm/project/AC6/GnuSyntax.s @@ -0,0 +1,10 @@ + + .syntax unified + .arch armv7-m + + .ifndef GAS_DEF + .error "GAS_DEF is not defined!" + .endif + + .end + \ No newline at end of file diff --git a/test/data/build-asm/project/AC6/PreProcessed.S b/test/data/build-asm/project/AC6/PreProcessed.S new file mode 100644 index 00000000..4fd3eaf7 --- /dev/null +++ b/test/data/build-asm/project/AC6/PreProcessed.S @@ -0,0 +1,9 @@ + + .syntax unified + .arch armv7-m + +#ifndef PRE_PROCESSED_DEF + .error "PRE_PROCESSED_DEF is not defined!" +#endif + + .end diff --git a/test/data/build-asm/project/GCC/GAS.s b/test/data/build-asm/project/GCC/GAS.s new file mode 100644 index 00000000..39daecaf --- /dev/null +++ b/test/data/build-asm/project/GCC/GAS.s @@ -0,0 +1,9 @@ + + .syntax unified + .arch armv7-m + + .ifndef GAS_DEF + .error "GAS_DEF is not defined!" + .endif + + .end diff --git a/test/data/build-asm/project/GCC/NonPreProcessed.s b/test/data/build-asm/project/GCC/NonPreProcessed.s new file mode 100644 index 00000000..8c374a98 --- /dev/null +++ b/test/data/build-asm/project/GCC/NonPreProcessed.s @@ -0,0 +1,13 @@ + + .syntax unified + .arch armv7-m + +#ifndef PRE_PROCESSED_DEF + .equ SET_ERR_DEF,1 +#endif + + .ifndef SET_ERR_DEF + .error "SET_ERR_DEF is not defined! It seems this file was preprocessed but it shouldn't!" + .endif + + .end diff --git a/test/data/build-asm/project/GCC/PreProcessed.S b/test/data/build-asm/project/GCC/PreProcessed.S new file mode 100644 index 00000000..4fd3eaf7 --- /dev/null +++ b/test/data/build-asm/project/GCC/PreProcessed.S @@ -0,0 +1,9 @@ + + .syntax unified + .arch armv7-m + +#ifndef PRE_PROCESSED_DEF + .error "PRE_PROCESSED_DEF is not defined!" +#endif + + .end diff --git a/test/data/build-asm/project/IAR/Asm.s b/test/data/build-asm/project/IAR/Asm.s new file mode 100644 index 00000000..30354d8f --- /dev/null +++ b/test/data/build-asm/project/IAR/Asm.s @@ -0,0 +1,15 @@ + MODULE ?Asm + +#ifndef IAR_ASM_DEF +#error "IAR_ASM_DEF is not defined!" +#endif + + EXTERN Reset_Handler_C + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =Reset_Handler_C + BX R0 + + END diff --git a/test/data/MyProject/CM3/MyMain.c b/test/data/build-asm/project/main.c similarity index 65% rename from test/data/MyProject/CM3/MyMain.c rename to test/data/build-asm/project/main.c index 1c44aa3a..2e169c3f 100644 --- a/test/data/MyProject/CM3/MyMain.c +++ b/test/data/build-asm/project/main.c @@ -1,7 +1,6 @@ - #include "RTE_Components.h" #include CMSIS_device_header -int main (void) { - return 1; +int main(void) { + return 0; } diff --git a/test/data/build-asm/project/project.cproject.yml b/test/data/build-asm/project/project.cproject.yml new file mode 100644 index 00000000..c492c5ee --- /dev/null +++ b/test/data/build-asm/project/project.cproject.yml @@ -0,0 +1,53 @@ +project: + + components: + - component: ARM::CMSIS:CORE + - component: ARM::Device:Startup&C Startup + + groups: + - group: Source + files: + - file: ./main.c + + - group: GCC-CLANG + for-compiler: [GCC, CLANG] + files: + - file: ./GCC/GAS.s + for-compiler: GCC + define: + - GAS_DEF + - file: ./GCC/PreProcessed.S + define: + - PRE_PROCESSED_DEF + - file: ./GCC/NonPreProcessed.s + misc: + - ASM: + - -DPRE_PROCESSED_DEF + + - group: AC6 + for-compiler: AC6 + files: + - file: ./AC6/AsmArm.s + define: + - HEXADECIMAL_TEST: 0xABCDEF + - DECIMAL_TEST: 1234567890 + - STRING_TEST: "\"String0\"" + - file: ./AC6/GnuSyntax.s + define: + - GAS_DEF + misc: + - ASM: + - -masm=gnu + - file: ./AC6/PreProcessed.S + define: + - PRE_PROCESSED_DEF + - file: ./AC6/Auto.s + define: + - AUTO_DEF + + - group: IAR + for-compiler: IAR + files: + - file: ./IAR/Asm.s + define: + - IAR_ASM_DEF diff --git a/test/data/build-asm/solution.csolution.yml b/test/data/build-asm/solution.csolution.yml new file mode 100644 index 00000000..7672cd9c --- /dev/null +++ b/test/data/build-asm/solution.csolution.yml @@ -0,0 +1,27 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + + target-types: + - type: ARMCM0 + device: ARMCM0 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml diff --git a/test/data/build-c/project/main.c b/test/data/build-c/project/main.c new file mode 100644 index 00000000..2e169c3f --- /dev/null +++ b/test/data/build-c/project/main.c @@ -0,0 +1,6 @@ +#include "RTE_Components.h" +#include CMSIS_device_header + +int main(void) { + return 0; +} diff --git a/test/data/build-c/project/project.cproject.yml b/test/data/build-c/project/project.cproject.yml new file mode 100644 index 00000000..0d21eac3 --- /dev/null +++ b/test/data/build-c/project/project.cproject.yml @@ -0,0 +1,10 @@ +project: + + components: + - component: ARM::CMSIS:CORE + - component: ARM::Device:Startup&C Startup + + groups: + - group: Source + files: + - file: ./main.c diff --git a/test/data/build-c/solution.csolution.yml b/test/data/build-c/solution.csolution.yml new file mode 100644 index 00000000..992edef2 --- /dev/null +++ b/test/data/build-c/solution.csolution.yml @@ -0,0 +1,31 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + + target-types: + - type: ARMCM0 + device: ARMCM0 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + misc: + - Library: + - -lm + - -lc + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml diff --git a/test/data/build-cpp/project/main.cpp b/test/data/build-cpp/project/main.cpp new file mode 100644 index 00000000..c3103edf --- /dev/null +++ b/test/data/build-cpp/project/main.cpp @@ -0,0 +1,8 @@ +#include "RTE_Components.h" +#include CMSIS_device_header +#include + +int main(void) { + std::size_t s = 0; + return s; +} diff --git a/test/data/build-cpp/project/project.cproject.yml b/test/data/build-cpp/project/project.cproject.yml new file mode 100644 index 00000000..7198351d --- /dev/null +++ b/test/data/build-cpp/project/project.cproject.yml @@ -0,0 +1,10 @@ +project: + + components: + - component: ARM::CMSIS:CORE + - component: ARM::Device:Startup&C Startup + + groups: + - group: Source + files: + - file: ./main.cpp diff --git a/test/data/build-cpp/solution.csolution.yml b/test/data/build-cpp/solution.csolution.yml new file mode 100644 index 00000000..5014957d --- /dev/null +++ b/test/data/build-cpp/solution.csolution.yml @@ -0,0 +1,27 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + + target-types: + - type: ARMCM55 + device: ARMCM55 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml diff --git a/test/data/include-define/project/inc1/inc.h b/test/data/include-define/project/inc1/inc.h new file mode 100644 index 00000000..04ff366f --- /dev/null +++ b/test/data/include-define/project/inc1/inc.h @@ -0,0 +1 @@ +#define INC1 1 diff --git a/test/data/include-define/project/inc2/inc.h b/test/data/include-define/project/inc2/inc.h new file mode 100644 index 00000000..0c9d146c --- /dev/null +++ b/test/data/include-define/project/inc2/inc.h @@ -0,0 +1 @@ +#define INC2 1 diff --git a/test/data/include-define/project/main.c b/test/data/include-define/project/main.c new file mode 100644 index 00000000..2e169c3f --- /dev/null +++ b/test/data/include-define/project/main.c @@ -0,0 +1,6 @@ +#include "RTE_Components.h" +#include CMSIS_device_header + +int main(void) { + return 0; +} diff --git a/test/data/include-define/project/project.cproject.yml b/test/data/include-define/project/project.cproject.yml new file mode 100644 index 00000000..c6f1826b --- /dev/null +++ b/test/data/include-define/project/project.cproject.yml @@ -0,0 +1,50 @@ +project: + + components: + - component: ARM::CMSIS:CORE + del-path: + - ./inc1 + undefine: + - DEF1 + - component: ARM::Device:Startup&C Startup + add-path: + - ./inc2 + define: + - DEF2: 1 + + groups: + - group: Source1 + files: + - file: source1.c + add-path: + - ./inc1 + define: + - DEF1: 1 + groups: + - group: Source2 + files: + - file: source2.c + add-path: + - ./inc2 + define: + - DEF2: 1 + del-path: + - ./inc1 + undefine: + - DEF1 + + - group: Main + files: + - file: ./main.c + add-path: + - ./inc2 + define: + - DEF2 + del-path: + - ./not-supported + undefine: + - not-supported + + - group: Headers + files: + - file: ./inc3/inc.h diff --git a/test/data/include-define/project/source1.c b/test/data/include-define/project/source1.c new file mode 100644 index 00000000..9dbf2665 --- /dev/null +++ b/test/data/include-define/project/source1.c @@ -0,0 +1,13 @@ +#include "inc.h" + +#ifndef INC1 +#error "INC1 is not defined" +#endif + +#ifndef DEF1 +#error "DEF1 is not defined" +#endif + +int source1(void) { + return 0; +} diff --git a/test/data/include-define/project/source2.c b/test/data/include-define/project/source2.c new file mode 100644 index 00000000..c9fe683a --- /dev/null +++ b/test/data/include-define/project/source2.c @@ -0,0 +1,21 @@ +#include "inc.h" + +#ifdef INC1 +#error "INC1 is defined" +#endif + +#ifndef INC2 +#error "INC2 is not defined" +#endif + +#ifdef DEF1 +#error "DEF1 is defined" +#endif + +#ifndef DEF2 +#error "DEF2 is not defined" +#endif + +int source2(void) { + return 0; +} diff --git a/test/data/include-define/solution.csolution.yml b/test/data/include-define/solution.csolution.yml new file mode 100644 index 00000000..7672cd9c --- /dev/null +++ b/test/data/include-define/solution.csolution.yml @@ -0,0 +1,27 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + + target-types: + - type: ARMCM0 + device: ARMCM0 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml diff --git a/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/ac6_linker_script.sct.src b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/ac6_linker_script.sct.src new file mode 100644 index 00000000..7820e1f1 --- /dev/null +++ b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/ac6_linker_script.sct.src @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + */ + +/* ---------------------------------------------------------------------------- + Stack seal size definition + *----------------------------------------------------------------------------*/ +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#define __STACKSEAL_SIZE 8 +#else +#define __STACKSEAL_SIZE 0 +#endif + +/*---------------------------------------------------------------------------- + Scatter File Definitions definition + *----------------------------------------------------------------------------*/ + +LR_ROM0 __ROM0_BASE __ROM0_SIZE { + + ER_ROM0 __ROM0_BASE __ROM0_SIZE { + *.o (RESET, +First) + *(InRoot$$Sections) + *(+RO +XO) + } + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + ER_CMSE_VENEER AlignExpr(+0, 32) (__ROM0_SIZE - AlignExpr(ImageLength(ER_ROM0), 32)) { + *(Veneer$$CMSE) + } +#endif + + RW_NOINIT __RAM0_BASE UNINIT (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE) { + *.o(.bss.noinit) + *.o(.bss.noinit.*) + } + + RW_RAM0 AlignExpr(+0, 8) (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) { + *(+RW +ZI) + } + +#if __HEAP_SIZE > 0 + ARM_LIB_HEAP (AlignExpr(+0, 8)) EMPTY __HEAP_SIZE { ; Reserve empty region for heap + } +#endif + + ARM_LIB_STACK (__RAM0_BASE + __RAM0_SIZE - __STACKSEAL_SIZE) EMPTY -__STACK_SIZE { ; Reserve empty region for stack + } + +#if __STACKSEAL_SIZE > 0 + STACKSEAL +0 EMPTY __STACKSEAL_SIZE { ; Reserve empty region for stack seal immediately after stack + } +#endif + +#if __RAM1_SIZE > 0 + RW_RAM1 __RAM1_BASE __RAM1_SIZE { + .ANY (+RW +ZI) + } +#endif + +#if __RAM2_SIZE > 0 + RW_RAM2 __RAM2_BASE __RAM2_SIZE { + .ANY (+RW +ZI) + } +#endif + +#if __RAM3_SIZE > 0 + RW_RAM3 __RAM3_BASE __RAM3_SIZE { + .ANY (+RW +ZI) + } +#endif +} + +#if __ROM1_SIZE > 0 +LR_ROM1 __ROM1_BASE __ROM1_SIZE { + ER_ROM1 +0 __ROM1_SIZE { + .ANY (+RO +XO) + } +} +#endif + +#if __ROM2_SIZE > 0 +LR_ROM2 __ROM2_BASE __ROM2_SIZE { + ER_ROM2 +0 __ROM2_SIZE { + .ANY (+RO +XO) + } +} +#endif + +#if __ROM3_SIZE > 0 +LR_ROM3 __ROM3_BASE __ROM3_SIZE { + ER_ROM3 +0 __ROM3_SIZE { + .ANY (+RO +XO) + } +} +#endif diff --git a/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/clang_linker_script.ld.src b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/clang_linker_script.ld.src new file mode 100644 index 00000000..db077496 --- /dev/null +++ b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/clang_linker_script.ld.src @@ -0,0 +1,374 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2019 Keith Packard + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* ---------------------------------------------------------------------------- + Stack seal size definition + *----------------------------------------------------------------------------*/ +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#define __STACKSEAL_SIZE ( 8 ) +#else +#define __STACKSEAL_SIZE ( 0 ) +#endif + +/* ---------------------------------------------------------------------------- + Memory definition + *----------------------------------------------------------------------------*/ +MEMORY +{ + ROM0 (rx!w) : ORIGIN = __ROM0_BASE, LENGTH = __ROM0_SIZE +#if __ROM1_SIZE > 0 + ROM1 (rx!w) : ORIGIN = __ROM1_BASE, LENGTH = __ROM1_SIZE +#endif +#if __ROM2_SIZE > 0 + ROM2 (rx!w) : ORIGIN = __ROM2_BASE, LENGTH = __ROM2_SIZE +#endif +#if __ROM3_SIZE > 0 + ROM3 (rx!w) : ORIGIN = __ROM3_BASE, LENGTH = __ROM3_SIZE +#endif + + RAM0 (w!rx) : ORIGIN = __RAM0_BASE, LENGTH = __RAM0_SIZE +#if __RAM1_SIZE > 0 + RAM1 (w!rx) : ORIGIN = __RAM1_BASE, LENGTH = __RAM1_SIZE +#endif +#if __RAM2_SIZE > 0 + RAM2 (w!rx) : ORIGIN = __RAM2_BASE, LENGTH = __RAM2_SIZE +#endif +#if __RAM3_SIZE > 0 + RAM3 (w!rx) : ORIGIN = __RAM3_BASE, LENGTH = __RAM3_SIZE +#endif +} + +ENTRY(Reset_Handler) + +PHDRS +{ + text PT_LOAD; + ram PT_LOAD; + ram_init PT_LOAD; + tls PT_TLS; +} + +SECTIONS +{ + .init : { + KEEP (*(.vectors)) + KEEP (*(.text.init.enter)) + KEEP (*(.data.init.enter)) + KEEP (*(SORT_BY_NAME(.init) SORT_BY_NAME(.init.*))) + } >ROM0 AT>ROM0 :text + + .text : { + + /* code */ + *(.text.unlikely .text.unlikely.*) + *(.text.startup .text.startup.*) + *(.text .text.* .opd .opd.*) + *(.gnu.linkonce.t.*) + KEEP (*(.fini .fini.*)) + __text_end = .; + + PROVIDE (__etext = __text_end); + PROVIDE (_etext = __text_end); + PROVIDE (etext = __text_end); + + /* read-only data */ + *(.rdata) + *(.rodata .rodata.*) + *(.gnu.linkonce.r.*) + + *(.srodata.cst16) + *(.srodata.cst8) + *(.srodata.cst4) + *(.srodata.cst2) + *(.srodata .srodata.*) + *(.data.rel.ro .data.rel.ro.*) + *(.got .got.*) + + /* Need to pre-align so that the symbols come after padding */ + . = ALIGN(8); + + /* lists of constructors and destructors */ + PROVIDE_HIDDEN ( __preinit_array_start = . ); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN ( __preinit_array_end = . ); + + PROVIDE_HIDDEN ( __init_array_start = . ); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array .ctors)) + PROVIDE_HIDDEN ( __init_array_end = . ); + + PROVIDE_HIDDEN ( __fini_array_start = . ); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array .dtors)) + PROVIDE_HIDDEN ( __fini_array_end = . ); + + } >ROM0 AT>ROM0 :text + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + .veneers : + { + . = ALIGN(32); + KEEP(*(.gnu.sgstubs)) + } > ROM0 AT>ROM0 :text +#endif + + .toc : { + *(.toc .toc.*) + } >ROM0 AT>ROM0 :text + + /* additional sections when compiling with C++ exception support */ + + .except_ordered : { + *(.gcc_except_table *.gcc_except_table.*) + KEEP (*(.eh_frame .eh_frame.*)) + *(.ARM.extab* .gnu.linkonce.armextab.*) + } >ROM0 AT>ROM0 :text + + .except_unordered : { + . = ALIGN(8); + + PROVIDE(__exidx_start = .); + *(.ARM.exidx*) + PROVIDE(__exidx_end = .); + } >ROM0 AT>ROM0 :text + + + /* + * Data values which are preserved across reset + */ + .preserve (NOLOAD) : { + PROVIDE(__preserve_start__ = .); + KEEP(*(SORT_BY_NAME(.preserve.*))) + KEEP(*(.preserve)) + PROVIDE(__preserve_end__ = .); + } >RAM0 AT>RAM0 :ram + + .data : { + *(.data .data.*) + *(.gnu.linkonce.d.*) + + /* Need to pre-align so that the symbols come after padding */ + . = ALIGN(8); + + PROVIDE( __global_pointer$ = . + 0x800 ); + *(.sdata .sdata.* .sdata2.*) + *(.gnu.linkonce.s.*) + } >RAM0 AT>ROM0 :ram_init + PROVIDE(__data_start = ADDR(.data)); + PROVIDE(__data_source = LOADADDR(.data)); + + /* Thread local initialized data. This gets + * space allocated as it is expected to be placed + * in ram to be used as a template for TLS data blocks + * allocated at runtime. We're slightly abusing that + * by placing the data in flash where it will be copied + * into the allocate ram addresses by the existing + * data initialization code in crt0 + */ + .tdata : { + *(.tdata .tdata.* .gnu.linkonce.td.*) + PROVIDE(__data_end = .); + PROVIDE(__tdata_end = .); + } >RAM0 AT>ROM0 :tls :ram_init + PROVIDE( __tls_base = ADDR(.tdata)); + PROVIDE( __tdata_start = ADDR(.tdata)); + PROVIDE( __tdata_source = LOADADDR(.tdata) ); + PROVIDE( __tdata_source_end = LOADADDR(.tdata) + SIZEOF(.tdata) ); + PROVIDE( __data_source_end = __tdata_source_end ); + PROVIDE( __tdata_size = SIZEOF(.tdata) ); + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata),ALIGNOF(.tbss)) ); + + PROVIDE( __edata = __data_end ); + PROVIDE( _edata = __data_end ); + PROVIDE( edata = __data_end ); + PROVIDE( __data_size = __data_end - __data_start ); + PROVIDE( __data_source_size = __data_source_end - __data_source ); + + .tbss (NOLOAD) : { + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + PROVIDE( __tls_end = . ); + PROVIDE( __tbss_end = . ); + } >RAM0 AT>RAM0 :tls :ram + PROVIDE( __bss_start = ADDR(.tbss)); + PROVIDE( __tbss_start = ADDR(.tbss)); + PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) ); + PROVIDE( __tbss_size = SIZEOF(.tbss) ); + PROVIDE( __tls_size = __tls_end - __tls_base ); + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); + PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); + PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) ); + + /* + * The linker special cases .tbss segments which are + * identified as segments which are not loaded and are + * thread_local. + * + * For these segments, the linker does not advance 'dot' + * across them. We actually need memory allocated for tbss, + * so we create a special segment here just to make room + */ + /* + .tbss_space (NOLOAD) : { + . = ADDR(.tbss); + . = . + SIZEOF(.tbss); + } >RAM0 AT>RAM0 :ram + */ + + .bss (NOLOAD) : { + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + + /* Align the end of this section, so next can start on aligned address */ + . = ALIGN(8); + __bss_end = .; + } >RAM0 AT>RAM0 :ram + PROVIDE( __non_tls_bss_start = ADDR(.bss) ); + PROVIDE( __bss_size = __bss_end - __bss_start ); + + /* This section contains data that is not initialized during load, + or during the application's initialization sequence. */ + .noinit (NOLOAD) : { + __noinit_start__ = .; + *(.noinit) + *(.noinit.*) + + /* Align the end of this section, so next (heap) can start on aligned address */ + . = ALIGN(8); + __noinit_end__ = .; + } >RAM0 AT>RAM0 :ram + + PROVIDE( __end = . ); + PROVIDE( _end = . ); + PROVIDE( end = . ); + + /* Make the rest of memory available for heap storage */ + PROVIDE (__heap_start = __end); +#ifdef __HEAP_SIZE + PROVIDE (__heap_end = __heap_start + __HEAP_SIZE); + PROVIDE (__heap_size = __HEAP_SIZE); +#else + PROVIDE (__heap_end = __stack - __STACK_SIZE); + PROVIDE (__heap_size = __heap_end - __heap_start); +#endif + .heap (NOLOAD) : { + . += __heap_size; + } >RAM0 :ram + + /* Define a stack region to make sure it fits in memory */ + PROVIDE(__stack = ORIGIN(RAM0) + LENGTH(RAM0) - __STACKSEAL_SIZE); + PROVIDE(__stack_limit = __stack - __STACK_SIZE); + .stack (__stack_limit) (NOLOAD) : { + . += __STACK_SIZE; + } >RAM0 :ram + +#if __STACKSEAL_SIZE > 0 + PROVIDE(__stack_seal = __stack); + .stackseal (__stack) (NOLOAD) : + { + . += __STACKSEAL_SIZE; + } >RAM0 :ram +#endif + + /* Throw away C++ exception handling information */ + + /* + + /DISCARD/ : { + *(.note .note.*) + *(.eh_frame .eh_frame.*) + *(.ARM.extab* .gnu.linkonce.armextab.*) + *(.ARM.exidx*) + } + + */ + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1. */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions. */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2. */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3. */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF 5. */ + .debug_addr 0 : { *(.debug_addr) } + .debug_line_str 0 : { *(.debug_line_str) } + .debug_loclists 0 : { *(.debug_loclists) } + .debug_macro 0 : { *(.debug_macro) } + .debug_names 0 : { *(.debug_names) } + .debug_rnglists 0 : { *(.debug_rnglists) } + .debug_str_offsets 0 : { *(.debug_str_offsets) } + .debug_sup 0 : { *(.debug_sup) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } +} +/* + * Check that sections that are copied from flash to RAM have matching + * padding, so that a single memcpy() of __data_size copies the correct bytes. + */ +ASSERT( __data_size == __data_source_size, + "ERROR: .data/.tdata flash size does not match RAM size"); diff --git a/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/gcc_linker_script.ld.src b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/gcc_linker_script.ld.src new file mode 100644 index 00000000..7cd986d8 --- /dev/null +++ b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/gcc_linker_script.ld.src @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2023 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + */ + +/* ---------------------------------------------------------------------------- + Stack seal size definition + *----------------------------------------------------------------------------*/ +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#define __STACKSEAL_SIZE ( 8 ) +#else +#define __STACKSEAL_SIZE ( 0 ) +#endif + +/* ---------------------------------------------------------------------------- + Memory definition + *----------------------------------------------------------------------------*/ +MEMORY +{ + ROM0 (rx) : ORIGIN = __ROM0_BASE, LENGTH = __ROM0_SIZE +#if __ROM1_SIZE > 0 + ROM1 (rx) : ORIGIN = __ROM1_BASE, LENGTH = __ROM1_SIZE +#endif +#if __ROM2_SIZE > 0 + ROM2 (rx) : ORIGIN = __ROM2_BASE, LENGTH = __ROM2_SIZE +#endif +#if __ROM3_SIZE > 0 + ROM3 (rx) : ORIGIN = __ROM3_BASE, LENGTH = __ROM3_SIZE +#endif + + RAM0 (rwx) : ORIGIN = __RAM0_BASE, LENGTH = __RAM0_SIZE +#if __RAM1_SIZE > 0 + RAM1 (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __RAM1_SIZE +#endif +#if __RAM2_SIZE > 0 + RAM2 (rwx) : ORIGIN = __RAM2_BASE, LENGTH = __RAM2_SIZE +#endif +#if __RAM3_SIZE > 0 + RAM3 (rwx) : ORIGIN = __RAM3_BASE, LENGTH = __RAM3_SIZE +#endif +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext (deprecated) + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __noinit_start + * __noinit_end + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.vectors)) + *(.text*) + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata*) + + KEEP(*(.eh_frame*)) + } > ROM0 + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + .gnu.sgstubs : + { + . = ALIGN(32); + } > ROM0 +#endif + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > ROM0 + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > ROM0 + __exidx_end = .; + + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + + LONG (LOADADDR(.data)) + LONG (ADDR(.data)) + LONG (SIZEOF(.data) / 4) + + /* Add each additional data section here */ +/* + LONG (LOADADDR(.data2)) + LONG (ADDR(.data2)) + LONG (SIZEOF(.data2) / 4) +*/ + __copy_table_end__ = .; + } > ROM0 + + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + +/* .bss initialization to zero is already done during C Run-Time Startup. + LONG (ADDR(.bss)) + LONG (SIZEOF(.bss) / 4) +*/ + + /* Add each additional bss section here */ +/* + LONG (ADDR(.bss2)) + LONG (SIZEOF(.bss2) / 4) +*/ + __zero_table_end__ = .; + } > ROM0 + + /* + * This __etext variable is kept for backward compatibility with older, + * ASM based startup files. + */ + PROVIDE(__etext = LOADADDR(.data)); + + .data : ALIGN(4) + { + __data_start__ = .; + *(vtable) + *(.data) + *(.data.*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM0 AT > ROM0 + + /* + * Secondary data section, optional + * + * Remember to add each additional data section + * to the .copy.table above to assure proper + * initialization during startup. + */ +/* + .data2 : ALIGN(4) + { + . = ALIGN(4); + __data2_start__ = .; + *(.data2) + *(.data2.*) + . = ALIGN(4); + __data2_end__ = .; + + } > RAM1 AT > ROM0 +*/ + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM0 AT > RAM0 + + /* + * Secondary bss section, optional + * + * Remember to add each additional bss section + * to the .zero.table above to assure proper + * initialization during startup. + */ +/* + .bss2 : + { + . = ALIGN(4); + __bss2_start__ = .; + *(.bss2) + *(.bss2.*) + . = ALIGN(4); + __bss2_end__ = .; + } > RAM1 AT > RAM1 +*/ + + /* This section contains data that is not initialized during load, + or during the application's initialization sequence. */ + .noinit (NOLOAD) : + { + . = ALIGN(4); + __noinit_start = .; + *(.noinit) + *(.noinit.*) + . = ALIGN(4); + __noinit_end = .; + } > RAM0 + + .heap (NOLOAD) : + { + . = ALIGN(8); + __end__ = .; + PROVIDE(end = .); + . = . + __HEAP_SIZE; + . = ALIGN(8); + __HeapLimit = .; + } > RAM0 + + .stack (ORIGIN(RAM0) + LENGTH(RAM0) - __STACK_SIZE - __STACKSEAL_SIZE) (NOLOAD) : + { + . = ALIGN(8); + __StackLimit = .; + . = . + __STACK_SIZE; + . = ALIGN(8); + __StackTop = .; + } > RAM0 + PROVIDE(__stack = __StackTop); + +#if __STACKSEAL_SIZE > 0 + .stackseal (ORIGIN(RAM0) + LENGTH(RAM0) - __STACKSEAL_SIZE) (NOLOAD) : + { + . = ALIGN(8); + __StackSeal = .; + . = . + 8; + . = ALIGN(8); + } > RAM0 +#endif + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/iar_linker_script.icf.src b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/iar_linker_script.icf.src new file mode 100644 index 00000000..5689ea8a --- /dev/null +++ b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/iar_linker_script.icf.src @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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. + */ + +define memory mem with size = 4G; + +#if __ROM0_SIZE > 0 + define region ROM0_region = mem:[from __ROM0_BASE to (__ROM0_BASE+__ROM0_SIZE-1)]; +#else + define region ROM0_region = []; +#endif + +#if __ROM1_SIZE > 0 + define region ROM1_region = mem:[from __ROM1_BASE to (__ROM0_BASE+__ROM1_SIZE-1)]; +#else + define region ROM1_region = []; +#endif + +#if __ROM2_SIZE > 0 + define region ROM2_region = mem:[from __ROM2_BASE to (__ROM2_BASE+__ROM2_SIZE-1)]; +#else + define region ROM2_region = []; +#endif + +#if __ROM3_SIZE > 0 + define region ROM3_region = mem:[from __ROM3_BASE to (__ROM3_BASE+__ROM3_SIZE-1)]; +#else + define region ROM3_region = []; +#endif + +define region ROM_region = ROM0_region | ROM1_region | ROM2_region | ROM3_region; + +#if __RAM0_SIZE > 0 + define region RAM0_region = mem:[from __RAM0_BASE to (__RAM0_BASE+__RAM0_SIZE-1)]; +#else + define region RAM0_region = []; +#endif + +#if __RAM1_SIZE > 0 + define region RAM1_region = mem:[from __RAM1_BASE to (__RAM0_BASE+__RAM1_SIZE-1)]; +#else + define region RAM1_region = []; +#endif + +#if __RAM2_SIZE > 0 + define region RAM2_region = mem:[from __RAM2_BASE to (__RAM2_BASE+__RAM2_SIZE-1)]; +#else + define region RAM2_region = []; +#endif + +#if __RAM3_SIZE > 0 + define region RAM3_region = mem:[from __RAM3_BASE to (__RAM3_BASE+__RAM3_SIZE-1)]; +#else + define region RAM3_region = []; +#endif + +define region RAM_region = RAM0_region | RAM1_region | RAM2_region | RAM3_region; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ROM0_BASE { readonly section .intvec }; + +if (!isempty(ROM_region)) +{ + place in ROM_region { readonly }; +} + +if (!isempty(RAM_region)) +{ + define block CSTACK with alignment = 8, size = __STACK_SIZE { }; + define block PROC_STACK with alignment = 8, size = 0 { }; + define block HEAP with alignment = 8, size = __HEAP_SIZE { }; + place in RAM_region { readwrite, block CSTACK, block PROC_STACK, block HEAP }; +} diff --git a/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/regions_ARMCM0.h b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/regions_ARMCM0.h new file mode 100644 index 00000000..c40d7aa7 --- /dev/null +++ b/test/data/linker-pre-processing/project/RTE/Device/ARMCM0/regions_ARMCM0.h @@ -0,0 +1,60 @@ +#ifndef REGIONS_ARMCM0_H +#define REGIONS_ARMCM0_H + + +//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- + +// Device pack: ARM::Cortex_DFP@1.0.0 +// Device pack used to generate this file + +// ROM Configuration +// ======================= +// ROM=<__ROM0> +// Base address <0x0-0xFFFFFFFF:8> +// Defines base address of memory region. +// Default: 0x00000000 +#define __ROM0_BASE 0x00000000 +// Region size [bytes] <0x0-0xFFFFFFFF:8> +// Defines size of memory region. +// Default: 0x00040000 +#define __ROM0_SIZE 0x00040000 +// Default region +// Enables memory region globally for the application. +#define __ROM0_DEFAULT 1 +// Startup +// Selects region to be used for startup code. +#define __ROM0_STARTUP 1 +// + +// + +// RAM Configuration +// ======================= +// RAM=<__RAM0> +// Base address <0x0-0xFFFFFFFF:8> +// Defines base address of memory region. +// Default: 0x20000000 +#define __RAM0_BASE 0x20000000 +// Region size [bytes] <0x0-0xFFFFFFFF:8> +// Defines size of memory region. +// Default: 0x00020000 +#define __RAM0_SIZE 0x00020000 +// Default region +// Enables memory region globally for the application. +#define __RAM0_DEFAULT 1 +// No zero initialize +// Excludes region from zero initialization. +#define __RAM0_NOINIT 0 +// + +// + +// Stack / Heap Configuration +// Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +// Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +#define __STACK_SIZE 0x00000200 +#define __HEAP_SIZE 0x00000C00 +// + + +#endif /* REGIONS_ARMCM0_H */ diff --git a/test/data/linker-pre-processing/project/main.c b/test/data/linker-pre-processing/project/main.c new file mode 100644 index 00000000..2e169c3f --- /dev/null +++ b/test/data/linker-pre-processing/project/main.c @@ -0,0 +1,6 @@ +#include "RTE_Components.h" +#include CMSIS_device_header + +int main(void) { + return 0; +} diff --git a/test/data/linker-pre-processing/project/project.cproject.yml b/test/data/linker-pre-processing/project/project.cproject.yml new file mode 100644 index 00000000..fa74a6b5 --- /dev/null +++ b/test/data/linker-pre-processing/project/project.cproject.yml @@ -0,0 +1,14 @@ +project: + + components: + - component: ARM::CMSIS:CORE + - component: ARM::Device:Startup&C Startup + + groups: + - group: Source + files: + - file: ./main.c + + linker: + - define: + - DEF_LD_PP diff --git a/test/data/linker-pre-processing/solution.csolution.yml b/test/data/linker-pre-processing/solution.csolution.yml new file mode 100644 index 00000000..e58a6431 --- /dev/null +++ b/test/data/linker-pre-processing/solution.csolution.yml @@ -0,0 +1,35 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + + target-types: + - type: ARMCM0 + device: ARMCM0 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml + + misc: + - for-compiler: AC6 + Link: + - --info summarysizes + - --info sizes + - --info totals + - --info unused diff --git a/test/data/pre-include/pack/ARM.PreIncludeTestPack.pdsc b/test/data/pre-include/pack/ARM.PreIncludeTestPack.pdsc new file mode 100644 index 00000000..38767576 --- /dev/null +++ b/test/data/pre-include/pack/ARM.PreIncludeTestPack.pdsc @@ -0,0 +1,56 @@ + + + + ARM + https://www.arm.com/ + PreIncludeTestPack + PreIncludeTestPack + + + + Initial release of PreIncludeTestPack. + + + + + PreIncludeTestPack + + + + + + Test Device + + + + + + + TestGlobal + + // enabling global pre include + #define GLOBAL_TEST 0x1 + + + + + + + + + TestLocal + + // enabling local pre include + #define LOCAL_TEST 0x2 + + + + + + + + + + + + diff --git a/test/data/pre-include/pack/Files/config-header1.h b/test/data/pre-include/pack/Files/config-header1.h new file mode 100644 index 00000000..2873dd0f --- /dev/null +++ b/test/data/pre-include/pack/Files/config-header1.h @@ -0,0 +1 @@ +#define PRE_INCLUDE_GLOBAL_CONFIG 1 diff --git a/test/data/pre-include/pack/Files/config-header2.h b/test/data/pre-include/pack/Files/config-header2.h new file mode 100644 index 00000000..cab06468 --- /dev/null +++ b/test/data/pre-include/pack/Files/config-header2.h @@ -0,0 +1 @@ +#define PRE_INCLUDE_LOCAL_CONFIG 1 diff --git a/test/data/pre-include/pack/Files/header1.h b/test/data/pre-include/pack/Files/header1.h new file mode 100644 index 00000000..8c01106f --- /dev/null +++ b/test/data/pre-include/pack/Files/header1.h @@ -0,0 +1 @@ +#define PRE_INCLUDE_GLOBAL 1 diff --git a/test/data/pre-include/pack/Files/header2.h b/test/data/pre-include/pack/Files/header2.h new file mode 100644 index 00000000..10e70504 --- /dev/null +++ b/test/data/pre-include/pack/Files/header2.h @@ -0,0 +1 @@ +#define PRE_INCLUDE_LOCAL 1 diff --git a/test/data/pre-include/pack/Files/test1.c b/test/data/pre-include/pack/Files/test1.c new file mode 100644 index 00000000..8694e8c0 --- /dev/null +++ b/test/data/pre-include/pack/Files/test1.c @@ -0,0 +1,13 @@ +#ifndef PRE_INCLUDE_GLOBAL +#error "PRE_INCLUDE_GLOBAL is not defined" +#endif + +#ifndef PRE_INCLUDE_GLOBAL_CONFIG +#error "PRE_INCLUDE_GLOBAL_CONFIG is not defined" +#endif + +#ifndef GLOBAL_TEST +#error "GLOBAL_TEST is not defined" +#endif + +int PreIncludeGlobal; diff --git a/test/data/pre-include/pack/Files/test2.c b/test/data/pre-include/pack/Files/test2.c new file mode 100644 index 00000000..be0f7821 --- /dev/null +++ b/test/data/pre-include/pack/Files/test2.c @@ -0,0 +1,13 @@ +#ifndef PRE_INCLUDE_LOCAL +#error "PRE_INCLUDE_LOCAL is not defined" +#endif + +#ifndef PRE_INCLUDE_LOCAL_CONFIG +#error "PRE_INCLUDE_LOCAL_CONFIG is not defined" +#endif + +#ifndef LOCAL_TEST +#error "LOCAL_TEST is not defined" +#endif + +int PreIncludeLocal; diff --git a/test/data/pre-include/project/main.c b/test/data/pre-include/project/main.c new file mode 100644 index 00000000..2e169c3f --- /dev/null +++ b/test/data/pre-include/project/main.c @@ -0,0 +1,6 @@ +#include "RTE_Components.h" +#include CMSIS_device_header + +int main(void) { + return 0; +} diff --git a/test/data/pre-include/project/project.cproject.yml b/test/data/pre-include/project/project.cproject.yml new file mode 100644 index 00000000..2824b155 --- /dev/null +++ b/test/data/pre-include/project/project.cproject.yml @@ -0,0 +1,12 @@ +project: + + components: + - component: ARM::CMSIS:CORE + - component: ARM::Device:Startup&C Startup + - component: ARM::TestClass:TestGlobal + - component: ARM::TestClass:TestLocal + + groups: + - group: Source + files: + - file: ./main.c diff --git a/test/data/pre-include/solution.csolution.yml b/test/data/pre-include/solution.csolution.yml new file mode 100644 index 00000000..be94a6af --- /dev/null +++ b/test/data/pre-include/solution.csolution.yml @@ -0,0 +1,29 @@ +solution: + created-for: CMSIS-Toolbox@2.2.1 + cdefault: + + packs: + - pack: ARM::Cortex_DFP + - pack: ARM::CMSIS + - pack: ARM::PreIncludeTestPack + path: ./pack + + target-types: + - type: ARMCM0 + device: ARMCM0 + + build-types: + - type: AC6 + compiler: AC6 + + - type: GCC + compiler: GCC + + - type: IAR + compiler: IAR + + - type: CLANG + compiler: CLANG + + projects: + - project: ./project/project.cproject.yml diff --git a/test/resources/utils.resource b/test/resources/utils.resource index 7ab3dd09..35ffd77f 100644 --- a/test/resources/utils.resource +++ b/test/resources/utils.resource @@ -13,4 +13,4 @@ Run Program Run csolution [Documentation] Run csolution example with specified arguments [Arguments] ${input_file} @{args} - Run Program cbuild.exe ${input_file} @{args} \ No newline at end of file + Run Program cbuild ${input_file} @{args} \ No newline at end of file diff --git a/test/src/test.robot b/test/src/test.robot index ea872508..0ffcb77f 100644 --- a/test/src/test.robot +++ b/test/src/test.robot @@ -11,8 +11,7 @@ ${RESOURCES} ../resources *** Test Cases *** ${input_file} ${args} -Run MyProject example ${testDataDir}/MyProject${/}MyProject.csolution.yml --context=MyProject_CM3.Debug+CM3 -r --update-rte -Run Hello example ${testDataDir}/Hello${/}Hello.csolution.yml -r --update-rte +Run Hello example ${testDataDir}/Hello${/}Hello.csolution.yml -p -r --update-rte *** Keywords *** diff --git a/test/configs/vcpkg-configuration.json b/test/vcpkg-configuration.json similarity index 100% rename from test/configs/vcpkg-configuration.json rename to test/vcpkg-configuration.json From b6291185b7f008ac797c5c1df4b275348b264bcc Mon Sep 17 00:00:00 2001 From: Sourabh Mehta Date: Tue, 9 Apr 2024 16:20:10 +0200 Subject: [PATCH 3/5] Added more examples --- .github/workflows/robot-tests.yml | 26 +- .gitignore | 7 +- test/data/Hello/Board_IO/retarget_stdio.c | 109 ------ .../Hello/Board_IO/vio_V2M-MPS3-SSE-300.c | 354 ------------------ test/data/Hello/Hello.cproject.yml | 32 -- test/data/Hello/Hello.csolution.yml | 26 -- test/data/Hello/README.md | 49 --- test/data/Hello/hello.c | 50 --- test/data/Hello/main.c | 45 --- test/data/Hello/main.h | 27 -- test/data/build-asm/solution.csolution.yml | 4 +- test/data/build-c/solution.csolution.yml | 4 +- test/data/build-cpp/solution.csolution.yml | 4 +- .../include-define/solution.csolution.yml | 4 +- .../solution.csolution.yml | 4 +- test/data/pre-include/solution.csolution.yml | 4 +- test/resources/utils.resource | 10 +- test/src/test.robot | 31 +- test/vcpkg-configuration.json | 6 +- 19 files changed, 63 insertions(+), 733 deletions(-) delete mode 100644 test/data/Hello/Board_IO/retarget_stdio.c delete mode 100644 test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c delete mode 100644 test/data/Hello/Hello.cproject.yml delete mode 100644 test/data/Hello/Hello.csolution.yml delete mode 100644 test/data/Hello/README.md delete mode 100644 test/data/Hello/hello.c delete mode 100644 test/data/Hello/main.c delete mode 100644 test/data/Hello/main.h diff --git a/.github/workflows/robot-tests.yml b/.github/workflows/robot-tests.yml index 17c5e18f..fe3ccd3d 100644 --- a/.github/workflows/robot-tests.yml +++ b/.github/workflows/robot-tests.yml @@ -13,8 +13,7 @@ concurrency: cancel-in-progress: true jobs: - - robot-tests: + test: runs-on: ubuntu-latest env: CMSIS_PACK_ROOT: /home/runner/.cache/arm/packs @@ -60,29 +59,22 @@ jobs: run: | . /home/runner/.vcpkg/vcpkg-init vcpkg activate - python -m robot --outputdir reports src/test.robot - - # - name: Run Test and create report - # working-directory: ./test - # run: | - # python -m robot -d reports -x junit-report.xml "src/test.robot" - - - name: Run Robot Framework tests and generate report - if: always() - run: | - echo "ROBOT_RC=$?" >> "$GITHUB_ENV" + python -m robot --outputdir ../reports -x junit-report.xml src/test.robot - - name: Publish test results + - name: Archieve test results if: always() uses: actions/upload-artifact@v4 with: name: reports - path: ./test/reports + path: reports - generate_report: + report: runs-on: ubuntu-latest - needs: robot-tests + needs: test + permissions: write-all steps: + - uses: actions/checkout@v4 + - name: Download reports uses: actions/download-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 378eac25..9d8c2e8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -build +# Directories +/build*/ +**/run + +# Files +**/stdout.txt \ No newline at end of file diff --git a/test/data/Hello/Board_IO/retarget_stdio.c b/test/data/Hello/Board_IO/retarget_stdio.c deleted file mode 100644 index d1a8ad4a..00000000 --- a/test/data/Hello/Board_IO/retarget_stdio.c +++ /dev/null @@ -1,109 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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. - * - * Name: retarget_stdio.c - * Purpose: Retarget stdio to USART - * - *---------------------------------------------------------------------------*/ - -#include "Driver_USART.h" - -#define USART_DRV_NUM 0 -#define USART_BAUDRATE 115200 - -#define _USART_Driver_(n) Driver_USART##n -#define USART_Driver_(n) _USART_Driver_(n) - -extern ARM_DRIVER_USART USART_Driver_(USART_DRV_NUM); -#define ptrUSART (&USART_Driver_(USART_DRV_NUM)) - -/** - Initialize stdio - - \return 0 on success, or -1 on error. -*/ -int stdio_init (void) { - int32_t status; - - status = ptrUSART->Initialize(NULL); - if (status != ARM_DRIVER_OK) return (-1); - - status = ptrUSART->PowerControl(ARM_POWER_FULL); - if (status != ARM_DRIVER_OK) return (-1); - - status = ptrUSART->Control(ARM_USART_MODE_ASYNCHRONOUS | - ARM_USART_DATA_BITS_8 | - ARM_USART_PARITY_NONE | - ARM_USART_STOP_BITS_1 | - ARM_USART_FLOW_CONTROL_NONE, - USART_BAUDRATE); - if (status != ARM_DRIVER_OK) return (-1); - - status = ptrUSART->Control(ARM_USART_CONTROL_RX, 1); - if (status != ARM_DRIVER_OK) return (-1); - - return (0); -} - -/** - Put a character to the stderr - - \param[in] ch Character to output - \return The character written, or -1 on write error. -*/ -int stderr_putchar (int ch) { - uint8_t buf[1]; - - buf[0] = ch; - if (ptrUSART->Send(buf, 1) != ARM_DRIVER_OK) { - return (-1); - } - while (ptrUSART->GetTxCount() != 1); - return (ch); -} - -/** - Put a character to the stdout - - \param[in] ch Character to output - \return The character written, or -1 on write error. -*/ -int stdout_putchar (int ch) { - uint8_t buf[1]; - - buf[0] = ch; - if (ptrUSART->Send(buf, 1) != ARM_DRIVER_OK) { - return (-1); - } - while (ptrUSART->GetTxCount() != 1); - return (ch); -} - -/** - Get a character from the stdio - - \return The next character from the input, or -1 on read error. -*/ -int stdin_getchar (void) { - uint8_t buf[1]; - - if (ptrUSART->Receive(buf, 1) != ARM_DRIVER_OK) { - return (-1); - } - while (ptrUSART->GetRxCount() != 1); - return (buf[0]); -} diff --git a/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c b/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c deleted file mode 100644 index 5ce50811..00000000 --- a/test/data/Hello/Board_IO/vio_V2M-MPS3-SSE-300.c +++ /dev/null @@ -1,354 +0,0 @@ -/****************************************************************************** - * @file vio.c - * @brief Virtual I/O implementation template - * @version V1.0.0 - * @date 23. March 2020 - ******************************************************************************/ -/* - * Copyright (c) 2019-2020 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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. - */ - -/*! \page vio_V2M-MPS3-SSE-300 Physical I/O Mapping -The table below lists the physical I/O mapping of this CMSIS-Driver VIO implementation. -Virtual Resource | Variable | Physical Resource on V2M-MPS3-SSE-300 | -:-----------------|:---------------|:-----------------------------------------------| -vioBUTTON0 | vioSignalIn.0 | User Button PB1 | -vioBUTTON1 | vioSignalIn.1 | User Button PB1 | -vioLED0 | vioSignalOut.0 | User LED UL0 | -vioLED1 | vioSignalOut.1 | User LED UL1 | -vioLED2 | vioSignalOut.2 | User LED UL2 | -vioLED3 | vioSignalOut.3 | User LED UL3 | -vioLED4 | vioSignalOut.4 | User LED UL4 | -vioLED5 | vioSignalOut.5 | User LED UL5 | -vioLED6 | vioSignalOut.6 | User LED UL6 | -vioLED7 | vioSignalOut.7 | User LED UL7 | -*/ - -#include -#include -#include -#include "cmsis_vio.h" - -#include "RTE_Components.h" // Component selection -#include CMSIS_device_header - -#if !defined CMSIS_VOUT || !defined CMSIS_VIN -#include "arm_mps3_io_drv.h" -#include "device_cfg.h" -#include "device_definition.h" -#endif - -// VIO input, output definitions -#define VIO_PRINT_MAX_SIZE 64U // maximum size of print memory -#define VIO_PRINTMEM_NUM 4U // number of print memories -#define VIO_VALUE_NUM 3U // number of values -#define VIO_VALUEXYZ_NUM 3U // number of XYZ values -#define VIO_IPV4_ADDRESS_NUM 2U // number of IPv4 addresses -#define VIO_IPV6_ADDRESS_NUM 2U // number of IPv6 addresses - -// VIO input, output variables -__USED uint32_t vioSignalIn; // Memory for incoming signal -__USED uint32_t vioSignalOut; // Memory for outgoing signal -__USED char vioPrintMem[VIO_PRINTMEM_NUM][VIO_PRINT_MAX_SIZE]; // Memory for the last value for each level -__USED int32_t vioValue [VIO_VALUE_NUM]; // Memory for value used in vioGetValue/vioSetValue -__USED vioValueXYZ_t vioValueXYZ[VIO_VALUEXYZ_NUM]; // Memory for XYZ value for 3-D vector -__USED vioAddrIPv4_t vioAddrIPv4[VIO_IPV4_ADDRESS_NUM]; // Memory for IPv4 address value used in vioSetIPv4/vioGetIPv4 -__USED vioAddrIPv6_t vioAddrIPv6[VIO_IPV6_ADDRESS_NUM]; // Memory for IPv6 address value used in vioSetIPv6/vioGetIPv6 - -#if !defined CMSIS_VOUT -// Add global user types, variables, functions here: - -#endif - -#if !defined CMSIS_VIN -// Add global user types, variables, functions here: - -#endif - -// Initialize test input, output. -void vioInit (void) { -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - - vioSignalIn = 0U; - vioSignalOut = 0U; - - memset (vioPrintMem, 0, sizeof(vioPrintMem)); - memset (vioValue, 0, sizeof(vioValue)); - memset (vioValueXYZ, 0, sizeof(vioValueXYZ)); - memset (vioAddrIPv4, 0, sizeof(vioAddrIPv4)); - memset (vioAddrIPv6, 0, sizeof(vioAddrIPv6)); - -#if !defined CMSIS_VOUT - // Turn off all LEDs - arm_mps3_io_write_leds(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PORT, 0U, 0U); -#endif - -#if !defined CMSIS_VIN -// Add user code here: - -#endif -} - -// Print formated string to test terminal. -int32_t vioPrint (uint32_t level, const char *format, ...) { - va_list args; - int32_t ret; -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif - - if (level > vioLevelError) { - return (-1); - } - - if (level > VIO_PRINTMEM_NUM) { - return (-1); - } - - va_start(args, format); - - ret = vsnprintf((char *)vioPrintMem[level], sizeof(vioPrintMem[level]), format, args); - - va_end(args); - -#if !defined CMSIS_VOUT -// Add user code here: - -#endif - - return (ret); -} - -// Set signal output. -void vioSetSignal (uint32_t mask, uint32_t signal) { -#if !defined CMSIS_VOUT - uint32_t n; -#endif - - vioSignalOut &= ~mask; - vioSignalOut |= mask & signal; - -#if !defined CMSIS_VOUT - for (n = 0U; n < 8U; n++) { - if (mask & (1U << n)) { - arm_mps3_io_write_leds(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PIN, n, signal & (1U << n)); - } - } -#endif -} - -// Get signal input. -uint32_t vioGetSignal (uint32_t mask) { - uint32_t signal; -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - -#if !defined CMSIS_VIN - vioSignalIn = arm_mps3_io_read_buttons(&MPS3_IO_DEV, ARM_MPS3_IO_ACCESS_PORT, 0); -#endif - - signal = vioSignalIn; - - return (signal & mask); -} - -// Set value output. -void vioSetValue (uint32_t id, int32_t value) { - uint32_t index = id; -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif - - if (index >= VIO_VALUE_NUM) { - return; /* return in case of out-of-range index */ - } - - vioValue[index] = value; - -#if !defined CMSIS_VOUT -// Add user code here: - -#endif -} - -// Get value input. -int32_t vioGetValue (uint32_t id) { - uint32_t index = id; - int32_t value = 0; -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - - if (index >= VIO_VALUE_NUM) { - return value; /* return default in case of out-of-range index */ - } - -#if !defined CMSIS_VIN -// Add user code here: - -// vioValue[index] = ...; -#endif - - value = vioValue[index]; - - return value; -} - -// Set XYZ value output. -void vioSetXYZ (uint32_t id, vioValueXYZ_t valueXYZ) { - uint32_t index = id; -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif - - if (index >= VIO_VALUEXYZ_NUM) { - return; /* return in case of out-of-range index */ - } - - vioValueXYZ[index] = valueXYZ; - -#if !defined CMSIS_VOUT -// Add user code here: - -#endif -} - -// Get XYZ value input. -vioValueXYZ_t vioGetXYZ (uint32_t id) { - uint32_t index = id; - vioValueXYZ_t valueXYZ = {0, 0, 0}; -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - - if (index >= VIO_VALUEXYZ_NUM) { - return valueXYZ; /* return default in case of out-of-range index */ - } - -#if !defined CMSIS_VIN -// Add user code here: - -// vioValueXYZ[index] = ...; -#endif - - valueXYZ = vioValueXYZ[index]; - - return valueXYZ; -} - -// Set IPv4 address output. -void vioSetIPv4 (uint32_t id, vioAddrIPv4_t addrIPv4) { - uint32_t index = id; -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif - - if (index >= VIO_IPV4_ADDRESS_NUM) { - return; /* return in case of out-of-range index */ - } - - vioAddrIPv4[index] = addrIPv4; - -#if !defined CMSIS_VOUT -// Add user code here: - -#endif -} - -// Get IPv4 address input. -vioAddrIPv4_t vioGetIPv4 (uint32_t id) { - uint32_t index = id; - vioAddrIPv4_t addrIPv4 = {0U, 0U, 0U, 0U}; -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - - if (index >= VIO_IPV4_ADDRESS_NUM) { - return addrIPv4; /* return default in case of out-of-range index */ - } - -#if !defined CMSIS_VIN -// Add user code here: - -// vioAddrIPv4[index] = ...; -#endif - - addrIPv4 = vioAddrIPv4[index]; - - return addrIPv4; -} - -// Set IPv6 address output. -void vioSetIPv6 (uint32_t id, vioAddrIPv6_t addrIPv6) { - uint32_t index = id; -#if !defined CMSIS_VOUT -// Add user variables here: - -#endif - - if (index >= VIO_IPV6_ADDRESS_NUM) { - return; /* return in case of out-of-range index */ - } - - vioAddrIPv6[index] = addrIPv6; - -#if !defined CMSIS_VOUT -// Add user code here: - -#endif -} - -// Get IPv6 address input. -vioAddrIPv6_t vioGetIPv6 (uint32_t id) { - uint32_t index = id; - vioAddrIPv6_t addrIPv6 = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, - 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U}; -#if !defined CMSIS_VIN -// Add user variables here: - -#endif - - if (index >= VIO_IPV6_ADDRESS_NUM) { - return addrIPv6; /* return default in case of out-of-range index */ - } - -#if !defined CMSIS_VIN -// Add user code here: - -// vioAddrIPv6[index] = ...; -#endif - - addrIPv6 = vioAddrIPv6[index]; - - return addrIPv6; -} diff --git a/test/data/Hello/Hello.cproject.yml b/test/data/Hello/Hello.cproject.yml deleted file mode 100644 index d5ab83da..00000000 --- a/test/data/Hello/Hello.cproject.yml +++ /dev/null @@ -1,32 +0,0 @@ -project: - -# it is recommended to list the packs that contain the components in the cproject.yml file. - packs: - - pack: ARM::V2M_MPS3_SSE_300_BSP@1.2.0 # optional packs can specify a version - - pack: Keil::ARM_Compiler # for retargeting stdout to UART - - groups: - - group: Documentation - files: - - file: ./README.md - - group: Main - files: - - file: ./main.c - - group: App - files: - - file: ./hello.c - - group: Board IO - files: - - file: ./Board_IO/retarget_stdio.c - - components: - - component: CMSIS:CORE # short form, vendor selected from available packs - - component: ARM::CMSIS:RTOS2:Keil RTX5&Source # long form, vendor explicitly stated - - component: CMSIS Driver:USART - - component: ARM::Native Driver:IO - - component: ARM::Native Driver:UART - - component: Compiler:I/O:STDERR&User - - component: Compiler:I/O:STDIN&User - - component: Compiler:I/O:STDOUT&User - - component: Device:Definition - - component: Device:Startup&Baremetal diff --git a/test/data/Hello/Hello.csolution.yml b/test/data/Hello/Hello.csolution.yml deleted file mode 100644 index 4a0e123a..00000000 --- a/test/data/Hello/Hello.csolution.yml +++ /dev/null @@ -1,26 +0,0 @@ -solution: - created-for: CMSIS-Toolbox@2.0.0 - description: Print Hello World and a counter value via UART - cdefault: - compiler: AC6 # currently required for components Compiler:I/O - -# it is recommended to list the pack or packs that define the device or board used in the csolution.yml file - packs: - - pack: ARM::CMSIS@5.9.0 - - target-types: - - type: AVH # runs on Arm Virtual Hardware - device: ARM::SSE-300-MPS3 - # add more hardware targets (don't forget to add the required packs) - - build-types: # defines toolchain options for 'debug' and 'release' - - type: Release - debug: off - optimize: balanced - - - type: Debug - debug: on - optimize: none - - projects: # list related projects - - project: ./Hello.cproject.yml diff --git a/test/data/Hello/README.md b/test/data/Hello/README.md deleted file mode 100644 index 1922d8b8..00000000 --- a/test/data/Hello/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Hello project - -This project prints "Hello World" and a counter value via the UART output. It is configured for Arm Virtual Hardware, but other target hardware that provides a CMSIS Driver:USART can be easily added. - -## Prerequisites - -### Tools - -- [CMSIS-Toolbox 2.0.0](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/releases) or higher -- [Keil MDK 5.37](https://www2.keil.com/mdk5/) - - Arm Compiler 6.18 (part of MDK, Eval Version sufficient for compilation) - - Arm Virtual Hardware for Corstone-300 v11.18.1 (requires MDK - Professional) - ->**Note:** later versions will also compiler with GCC. - -### Packs - -- Required packs are listed in the file [`Hello.csolution.yml`](./Hello.csolution.yml) and [`Hello.cproject.yml`](./Hello.cproject.yml) - -## Project Structure - -The project is generated using the [CMSIS-Toolbox](https://github.com/Open-CMSIS-Pack/devtools/blob/main/tools/projmgr/docs/Manual/Overview.md) and is defined in [`csolution`](https://github.com/Open-CMSIS-Pack/devtools/blob/main/tools/projmgr/docs/Manual/YML-Format.md) format: - -- [`Hello.csolution.yml`](./Hello.csolution.yml) lists the required packs and defines the hardware target and build-types (along with the compiler). -- [`Hello.cproject.yml`](./Hello.cproject.yml) defines the source files and the software components. - -## Generated Project - -```txt -> cbuild Hello.csolution.yml --packs -``` - ->**Note:** During the build process required packs may be downloaded. - -## Execute Project - -The project is configured for execution on Arm Virtual Hardware which removes the requirement for a physical hardware board. - -- When using MDK-Professional, you may execute it with the command: - - ```txt - > C:/Keil_v5/ARM/VHT/VHT_Corstone_SSE-300_Ethos-U55 -f vht-config.txt -a ./out/Hello/AVH/Debug/Debug+AVH.axf - ``` - -- [Keil Studio Cloud](https://studio.keil.arm.com/) integrates also the Arm Virtual Hardware VHT_Corstone_SSE-300_Ethos-U55 model. The steps to use the example are: - - Start [Keil Studio Cloud](https://studio.keil.arm.com/) and login to the system using your account. - - Use **File - Clone** and enter the URL: (https://github.com/Open-CMSIS-Pack/csolution-examples). Add - - Select from the drop-down *Target hardware*: **Corstone SSE-300 (Cortex-M55, Ethos-U55)** - - Click **Run project** which executes the project build step and then starts running on Arm Virtual Hardware. diff --git a/test/data/Hello/hello.c b/test/data/Hello/hello.c deleted file mode 100644 index 9b4bbfd3..00000000 --- a/test/data/Hello/hello.c +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2020 Arm Limited (or its affiliates). All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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. - * - * Name: Hello.c - * Purpose: Hello World based on RTX - * - *---------------------------------------------------------------------------*/ - -#include "main.h" -#include -#include "cmsis_os2.h" // ::CMSIS:RTOS2 - - -/*--------------------------------------------------------------------------- - * Application main thread - *---------------------------------------------------------------------------*/ - -static int count = 0; - -static void app_main (void *argument) { - (void)argument; - - while (1) { - printf ("Hello World %d\r\n", count); - if (count > 100) printf ("\x04"); // EOT (0x04) stops simulation - count++; - osDelay (1000); - } -} - -/*--------------------------------------------------------------------------- - * Application initialization - *---------------------------------------------------------------------------*/ -void app_initialize (void) { - osThreadNew(app_main, NULL, NULL); -} diff --git a/test/data/Hello/main.c b/test/data/Hello/main.c deleted file mode 100644 index 51e09afa..00000000 --- a/test/data/Hello/main.c +++ /dev/null @@ -1,45 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 "RTE_Components.h" -#include CMSIS_device_header -#include "cmsis_os2.h" -#ifdef RTE_Compiler_EventRecorder -#include "EventRecorder.h" -#endif - -#include "main.h" - -extern int stdio_init (void); - -int main (void) { - stdio_init(); // Initialize stdio - - -#if defined(RTE_Compiler_EventRecorder) && \ - (defined(__MICROLIB) || \ - !(defined(RTE_CMSIS_RTOS2_RTX5) || defined(RTE_CMSIS_RTOS2_FreeRTOS))) - EventRecorderInitialize(EventRecordAll, 1U); -#endif - - osKernelInitialize(); // Initialize CMSIS-RTOS2 - app_initialize(); // Initialize application - osKernelStart(); // Start thread execution - - for (;;) {} -} diff --git a/test/data/Hello/main.h b/test/data/Hello/main.h deleted file mode 100644 index f0d25f99..00000000 --- a/test/data/Hello/main.h +++ /dev/null @@ -1,27 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2020-2021 Arm Limited (or its affiliates). - * All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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. - *---------------------------------------------------------------------------*/ - -#ifndef MAIN_H__ -#define MAIN_H__ - -#include - -/* Prototypes */ -extern void app_initialize (void); - -#endif diff --git a/test/data/build-asm/solution.csolution.yml b/test/data/build-asm/solution.csolution.yml index 7672cd9c..2c8cfb32 100644 --- a/test/data/build-asm/solution.csolution.yml +++ b/test/data/build-asm/solution.csolution.yml @@ -17,8 +17,8 @@ solution: - type: GCC compiler: GCC - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/data/build-c/solution.csolution.yml b/test/data/build-c/solution.csolution.yml index 992edef2..03925585 100644 --- a/test/data/build-c/solution.csolution.yml +++ b/test/data/build-c/solution.csolution.yml @@ -21,8 +21,8 @@ solution: - -lm - -lc - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/data/build-cpp/solution.csolution.yml b/test/data/build-cpp/solution.csolution.yml index 5014957d..b95b8dfc 100644 --- a/test/data/build-cpp/solution.csolution.yml +++ b/test/data/build-cpp/solution.csolution.yml @@ -17,8 +17,8 @@ solution: - type: GCC compiler: GCC - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/data/include-define/solution.csolution.yml b/test/data/include-define/solution.csolution.yml index 7672cd9c..2c8cfb32 100644 --- a/test/data/include-define/solution.csolution.yml +++ b/test/data/include-define/solution.csolution.yml @@ -17,8 +17,8 @@ solution: - type: GCC compiler: GCC - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/data/linker-pre-processing/solution.csolution.yml b/test/data/linker-pre-processing/solution.csolution.yml index e58a6431..b2a7aa5b 100644 --- a/test/data/linker-pre-processing/solution.csolution.yml +++ b/test/data/linker-pre-processing/solution.csolution.yml @@ -17,8 +17,8 @@ solution: - type: GCC compiler: GCC - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/data/pre-include/solution.csolution.yml b/test/data/pre-include/solution.csolution.yml index be94a6af..f078e696 100644 --- a/test/data/pre-include/solution.csolution.yml +++ b/test/data/pre-include/solution.csolution.yml @@ -19,8 +19,8 @@ solution: - type: GCC compiler: GCC - - type: IAR - compiler: IAR + # - type: IAR + # compiler: IAR - type: CLANG compiler: CLANG diff --git a/test/resources/utils.resource b/test/resources/utils.resource index 35ffd77f..bf0e7b53 100644 --- a/test/resources/utils.resource +++ b/test/resources/utils.resource @@ -1,6 +1,7 @@ *** Settings *** Documentation A resource file with reusable keywords and variables. Library Process +Library OperatingSystem *** Keywords *** Run Program @@ -10,7 +11,12 @@ Run Program Run Keyword If '${result.rc}' != '${expected_ret_code}' Log Many Output: ${result.stdout} Return Code: ${result.rc} Should Be Equal '${result.rc}' '${expected_ret_code}' -Run csolution +Run cbuild [Documentation] Run csolution example with specified arguments [Arguments] ${input_file} @{args} - Run Program cbuild ${input_file} @{args} \ No newline at end of file + Run Program cbuild ${input_file} @{args} -p -r --update-rte + +Copy Directory with Content + [Documentation] Recursively copy context from source to destination + [Arguments] ${src_dir} ${dst_dir} + Copy Directory ${src_dir} ${dst_dir} diff --git a/test/src/test.robot b/test/src/test.robot index 0ffcb77f..9587fe1d 100644 --- a/test/src/test.robot +++ b/test/src/test.robot @@ -1,23 +1,40 @@ *** Settings *** Documentation Test to execute csolution example Suite Setup Suite Setup +Suite Teardown Suite Teardown Resource ${RESOURCES}/utils.resource -Library Process Test Template Run csolution examples *** Variables *** -${RESOURCES} ../resources +${RESOURCES} ..${/}resources -*** Test Cases *** ${input_file} ${args} -Run Hello example ${testDataDir}/Hello${/}Hello.csolution.yml -p -r --update-rte +*** Test Cases *** ${input_file} ${args} +Run build-asm ${testDataDir}/build-asm${/}solution.csolution.yml +Run build-c cbuild2cmake ${testDataDir}/build-c${/}solution.csolution.yml +Run build-cpp ${testDataDir}/build-cpp${/}solution.csolution.yml +# Run include-define ${testDataDir}/include-define${/}solution.csolution.yml +Run linker-pre-processing ${testDataDir}/linker-pre-processing${/}solution.csolution.yml +Run pre-include ${testDataDir}/pre-include${/}solution.csolution.yml + + +Run build-asm cbuild2cmake ${testDataDir}${/}build-asm${/}solution.csolution.yml --cbuild2cmake +Run build-c cbuild2cmake ${testDataDir}/build-c${/}solution.csolution.yml --cbuild2cmake +Run build-cpp cbuild2cmake ${testDataDir}/build-cpp${/}solution.csolution.yml --cbuild2cmake +Run linker-pre-processing cbuild2cmake ${testDataDir}/linker-pre-processing${/}solution.csolution.yml --cbuild2cmake +Run pre-include cbuild2cmake ${testDataDir}/pre-include${/}solution.csolution.yml --cbuild2cmake *** Keywords *** Run csolution examples - [Arguments] ${input_file} @{args} - Run csolution ${input_file} @{args} + [Arguments] ${input_file} @{args} + Run cbuild ${input_file} @{args} Suite Setup - Set Global Variable ${testDataDir} ${CURDIR}${/}..${/}data${/} + ${source_directory} Set Variable ${CURDIR}${/}..${/}data + Set Global Variable ${testDataDir} ${source_directory}${/}..${/}run + Copy Directory with Content ${source_directory} ${testDataDir} + +Suite Teardown + Remove Directory ${testDataDir} recursive=True diff --git a/test/vcpkg-configuration.json b/test/vcpkg-configuration.json index 80746868..72b29dd9 100644 --- a/test/vcpkg-configuration.json +++ b/test/vcpkg-configuration.json @@ -14,7 +14,9 @@ "requires": { "microsoft:cmake": "^3.25.2", "microsoft:ninja": "^1.10.2", - "arm:compilers/arm/armclang":"^6.20.0", - "arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.0.0-0", + "arm:compilers/arm/armclang":"^6.21.0", + "arm:compilers/arm/arm-none-eabi-gcc": "^13.2.1", + "arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.3.0", + "arm:compilers/arm/llvm-embedded": "^17.0.1" } } From a78894cd2c1dd6349498cc9b67681e69a73af28c Mon Sep 17 00:00:00 2001 From: Sourabh Mehta Date: Thu, 11 Apr 2024 15:12:16 +0200 Subject: [PATCH 4/5] cleanup --- test/resources/utils.resource | 16 ++++++-- test/src/test.robot | 69 +++++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/test/resources/utils.resource b/test/resources/utils.resource index bf0e7b53..c6fdf63e 100644 --- a/test/resources/utils.resource +++ b/test/resources/utils.resource @@ -16,7 +16,15 @@ Run cbuild [Arguments] ${input_file} @{args} Run Program cbuild ${input_file} @{args} -p -r --update-rte -Copy Directory with Content - [Documentation] Recursively copy context from source to destination - [Arguments] ${src_dir} ${dst_dir} - Copy Directory ${src_dir} ${dst_dir} +Change Directory Permissions + [Documentation] Change directory permissions + [Arguments] ${target_dir} + ${result} Run Process chmod -R 755 ${target_dir} + Should Be Equal ${result.rc} ${0} + +Remove Directory with Content + [Documentation] Remove directory and its content from target directory + [Arguments] ${target_dir} + Change Directory Permissions ${target_dir} + Remove Directory ${target_dir} recursive=${True} + Wait Until Removed ${target_dir} timeout=5 seconds diff --git a/test/src/test.robot b/test/src/test.robot index 9587fe1d..7a5df265 100644 --- a/test/src/test.robot +++ b/test/src/test.robot @@ -1,30 +1,41 @@ *** Settings *** -Documentation Test to execute csolution example -Suite Setup Suite Setup -Suite Teardown Suite Teardown -Resource ${RESOURCES}/utils.resource -Test Template Run csolution examples - +Documentation Test to execute solution examples +Suite Setup Suite Setup +Suite Teardown Suite Teardown +Resource ${RESOURCES}/utils.resource +# Test Template Run csolution examples +Library Collections *** Variables *** -${RESOURCES} ..${/}resources - - -*** Test Cases *** ${input_file} ${args} -Run build-asm ${testDataDir}/build-asm${/}solution.csolution.yml -Run build-c cbuild2cmake ${testDataDir}/build-c${/}solution.csolution.yml -Run build-cpp ${testDataDir}/build-cpp${/}solution.csolution.yml -# Run include-define ${testDataDir}/include-define${/}solution.csolution.yml -Run linker-pre-processing ${testDataDir}/linker-pre-processing${/}solution.csolution.yml -Run pre-include ${testDataDir}/pre-include${/}solution.csolution.yml - - -Run build-asm cbuild2cmake ${testDataDir}${/}build-asm${/}solution.csolution.yml --cbuild2cmake -Run build-c cbuild2cmake ${testDataDir}/build-c${/}solution.csolution.yml --cbuild2cmake -Run build-cpp cbuild2cmake ${testDataDir}/build-cpp${/}solution.csolution.yml --cbuild2cmake -Run linker-pre-processing cbuild2cmake ${testDataDir}/linker-pre-processing${/}solution.csolution.yml --cbuild2cmake -Run pre-include cbuild2cmake ${testDataDir}/pre-include${/}solution.csolution.yml --cbuild2cmake - +${RESOURCES} ..${/}resources +@{build_examples} build-asm build-c build-cpp linker-pre-processing pre-include +@{build_files} solution solution solution solution solution + +*** Test Cases *** +Build Examples with cbuildgen + FOR ${example} IN @{build_examples} + ${index}= Get Index From List ${build_examples} ${example} + Run cbuild ${testDataDir}${/}${example}${/}${build_files}[${index}].csolution.yml + END + +Build Examples with cbuild2cmake + FOR ${example} IN @{build_examples} + ${index}= Get Index From List ${build_examples} ${example} + Run cbuild ${testDataDir}${/}${example}${/}${build_files}[${index}].csolution.yml --cbuild2cmake + END +# Run build-asm ${testDataDir}${/}build-asm${/}solution.csolution.yml +# Run build-c ${testDataDir}/build-c${/}solution.csolution.yml +# Run build-cpp ${testDataDir}/build-cpp${/}solution.csolution.yml +# # Run include-define ${testDataDir}/include-define${/}solution.csolution.yml +# Run linker-pre-processing ${testDataDir}/linker-pre-processing${/}solution.csolution.yml +# Run pre-include ${testDataDir}/pre-include${/}solution.csolution.yml + + +# Run build-asm cbuild2cmake ${testDataDir}${/}build-asm${/}solution.csolution.yml --cbuild2cmake +# Run build-c cbuild2cmake ${testDataDir}/build-c${/}solution.csolution.yml --cbuild2cmake +# Run build-cpp cbuild2cmake ${testDataDir}/build-cpp${/}solution.csolution.yml --cbuild2cmake +# Run linker-pre-processing cbuild2cmake ${testDataDir}/linker-pre-processing${/}solution.csolution.yml --cbuild2cmake +# Run pre-include cbuild2cmake ${testDataDir}/pre-include${/}solution.csolution.yml --cbuild2cmake *** Keywords *** Run csolution examples @@ -32,9 +43,11 @@ Run csolution examples Run cbuild ${input_file} @{args} Suite Setup - ${source_directory} Set Variable ${CURDIR}${/}..${/}data - Set Global Variable ${testDataDir} ${source_directory}${/}..${/}run - Copy Directory with Content ${source_directory} ${testDataDir} + ${parent_dir}= Join Path ${CURDIR} .. + ${src_dir}= Join Path ${parent_dir} data + ${dest_dir}= Join Path ${parent_dir} run + Set Global Variable ${testDataDir} ${dest_dir} + Copy Directory ${src_dir} ${testDataDir} Suite Teardown - Remove Directory ${testDataDir} recursive=True + Remove Directory with Content ${testDataDir} From e694e6239cc7fbdbf90fdc0cd17011c88fa44986 Mon Sep 17 00:00:00 2001 From: Sourabh Mehta Date: Mon, 15 Apr 2024 13:34:28 +0200 Subject: [PATCH 5/5] trial --- .github/workflows/robot-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/robot-tests.yml b/.github/workflows/robot-tests.yml index fe3ccd3d..90d0cc8c 100644 --- a/.github/workflows/robot-tests.yml +++ b/.github/workflows/robot-tests.yml @@ -17,7 +17,6 @@ jobs: runs-on: ubuntu-latest env: CMSIS_PACK_ROOT: /home/runner/.cache/arm/packs - steps: - uses: actions/checkout@v4