Skip to content

Commit

Permalink
Set up genio pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando79513 committed Mar 19, 2024
1 parent ade5369 commit f1af9cb
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 55 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/tox-contrib-genio.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
name: Test provider-genio (from contrib area) with tox

on:
push:
branches: [ main ]
paths:
- contrib/genio/**
pull_request:
branches: [ main ]
paths:
- contrib/genio/**
workflow_dispatch:

jobs:
tox_test_contrib_ce_oem_provider:
tox_test_genio_provider:
continue-on-error: true
name: Test Genio provider (from contrib area) with tox
defaults:
Expand Down Expand Up @@ -37,4 +45,4 @@ jobs:
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: contrib-provider-genio
flags: provider-base
2 changes: 1 addition & 1 deletion contrib/genio/bin/set_as_performance_mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ get_current_setting() {
for i in {0..2}
do
# shellcheck disable=SC2027
echo "- /sys/class/thermal/thermal_zone0/trip_point_"$i"_temp"
echo "- /sys/class/thermal/thermal_zone0/trip_point_""$i""_temp"
cat /sys/class/thermal/thermal_zone0/trip_point_"$i"_temp
done
elif [ "${1}" == "G350" ]; then
Expand Down
11 changes: 11 additions & 0 deletions contrib/genio/bin/test_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

output=$(tr -d '\0' < /proc/device-tree/compatible)
# Set comma as delimiter
IFS=','
read -ra output_arr <<< "$output"
# Set dash as delimiter
IFS='-'
read -ra s <<< "${output_arr[1]}"
echo "SoC: ${s[0]}"
echo
2 changes: 1 addition & 1 deletion contrib/genio/bin/verify-mt8188-ccf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if [ "${NR_MISSING_CLKS}" -ne "0" ]; then
printf "[-] Missing clocks: \n"
cat missing-clocks.txt

printf "\n[-] Count missing clocks: "${NR_MISSING_CLKS}"\n"
printf "\n[-] Count missing clocks: %s\n" "${NR_MISSING_CLKS}"
else
printf "[-] Success, all clocks are mapped !\n"
fi
Expand Down
2 changes: 1 addition & 1 deletion contrib/genio/bin/verify-mt8195-ccf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if [ "${NR_MISSING_CLKS}" -ne "0" ]; then
printf "[-] Missing clocks: \n"
cat missing-clocks.txt

printf "\n[-] Count missing clocks: "${NR_MISSING_CLKS}"\n"
printf "\n[-] Count missing clocks: %s\n" "${NR_MISSING_CLKS}"
else
printf "[-] Success, all clocks are mapped !\n"
fi
Expand Down
24 changes: 16 additions & 8 deletions contrib/genio/tests/test_boot_partition.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import unittest
from unittest.mock import patch, MagicMock
import boot_partition as bp
Expand All @@ -15,7 +16,14 @@ def test_runcmd(self, mock_run):
)
result = bp.runcmd("echo Hello")

mock_run.assert_called_once()
mock_run.assert_called_once_with(
"echo Hello",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
timeout=1,
)
self.assertEqual(result.stdout, "output")
self.assertEqual(result.stderr, "error")
self.assertEqual(result.returncode, 0)
Expand All @@ -35,8 +43,8 @@ def test_check_is_block_device(self, mock_is_block_device):
@patch("boot_partition.TestPartedBootDevice.check_partitions")
def test_check_disk(self, mock_cp, mock_css):
self.pbd.check_disk()
self.pbd.check_sector_size.assert_called_once()
self.pbd.check_partitions.assert_called_once()
self.pbd.check_sector_size.assert_called_once_with()
self.pbd.check_partitions.assert_called_once_with()

@patch("boot_partition.runcmd")
def test_get_disk_information(self, mock_runcmd):
Expand Down Expand Up @@ -172,9 +180,9 @@ def test_main_with_path(
with patch("sys.argv", args):
self.pbd.main()
mock_check_dev.assert_not_called()
mock_is_block.assert_called_once()
mock_get_disk.assert_called_once()
mock_check_disk.assert_called_once()
mock_is_block.assert_called_once_with()
mock_get_disk.assert_called_once_with()
mock_check_disk.assert_called_once_with()

@patch("boot_partition.TestPartedBootDevice.check_device")
@patch("boot_partition.TestPartedBootDevice.check_is_block_device")
Expand All @@ -183,7 +191,7 @@ def test_main_check_device(self, mock_is_block, mock_check_dev):
args = ["script_name", "--check_device_name"]
with patch("sys.argv", args):
self.pbd.main()
mock_check_dev.assert_called_once()
mock_check_dev.assert_called_once_with(False)
mock_is_block.assert_not_called()

@patch("boot_partition.TestPartedBootDevice.check_device")
Expand All @@ -197,4 +205,4 @@ def test_main_check_device_with_exit(self, mock_is_block):
mock_is_block.side_effect = SystemExit
with self.assertRaises(SystemExit):
with patch("sys.argv", args):
self.pbd.main()
self.pbd.main()
9 changes: 7 additions & 2 deletions contrib/genio/tests/test_cpu_idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def test_mt8365_cases(

def test_main_cases(self):
cases = {
"wfi": "test_wfi",
"mcdi-cpu": "test_mcdi_cpu",
"mcdi-cluster": "test_mcdi_cluster",
"dpidle": "test_dpidle",
Expand All @@ -254,12 +253,18 @@ def test_main_cases(self):
"cpuoff-b": "test_cpuoff_b",
}

args = ["soc", "mt8395", "--case", "wfi"]
with patch("cpu_idle.test_wfi") as mock_test:
with patch("sys.argv", args):
cpu.main()
mock_test.assert_called_once_with()

for case, func in cases.items():
args = ["soc", "mt8395", "--case", case]
with patch("cpu_idle." + func) as mock_test:
with patch("sys.argv", args):
cpu.main()
mock_test.assert_called_once()
mock_test.assert_called_once_with("mt8395")

@patch("cpu_idle.test_wfi", return_value=None)
def test_main_wrong_soc(self, mock_test_wfi):
Expand Down
1 change: 1 addition & 0 deletions contrib/genio/tests/test_dvfs_gpu_check_governors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ def test_main_wrong_attrs(self, mock_attrs_read):
with self.assertRaises(SystemExit):
dvfs.main()
self.assertEqual(mock_attrs_read.call_count, 1)
self.assertEqual(mock_attrs_read.call_count, 1)
9 changes: 8 additions & 1 deletion contrib/genio/tests/test_serialcheck.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import unittest
from unittest.mock import patch, MagicMock
import serialcheck as sc
Expand All @@ -12,7 +13,13 @@ def test_runcmd(self, mock_run):
)
result = sc.runcmd("echo Hello")

mock_run.assert_called_once()
mock_run.assert_called_once_with(
"echo Hello",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
)
self.assertEqual(result.stdout, "output")
self.assertEqual(result.stderr, "error")
self.assertEqual(result.returncode, 0)
Expand Down
10 changes: 9 additions & 1 deletion contrib/genio/tests/test_spidev.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import unittest
from unittest.mock import patch, MagicMock
import spidev_test as spidev
Expand All @@ -12,7 +13,14 @@ def test_runcmd(self, mock_run):
)
result = spidev.runcmd("echo Hello")

mock_run.assert_called_once()
mock_run.assert_called_once_with(
"echo Hello",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
timeout=1,
)
self.assertEqual(result.stdout, "output")
self.assertEqual(result.stderr, "error")
self.assertEqual(result.returncode, 0)
Expand Down
10 changes: 6 additions & 4 deletions contrib/genio/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ commands =
# Required because this provider depends on checkbox-support parsers & scripts
{envpython} -m pip -q install ../../checkbox-support
rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-resource.provider
rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-base.provider
# Required because this provider depends on the resource and base providers
# Required because this provider depends on the resource provider
{envpython} ../../providers/resource/manage.py develop
{envpython} ../../providers/base/manage.py develop
{envpython} manage.py develop
{envpython} manage.py validate
{envpython} -m coverage run manage.py test
Expand All @@ -22,6 +20,7 @@ commands =

[testenv:py35]
deps =
pytest
flake8
coverage == 5.5
natsort == 4.0.3
Expand All @@ -41,6 +40,7 @@ setenv=

[testenv:py36]
deps =
pytest
flake8
coverage == 5.5
natsort == 4.0.3
Expand All @@ -56,6 +56,7 @@ deps =

[testenv:py38]
deps =
pytest
flake8
coverage == 7.3.0
natsort == 7.0.1
Expand All @@ -71,6 +72,7 @@ deps =

[testenv:py310]
deps =
pytest
flake8
coverage == 7.3.0
natsort == 8.0.2
Expand All @@ -82,4 +84,4 @@ deps =
tqdm == 4.57.0
pyparsing == 2.4.7
distro == 1.7.0
PyYAML == 6.0.1
PyYAML == 6.0.1
4 changes: 2 additions & 2 deletions contrib/genio/units/device/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ command:
output=$(tr -d '\0' < /proc/device-tree/compatible)
# Set comma as delimiter
IFS=','
read -a output_arr <<< "$output"
read -ra output_arr <<< "$output"
# Set dash as delimiter
IFS='-'
read -a s <<< "${output_arr[1]}"
read -ra s <<< "${output_arr[1]}"
echo "SoC: ${s[0]}"
echo
2 changes: 1 addition & 1 deletion contrib/genio/units/graphic/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ _purpose:
The resolution of glmark2-es2-wayland is 1920x1080
command:
set -e
output=$(glmark2-es2-wayland -s 1920x1080 --data-path $SNAP/usr/share/glmark2)
output=$(glmark2-es2-wayland -s 1920x1080 --data-path "$SNAP"/usr/share/glmark2)
echo "$output"
if ! echo "$output" | grep "GL_VENDOR" | grep -q "ARM"; then
echo "FAIL: Wrong vendor!"
Expand Down
Loading

0 comments on commit f1af9cb

Please sign in to comment.