amd-debug-tools 0.2.2__py3-none-any.whl → 0.2.12__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.
test_display.py CHANGED
@@ -40,7 +40,7 @@ class TestDisplay(unittest.TestCase):
40
40
  display = Display()
41
41
 
42
42
  # Verify the EDID paths are correctly set
43
- expected_edid = {"card0": "/sys/devices/card0/edid"}
43
+ expected_edid = ["/sys/devices/card0/edid"]
44
44
  self.assertEqual(display.get_edid(), expected_edid)
45
45
  mock_context.assert_called_once()
46
46
 
@@ -54,7 +54,7 @@ class TestDisplay(unittest.TestCase):
54
54
  display = Display()
55
55
 
56
56
  # Verify the EDID dictionary is empty
57
- self.assertEqual(display.get_edid(), {})
57
+ self.assertEqual(display.get_edid(), [])
58
58
 
59
59
  @patch("amd_debug.display.Context")
60
60
  def test_device_without_card(self, mock_context):
@@ -70,7 +70,7 @@ class TestDisplay(unittest.TestCase):
70
70
  display = Display()
71
71
 
72
72
  # Verify the EDID dictionary is empty
73
- self.assertEqual(display.get_edid(), {})
73
+ self.assertEqual(display.get_edid(), [])
74
74
 
75
75
  @patch("amd_debug.display.Context")
76
76
  @patch("amd_debug.display.read_file")
@@ -94,7 +94,7 @@ class TestDisplay(unittest.TestCase):
94
94
  display = Display()
95
95
 
96
96
  # Verify the EDID dictionary is empty
97
- self.assertEqual(display.get_edid(), {})
97
+ self.assertEqual(display.get_edid(), [])
98
98
 
99
99
  @patch("amd_debug.display.Context")
100
100
  @patch("amd_debug.display.read_file")
@@ -116,7 +116,7 @@ class TestDisplay(unittest.TestCase):
116
116
  display = Display()
117
117
 
118
118
  # Verify the EDID dictionary is empty
119
- self.assertEqual(display.get_edid(), {})
119
+ self.assertEqual(display.get_edid(), [])
120
120
 
121
121
  @patch("amd_debug.display.Context")
122
122
  @patch("amd_debug.display.read_file")
@@ -140,4 +140,4 @@ class TestDisplay(unittest.TestCase):
140
140
  display = Display()
141
141
 
142
142
  # Verify the EDID dictionary is empty
143
- self.assertEqual(display.get_edid(), {})
143
+ self.assertEqual(display.get_edid(), [])
test_installer.py CHANGED
@@ -125,6 +125,29 @@ class TestInstaller(unittest.TestCase):
125
125
  )
126
126
  self.assertTrue(ret)
127
127
 
128
+ @patch("builtins.print")
129
+ @patch("amd_debug.installer.get_distro", return_value="fedora")
130
+ @patch("builtins.open", new_callable=mock_open, read_data="VARIANT_ID=kde\n")
131
+ @patch("os.execvp", return_value=None)
132
+ @patch("subprocess.check_call", return_value=0)
133
+ @patch("subprocess.call", return_value=1)
134
+ def test_install_iasl_fedora_kde(
135
+ self,
136
+ _mock_call,
137
+ _mock_check_call,
138
+ _mock_variant,
139
+ _mock_distro,
140
+ _fake_sudo,
141
+ _mock_print,
142
+ ):
143
+ """Test install requirements function on Fedora KDE"""
144
+ self.installer.set_requirements("iasl")
145
+ ret = self.installer.install_dependencies()
146
+ _mock_check_call.assert_called_once_with(
147
+ ["dnf", "install", "-y", "acpica-tools"]
148
+ )
149
+ self.assertTrue(ret)
150
+
128
151
  @patch("builtins.print")
129
152
  @patch("amd_debug.installer.get_distro", return_value="ubuntu")
130
153
  @patch("os.execvp", return_value=None)
@@ -162,6 +185,27 @@ class TestInstaller(unittest.TestCase):
162
185
  _mock_check_call.assert_called_once_with(["dnf", "install", "-y", "ethtool"])
163
186
  self.assertTrue(ret)
164
187
 
188
+ @patch("builtins.print")
189
+ @patch("amd_debug.installer.get_distro", return_value="fedora")
190
+ @patch("builtins.open", new_callable=mock_open, read_data="VARIANT_ID=kde\n")
191
+ @patch("os.execvp", return_value=None)
192
+ @patch("subprocess.check_call", return_value=0)
193
+ @patch("subprocess.call", return_value=1)
194
+ def test_install_ethtool_fedora_kde(
195
+ self,
196
+ _mock_call,
197
+ _mock_check_call,
198
+ _mock_variant,
199
+ _mock_distro,
200
+ _fake_sudo,
201
+ _mock_print,
202
+ ):
203
+ """Test install requirements function on Fedora KDE"""
204
+ self.installer.set_requirements("ethtool")
205
+ ret = self.installer.install_dependencies()
206
+ _mock_check_call.assert_called_once_with(["dnf", "install", "-y", "ethtool"])
207
+ self.assertTrue(ret)
208
+
165
209
  @patch("builtins.print")
166
210
  @patch("amd_debug.installer.get_distro", return_value="arch")
167
211
  @patch("os.execvp", return_value=None)
@@ -231,7 +275,30 @@ class TestInstaller(unittest.TestCase):
231
275
  self.installer.set_requirements("edid-decode")
232
276
  ret = self.installer.install_dependencies()
