Skip to content

Commit

Permalink
[WIP] Add tests for the 'robot2' framework
Browse files Browse the repository at this point in the history
These tests works only this branch:
https://github.com/tiacsys/zephyr/tree/snks/robot-twister-int
See also: zephyrproject-rtos/zephyr#64825

Signed-off-by: Kerstin Jenett <[email protected]>
  • Loading branch information
Kerstin20 committed Feb 16, 2024
1 parent cea4890 commit 5c2e91c
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 0 deletions.
15 changes: 15 additions & 0 deletions samples/robot2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2021-2023 TiaC Systems
# Copyright (c) 2019-2021 Li-Pro.Net
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

# Standard Bridle application boilerplate, includes Zephyr.
find_package(Bridle REQUIRED HINTS $ENV{BRIDLE_BASE})
project("Robot Test" VERSION 0.1)

assert(CONFIG_SHELL "Zephyr's embedded shell must be enabled")

# Add your source file to the "app" target. This must come after
# the boilerplate code, which defines the target.
target_sources(app PRIVATE src/main.c)
72 changes: 72 additions & 0 deletions samples/robot2/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _robot_framework:

Robot Framework
###############

Overview
********

A sample how you can use the Robot Framework without Renode to run
tests on a development board.

Requirements
************

* Checkout the branch "snks/robot-twister-int" from the Zephyr
repository in case it is not merged into main.

https://github.com/tiacsys/zephyr/tree/snks/robot-twister-int
* Install the Robot Framework using pip:

.. code-block:: console
pip install robotframework
* One of the following development boards:

* :ref:`zephyr:nucleo_f303re_board` (NUCLEO-F303RE)
* :ref:`zephyr:nucleo_f401re_board` (NUCLEO-F401RE)
* :ref:`zephyr:mimxrt1060_evk`

Building and Running
********************

* On :ref:`zephyr:nucleo_f303re_board` board run the following command:

.. code-block:: console
west twister --verbose --inline-logs --platform nucleo_f303re \
--testsuite-root bridle/samples/robot2 \
--device-testing --device-serial /dev/ttyACM0
* On :ref:`zephyr:nucleo_f401re_board` board run the following command:

.. code-block:: console
west twister --verbose --inline-logs --platform nucleo_f401re \
--testsuite-root bridle/samples/robot2 \
--device-testing --device-serial /dev/ttyACM0
* On :ref:`zephyr:mimxrt1060_evk` or MIMXRT1060_EVKB board run the
following command:

.. code-block:: console
west twister --verbose --inline-logs --west-flash --west-runner=pyocd \
--platform mimxrt1060_evkb --testsuite-root bridle/samples/robot2 \
--device-testing --device-serial /dev/ttyACM0
Sample output
=============

The log, report and output files from the Robot Framework can be found
in the 'twister_out' folder, e.g:

.. code-block:: console
ls twister-out/*2023*
twister-out/log*.html
twister-out/output*.xml
twister-out/report*.html
18 changes: 18 additions & 0 deletions samples/robot2/boards/mimxrt1060_evkb.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2021-2023 TiaC Systems
* SPDX-License-Identifier: Apache-2.0
*
* disable unsupported components or components with issues
*
*/

/* FLEXPWM not routed to LED on this EVK revision, thus why board DTS
* disables &flexpwm2_pwm3 but neither related &pwmleds node nor alias. */

/ {
aliases {
/delete-property/ pwm-led0;
};

/delete-node/ pwmleds;
};
18 changes: 18 additions & 0 deletions samples/robot2/boards/nucleo_f401re.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2021-2023 TiaC Systems
* SPDX-License-Identifier: Apache-2.0
*
* disable unsupported components or components with issues
*
*/

/* FLEXPWM not routed to LED on this EVK revision, thus why board DTS
* disables &flexpwm2_pwm3 but neither related &pwmleds node nor alias. */

/ {
aliases {
/delete-property/ pwm-led0;
};

/delete-node/ pwmleds;
};
57 changes: 57 additions & 0 deletions samples/robot2/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) 2021-2023 TiaC Systems
# Copyright (c) 2019-2021 Li-Pro.Net
# SPDX-License-Identifier: Apache-2.0

# Multi-threaded, with timer support in the kernel
CONFIG_MULTITHREADING=y
CONFIG_NUM_COOP_PRIORITIES=16
CONFIG_NUM_METAIRQ_PRIORITIES=0

CONFIG_ERRNO=y
CONFIG_SCHED_DUMB=y
CONFIG_WAITQ_DUMB=y

