ci: migrate peripherals ttfw test scripts

This commit is contained in:
Fu Hanxi 2023-04-06 12:21:21 +08:00
parent b19b4c8e47
commit 1be18d4bc5
8 changed files with 170 additions and 172 deletions

View File

@ -246,6 +246,7 @@
- "components/driver/include/driver/sdio*.h"
- "components/driver/include/driver/sdmmc*.h"
- "components/sdmmc/**/*"
- "examples/peripherals/sdio/**/*"
# for jobs: component_ut_pytest_sdio related
.patterns-component_ut-sdio: &patterns-component_ut-sdio

View File

@ -97,6 +97,22 @@ pytest_examples_esp32_jtag:
SETUP_TOOLS: "1" # need gdb openocd
PYTEST_EXTRA_FLAGS: "--log-cli-level DEBUG"
pytest_examples_esp32_ccs811:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32
needs:
- build_pytest_examples_esp32
tags: [ esp32, ccs811 ]
pytest_examples_esp32_sdio:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32-sdio
needs:
- build_pytest_examples_esp32
tags: [ esp32, sdio_master_slave ]
pytest_examples_esp32s2_generic:
extends:
- .pytest_examples_dir_template
@ -1098,12 +1114,6 @@ example_test_001C:
- ESP32
- Example_GENERIC
.example_test_003:
extends: .example_test_esp32_template
tags:
- ESP32
- Example_SDIO
example_test_005:
extends:
- .example_test_esp32_template
@ -1112,12 +1122,6 @@ example_test_005:
- ESP32
- Example_WIFI_BT
example_test_007:
extends: .example_test_esp32_template
tags:
- ESP32
- Example_I2C_CCS811_SENSOR
example_test_C3_GENERIC:
extends: .example_test_esp32c3_template
tags:

View File

