amd-debug-tools 0.2.10__tar.gz → 0.2.12__tar.gz

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.
Files changed (69) hide show
  1. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/.github/workflows/ci.yml +1 -0
  2. {amd_debug_tools-0.2.10/src/amd_debug_tools.egg-info → amd_debug_tools-0.2.12}/PKG-INFO +1 -1
  3. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/failures.py +29 -9
  4. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/installer.py +1 -1
  5. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/prerequisites.py +43 -4
  6. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/s2idle.py +11 -9
  7. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/validator.py +15 -11
  8. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12/src/amd_debug_tools.egg-info}/PKG-INFO +1 -1
  9. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_installer.py +67 -0
  10. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_prerequisites.py +151 -2
  11. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_s2idle.py +9 -3
  12. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/.github/workflows/mirror.yml +0 -0
  13. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/.gitignore +0 -0
  14. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/.pre-commit-config.yaml +0 -0
  15. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/.vscode/settings.json +0 -0
  16. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/LICENSE +0 -0
  17. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/Makefile +0 -0
  18. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/README.md +0 -0
  19. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/amd_bios.py +0 -0
  20. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/amd_pstate.py +0 -0
  21. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/amd_s2idle.py +0 -0
  22. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/amd_ttm.py +0 -0
  23. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/docs/amd-bios.md +0 -0
  24. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/docs/amd-pstate.md +0 -0
  25. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/docs/amd-s2idle.md +0 -0
  26. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/docs/amd-ttm.md +0 -0
  27. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/docs/in-tree.md +0 -0
  28. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/install_deps.py +0 -0
  29. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/psr.py +0 -0
  30. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/pyproject.toml +0 -0
  31. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/setup.cfg +0 -0
  32. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/__init__.py +0 -0
  33. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/acpi.py +0 -0
  34. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/bash/amd-s2idle +0 -0
  35. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/battery.py +0 -0
  36. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/bios.py +0 -0
  37. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/common.py +0 -0
  38. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/database.py +0 -0
  39. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/display.py +0 -0
  40. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/kernel.py +0 -0
  41. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/pstate.py +0 -0
  42. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/s2idle-hook +0 -0
  43. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/sleep_report.py +0 -0
  44. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/templates/html +0 -0
  45. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/templates/md +0 -0
  46. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/templates/stdout +0 -0
  47. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/templates/txt +0 -0
  48. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/ttm.py +0 -0
  49. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug/wake.py +0 -0
  50. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug_tools.egg-info/SOURCES.txt +0 -0
  51. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug_tools.egg-info/dependency_links.txt +0 -0
  52. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug_tools.egg-info/entry_points.txt +0 -0
  53. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug_tools.egg-info/requires.txt +0 -0
  54. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/amd_debug_tools.egg-info/top_level.txt +0 -0
  55. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/launcher.py +0 -0
  56. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_acpi.py +0 -0
  57. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_batteries.py +0 -0
  58. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_bios.py +0 -0
  59. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_common.py +0 -0
  60. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_database.py +0 -0
  61. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_display.py +0 -0
  62. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_failures.py +0 -0
  63. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_kernel.py +0 -0
  64. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_launcher.py +0 -0
  65. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_pstate.py +0 -0
  66. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_sleep_report.py +0 -0
  67. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_ttm.py +0 -0
  68. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_validator.py +0 -0
  69. {amd_debug_tools-0.2.10 → amd_debug_tools-0.2.12}/src/test_wake.py +0 -0
@@ -98,6 +98,7 @@ jobs:
98
98
  python-version: "3.x"
99
99
  - name: install apt deps
100
100
  run: |
101
+ sudo apt update
101
102
  sudo apt install libsystemd-dev -y
102
103
  - name: install deps
103
104
  run: |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.10
3
+ Version: 0.2.12
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -576,15 +576,6 @@ class LimitedCores(S0i3Failure):
576
576
  )
577
577
 
578
578
 