# shell with log, kernel, and device commands
CONFIG_BOOT_BANNER=y
CONFIG_PRINTK=y
CONFIG_SHELL=y
CONFIG_LOG=y
CONFIG_KERNEL_SHELL=y
CONFIG_INIT_STACKS=y
CONFIG_THREAD_MONITOR=y
CONFIG_THREAD_NAME=y
CONFIG_THREAD_STACK_INFO=y
CONFIG_DEVICE_SHELL=y

# shell with hwinfo, regulator, and counter commands
CONFIG_HWINFO=y
CONFIG_HWINFO_SHELL=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_SHELL=y
CONFIG_COUNTER=y
CONFIG_COUNTER_SHELL=y

# shell with flash, led, and sensor commands
CONFIG_FLASH=y
CONFIG_FLASH_SHELL=y
CONFIG_LED=y
CONFIG_LED_SHELL=y
CONFIG_SENSOR=y
CONFIG_SENSOR_INFO=y
CONFIG_SENSOR_SHELL=y

# shell with adc, dac, pwm, gpio, and i2c commands
CONFIG_ADC=y
CONFIG_ADC_SHELL=y
CONFIG_DAC=y
CONFIG_DAC_SHELL=y
CONFIG_PWM=y
CONFIG_PWM_SHELL=y
CONFIG_GPIO=y
CONFIG_GPIO_SHELL=y
CONFIG_I2C=y
CONFIG_I2C_SHELL=y

# Bridle secific configuration
CONFIG_BRIDLE_COMMANDS=y
CONFIG_BRIDLE_CMD_HELLO=y
21 changes: 21 additions & 0 deletions samples/robot2/robot/led_module.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Documentation This robot example runs some commands on the connected board
... (e.g.nucleo_f303re, nucleo_f401re, mimxrt1060_evkb). It uses
... the space separated plain text format.
Library twister_harness.robot_framework.ZephyrLibrary
Suite Setup Get a Device
Suite Teardown Close Device

*** Variables ***
${CMD_LED_ON} led on leds 0
${LED_0} 0

*** Test Cases ***
Should Set Led On
[Documentation] Test that the led can be switched on.
[Tags] SWRQT-LED_RQT SYSRQT-LED_SYSTEM_RQT
Run Device
Run Command ${CMD_LED_ON}
34 changes: 34 additions & 0 deletions samples/robot2/robot/shell_module.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Documentation This robot example runs some commands on the connected board
... (e.g.nucleo_f303re, nucleo_f401re, mimxrt1060_evkb). It uses
... the space separated plain text format.
Library twister_harness.robot_framework.ZephyrLibrary
Suite Setup Get a Device
Suite Teardown Close Device

*** Variables ***
${CMD_KERNEL_VERSION} kernel version
${RSP_ZEPHYR_VERSION} Zephyr version 3.5.99
${CMD_DEVICE_LIST} device list
${RSP_I2C_0005400} i2c@40005400 (READY)
${CMD_SCAN_I2C} i2c scan i2c@40005400
${RSP_SCAN_I2C} devices found on i2c@40005400

*** Test Cases ***
Should Read Version
[Documentation] Test that the Zephyr version is correct.
... ${RSP_ZEPHYR_VERSION}
[Tags] SWRQT-VERSION_RQT SWRQT-OTHER_RQT SYSRQT-VERSION_SYSTEM_RQT
Run Device
Run Command ${CMD_KERNEL_VERSION}

Check I2C Interface
[Documentation] Test that the I2C bus is configured.
... ${RSP_I2C_0005400}
[Tags] SWRQT-I2C_RQT SYSRQT-I2C_SYSTEM_RQT
Run Command ${CMD_DEVICE_LIST}
Run Command ${CMD_SCAN_I2C}
20 changes: 20 additions & 0 deletions samples/robot2/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sample:
description: Robot Framework sample to test uart and led on a device
name: robot2 tests
common:
tags: introduction
integration_platforms:
- nucleo_f303re
- nucleo_f401re
- mimxrt1060_evkb
tests:
bridle.samples.robot2:
harness: robot2
platform_allow:
- nucleo_f401re
- mimxrt1060_evkb
timeout: 300
tags:
- test_framework
- robot
- shell
12 changes: 12 additions & 0 deletions samples/robot2/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2021-2023 TiaC Systems
* Copyright (c) 2019-2021 Li-Pro.Net
* Copyright (c) 2012-2014 Wind River Systems, Inc.
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/init.h>

/* Empty main */
int main(void) {return 0;}
Loading

0 comments on commit 5c2e91c

Please sign in to comment.