233
277
  _mock_check_call.assert_called_once_with(
234
- ["dnf", "install", "-y", "libdisplay-info"]
278
+ ["dnf", "install", "-y", "libdisplay-info-tools"]
279
+ )
280
+ self.assertTrue(ret)
281
+
282
+ @patch("builtins.print")
283
+ @patch("amd_debug.installer.get_distro", return_value="fedora")
284
+ @patch("builtins.open", new_callable=mock_open, read_data="VARIANT_ID=kde\n")
285
+ @patch("os.execvp", return_value=None)
286
+ @patch("subprocess.check_call", return_value=0)
287
+ @patch("subprocess.call", return_value=1)
288
+ def test_install_edid_decode_fedora_kde(
289
+ self,
290
+ _mock_call,
291
+ _mock_check_call,
292
+ _mock_variant,
293
+ _mock_distro,
294
+ _fake_sudo,
295
+ _mock_print,
296
+ ):
297
+ """Test install requirements function for edid-decode on Fedora KDE"""
298
+ self.installer.set_requirements("edid-decode")
299
+ ret = self.installer.install_dependencies()
300
+ _mock_check_call.assert_called_once_with(
301
+ ["dnf", "install", "-y", "libdisplay-info-tools"]
235
302
  )
236
303
  self.assertTrue(ret)
237
304
 
test_kernel.py CHANGED
@@ -26,7 +26,7 @@ class TestKernelLog(unittest.TestCase):
26
26
  kernel_cmdline = "quiet splash"
27
27
  expected_output = ""
28
28
  with patch(
29
- "builtins.open", new_callable=mock_open, read_data=kernel_cmdline
29
+ "amd_debug.common.open", new_callable=mock_open, read_data=kernel_cmdline
30
30
  ) as _mock_file:
31
31
  result = get_kernel_command_line()
32
32
  self.assertEqual(result, expected_output)
@@ -35,7 +35,7 @@ class TestKernelLog(unittest.TestCase):
35
35
  kernel_cmdline = ""
36
36
  expected_output = ""
37
37
  with patch(
38
- "builtins.open", new_callable=mock_open, read_data=kernel_cmdline
38
+ "amd_debug.common.open", new_callable=mock_open, read_data=kernel_cmdline
39
39
  ) as _mock_file:
40
40
  result = get_kernel_command_line()
41
41
  self.assertEqual(result, expected_output)
@@ -44,7 +44,7 @@ class TestKernelLog(unittest.TestCase):
44
44
  kernel_cmdline = "quiet splash --debug=1"
45
45
  expected_output = "--debug=1"
46
46
  with patch(
47
- "builtins.open", new_callable=mock_open, read_data=kernel_cmdline
47
+ "amd_debug.common.open", new_callable=mock_open, read_data=kernel_cmdline
48
48
  ) as _mock_file:
49
49
  result = get_kernel_command_line()
50
50
  self.assertEqual(result, expected_output)
@@ -53,7 +53,7 @@ class TestKernelLog(unittest.TestCase):
53
53
  kernel_cmdline = "quiet splash initrd=foo modprobe.blacklist=foo"
54
54
  expected_output = "modprobe.blacklist=foo"
55
55
  with patch(
56
- "builtins.open", new_callable=mock_open, read_data=kernel_cmdline
56
+ "amd_debug.common.open", new_callable=mock_open, read_data=kernel_cmdline
57
57
  ) as _mock_file:
58
58
  result = get_kernel_command_line()
59
59
  self.assertEqual(result, expected_output)
@@ -85,7 +85,7 @@ class TestKernelLog(unittest.TestCase):
85
85
 
86
86
  # test a real post code line
87
87
  line = 'ex_trace_args: " POST CODE: %X ACPI TIMER: %X TIME: %d.%d ms\\n", b0003f33, 83528798, 0, 77, 0, 0'
88
- expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.77 ms"
88
+ expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.119 ms"
89
89
  result = sscanf_bios_args(line)
90
90
  self.assertEqual(result, expected_output)
91
91
 
@@ -114,7 +114,8 @@ class TestDmesgLogger(unittest.TestCase):
114
114
  """Test Dmesg logger functions"""
115
115
 
116
116
  @classmethod
117
- def setUpClass(cls):
117
+ @patch("subprocess.run")
118
+ def setUpClass(cls, _mock_run=None):
118
119
  logging.basicConfig(filename="/dev/null", level=logging.DEBUG)
119
120
 
120
121
  def test_dmesg_logger_initialization(self):
test_launcher.py CHANGED
@@ -26,10 +26,11 @@ class TestLauncher(unittest.TestCase):
26
26
  """Test launching as unknown exe"""
27
27
 
28
28
  with patch("builtins.print") as mock_print:
29
- amd_debug.launch_tool("unknown_exe.py")
29
+ result = amd_debug.launch_tool("unknown_exe.py")
30
30
  mock_print.assert_called_once_with(
31
31
  "\033[91mUnknown exe: unknown_exe.py\033[0m"
32
32
  )
33
+ self.assertIsNotNone(result)
33
34
 
34
35
  def test_launcher_amd_s2idle(self):
35
36
  """Test launching amd_s2idle"""
@@ -51,3 +52,10 @@ class TestLauncher(unittest.TestCase):
51
52
  with patch("amd_debug.pstate.main") as mock_main:
52
53
  amd_debug.launch_tool("amd_pstate.py")
53
54
  mock_main.assert_called_once()
55
+
56
+ def test_launcher_amd_ttm(self):
57
+ """Test launching amd_ttm"""
58
+
59
+ with patch("amd_debug.ttm.main") as mock_main:
60
+ amd_debug.launch_tool("amd_ttm.py")
61
+ mock_main.assert_called_once()