Skip to content

Commit

Permalink
Fix: bug fixed
Browse files Browse the repository at this point in the history
bug fixed
  • Loading branch information
stanley31huang committed Dec 12, 2023
1 parent 9e37e76 commit ca08b26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
7 changes: 4 additions & 3 deletions checkbox-provider-ce-oem/bin/check_vpu_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def determine_expected_imx_vpu(soc_type, kernel_version):
"Supported VPU devices for {} is not defined".format(soc_type))

major_ver, minor_ver = kernel_version.split(".")
if int(major_ver) >= 5 and int(minor_ver) >= 15:
if int(major_ver) > 5 or (int(major_ver) == 5 and int(minor_ver) >= 15):
expected_devices.remove("ion")

return expected_devices
Expand Down Expand Up @@ -198,11 +198,12 @@ def check_mtk_vpu_devices():
"mtk-vcodec-dec", "mtk-vcodec-enc", "mtk-mdp[0-9]*:m2m"]

check_result = []
for dev_name in get_v4l2_devices():
for pattern in expected_device_pattern:
for pattern in expected_device_pattern:
for dev_name in get_v4l2_devices():
if re.search(pattern, dev_name):
check_result.append(dev_name)
logging.info("VPU %s device detected", dev_name)
break

if len(check_result) == len(expected_device_pattern):
logging.info("# VPU devices check: Passed")
Expand Down
23 changes: 13 additions & 10 deletions checkbox-provider-ce-oem/tests/test_check_vpu_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_imx_chip_mismatch(self):
):
check_vpu_device.determine_expected_imx_vpu("i.MX8MX", "5.4")

@mock.patch("os.listdir")
@mock.patch("pathlib.Path.iterdir")
@mock.patch("check_vpu_device.get_soc_id")
@mock.patch("check_vpu_device.get_kernel_version")
@mock.patch("check_vpu_device.determine_expected_imx_vpu")
Expand All @@ -186,9 +186,11 @@ def test_imx8mm_vpu_device_exist(
mock_expected_imx_vpu.return_value = expected_imx_vpus
mock_kernel_ver.return_value = "5.4"
mock_soc_id.return_value = "i.MX8MM"
mock_listdir.return_value = [
"tty1", "ion", "mxc_hantro", "mxc_hantro_h1"
]
mock_result = [mock.Mock(), mock.Mock(), mock.Mock()]
mock_result[0].name = "ion"
mock_result[1].name = "mxc_hantro"
mock_result[2].name = "mxc_hantro_h1"
mock_listdir.return_value = mock_result

with self.assertLogs() as lc:
check_vpu_device.check_imx_vpu_devices()
Expand All @@ -198,7 +200,7 @@ def test_imx8mm_vpu_device_exist(
prefix.format(value), lc.output[index])
self.assertIn("# VPU devices check: Passed", lc.output[-1])

@mock.patch("os.listdir")
@mock.patch("pathlib.Path.iterdir")
@mock.patch("check_vpu_device.get_soc_id")
@mock.patch("check_vpu_device.get_kernel_version")
@mock.patch("check_vpu_device.determine_expected_imx_vpu")
Expand All @@ -216,9 +218,10 @@ def test_imx8mm_vpu_device_not_exist(
mock_expected_imx_vpu.return_value = [
"ion", "mxc_hantro", "mxc_hantro_h1"
]
mock_listdir.return_value = [
"tty1", "ion", "mxc_hantro"
]
mock_result = [mock.Mock(), mock.Mock()]
mock_result[0].name = "ion"
mock_result[1].name = "mxc_hantro"
mock_listdir.return_value = mock_result

with self.assertRaises(SystemExit), \
self.assertLogs(level="ERROR") as lc:
Expand All @@ -241,8 +244,8 @@ def test_mtk_vpu_devices(self, mock_v4l2_devices):
]
expected_devices = [
"mtk-vcodec-dec",
"mtk-mdp:m2m",
"mtk-vcodec-enc"
"mtk-vcodec-enc",
"mtk-mdp:m2m"
]
prefix = "INFO:root:VPU {} device detected"

Expand Down

0 comments on commit ca08b26

Please sign in to comment.