579
- class CpuTopologyUnknown(S0i3Failure):
580
- """CPU topology unknown"""
581
-
582
- def __init__(self):
583
- super().__init__()
584
- self.description = "CPU topology unknown"
585
- self.explanation = "The CPU topology could not be determined. This may prevent the system from entering hardware sleep states correctly."
586
-
587
-
588
579
  class RogAllyOldMcu(S0i3Failure):
589
580
  """MCU firwmare is too old"""
590
581
 
@@ -619,3 +610,32 @@ class DmcubTooOld(S0i3Failure):
619
610
  f"The DMCUB microcode version {hex(current)} is older than the"
620
611
  f"minimum suggested version {hex(expected)}."
621
612
  )
613
+
614
+
615
+ class MissingIsp4PlatformDriver(S0i3Failure):
616
+ """ISP4 platform driver is missing"""
617
+
618
+ def __init__(self):
619
+ super().__init__()
620
+ self.description = "ISP4 platform driver is missing"
621
+ self.explanation = (
622
+ "The ISP4 platform driver is required for the camera interface included "
623
+ "with the SOC to enter the proper power states. "
624
+ "Be sure that you have enabled CONFIG_AMD_ISP_PLATFORM in your kernel."
625
+ )
626
+
627
+
628
+ class MissingAmdCaptureModule(S0i3Failure):
629
+ """AMD Capture module is missing"""
630
+
631
+ def __init__(self):
632
+ super().__init__()
633
+ self.description = "AMD Capture module is missing"
634
+ self.explanation = (
635
+ "The amd_capture module is required for the camera interface included "
636
+ "with the SOC to enter the proper power states. "
637
+ "Be sure that the amd_capture module is loaded."
638
+ ""
639
+ "If the module is not available, disable the camera in the BIOS to prevent issues."
640
+ )
641
+ self.url = "https://gitlab.freedesktop.org/drm/amd/-/issues/4869"
@@ -64,7 +64,7 @@ class DistroPackage:
64
64
  for line in release.split("\n"):
65
65
  if line.startswith("VARIANT_ID"):
66
66
  variant = line.split("=")[-1]
67
- if variant != "workstation":
67
+ if variant not in ("workstation", "kde"):
68
68
  return False
69
69
  installer = ["dnf", "install", "-y", self.rpm]
70
70
  elif dist == "arch" or os.path.exists("/etc/arch-release"):
