scripts: tests: update genpinctrl tests

Update genpinctrl unit tests to match latest changes.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2020-11-22 19:15:13 +01:00 committed by Kumar Gala
parent cfa91174ff
commit 79a847bf2b
10 changed files with 85 additions and 23 deletions

View File

@ -1,2 +1,3 @@
pytest~=6.0
pytest-cov~=2.10
pytest-cov~=2.10
pytest-mock~=3.3

View File

@ -15,6 +15,6 @@ def data():
@pytest.fixture()
def cubemx(data):
"""Pytest fixture to load test CubeMX files"""
return data / "cubemx"
def pindata(data):
"""Pytest fixture to load test STM32 Open Pin Data files"""
return data / "pindata"

View File

@ -0,0 +1,46 @@
*-pinctrl.dtsi generated files
##############################
Origin:
Generated
Status:
Generated using STM32 Open Pin Data
Purpose:
SoC package specific -pintrl.dtsi files
Description:
This directory contains *-pcintrl.dtsi files generated using generation
script (available under scripts/genpinctrl) along with inputs from
STM32 Open Pin Data database.
Each file matches a STM32 SoC package and contains, for each pin of the
package the exhaustive list of pinctrl configurations depending on its
capabilities and the various pin configurations described in
scripts/genpinctrl/stm32*-pinctrl-config.yaml files.
New set of files could be generated based on:
- new version of STM32 Open Pin Data
- new version of stm32*-pinctrl-config.yaml files
Dependencies:
* STM32 Open Pin Data
* Generation script available in current repo under scripts/genpinctrl
and configuration files.
URL:
https://github.com/STMicroelectronics/STM32_open_pin_data
Commit:
TEST
Maintained-by:
External
License:
Generated files fall under license Apache-2.0
License Link:
https://www.apache.org/licenses/LICENSE-2.0
Patch List:
None

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<IP xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<IP xmlns="http://dummy.com">
<GPIO_Pin PortName="PA" Name="PA0">
<!-- Signal without "SpecificParameter" entry -->
<PinSignal Name="TEST_SIGNAL_INVALID1">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<IP xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<IP xmlns="http://dummy.com">
<GPIO_Pin PortName="PA" Name="PA0">
<!-- Invalid signal (no remaps) -->
<PinSignal Name="TEST_SIGNAL_INVALID1">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Mcu Family="STM32F0" RefName="STM32F0TESTDIE" xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<Mcu Family="STM32F0" RefName="STM32F0TESTDIE" xmlns="http://dummy.com">
<IP Name="GPIO" Version="STM32F0TESTIP"/>
<!-- Non I/O pin -->
<Pin Name="PZ0" Type="Power">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Mcu Family="STM32F0" RefName="STM32F0TESTDIE2" xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<Mcu Family="STM32F0" RefName="STM32F0TESTDIE2" xmlns="http://dummy.com">
<!-- Non existing IP -->
<IP Name="GPIO" Version="NON_EXISTING_IP"/>
</Mcu>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Mcu Family="TEST_FAMILY" RefName="STM32F0TESTDIE1" xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<Mcu Family="TEST_FAMILY" RefName="STM32F0TESTDIE1" xmlns="http://dummy.com">
<!-- File without GPIO IP entry -->
<IP Name="X" Version="Y"/>
</Mcu>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Mcu Family="STM32F1" RefName="STM32F1TESTDIE" xmlns="http://mcd.rou.st.com/modules.php?name=mcu">
<Mcu Family="STM32F1" RefName="STM32F1TESTDIE" xmlns="http://dummy.com">
<IP Name="GPIO" Version="STM32F1TESTIP"/>
<!-- Valid pin -->
<Pin Name="PA0" Type="I/O">

View File

@ -154,10 +154,12 @@ def test_format_remap():
format_remap(5)
def test_get_gpio_ip_afs(cubemx):
"""Test that IP AF files part of test CubeMX files are parsed correctly."""
def test_get_gpio_ip_afs(pindata):
"""Test that IP AF files part of test STM32 Open Pin Data files are parsed
correctly.
"""
afs = get_gpio_ip_afs(cubemx)
afs = get_gpio_ip_afs(pindata)
assert afs == {
"STM32F0TESTIP": {
"PA0": {
@ -174,11 +176,11 @@ def test_get_gpio_ip_afs(cubemx):
}
def test_get_mcu_signals(cubemx):
"""Test that MCU files part of test CubeMX are parsed correctly."""
def test_get_mcu_signals(pindata):
"""Test that MCU files part of test STM32 Open Pin Data are parsed correctly."""
afs = get_gpio_ip_afs(cubemx)
signals = get_mcu_signals(cubemx, afs)
afs = get_gpio_ip_afs(pindata)
signals = get_mcu_signals(pindata, afs)
assert signals == {
"STM32F0": [
{
@ -219,8 +221,10 @@ def test_get_mcu_signals(cubemx):
}
def test_cubemx_missing():
"""Test that missing CubeMX folders is handled correctly by parsing functions."""
def test_folders_missing():
"""Test that missing STM32 Open Pin Data folders is handled correctly by
parsing functions.
"""
with pytest.raises(FileNotFoundError):
get_gpio_ip_afs(Path("MISSING_PATH"))
@ -229,14 +233,25 @@ def test_cubemx_missing():
get_mcu_signals(Path("MISSING_PATH"), dict())
def test_main(data, cubemx, tmp_path):
def test_main(data, pindata, tmp_path, mocker):
"""Test that DTS files are generated correctly."""
main(cubemx, tmp_path)
mocker.patch("genpinctrl.check_output", return_value=b"TEST")
main(pindata, tmp_path)
# check readme file
ref_readme_file = data / "README.md"
gen_readme_file = tmp_path / "README.md"
assert gen_readme_file.exists()
with open(ref_readme_file) as ref, open(gen_readme_file) as gen:
assert ref.read() == gen.read()
# check f0 file
ref_pinctrl_file = data / "stm32f0testdie-pinctrl.dtsi"
gen_pinctrl_file = tmp_path / "f0" / "stm32f0testdie-pinctrl.dtsi"
gen_pinctrl_file = tmp_path / "st" / "f0" / "stm32f0testdie-pinctrl.dtsi"
assert gen_pinctrl_file.exists()
@ -245,7 +260,7 @@ def test_main(data, cubemx, tmp_path):
# check f1 file
ref_pinctrl_file = data / "stm32f1testdie-pinctrl.dtsi"
gen_pinctrl_file = tmp_path / "f1" / "stm32f1testdie-pinctrl.dtsi"
gen_pinctrl_file = tmp_path / "st" / "f1" / "stm32f1testdie-pinctrl.dtsi"
assert gen_pinctrl_file.exists()