@ -122,6 +122,7 @@ ENV_MARKERS = {
'psramv0': 'Runner with PSRAM version 0',
'esp32eco3': 'Runner with esp32 eco3 connected',
'ecdsa_efuse': 'Runner with test ECDSA private keys programmed in efuse',
'ccs811': 'Runner with CCS811 connected',
# multi-dut markers
'ieee802154': 'ieee802154 related tests should run on ieee802154 runners.',
'openthread_br': 'tests should be used for openthread border router.',

View File

@ -165,10 +165,18 @@ examples/peripherals/sdio/host:
- if: IDF_TARGET == "esp32"
temporary: true
reason: Only the SDSPI of ESP32 supports ESP SDIO slave for now
disable_test:
- if: IDF_TARGET != "esp32"
temporary: true
reason: lack of runners
examples/peripherals/sdio/slave:
disable:
- if: SOC_SDIO_SLAVE_SUPPORTED != 1
disable_test:
- if: IDF_TARGET != "esp32"
temporary: true
reason: lack of runners
examples/peripherals/secure_element/atecc608_ecdsa:
enable:

View File

@ -1,37 +0,0 @@
from __future__ import print_function
import ttfw_idf
EXPECT_TIMEOUT = 20
@ttfw_idf.idf_example_test(env_tag='Example_I2C_CCS811_SENSOR')
def test_i2ctools_example(env, extra_data):
# Get device under test, flash and start example. "i2ctool" must be defined in EnvConfig
dut = env.get_dut('i2ctools', 'examples/peripherals/i2c/i2c_tools', dut_class=ttfw_idf.ESP32DUT)
dut.start_app()
dut.expect('i2c-tools>', timeout=EXPECT_TIMEOUT)
# Get i2c address
dut.write('i2cdetect')
dut.expect('5b', timeout=EXPECT_TIMEOUT)
# Get chip ID
dut.write('i2cget -c 0x5b -r 0x20 -l 1')
dut.expect('0x81', timeout=EXPECT_TIMEOUT)
# Reset sensor
dut.write('i2cset -c 0x5b -r 0xFF 0x11 0xE5 0x72 0x8A')
dut.expect('OK', timeout=EXPECT_TIMEOUT)
# Get status
dut.write('i2cget -c 0x5b -r 0x00 -l 1')
dut.expect_any('0x10', timeout=EXPECT_TIMEOUT)
# Change work mode
dut.write('i2cset -c 0x5b -r 0xF4')
dut.expect('OK', timeout=EXPECT_TIMEOUT)
dut.write('i2cset -c 0x5b -r 0x01 0x10')
dut.expect('OK', timeout=EXPECT_TIMEOUT)
# Get new status
dut.write('i2cget -c 0x5b -r 0x00 -l 1')
dut.expect_any('0x98', '0x90', timeout=EXPECT_TIMEOUT)
if __name__ == '__main__':
test_i2ctools_example()

View File

@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded_idf import IdfDut
EXPECT_TIMEOUT = 20
@pytest.mark.esp32
@pytest.mark.ccs811
def test_i2ctools_example(dut: IdfDut) -> None:
dut.expect_exact('i2c-tools>', timeout=EXPECT_TIMEOUT)
# Get i2c address
dut.write('i2cdetect')
dut.expect_exact('5b', timeout=EXPECT_TIMEOUT)
# Get chip ID
dut.write('i2cget -c 0x5b -r 0x20 -l 1')
dut.expect_exact('0x81', timeout=EXPECT_TIMEOUT)
# Reset sensor
dut.write('i2cset -c 0x5b -r 0xFF 0x11 0xE5 0x72 0x8A')
dut.expect_exact('OK', timeout=EXPECT_TIMEOUT)
# Get status
dut.write('i2cget -c 0x5b -r 0x00 -l 1')
dut.expect_exact('0x10', timeout=EXPECT_TIMEOUT)
# Change work mode
dut.write('i2cset -c 0x5b -r 0xF4')
dut.expect_exact('OK', timeout=EXPECT_TIMEOUT)
dut.write('i2cset -c 0x5b -r 0x01 0x10')
dut.expect_exact('OK', timeout=EXPECT_TIMEOUT)
# Get new status
dut.write('i2cget -c 0x5b -r 0x00 -l 1')
dut.expect_exact(['0x98', '0x90'], timeout=EXPECT_TIMEOUT)

View File

@ -0,0 +1,112 @@
# SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import os
from typing import Tuple
import pytest
from pytest_embedded_idf import IdfDut
@pytest.mark.esp32
@pytest.mark.sdio_master_slave
@pytest.mark.parametrize(
'count, app_path',
[
(2, f'{os.path.join(os.path.dirname(__file__), "host")}|{os.path.join(os.path.dirname(__file__), "slave")}'),
],
indirect=True,
)
def test_example_sdio_communication(dut: Tuple[IdfDut, IdfDut]) -> None:
"""
Configurations
host = host -> slave = slave
should be in the same group of devices, otherwise may meet download issue
group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier)
group2: (Wrover module: WroverKit v3)
GPIO14->GPIO14
GPIO15->GPIO15
GPIO2->GPIO2
GPIO4->GPIO4
GND->GND
VDD3.3 -> GPIO13 if slave uses WroverKit v3
or use sdio test board, which has two wrover modules connect to a same FT3232
Assume that first dut is host and second is slave
"""
host = dut[0]
slave = dut[1]
host.pexpect_proc.timeout = 5
slave.pexpect_proc.timeout = 5
host.expect_exact('host ready, start initializing slave...')
host.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
host.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67')
host.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
host.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb')
slave.expect_exact('================ JOB_WRITE_REG ================')
slave.expect_exact('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
slave.expect_exact('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 5e 61 64 67')
slave.expect_exact('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
slave.expect_exact('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb')
host.expect_exact('host int: 0')
host.expect_exact('host int: 1')
host.expect_exact('host int: 2')
host.expect_exact('host int: 3')
host.expect_exact('host int: 4')
host.expect_exact('host int: 5')
host.expect_exact('host int: 6')
host.expect_exact('host int: 7')
host.expect_exact('host int: 0')
host.expect_exact('host int: 1')
host.expect_exact('host int: 2')
host.expect_exact('host int: 3')
host.expect_exact('host int: 4')
host.expect_exact('host int: 5')
host.expect_exact('host int: 6')
host.expect_exact('host int: 7')
slave.expect_exact('================ JOB_SEND_INT ================')
slave.expect_exact('================ JOB_SEND_INT ================')
host.expect_exact('send packet length: 6')
host.expect_exact('send packet length: 12')
host.expect_exact('send packet length: 1024')
host.expect_exact('send packet length: 512')
host.expect_exact('send packet length: 3')
slave.expect_exact('Packet received, len: 6')
slave.expect_exact('Buffer 0, len: 6')
slave.expect_exact('Packet received, len: 12')
slave.expect_exact('Buffer 0, len: 12')
# 1024
slave.expect_exact('Packet received, len: 1024')
for i in range(8):
slave.expect_exact(f'Buffer {i}, len: 128')
# 512
slave.expect_exact('Packet received, len: 512')
for i in range(4):
slave.expect_exact(f'Buffer {i}, len: 128')
# 3
slave.expect_exact('Packet received, len: 3')
slave.expect_exact('Buffer 0, len: 3')
# same as slave received
host.expect_exact('receive data, size: 6')
host.expect_exact('receive data, size: 12')
for _ in range(8):
host.expect_exact('receive data, size: 128')
for _ in range(4):
host.expect_exact('receive data, size: 128')
host.expect_exact('receive data, size: 3')
# the last valid line of one round
host.expect_exact('aa af b4')
# the first 2 lines of the second round
host.expect_exact('46 4b 50 55 5a 5f')
host.expect_exact('6e 73 78 7d 82 87 8c 91 96 9b a0 a5')

View File

@ -1,123 +0,0 @@
# Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ttfw_idf
from tiny_test_fw import TinyFW
@ttfw_idf.idf_example_test(env_tag='Example_SDIO', ignore=True)
def test_example_sdio_communication(env, extra_data):
"""
Configurations
dut1 = host -> dut2 = slave
should be in the same group of devices, otherwise may meet download issue
group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier)
group2: (Wrover module: WroverKit v3)
GPIO14->GPIO14
GPIO15->GPIO15
GPIO2->GPIO2
GPIO4->GPIO4
GND->GND
VDD3.3 -> GPIO13 if dut2 uses WroverKit v3
or use sdio test board, which has two wrover modules connect to a same FT3232
Assume that first dut is host and second is slave
"""
dut1 = env.get_dut('sdio_host', 'examples/peripherals/sdio/host', dut_class=ttfw_idf.ESP32DUT)
dut2 = env.get_dut('sdio_slave', 'examples/peripherals/sdio/slave', dut_class=ttfw_idf.ESP32DUT)
dut1.start_app()
# wait until the master is ready to setup the slave
dut1.expect('host ready, start initializing slave...')
dut2.start_app()
dut1.expect('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
dut1.expect('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00')
dut1.expect('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
dut1.expect('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7')
dut2.expect('================ JOB_WRITE_REG ================')
dut2.expect('0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37')
dut2.expect('3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00')
dut2.expect('6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97')
dut2.expect('9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7')
dut1.expect('host int: 0')
dut1.expect('host int: 1')
dut1.expect('host int: 2')
dut1.expect('host int: 3')
dut1.expect('host int: 4')
dut1.expect('host int: 5')
dut1.expect('host int: 6')
dut1.expect('host int: 7')
dut1.expect('host int: 0')
dut1.expect('host int: 1')
dut1.expect('host int: 2')
dut1.expect('host int: 3')
dut1.expect('host int: 4')
dut1.expect('host int: 5')
dut1.expect('host int: 6')
dut1.expect('host int: 7')
dut2.expect('================ JOB_SEND_INT ================')
dut2.expect('================ JOB_SEND_INT ================')
dut1.expect('send packet length: 3')
dut1.expect('send packet length: 6')
dut1.expect('send packet length: 12')
dut1.expect('send packet length: 128')
dut1.expect('send packet length: 511')
dut1.expect('send packet length: 512')
dut2.expect('recv len: 3')
dut2.expect('recv len: 6')
dut2.expect('recv len: 12')
dut2.expect('recv len: 128')
# 511
dut2.expect('recv len: 128')
dut2.expect('recv len: 128')
dut2.expect('recv len: 128')
dut2.expect('recv len: 127')
# 512
dut2.expect('recv len: 128')
dut2.expect('recv len: 128')
dut2.expect('recv len: 128')
dut2.expect('recv len: 128')
dut1.expect('receive data, size: 3')
dut1.expect('receive data, size: 6')
dut1.expect('receive data, size: 12')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 127')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
dut1.expect('receive data, size: 128')
# the last valid line of one round
dut1.expect('ce d3 d8 dd e2 e7 ec f1 f6 fb 00 05 0a 0f 14 19')
# the first 2 lines of the second round
dut1.expect('46 4b 50')
dut1.expect('5a 5f 64 69 6e 73')
if __name__ == '__main__':
TinyFW.set_default_config(env_config_file='EnvConfigTemplate.yml', dut=ttfw_idf.IDFDUT)
test_example_sdio_communication()