amd-debug-tools 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of amd-debug-tools might be problematic. Click here for more details.
- amd_debug/common.py +24 -0
- amd_debug/display.py +34 -0
- amd_debug/installer.py +36 -4
- amd_debug/prerequisites.py +84 -46
- amd_debug/s2idle.py +25 -10
- {amd_debug_tools-0.2.0.dist-info → amd_debug_tools-0.2.1.dist-info}/METADATA +1 -1
- amd_debug_tools-0.2.1.dist-info/RECORD +45 -0
- {amd_debug_tools-0.2.0.dist-info → amd_debug_tools-0.2.1.dist-info}/WHEEL +1 -1
- amd_debug_tools-0.2.1.dist-info/top_level.txt +18 -0
- launcher.py +35 -0
- test_acpi.py +90 -0
- test_batteries.py +92 -0
- test_bios.py +250 -0
- test_common.py +332 -0
- test_database.py +284 -0
- test_display.py +143 -0
- test_failures.py +146 -0
- test_installer.py +279 -0
- test_kernel.py +205 -0
- test_launcher.py +53 -0
- test_prerequisites.py +1769 -0
- test_pstate.py +164 -0
- test_s2idle.py +833 -0
- test_sleep_report.py +167 -0
- test_validator.py +725 -0
- test_wake.py +216 -0
- amd_debug_tools-0.2.0.dist-info/RECORD +0 -27
- amd_debug_tools-0.2.0.dist-info/top_level.txt +0 -1
- {amd_debug_tools-0.2.0.dist-info → amd_debug_tools-0.2.1.dist-info}/entry_points.txt +0 -0
- {amd_debug_tools-0.2.0.dist-info → amd_debug_tools-0.2.1.dist-info}/licenses/LICENSE +0 -0
test_display.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
This module contains unit tests for the display functions in the amd-debug-tools package.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import unittest
|
|
10
|
+
from unittest.mock import patch, MagicMock
|
|
11
|
+
from amd_debug.display import Display
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TestDisplay(unittest.TestCase):
|
|
15
|
+
"""Unit tests for the Display class in amd-debug-tools"""
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def setUpClass(cls):
|
|
19
|
+
logging.basicConfig(filename="/dev/null", level=logging.DEBUG)
|
|
20
|
+
|
|
21
|
+
@patch("amd_debug.display.Context")
|
|
22
|
+
@patch("amd_debug.display.read_file")
|
|
23
|
+
@patch("os.path.exists")
|
|
24
|
+
def test_display_initialization(self, mock_exists, mock_read_file, mock_context):
|
|
25
|
+
"""Test the Display class initialization and EDID retrieval"""
|
|
26
|
+
# Mock the pyudev Context and its list_devices method
|
|
27
|
+
mock_device = MagicMock()
|
|
28
|
+
mock_device.device_path = "/devices/card0"
|
|
29
|
+
mock_device.sys_path = "/sys/devices/card0"
|
|
30
|
+
mock_device.sys_name = "card0"
|
|
31
|
+
mock_context.return_value.list_devices.return_value = [mock_device]
|
|
32
|
+
|
|
33
|
+
# Mock os.path.exists and read_file behavior
|
|
34
|
+
mock_exists.side_effect = lambda path: "status" in path or "enabled" in path
|
|
35
|
+
mock_read_file.side_effect = lambda path: (
|
|
36
|
+
"connected" if "status" in path else "enabled"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Initialize the Display class
|
|
40
|
+
display = Display()
|
|
41
|
+
|
|
42
|
+
# Verify the EDID paths are correctly set
|
|
43
|
+
expected_edid = {"card0": "/sys/devices/card0/edid"}
|
|
44
|
+
self.assertEqual(display.get_edid(), expected_edid)
|
|
45
|
+
mock_context.assert_called_once()
|
|
46
|
+
|
|
47
|
+
@patch("amd_debug.display.Context")
|
|
48
|
+
def test_no_connected_displays(self, mock_context):
|
|
49
|
+
"""Test the Display class when no connected displays are found"""
|
|
50
|
+
# Mock the pyudev Context to return no devices
|
|
51
|
+
mock_context.return_value.list_devices.return_value = []
|
|
52
|
+
|
|
53
|
+
# Initialize the Display class
|
|
54
|
+
display = Display()
|
|
55
|
+
|
|
56
|
+
# Verify the EDID dictionary is empty
|
|
57
|
+
self.assertEqual(display.get_edid(), {})
|
|
58
|
+
|
|
59
|
+
@patch("amd_debug.display.Context")
|
|
60
|
+
def test_device_without_card(self, mock_context):
|
|
61
|
+
"""Test the Display class with a device that does not have 'card' in the name"""
|
|
62
|
+
# Mock the pyudev Context to return a device without 'card' in the name
|
|
63
|
+
mock_device = MagicMock()
|
|
64
|
+
mock_device.device_path = "/devices/other_device"
|
|
65
|
+
mock_device.sys_path = "/sys/devices/other_device"
|
|
66
|
+
mock_device.sys_name = "other_device"
|
|
67
|
+
mock_context.return_value.list_devices.return_value = [mock_device]
|
|
68
|
+
|
|
69
|
+
# Initialize the Display class
|
|
70
|
+
display = Display()
|
|
71
|
+
|
|
72
|
+
# Verify the EDID dictionary is empty
|
|
73
|
+
self.assertEqual(display.get_edid(), {})
|
|
74
|
+
|
|
75
|
+
@patch("amd_debug.display.Context")
|
|
76
|
+
@patch("amd_debug.display.read_file")
|
|
77
|
+
@patch("os.path.exists")
|
|
78
|
+
def test_device_not_enabled(self, mock_exists, mock_read_file, mock_context):
|
|
79
|
+
"""Test the Display class with a device that is not enabled"""
|
|
80
|
+
# Mock the pyudev Context to return a device that is not enabled
|
|
81
|
+
mock_device = MagicMock()
|
|
82
|
+
mock_device.device_path = "/devices/card0"
|
|
83
|
+
mock_device.sys_path = "/sys/devices/card0"
|
|
84
|
+
mock_device.sys_name = "card0"
|
|
85
|
+
mock_context.return_value.list_devices.return_value = [mock_device]
|
|
86
|
+
|
|
87
|
+
# Mock os.path.exists and read_file behavior
|
|
88
|
+
mock_exists.side_effect = lambda path: "status" in path or "enabled" in path
|
|
89
|
+
mock_read_file.side_effect = lambda path: (
|
|
90
|
+
"connected" if "status" in path else "disabled"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Initialize the Display class
|
|
94
|
+
display = Display()
|
|
95
|
+
|
|
96
|
+
# Verify the EDID dictionary is empty
|
|
97
|
+
self.assertEqual(display.get_edid(), {})
|
|
98
|
+
|
|
99
|
+
@patch("amd_debug.display.Context")
|
|
100
|
+
@patch("amd_debug.display.read_file")
|
|
101
|
+
@patch("os.path.exists")
|
|
102
|
+
def test_missing_status_file(self, mock_exists, mock_read_file, mock_context):
|
|
103
|
+
"""Test the Display class when the status file is missing"""
|
|
104
|
+
# Mock the pyudev Context to return a device with a missing status file
|
|
105
|
+
mock_device = MagicMock()
|
|
106
|
+
mock_device.device_path = "/devices/card0"
|
|
107
|
+
mock_device.sys_path = "/sys/devices/card0"
|
|
108
|
+
mock_device.sys_name = "card0"
|
|
109
|
+
mock_context.return_value.list_devices.return_value = [mock_device]
|
|
110
|
+
|
|
111
|
+
# Mock os.path.exists to return False for the status file
|
|
112
|
+
mock_exists.side_effect = lambda path: "enabled" in path
|
|
113
|
+
mock_read_file.side_effect = lambda path: "enabled" if "enabled" in path else ""
|
|
114
|
+
|
|
115
|
+
# Initialize the Display class
|
|
116
|
+
display = Display()
|
|
117
|
+
|
|
118
|
+
# Verify the EDID dictionary is empty
|
|
119
|
+
self.assertEqual(display.get_edid(), {})
|
|
120
|
+
|
|
121
|
+
@patch("amd_debug.display.Context")
|
|
122
|
+
@patch("amd_debug.display.read_file")
|
|
123
|
+
@patch("os.path.exists")
|
|
124
|
+
def test_status_not_connected(self, mock_exists, mock_read_file, mock_context):
|
|
125
|
+
"""Test the Display class when the status file does not indicate connected"""
|
|
126
|
+
# Mock the pyudev Context to return a device with a status file that does not indicate connected
|
|
127
|
+
mock_device = MagicMock()
|
|
128
|
+
mock_device.device_path = "/devices/card0"
|
|
129
|
+
mock_device.sys_path = "/sys/devices/card0"
|
|
130
|
+
mock_device.sys_name = "card0"
|
|
131
|
+
mock_context.return_value.list_devices.return_value = [mock_device]
|
|
132
|
+
|
|
133
|
+
# Mock os.path.exists and read_file behavior
|
|
134
|
+
mock_exists.side_effect = lambda path: "status" in path or "enabled" in path
|
|
135
|
+
mock_read_file.side_effect = lambda path: (
|
|
136
|
+
"not_connected" if "status" in path else "enabled"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Initialize the Display class
|
|
140
|
+
display = Display()
|
|
141
|
+
|
|
142
|
+
# Verify the EDID dictionary is empty
|
|
143
|
+
self.assertEqual(display.get_edid(), {})
|
test_failures.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
This module contains unit tests for the failure functions in the amd-debug-tools package.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from unittest.mock import patch, call
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import unittest
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
import amd_debug.failures
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestFailures(unittest.TestCase):
|
|
18
|
+
"""Test failure functions"""
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def setUpClass(cls):
|
|
22
|
+
logging.basicConfig(filename="/dev/null", level=logging.DEBUG)
|
|
23
|
+
|
|
24
|
+
@patch("builtins.print")
|
|
25
|
+
def test_failures(self, mocked_print):
|
|
26
|
+
"""Test failure functions"""
|
|
27
|
+
|
|
28
|
+
cls = amd_debug.failures.RtcAlarmWrong()
|
|
29
|
+
self.assertEqual(
|
|
30
|
+
cls.get_description(), "rtc_cmos is not configured to use ACPI alarm"
|
|
31
|
+
)
|
|
32
|
+
self.assertEqual(
|
|
33
|
+
str(cls),
|
|
34
|
+
"Some problems can occur during wakeup cycles if the HPET RTC "
|
|
35
|
+
"emulation is used to wake systems. This can manifest in unexpected "
|
|
36
|
+
"wakeups or high power consumption.For more information on this failure "
|
|
37
|
+
"see:https://github.com/systemd/systemd/issues/24279",
|
|
38
|
+
)
|
|
39
|
+
cls = amd_debug.failures.MissingAmdgpu()
|
|
40
|
+
self.assertEqual(cls.get_description(), "AMDGPU driver is missing")
|
|
41
|
+
cls = amd_debug.failures.MissingAmdgpuFirmware(["foo", "bar"])
|
|
42
|
+
self.assertEqual(cls.get_description(), "AMDGPU firmware is missing")
|
|
43
|
+
cls = amd_debug.failures.AmdgpuPpFeatureMask()
|
|
44
|
+
self.assertEqual(cls.get_description(), "AMDGPU ppfeaturemask changed")
|
|
45
|
+
cls = amd_debug.failures.MissingAmdPmc()
|
|
46
|
+
self.assertEqual(cls.get_description(), "AMD-PMC driver is missing")
|
|
47
|
+
cls = amd_debug.failures.MissingThunderbolt()
|
|
48
|
+
self.assertEqual(cls.get_description(), "thunderbolt driver is missing")
|
|
49
|
+
cls = amd_debug.failures.MissingXhciHcd()
|
|
50
|
+
self.assertEqual(cls.get_description(), "xhci_hcd driver is missing")
|
|
51
|
+
cls = amd_debug.failures.MissingDriver("4")
|
|
52
|
+
self.assertEqual(cls.get_description(), "4 driver is missing")
|
|
53
|
+
cls = amd_debug.failures.AcpiBiosError("5")
|
|
54
|
+
self.assertEqual(cls.get_description(), "ACPI BIOS Errors detected")
|
|
55
|
+
cls = amd_debug.failures.UnsupportedModel()
|
|
56
|
+
self.assertEqual(cls.get_description(), "Unsupported CPU model")
|
|
57
|
+
cls = amd_debug.failures.UserNvmeConfiguration()
|
|
58
|
+
self.assertEqual(cls.get_description(), "NVME ACPI support is disabled")
|
|
59
|
+
cls = amd_debug.failures.AcpiNvmeStorageD3Enable("foo", 2)
|
|
60
|
+
self.assertEqual(cls.get_description(), "foo missing ACPI attributes")
|
|
61
|
+
cls = amd_debug.failures.DevSlpHostIssue()
|
|
62
|
+
self.assertEqual(
|
|
63
|
+
cls.get_description(), "AHCI controller doesn't support DevSlp"
|
|
64
|
+
)
|
|
65
|
+
cls = amd_debug.failures.DevSlpDiskIssue()
|
|
66
|
+
self.assertEqual(cls.get_description(), "SATA disk doesn't support DevSlp")
|
|
67
|
+
cls = amd_debug.failures.SleepModeWrong()
|
|
68
|
+
self.assertEqual(
|
|
69
|
+
cls.get_description(),
|
|
70
|
+
"The system hasn't been configured for Modern Standby in BIOS setup",
|
|
71
|
+
)
|
|
72
|
+
cls = amd_debug.failures.DeepSleep()
|
|
73
|
+
self.assertEqual(
|
|
74
|
+
cls.get_description(),
|
|
75
|
+
"The kernel command line is asserting the system to use deep sleep",
|
|
76
|
+
)
|
|
77
|
+
cls = amd_debug.failures.FadtWrong()
|
|
78
|
+
self.assertEqual(
|
|
79
|
+
cls.get_description(),
|
|
80
|
+
"The kernel didn't emit a message that low power idle was supported",
|
|
81
|
+
)
|
|
82
|
+
cls = amd_debug.failures.Irq1Workaround()
|
|
83
|
+
self.assertEqual(
|
|
84
|
+
cls.get_description(),
|
|
85
|
+
"The wakeup showed an IRQ1 wakeup source, which might be a platform firmware bug",
|
|
86
|
+
)
|
|
87
|
+
cls = amd_debug.failures.KernelRingBufferWrapped()
|
|
88
|
+
self.assertEqual(cls.get_description(), "Kernel ringbuffer has wrapped")
|
|
89
|
+
cls = amd_debug.failures.AmdHsmpBug()
|
|
90
|
+
self.assertEqual(cls.get_description(), "amd-hsmp built in to kernel")
|
|
91
|
+
cls = amd_debug.failures.WCN6855Bug()
|
|
92
|
+
self.assertEqual(
|
|
93
|
+
cls.get_description(),
|
|
94
|
+
"The firmware loaded for the WCN6855 causes spurious wakeups",
|
|
95
|
+
)
|
|
96
|
+
cls = amd_debug.failures.I2CHidBug("touchpad", "block")
|
|
97
|
+
self.assertEqual(
|
|
98
|
+
cls.get_description(),
|
|
99
|
+
"The touchpad device has been reported to cause high power consumption and spurious wakeups",
|
|
100
|
+
)
|
|
101
|
+
cls = amd_debug.failures.SpuriousWakeup(1, 0)
|
|
102
|
+
self.assertEqual(
|
|
103
|
+
cls.get_description(), "Userspace wasn't asleep at least 0:00:01"
|
|
104
|
+
)
|
|
105
|
+
cls = amd_debug.failures.LowHardwareSleepResidency(5, 30)
|
|
106
|
+
self.assertEqual(
|
|
107
|
+
cls.get_description(), "System had low hardware sleep residency"
|
|
108
|
+
)
|
|
109
|
+
cls = amd_debug.failures.MSRFailure()
|
|
110
|
+
self.assertEqual(cls.get_description(), "PC6 or CC6 state disabled")
|
|
111
|
+
cls = amd_debug.failures.TaintedKernel()
|
|
112
|
+
self.assertEqual(cls.get_description(), "Kernel is tainted")
|
|
113
|
+
cls = amd_debug.failures.DMArNotEnabled()
|
|
114
|
+
self.assertEqual(cls.get_description(), "Pre-boot DMA protection disabled")
|
|
115
|
+
cls = amd_debug.failures.MissingIommuACPI("foo")
|
|
116
|
+
self.assertEqual(cls.get_description(), "Device foo missing from ACPI tables")
|
|
117
|
+
cls = amd_debug.failures.MissingIommuPolicy("foo")
|
|
118
|
+
self.assertEqual(
|
|
119
|
+
cls.get_description(), "Device foo does not have IOMMU policy applied"
|
|
120
|
+
)
|
|
121
|
+
cls = amd_debug.failures.IommuPageFault("foo")
|
|
122
|
+
self.assertEqual(cls.get_description(), "Page fault reported for foo")
|
|
123
|
+
cls = amd_debug.failures.SMTNotEnabled()
|
|
124
|
+
self.assertEqual(cls.get_description(), "SMT is not enabled")
|
|
125
|
+
cls = amd_debug.failures.ASpmWrong()
|
|
126
|
+
self.assertEqual(cls.get_description(), "ASPM is overridden")
|
|
127
|
+
cls = amd_debug.failures.UnservicedGpio()
|
|
128
|
+
self.assertEqual(cls.get_description(), "GPIO interrupt is not serviced")
|
|
129
|
+
cls = amd_debug.failures.DmiNotSetup()
|
|
130
|
+
self.assertEqual(cls.get_description(), "DMI data was not scanned")
|
|
131
|
+
cls = amd_debug.failures.LimitedCores(10, 7)
|
|
132
|
+
self.assertEqual(cls.get_description(), "CPU cores have been limited")
|
|
133
|
+
cls = amd_debug.failures.RogAllyOldMcu(1, 2)
|
|
134
|
+
self.assertEqual(cls.get_description(), "Rog Ally MCU firmware is too old")
|
|
135
|
+
os.environ["TERM"] = "dumb"
|
|
136
|
+
cls = amd_debug.failures.RogAllyMcuPowerSave()
|
|
137
|
+
self.assertEqual(cls.get_description(), "Rog Ally MCU power save is disabled")
|
|
138
|
+
failure = "The MCU powersave feature is disabled which will cause problems with the controller after suspend/resume."
|
|
139
|
+
self.assertEqual(str(cls), failure)
|
|
140
|
+
cls.get_failure()
|
|
141
|
+
mocked_print.assert_has_calls(
|
|
142
|
+
[
|
|
143
|
+
call("🚦 Rog Ally MCU power save is disabled"),
|
|
144
|
+
call(failure),
|
|
145
|
+
]
|
|
146
|
+
)
|
test_installer.py
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
This module contains unit tests for the installer functions in the amd-debug-tools package.
|
|
6
|
+
"""
|
|
7
|
+
from unittest.mock import patch, mock_open
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import unittest
|
|
11
|
+
|
|
12
|
+
from amd_debug.installer import Installer
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TestInstaller(unittest.TestCase):
|
|
16
|
+
"""Test installer functions"""
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def setUpClass(cls):
|
|
20
|
+
logging.basicConfig(filename="/dev/null", level=logging.DEBUG)
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
self.installer = Installer(tool_debug=False)
|
|
24
|
+
|
|
25
|
+
@patch("builtins.print")
|
|
26
|
+
@patch("shutil.copy", return_value=None)
|
|
27
|
+
@patch("os.chmod", return_value=None)
|
|
28
|
+
@patch("builtins.open")
|
|
29
|
+
@patch("subprocess.call", return_value=0)
|
|
30
|
+
@patch("os.makedirs", return_value=None)
|
|
31
|
+
def test_install_hook(
|
|
32
|
+
self,
|
|
33
|
+
_mock_mkdir,
|
|
34
|
+
_mock_call,
|
|
35
|
+
_mock_open,
|
|
36
|
+
_mock_chmod,
|
|
37
|
+
_mock_shutil,
|
|
38
|
+
_mock_print,
|
|
39
|
+
):
|
|
40
|
+
"""Test install hook function"""
|
|
41
|
+
self.installer.install()
|
|
42
|
+
|
|
43
|
+
@patch("builtins.print")
|
|
44
|
+
@patch("shutil.copy", return_value=None)
|
|
45
|
+
@patch("os.chmod", return_value=None)
|
|
46
|
+
@patch("builtins.open")
|
|
47
|
+
@patch("subprocess.call", return_value=0)
|
|
48
|
+
@patch("os.makedirs", return_value=None)
|
|
49
|
+
def test_install_hook_missing_path(
|
|
50
|
+
self,
|
|
51
|
+
_mock_mkdir,
|
|
52
|
+
_mock_call,
|
|
53
|
+
_mock_open,
|
|
54
|
+
_mock_chmod,
|
|
55
|
+
_mock_shutil,
|
|
56
|
+
_mock_print,
|
|
57
|
+
):
|
|
58
|
+
"""Test install hook function, but some paths are missing"""
|
|
59
|
+
with patch("os.path.exists", return_value=False):
|
|
60
|
+
self.installer.install()
|
|
61
|
+
|
|
62
|
+
@patch("builtins.print")
|
|
63
|
+
@patch("os.remove", return_value=None)
|
|
64
|
+
@patch("builtins.open")
|
|
65
|
+
@patch("amd_debug.installer.get_distro", return_value="ubuntu")
|
|
66
|
+
@patch("subprocess.call", return_value=0)
|
|
67
|
+
def test_remove_hook(
|
|
68
|
+
self, _mock_call, _mock_get_distro, _mock_open, _mock_remove, _mock_print
|
|
69
|
+
):
|
|
70
|
+
"""Test remove hook function"""
|
|
71
|
+
with patch("os.path.exists", return_value=True):
|
|
72
|
+
self.installer.remove()
|
|
73
|
+
|
|
74
|
+
@patch("builtins.print")
|
|
75
|
+
@patch("os.path.exists", return_value=False)
|
|
76
|
+
@patch("subprocess.call", return_value=0)
|
|
77
|
+
def test_remove_hook_missing_path(self, _mock_call, _mock_exists, _mock_print):
|
|
78
|
+
"""Test remove hook function when the file is missing"""
|
|
79
|
+
self.installer.remove()
|
|
80
|
+
|
|
81
|
+
@patch("builtins.print")
|
|
82
|
+
@patch("subprocess.call", return_value=0)
|
|
83
|
+
def test_already_installed_iasl(self, _mock_call, _mock_print):
|
|
84
|
+
"""Test that an already installed iasl is found"""
|
|
85
|
+
self.installer.set_requirements("iasl")
|
|
86
|
+
ret = self.installer.install_dependencies()
|
|
87
|
+
self.assertTrue(ret)
|
|
88
|
+
|
|
89
|
+
@patch("builtins.print")
|
|
90
|
+
@patch("amd_debug.installer.get_distro", return_value="ubuntu")
|
|
91
|
+
@patch("os.execvp", return_value=None)
|
|
92
|
+
@patch("subprocess.check_call", return_value=0)
|
|
93
|
+
@patch("subprocess.call", return_value=1)
|
|
94
|
+
def test_install_iasl_ubuntu(
|
|
95
|
+
self, _mock_call, _mock_check_call, _mock_distro, _fake_sudo, _mock_print
|
|
96
|
+
):
|
|
97
|
+
"""Test install requirements function"""
|
|
98
|
+
self.installer.set_requirements("iasl")
|
|
99
|
+
ret = self.installer.install_dependencies()
|
|
100
|
+
_mock_check_call.assert_called_once_with(["apt", "install", "acpica-tools"])
|
|
101
|
+
self.assertTrue(ret)
|
|
102
|
+
|
|
103
|
+
@patch("builtins.print")
|
|
104
|
+
@patch("amd_debug.installer.get_distro", return_value="fedora")
|
|
105
|
+
@patch(
|
|
106
|
+
"builtins.open", new_callable=mock_open, read_data="VARIANT_ID=workstation\n"
|
|
107
|
+
)
|
|
108
|
+
@patch("os.execvp", return_value=None)
|
|
109
|
+
@patch("subprocess.check_call", return_value=0)
|
|
110
|
+
@patch("subprocess.call", return_value=1)
|
|
111
|
+
def test_install_iasl_fedora(
|
|
112
|
+
self,
|
|
113
|
+
_mock_call,
|
|
114
|
+
_mock_check_call,
|
|
115
|
+
_mock_variant,
|
|
116
|
+
_mock_distro,
|
|
117
|
+
_fake_sudo,
|
|
118
|
+
_mock_print,
|
|
119
|
+
):
|
|
120
|
+
"""Test install requirements function"""
|
|
121
|
+
self.installer.set_requirements("iasl")
|
|
122
|
+
ret = self.installer.install_dependencies()
|
|
123
|
+
_mock_check_call.assert_called_once_with(
|
|
124
|
+
["dnf", "install", "-y", "acpica-tools"]
|
|
125
|
+
)
|
|
126
|
+
self.assertTrue(ret)
|
|
127
|
+
|
|
128
|
+
@patch("builtins.print")
|
|
129
|
+
@patch("amd_debug.installer.get_distro", return_value="ubuntu")
|
|
130
|
+
@patch("os.execvp", return_value=None)
|
|
131
|
+
@patch("subprocess.check_call", return_value=0)
|
|
132
|
+
@patch("subprocess.call", return_value=1)
|
|
133
|
+
def test_install_ethtool_ubuntu(
|
|
134
|
+
self, _mock_call, _mock_check_call, _mock_distro, _fake_sudo, _mock_print
|
|
135
|
+
):
|
|
136
|
+
"""Test install requirements function"""
|
|
137
|
+
self.installer.set_requirements("ethtool")
|
|
138
|
+
ret = self.installer.install_dependencies()
|
|
139
|
+
_mock_check_call.assert_called_once_with(["apt", "install", "ethtool"])
|
|
140
|
+
self.assertTrue(ret)
|
|
141
|
+
|
|
142
|
+
@patch("builtins.print")
|
|
143
|
+
@patch("amd_debug.installer.get_distro", return_value="fedora")
|
|
144
|
+
@patch(
|
|
145
|
+
"builtins.open", new_callable=mock_open, read_data="VARIANT_ID=workstation\n"
|
|
146
|
+
)
|
|
147
|
+
@patch("os.execvp", return_value=None)
|
|
148
|
+
@patch("subprocess.check_call", return_value=0)
|
|
149
|
+
@patch("subprocess.call", return_value=1)
|
|
150
|
+
def test_install_ethtool_fedora(
|
|
151
|
+
self,
|
|
152
|
+
_mock_call,
|
|
153
|
+
_mock_check_call,
|
|
154
|
+
_mock_variant,
|
|
155
|
+
_mock_distro,
|
|
156
|
+
_fake_sudo,
|
|
157
|
+
_mock_print,
|
|
158
|
+
):
|
|
159
|
+
"""Test install requirements function"""
|
|
160
|
+
self.installer.set_requirements("ethtool")
|
|
161
|
+
ret = self.installer.install_dependencies()
|
|
162
|
+
_mock_check_call.assert_called_once_with(["dnf", "install", "-y", "ethtool"])
|
|
163
|
+
self.assertTrue(ret)
|
|
164
|
+
|
|
165
|
+
@patch("builtins.print")
|
|
166
|
+
@patch("amd_debug.installer.get_distro", return_value="arch")
|
|
167
|
+
@patch("os.execvp", return_value=None)
|
|
168
|
+
@patch("subprocess.check_call", return_value=0)
|
|
169
|
+
@patch("subprocess.call", return_value=1)
|
|
170
|
+
def test_install_ethtool_arch(
|
|
171
|
+
self,
|
|
172
|
+
_mock_call,
|
|
173
|
+
_mock_check_call,
|
|
174
|
+
_mock_distro,
|
|
175
|
+
_fake_sudo,
|
|
176
|
+
_mock_print,
|
|
177
|
+
):
|
|
178
|
+
"""Test install requirements function"""
|
|
179
|
+
self.installer.set_requirements("ethtool")
|
|
180
|
+
ret = self.installer.install_dependencies()
|
|
181
|
+
_mock_check_call.assert_called_once_with(["pacman", "-Sy", "ethtool"])
|
|
182
|
+
self.assertTrue(ret)
|
|
183
|
+
|
|
184
|
+
@patch("builtins.print")
|
|
185
|
+
@patch("os.path.exists", return_value=False)
|
|
186
|
+
@patch("os.execvp", return_value=None)
|
|
187
|
+
@patch("amd_debug.installer.get_distro", return_value="gentoo")
|
|
188
|
+
@patch("subprocess.call", return_value=1)
|
|
189
|
+
def test_install_iasl_gentoo(
|
|
190
|
+
self, _mock_call, _mock_distro, _fake_sudo, _mock_exists, _mock_print
|
|
191
|
+
):
|
|
192
|
+
"""Test install requirements function"""
|
|
193
|
+
self.installer.set_requirements("iasl", "ethtool")
|
|
194
|
+
ret = self.installer.install_dependencies()
|
|
195
|
+
self.assertFalse(ret)
|
|
196
|
+
|
|
197
|
+
@patch("builtins.print")
|
|
198
|
+
@patch("amd_debug.installer.get_distro", return_value="ubuntu")
|
|
199
|
+
@patch("os.execvp", return_value=None)
|
|
200
|
+
@patch("subprocess.check_call", return_value=0)
|
|
201
|
+
@patch("subprocess.call", return_value=1)
|
|
202
|
+
def test_install_edid_decode_ubuntu(
|
|
203
|
+
self, _mock_call, _mock_check_call, _mock_distro, _fake_sudo, _mock_print
|
|
204
|
+
):
|
|
205
|
+
"""Test install requirements function for edid-decode on Ubuntu"""
|
|
206
|
+
self.installer.set_requirements("edid-decode")
|
|
207
|
+
ret = self.installer.install_dependencies()
|
|
208
|
+
_mock_check_call.assert_called_once_with(["apt", "install", "edid-decode"])
|
|
209
|
+
self.assertTrue(ret)
|
|
210
|
+
|
|
211
|
+
@patch("builtins.print")
|
|
212
|
+
@patch("amd_debug.installer.get_distro", return_value="fedora")
|
|
213
|
+
@patch(
|
|
214
|
+
"builtins.open", new_callable=mock_open, read_data="VARIANT_ID=workstation\n"
|
|
215
|
+
)
|
|
216
|
+
@patch("os.execvp", return_value=None)
|
|
217
|
+
@patch("subprocess.check_call", return_value=0)
|
|
218
|
+
@patch("subprocess.call", return_value=1)
|
|
219
|
+
def test_install_edid_decode_fedora(
|
|
220
|
+
self,
|
|
221
|
+
_mock_call,
|
|
222
|
+
_mock_check_call,
|
|
223
|
+
_mock_variant,
|
|
224
|
+
_mock_distro,
|
|
225
|
+
_fake_sudo,
|
|
226
|
+
_mock_print,
|
|
227
|
+
):
|
|
228
|
+
"""Test install requirements function for edid-decode on Fedora"""
|
|
229
|
+
self.installer.set_requirements("edid-decode")
|
|
230
|
+
ret = self.installer.install_dependencies()
|
|
231
|
+
_mock_check_call.assert_called_once_with(
|
|
232
|
+
["dnf", "install", "-y", "edid-decode"]
|
|
233
|
+
)
|
|
234
|
+
self.assertTrue(ret)
|
|
235
|
+
|
|
236
|
+
@patch("builtins.print")
|
|
237
|
+
@patch("amd_debug.installer.get_distro", return_value="arch")
|
|
238
|
+
@patch("os.execvp", return_value=None)
|
|
239
|
+
@patch("subprocess.check_call", return_value=0)
|
|
240
|
+
@patch("subprocess.call", return_value=1)
|
|
241
|
+
def test_install_edid_decode_arch(
|
|
242
|
+
self,
|
|
243
|
+
_mock_call,
|
|
244
|
+
_mock_check_call,
|
|
245
|
+
_mock_distro,
|
|
246
|
+
_fake_sudo,
|
|
247
|
+
_mock_print,
|
|
248
|
+
):
|
|
249
|
+
"""Test install requirements function for edid-decode on Arch"""
|
|
250
|
+
self.installer.set_requirements("edid-decode")
|
|
251
|
+
ret = self.installer.install_dependencies()
|
|
252
|
+
_mock_check_call.assert_not_called() # edid-decode is not supported on Arch
|
|
253
|
+
self.assertFalse(ret)
|
|
254
|
+
|
|
255
|
+
@patch("builtins.print")
|
|
256
|
+
@patch("os.path.exists", return_value=False)
|
|
257
|
+
@patch("os.execvp", return_value=None)
|
|
258
|
+
@patch("amd_debug.installer.get_distro", return_value="gentoo")
|
|
259
|
+
@patch("subprocess.call", return_value=1)
|
|
260
|
+
def test_install_edid_decode_gentoo(
|
|
261
|
+
self, _mock_call, _mock_distro, _fake_sudo, _mock_exists, _mock_print
|
|
262
|
+
):
|
|
263
|
+
"""Test install requirements function for edid-decode on unsupported distro"""
|
|
264
|
+
self.installer.set_requirements("edid-decode")
|
|
265
|
+
ret = self.installer.install_dependencies()
|
|
266
|
+
self.assertFalse(ret)
|
|
267
|
+
|
|
268
|
+
@patch("builtins.print")
|
|
269
|
+
@patch("os.path.exists", return_value=False)
|
|
270
|
+
@patch("os.execvp", return_value=None)
|
|
271
|
+
@patch("amd_debug.installer.get_distro", return_value="gentoo")
|
|
272
|
+
@patch("subprocess.call", return_value=255)
|
|
273
|
+
def test_install_edid_decode_present(
|
|
274
|
+
self, _mock_call, _mock_distro, _fake_sudo, _mock_exists, _mock_print
|
|
275
|
+
):
|
|
276
|
+
"""Test install requirements function for edid-decode on unsupported distro"""
|
|
277
|
+
self.installer.set_requirements("edid-decode")
|
|
278
|
+
ret = self.installer.install_dependencies()
|
|
279
|
+
self.assertTrue(ret)
|