forked from canonical/checkbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cover smaller genio tests (New) (canonical#1060)
* Formatted dvfs test and removed typos * Added test for dvfs_gpu_check_governors * Raise SystemExit only on fail * Added serialcheck tests * Fixed Error raise when stdout is empty * Added spidev test * Added pmic regulator tests * Fixed errors in linux_ccf - Moved check_env_variables to function so the module can be imported without requiring them - Added choices for devices considered in the test - Test failing with wrong verify output * Added linux ccf tests * Update contrib/genio/bin/spidev_test.py Co-authored-by: kissiel <[email protected]> --------- Co-authored-by: kissiel <[email protected]>
- Loading branch information
Showing
9 changed files
with
584 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import unittest | ||
from unittest.mock import mock_open, patch | ||
import dvfs_gpu_check_governors as dvfs | ||
|
||
|
||
class TestDvfsGpuCheckGovernors(unittest.TestCase): | ||
|
||
def test_all_expected_governors(self): | ||
# Test when all expected governors are present | ||
governors = "userspace powersave performance simple_ondemand" | ||
with patch("builtins.open", mock_open(read_data=governors)): | ||
result = dvfs.test_sysfs_attrs_read("mt8365") | ||
self.assertEqual(result, 0) | ||
|
||
with patch("builtins.open", mock_open(read_data=governors)): | ||
result = dvfs.test_sysfs_attrs_read("mt8364") | ||
self.assertEqual(result, 0) | ||
|
||
def test_unexpected_governor(self): | ||
# Test when an unexpected governor is present | ||
governors = "userspace powersave performance unexpected_governor" | ||
with patch("builtins.open", mock_open(read_data=governors)): | ||
result = dvfs.test_sysfs_attrs_read("mt8365") | ||
self.assertEqual(result, 1) | ||
|
||
@patch("builtins.open", mock_open(read_data="")) | ||
def test_empty_file(self): | ||
# Test when the file is empty | ||
governors = "" | ||
with patch("builtins.open", mock_open(read_data=governors)): | ||
result = dvfs.test_sysfs_attrs_read("mt8365") | ||
self.assertEqual(result, 0) | ||
|
||
@patch("dvfs_gpu_check_governors.test_sysfs_attrs_read") | ||
def test_main(self, mock_attrs_read): | ||
mock_attrs_read.return_value = 0 | ||
with patch("sys.argv", ["script_name", "mt8395"]): | ||
result = dvfs.main() | ||
self.assertEqual(mock_attrs_read.call_count, 1) | ||
self.assertEqual(result, None) | ||
|
||
@patch("dvfs_gpu_check_governors.test_sysfs_attrs_read") | ||
def test_main_bad_args(self, mock_attrs_read): | ||
with patch("sys.argv", ["script_name", "bad_soc"]): | ||
with self.assertRaises(SystemExit): | ||
dvfs.main() | ||
self.assertEqual(mock_attrs_read.call_count, 0) | ||
|
||
@patch("dvfs_gpu_check_governors.test_sysfs_attrs_read") | ||
def test_main_wrong_attrs(self, mock_attrs_read): | ||
mock_attrs_read.return_value = 1 | ||
with patch("sys.argv", ["script_name", "mt8395"]): | ||
with self.assertRaises(SystemExit): | ||
dvfs.main() | ||
self.assertEqual(mock_attrs_read.call_count, 1) |
Oops, something went wrong.