amd-debug-tools 0.2.17__tar.gz → 0.2.18__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.
- {amd_debug_tools-0.2.17/src/amd_debug_tools.egg-info → amd_debug_tools-0.2.18}/PKG-INFO +1 -1
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/common.py +4 -3
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/ttm.py +93 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/validator.py +4 -1
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18/src/amd_debug_tools.egg-info}/PKG-INFO +1 -1
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_common.py +9 -49
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/.github/workflows/ci.yml +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/.github/workflows/mirror.yml +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/.gitignore +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/.pre-commit-config.yaml +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/.vscode/settings.json +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/LICENSE +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/Makefile +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/README.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/amd_bios.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/amd_pstate.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/amd_s2idle.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/amd_ttm.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/docs/amd-bios.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/docs/amd-pstate.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/docs/amd-s2idle.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/docs/amd-ttm.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/docs/in-tree.md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/install_deps.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/psr.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/pyproject.toml +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/setup.cfg +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/__init__.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/acpi.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/bash/amd-s2idle +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/battery.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/bios.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/database.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/display.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/failures.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/installer.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/kernel.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/prerequisites.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/pstate.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/s2idle-hook +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/s2idle.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/sleep_report.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/templates/html +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/templates/md +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/templates/stdout +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/templates/txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug/wake.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/SOURCES.txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/dependency_links.txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/entry_points.txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/requires.txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/top_level.txt +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/launcher.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_acpi.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_batteries.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_bios.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_database.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_display.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_failures.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_installer.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_kernel.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_launcher.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_prerequisites.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_pstate.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_s2idle.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_sleep_report.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_ttm.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_validator.py +0 -0
- {amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/test_wake.py +0 -0
|
@@ -273,8 +273,7 @@ def reboot():
|
|
|
273
273
|
return False
|
|
274
274
|
return True
|
|
275
275
|
|
|
276
|
-
|
|
277
|
-
result = loop.run_until_complete(reboot_dbus_fast())
|
|
276
|
+
result = asyncio.run(reboot_dbus_fast())
|
|
278
277
|
if not result:
|
|
279
278
|
return reboot_dbus()
|
|
280
279
|
|
|
@@ -392,7 +391,9 @@ def relaunch_sudo() -> None:
|
|
|
392
391
|
"XDG_RUNTIME_DIR",
|
|
393
392
|
"DBUS_SESSION_BUS_ADDRESS",
|
|
394
393
|
"XDG_SESSION_TYPE",
|
|
395
|
-
"XDG_DATA_DIRS"
|
|
394
|
+
"XDG_DATA_DIRS",
|
|
395
|
+
"SSH_CLIENT",
|
|
396
|
+
"SSH_TTY"
|
|
396
397
|
]:
|
|
397
398
|
value = os.environ.get(var)
|
|
398
399
|
if value:
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import asyncio
|
|
5
5
|
import os
|
|
6
6
|
import argparse
|
|
7
|
+
import glob
|
|
8
|
+
import subprocess
|
|
7
9
|
from amd_debug.common import (
|
|
8
10
|
AmdTool,
|
|
9
11
|
bytes_to_gb,
|
|
@@ -28,6 +30,94 @@ def maybe_reboot() -> bool:
|
|
|
28
30
|
return reboot()
|
|
29
31
|
return True
|
|
30
32
|
|
|
33
|
+
def is_ttm_in_initramfs(initramfs_path: str) -> bool:
|
|
34
|
+
"""
|
|
35
|
+
Check if the ttm module is included in the initramfs.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
initramfs_path: Path to the initramfs image (e.g., "/boot/initrd.img-6.12.74-amd64")
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
bool: True if "gpu/drm/ttm/ttm.ko" is found, False otherwise
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
# Run lsinitramfs and search for "ttm" in the output
|
|
45
|
+
result = subprocess.run(
|
|
46
|
+
["lsinitramfs", initramfs_path],
|
|
47
|
+
capture_output=True,
|
|
48
|
+
text=True,
|
|
49
|
+
check=True
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Check if "gpu/drm/ttm/ttm.ko" appears in the output
|
|
53
|
+
return "gpu/drm/ttm/ttm.ko" in result.stdout.lower()
|
|
54
|
+
|
|
55
|
+
except subprocess.CalledProcessError as e:
|
|
56
|
+
print_color(f"Error running lsinitramfs: {e}", "❌")
|
|
57
|
+
return False
|
|
58
|
+
except FileNotFoundError:
|
|
59
|
+
print_color("Error: 'lsinitramfs' command not found. Is initramfs-tools installed?", "❌")
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
def check_initramfs_images() -> bool:
|
|
63
|
+
"""Check if initramfs images exist in /boot/"""
|
|
64
|
+
print_color("Checking if the initramfs image needs to be regenerated", "🐧")
|
|
65
|
+
if not os.path.exists("/boot"):
|
|
66
|
+
print_color("Warning: /boot not found. Is it mounted?", "🚦")
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
# Check for common initramfs patterns
|
|
70
|
+
patterns = [
|
|
71
|
+
'/boot/initrd.img-*', # Debian/Ubuntu
|
|
72
|
+
'/boot/initramfs-*.img', # Fedora/RHEL
|
|
73
|
+
'/boot/initramfs-*' # Arch
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
for pattern in patterns:
|
|
77
|
+
initramfs_files = glob.glob(pattern)
|
|
78
|
+
if initramfs_files:
|
|
79
|
+
print_color(f"Found initramfs images: {initramfs_files}", "🐧")
|
|
80
|
+
|
|
81
|
+
latest_initramfs = max(initramfs_files)
|
|
82
|
+
if is_ttm_in_initramfs(latest_initramfs):
|
|
83
|
+
print_color(f"TTM module is included in initramfs: {latest_initramfs}", "✅")
|
|
84
|
+
print_color("The initramfs image needs to be regenerated", "🐧")
|
|
85
|
+
return True
|
|
86
|
+
else:
|
|
87
|
+
print_color(f"TTM module is not included in initramfs", "○")
|
|
88
|
+
print_color(f"The initramfs image does not need to be regenerated", "○")
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
def regenerate_initramfs():
|
|
92
|
+
"""Regenerate initramfs image"""
|
|
93
|
+
if not check_initramfs_images():
|
|
94
|
+
print_color("No initramfs images found, skipping regeneration", "○")
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
# Supported initramfs tools
|
|
98
|
+
initramfs_tools = [
|
|
99
|
+
["update-initramfs", "-u"],
|
|
100
|
+
["dracut", "--force"],
|
|
101
|
+
["mkinitcpio", "-P"]
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
for cmd in initramfs_tools:
|
|
105
|
+
tool = cmd[0]
|
|
106
|
+
if os.path.exists(f"/usr/sbin/{cmd[0]}") or os.path.exists(f"/usr/bin/{cmd[0]}"):
|
|
107
|
+
print_color(f"Updating initramfs using {tool}", "🐧")
|
|
108
|
+
try:
|
|
109
|
+
subprocess.run(cmd, check=True)
|
|
110
|
+
print_color("Initramfs updated successfully", "✅")
|
|
111
|
+
return
|
|
112
|
+
except subprocess.CalledProcessError as e:
|
|
113
|
+
print_color(f"Failed to update initramfs: {e}", "❌")
|
|
114
|
+
continue
|
|
115
|
+
except FileNotFoundError:
|
|
116
|
+
continue
|
|
117
|
+
|
|
118
|
+
print_color("No supported initramfs tool found", "❌")
|
|
119
|
+
return
|
|
120
|
+
|
|
31
121
|
|
|
32
122
|
class AmdTtmTool(AmdTool):
|
|
33
123
|
"""Class for handling TTM page configuration"""
|
|
@@ -96,6 +186,9 @@ class AmdTtmTool(AmdTool):
|
|
|
96
186
|
"🐧",
|
|
97
187
|
)
|
|
98
188
|
print_color(f"Configuration written to {MODPROBE_CONF_PATH}", "🐧")
|
|
189
|
+
|
|
190
|
+
regenerate_initramfs()
|
|
191
|
+
|
|
99
192
|
print_color("NOTE: You need to reboot for changes to take effect.", "○")
|
|
100
193
|
|
|
101
194
|
return maybe_reboot()
|
|
@@ -693,7 +693,10 @@ class SleepValidator(AmdTool):
|
|
|
693
693
|
"""Program the RTC wakealarm to wake the system after the requested duration"""
|
|
694
694
|
wakealarm = None
|
|
695
695
|
for device in self.pyudev.list_devices(subsystem="rtc"):
|
|
696
|
-
|
|
696
|
+
target = os.path.join(device.sys_path, "wakealarm")
|
|
697
|
+
if os.path.exists(target):
|
|
698
|
+
wakealarm = target
|
|
699
|
+
break
|
|
697
700
|
if wakealarm:
|
|
698
701
|
with open(wakealarm, "w", encoding="utf-8") as w:
|
|
699
702
|
w.write("0")
|
|
@@ -530,44 +530,17 @@ class TestCommon(unittest.TestCase):
|
|
|
530
530
|
self.assertAlmostEqual(get_system_mem(), expected_gb)
|
|
531
531
|
mock_file.assert_called_once_with("/proc/meminfo", "r", encoding="utf-8")
|
|
532
532
|
|
|
533
|
-
|
|
533
|
+
@patch("amd_debug.common.asyncio.run", return_value=True)
|
|
534
|
+
def test_reboot_dbus_fast_success(self, mock_asyncio_run):
|
|
534
535
|
"""Test reboot returns True when reboot_dbus_fast succeeds"""
|
|
536
|
+
result = reboot()
|
|
537
|
+
self.assertTrue(result)
|
|
538
|
+
mock_asyncio_run.assert_called_once()
|
|
535
539
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
# Consume the coroutine to prevent the warning
|
|
539
|
-
try:
|
|
540
|
-
# Close the coroutine to prevent the warning
|
|
541
|
-
coro.close()
|
|
542
|
-
except (AttributeError, RuntimeError):
|
|
543
|
-
pass
|
|
544
|
-
return True
|
|
545
|
-
|
|
546
|
-
mock_loop = Mock()
|
|
547
|
-
mock_loop.run_until_complete.side_effect = mock_run_until_complete
|
|
548
|
-
|
|
549
|
-
with patch("amd_debug.common.asyncio.get_event_loop", return_value=mock_loop):
|
|
550
|
-
result = reboot()
|
|
551
|
-
self.assertTrue(result)
|
|
552
|
-
mock_loop.run_until_complete.assert_called_once()
|
|
553
|
-
|
|
554
|
-
@patch("asyncio.get_event_loop")
|
|
555
|
-
def test_reboot_dbus_fast_failure_and_dbus_success(self, mock_get_event_loop):
|
|
540
|
+
@patch("amd_debug.common.asyncio.run", return_value=False)
|
|
541
|
+
def test_reboot_dbus_fast_failure_and_dbus_success(self, mock_asyncio_run):
|
|
556
542
|
"""Test reboot falls back to reboot_dbus when reboot_dbus_fast fails"""
|
|
557
543
|
|
|
558
|
-
# Create a mock loop that properly handles coroutines
|
|
559
|
-
def mock_run_until_complete(coro):
|
|
560
|
-
# Consume the coroutine to prevent the warning
|
|
561
|
-
try:
|
|
562
|
-
coro.close()
|
|
563
|
-
except (AttributeError, RuntimeError):
|
|
564
|
-
pass
|
|
565
|
-
return False
|
|
566
|
-
|
|
567
|
-
mock_loop = Mock()
|
|
568
|
-
mock_loop.run_until_complete.side_effect = mock_run_until_complete
|
|
569
|
-
mock_get_event_loop.return_value = mock_loop
|
|
570
|
-
|
|
571
544
|
# Mock the dbus module to avoid ImportError in CI
|
|
572
545
|
mock_dbus = Mock()
|
|
573
546
|
mock_bus = Mock()
|
|
@@ -583,23 +556,10 @@ class TestCommon(unittest.TestCase):
|
|
|
583
556
|
result = reboot()
|
|
584
557
|
self.assertTrue(result)
|
|
585
558
|
|
|
586
|
-
@patch("asyncio.
|
|
587
|
-
def test_reboot_dbus_fast_failure_and_dbus_failure(self,
|
|
559
|
+
@patch("amd_debug.common.asyncio.run", return_value=False)
|
|
560
|
+
def test_reboot_dbus_fast_failure_and_dbus_failure(self, mock_asyncio_run):
|
|
588
561
|
"""Test reboot returns False when both reboot_dbus_fast and reboot_dbus fail"""
|
|
589
562
|
|
|
590
|
-
# Create a mock loop that properly handles coroutines
|
|
591
|
-
def mock_run_until_complete(coro):
|
|
592
|
-
# Consume the coroutine to prevent the warning
|
|
593
|
-
try:
|
|
594
|
-
coro.close()
|
|
595
|
-
except (AttributeError, RuntimeError):
|
|
596
|
-
pass
|
|
597
|
-
return False
|
|
598
|
-
|
|
599
|
-
mock_loop = Mock()
|
|
600
|
-
mock_loop.run_until_complete.side_effect = mock_run_until_complete
|
|
601
|
-
mock_get_event_loop.return_value = mock_loop
|
|
602
|
-
|
|
603
563
|
# Mock the import to raise ImportError when dbus is imported
|
|
604
564
|
original_import = builtins.__import__
|
|
605
565
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{amd_debug_tools-0.2.17 → amd_debug_tools-0.2.18}/src/amd_debug_tools.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|