@@ -44,7 +44,6 @@ from amd_debug.failures import (
44
44
  AmdHsmpBug,
45
45
  AmdgpuPpFeatureMask,
46
46
  ASpmWrong,
47
- CpuTopologyUnknown,
48
47
  DeepSleep,
49
48
  DevSlpDiskIssue,
50
49
  DevSlpHostIssue,
@@ -55,6 +54,7 @@ from amd_debug.failures import (
55
54
  I2CHidBug,
56
55
  KernelRingBufferWrapped,
57
56
  LimitedCores,
57
+ MissingAmdCaptureModule,
58
58
  MissingAmdgpu,
59
59
  MissingAmdgpuFirmware,
60
60
  MissingAmdPmc,
@@ -62,6 +62,7 @@ from amd_debug.failures import (
62
62
  MissingDriver,
63
63
  MissingIommuACPI,
64
64
  MissingIommuPolicy,
65
+ MissingIsp4PlatformDriver,
65
66
  MissingThunderbolt,
66
67
  MissingXhciHcd,
67
68
  MSRFailure,
@@ -980,6 +981,44 @@ class PrerequisiteValidator(AmdTool):
980
981
  if debug_str:
981
982
  self.db.record_debug(debug_str)
982
983
 
984
+ def check_isp4(self):
985
+ """Check if camera supported by ISP is present and set up properly"""
986
+ devices = []
987
+ for dev in self.pyudev.list_devices(subsystem="acpi"):
988
+ # look for ACPI device for camera (OMNI5C10:00 is seen today)
989
+ if not dev.sys_name.startswith("OMNI5C10"):
990
+ continue
991
+ p = os.path.join(dev.sys_path, "path")
992
+ if not os.path.exists(p):
993
+ continue
994
+ devices.append(dev)
995
+ for dev in devices:
996
+ p = os.path.join(dev.sys_path, "physical_node", "driver")
997
+ if os.path.exists(p):
998
+ driver = os.path.basename(os.readlink(p))
999
+ else:
1000
+ driver = None
1001
+ if driver != "amd-isp4":
1002
+ self.db.record_prereq(
1003
+ f"ISP4 platform camera driver 'amd-isp4' not bound to {dev.sys_name}",
1004
+ "❌",
1005
+ )
1006
+ self.failures += [MissingIsp4PlatformDriver()]
1007
+ return False
1008
+ self.db.record_prereq(
1009
+ f"ISP4 platform camera driver 'amd-isp4' bound to {dev.sys_name}", "✅"
1010
+ )
1011
+ # check if `amd_capture` module is loaded
1012
+ p = os.path.join("/", "sys", "module", "amd_capture")
1013
+ if not os.path.exists(p):
1014
+ self.db.record_prereq(
1015
+ "Camera driver module 'amd_capture' not loaded", "❌"
1016
+ )
1017
+ self.failures += [MissingAmdCaptureModule()]
1018
+ return False
1019
+ self.db.record_prereq("Camera driver module 'amd_capture' loaded", "✅")
1020
+ return True
1021
+
983
1022
  def map_acpi_path(self):
984
1023
  """Map of ACPI devices to ACPI paths"""
985
1024
  devices = []
@@ -1124,10 +1163,9 @@ class PrerequisiteValidator(AmdTool):
1124
1163
  if level_type == 0:
1125
1164
  self.db.record_prereq(
1126
1165
  "Unable to discover CPU topology, didn't find socket level",
1127
- "❌",
1166
+ "🚦",
1128
1167
  )
1129
- self.failures += [CpuTopologyUnknown()]
1130
- return False
1168
+ return True
1131
1169
  if level_type == 4:
1132
1170
  break
1133
1171
  _, cpu_count, _, _ = read_cpuid(0, 0x80000026, level)
@@ -1334,6 +1372,7 @@ class PrerequisiteValidator(AmdTool):
1334
1372
  self.check_iommu,
1335
1373
  self.check_asus_rog_ally,
1336
1374
  self.check_dpia_pg_dmcub,
1375
+ self.check_isp4,
1337
1376
  ]
1338
1377
 
1339
1378
  checks += [
@@ -10,6 +10,7 @@ from datetime import date, timedelta, datetime
10
10
  from amd_debug.common import (
11
11
  convert_string_to_bool,
12
12
  colorize_choices,
13
+ fatal_error,
13
14
  is_root,
14
15
  relaunch_sudo,
15
16
  show_log_info,
@@ -60,15 +61,16 @@ def display_report_file(fname, fmt) -> None:
60
61
  return
61
62
  user = os.environ.get("SUDO_USER")
62
63
  if user:
63
- # ensure that xdg tools will know how to display the file
64
- # (user may need to call tool with sudo -E)
65
- if os.environ.get("XDG_SESSION_TYPE"):
66
- subprocess.call(["sudo", "-E", "-u", user, "xdg-open", fname])
67
- else:
68
- print(
69
- "To display report automatically in browser launch tool "
70
- f"with '-E' argument (Example: sudo -E {sys.argv[0]})"
71
- )
64
+ cmd = [
65
+ "systemd-run",
66
+ "--user",
67
+ f"--machine={user}@.host",
68
+ "xdg-open",
69
+ os.path.abspath(fname),
70
+ ]
71
+ ret = subprocess.call(cmd)
72
+ if ret:
73
+ fatal_error(f"Failed to open report: {ret}")
72
74
 
73
75
 
74
76
  def get_report_file(report_file, extension) -> str:
@@ -317,6 +317,9 @@ class SleepValidator(AmdTool):
317
317
  actions = read_file(os.path.join(p, "actions"))
318
318
  message = f"{Headers.WokeFromIrq} {n} ({chip_name} {hw}-{name} {actions})"
319
319
  self.db.record_debug(message)
320
+ irq = int(n)
321
+ if irq and irq not in self.wakeup_irqs:
322
+ self.wakeup_irqs += [irq]
320
323
  except OSError:
321
324
  pass
322
325
  return True
@@ -542,16 +545,6 @@ class SleepValidator(AmdTool):
542
545
 
543
546
  def analyze_kernel_log(self):
544
547
  """Analyze one of the lines from the kernel log"""
545
- self.cycle_count = 0
546
- self.upep = False
547
- self.upep_microsoft = False
548
- self.wakeup_irqs = []
549
- self.idle_masks = []
550
- self.acpi_errors = []
551
- self.active_gpios = []
552
- self.notify_devices = []
553
- self.page_faults = []
554
- self.irq1_workaround = False
555
548
  self.kernel_log.process_callback(self._analyze_kernel_log_line)
556
549
 
557
550
  if self.cycle_count:
@@ -641,9 +634,20 @@ class SleepValidator(AmdTool):
641
634
 
642
635
  def post(self):
643
636
  """Post-process the suspend test results"""
637
+ self.cycle_count = 0
638
+ self.upep = False
639
+ self.upep_microsoft = False
640
+ self.wakeup_irqs = []
641
+ self.idle_masks = []
642
+ self.acpi_errors = []
643
+ self.active_gpios = []
644
+ self.notify_devices = []
645
+ self.page_faults = []
646
+ self.irq1_workaround = False
647
+
644
648
  checks = [
645
- self.analyze_kernel_log,
646
649
  self.capture_wakeup_irq_data,
650
+ self.analyze_kernel_log,
647
651
  self.check_gpes,
648
652
  self.capture_lid,
649
653
  self.check_rtc_cmos,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.10
3
+ Version: 0.2.12
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -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)
@@ -235,6 +279,29 @@ class TestInstaller(unittest.TestCase):
235
279
  )
236
280
  self.assertTrue(ret)
237
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"]
302
+ )
303
+ self.assertTrue(ret)
304
+
238
305
  @patch("builtins.print")
239
306
  @patch("amd_debug.installer.get_distro", return_value="arch")
240
307
  @patch("os.execvp", return_value=None)
@@ -548,9 +548,9 @@ class TestPrerequisiteValidator(unittest.TestCase):
548
548
  struct.pack("4I", 0, 16, 0, 0), # subleaf 4: cpu_count = 16
549
549
  ]
550
550
  result = self.validator.check_cpu()
551
- self.assertFalse(result)
551
+ self.assertTrue(result)
552
552
  self.mock_db.record_prereq.assert_called_with(
553
- "Unable to discover CPU topology, didn't find socket level", "❌"
553
+ "Unable to discover CPU topology, didn't find socket level", "🚦"
554
554
  )
555
555
 
556
556
  @patch("builtins.open", new_callable=mock_open)
@@ -2387,3 +2387,152 @@ class TestPrerequisiteValidator(unittest.TestCase):
2387
2387
  self.assertTrue(
2388
2388
  any(isinstance(f, MissingAmdgpu) for f in self.validator.failures)
2389
2389
  )
2390
+
2391
+ @patch("amd_debug.prerequisites.os.path.exists")
2392
+ @patch("amd_debug.prerequisites.os.readlink")
2393
+ def test_check_isp4_no_devices(self, _mock_readlink, _mock_path_exists):
2394
+ """Test check_isp4 when no ISP4 camera devices are found"""
2395
+ self.mock_pyudev.list_devices.return_value = []
2396
+ result = self.validator.check_isp4()
2397
+ self.assertTrue(result)
2398
+ self.mock_db.record_prereq.assert_not_called()
2399
+
2400
+ @patch("amd_debug.prerequisites.os.path.exists")
2401
+ @patch("amd_debug.prerequisites.os.readlink")
2402
+ def test_check_isp4_device_without_path(self, _mock_readlink, mock_path_exists):
2403
+ """Test check_isp4 when ACPI device exists but path file is missing"""
2404
+ mock_path_exists.return_value = False
2405
+ self.mock_pyudev.list_devices.return_value = [
2406
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00")
2407
+ ]
2408
+ result = self.validator.check_isp4()
2409
+ self.assertTrue(result)
2410
+ self.mock_db.record_prereq.assert_not_called()
2411
+
2412
+ @patch("amd_debug.prerequisites.os.path.exists")
2413
+ @patch("amd_debug.prerequisites.os.readlink")
2414
+ def test_check_isp4_driver_not_bound(self, _mock_readlink, mock_path_exists):
2415
+ """Test check_isp4 when ISP4 driver is not bound to the device"""
2416
+ mock_path_exists.side_effect = lambda p: "path" in p
2417
+ self.mock_pyudev.list_devices.return_value = [
2418
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00")
2419
+ ]
2420
+ result = self.validator.check_isp4()
2421
+ self.assertFalse(result)
2422
+ self.mock_db.record_prereq.assert_called_with(
2423
+ "ISP4 platform camera driver 'amd-isp4' not bound to OMNI5C10:00", "❌"
2424
+ )
2425
+ self.assertTrue(
2426
+ any(
2427
+ isinstance(f, MissingIsp4PlatformDriver)
2428
+ for f in self.validator.failures
2429
+ )
2430
+ )
2431
+
2432
+ @patch("amd_debug.prerequisites.os.path.exists")
2433
+ @patch(
2434
+ "amd_debug.prerequisites.os.readlink",
2435
+ return_value="/sys/devices/platform/drivers/amd-isp4",
2436
+ )
2437
+ def test_check_isp4_driver_bound_but_module_not_loaded(
2438
+ self, _mock_readlink, mock_path_exists
2439
+ ):
2440
+ """Test check_isp4 when driver is bound but amd_capture module is not loaded"""
2441
+
2442
+ def exists_side_effect(path):
2443
+ if "path" in path or "driver" in path:
2444
+ return True
2445
+ if "amd_capture" in path:
2446
+ return False
2447
+ return True
2448
+
2449
+ mock_path_exists.side_effect = exists_side_effect
2450
+ self.mock_pyudev.list_devices.return_value = [
2451
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00")
2452
+ ]
2453
+ result = self.validator.check_isp4()
2454
+ self.assertFalse(result)
2455
+ self.mock_db.record_prereq.assert_any_call(
2456
+ "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:00", "✅"
2457
+ )
2458
+ self.mock_db.record_prereq.assert_any_call(
2459
+ "Camera driver module 'amd_capture' not loaded", "❌"
2460
+ )
2461
+ self.assertTrue(
2462
+ any(isinstance(f, MissingAmdCaptureModule) for f in self.validator.failures)
2463
+ )
2464
+
2465
+ @patch("amd_debug.prerequisites.os.path.exists")
2466
+ @patch(
2467
+ "amd_debug.prerequisites.os.readlink",
2468
+ return_value="/sys/devices/platform/drivers/amd-isp4",
2469
+ )
2470
+ def test_check_isp4_fully_configured(self, _mock_readlink, mock_path_exists):
2471
+ """Test check_isp4 when ISP4 is fully configured with driver and module"""
2472
+ mock_path_exists.return_value = True
2473
+ self.mock_pyudev.list_devices.return_value = [
2474
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00")
2475
+ ]
2476
+ result = self.validator.check_isp4()
2477
+ self.assertTrue(result)
2478
+ self.mock_db.record_prereq.assert_any_call(
2479
+ "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:00", "✅"
2480
+ )
2481
+ self.mock_db.record_prereq.assert_any_call(
2482
+ "Camera driver module 'amd_capture' loaded", "✅"
2483
+ )
2484
+
2485
+ @patch("amd_debug.prerequisites.os.path.exists")
2486
+ @patch(
2487
+ "amd_debug.prerequisites.os.readlink",
2488
+ return_value="/sys/devices/platform/drivers/other-driver",
2489
+ )
2490
+ def test_check_isp4_wrong_driver(self, _mock_readlink, mock_path_exists):
2491
+ """Test check_isp4 when wrong driver is bound to the device"""
2492
+ mock_path_exists.side_effect = lambda p: "path" in p or "driver" in p
2493
+ self.mock_pyudev.list_devices.return_value = [
2494
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00")
2495
+ ]
2496
+ result = self.validator.check_isp4()
2497
+ self.assertFalse(result)
2498
+ self.mock_db.record_prereq.assert_called_with(
2499
+ "ISP4 platform camera driver 'amd-isp4' not bound to OMNI5C10:00", "❌"
2500
+ )
2501
+ self.assertTrue(
2502
+ any(
2503
+ isinstance(f, MissingIsp4PlatformDriver)
2504
+ for f in self.validator.failures
2505
+ )
2506
+ )
2507
+
2508
+ @patch("amd_debug.prerequisites.os.path.exists")
2509
+ @patch(
2510
+ "amd_debug.prerequisites.os.readlink",
2511
+ return_value="/sys/devices/platform/drivers/amd-isp4",
2512
+ )
2513
+ def test_check_isp4_multiple_devices(self, _mock_readlink, mock_path_exists):
2514
+ """Test check_isp4 with multiple ISP4 camera devices"""
2515
+ mock_path_exists.return_value = True
2516
+ self.mock_pyudev.list_devices.return_value = [
2517
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:00", sys_name="OMNI5C10:00"),
2518
+ MagicMock(sys_path="/sys/devices/acpi/OMNI5C10:01", sys_name="OMNI5C10:01"),
2519
+ ]
2520
+ result = self.validator.check_isp4()
2521
+ self.assertTrue(result)
2522
+ self.mock_db.record_prereq.assert_any_call(
2523
+ "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:00", "✅"
2524
+ )
2525
+ self.mock_db.record_prereq.assert_any_call(
2526
+ "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:01", "✅"
2527
+ )
2528
+
2529
+ @patch("amd_debug.prerequisites.os.path.exists")
2530
+ def test_check_isp4_device_not_starting_with_omni5c10(self, mock_path_exists):
2531
+ """Test check_isp4 when ACPI devices don't match OMNI5C10 pattern"""
2532
+ mock_path_exists.return_value = True
2533
+ self.mock_pyudev.list_devices.return_value = [
2534
+ MagicMock(sys_path="/sys/devices/acpi/OTHER:00", sys_name="OTHER:00")
2535
+ ]
2536
+ result = self.validator.check_isp4()
2537
+ self.assertTrue(result)
2538
+ self.mock_db.record_prereq.assert_not_called()
@@ -611,12 +611,18 @@ class TestDisplayReportFile(unittest.TestCase):
611
611
  self, mock_subprocess_call, mock_env_get, mock_is_root
612
612
  ):
613
613
  """Test display_report_file when format is html, user is root, and SUDO_USER is set"""
614
- display_report_file("report.html", "html")
614
+ with self.assertRaises(SystemExit):
615
+ display_report_file("/tmp/report.html", "html")
615
616
  mock_is_root.assert_called_once()
616
617
  mock_env_get.assert_any_call("SUDO_USER")
617
- mock_env_get.assert_any_call("XDG_SESSION_TYPE")
618
618
  mock_subprocess_call.assert_called_once_with(
619
- ["sudo", "-E", "-u", "testuser", "xdg-open", "report.html"]
619
+ [
620
+ "systemd-run",
621
+ "--user",
622
+ "--machine=testuser@.host",
623
+ "xdg-open",
624
+ "/tmp/report.html",
625
+ ]
620
626
  )
621
627
 
622
628
  @patch("amd_debug.s2idle.is_root", return_value=True)