Fix for incorrect S0ix cycle count in amd-s2idle.py script
Signed-off-by: mythilam <mythilam@amd.com>
(Drop the extra unnecessary variables and fix unit tests)
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
diff --git a/src/amd_debug/s2idle.py b/src/amd_debug/s2idle.py
index 074b146..36d6759 100644
--- a/src/amd_debug/s2idle.py
+++ b/src/amd_debug/s2idle.py
@@ -238,6 +238,7 @@
rand=rand,
logind=logind,
)
+ until = datetime.now()
else:
since = None
until = None
diff --git a/src/test_s2idle.py b/src/test_s2idle.py
index 908a780..995a714 100644
--- a/src/test_s2idle.py
+++ b/src/test_s2idle.py
@@ -360,8 +360,10 @@
@patch("amd_debug.s2idle.prompt_test_arguments")
@patch("amd_debug.s2idle.prompt_report_arguments")
@patch("amd_debug.s2idle.display_report_file")
+ @patch("amd_debug.s2idle.datetime")
def test_test_success(
self,
+ mock_datetime,
mock_display_report_file,
mock_prompt_report_arguments,
mock_prompt_test_arguments,
@@ -371,6 +373,11 @@
mock_installer,
):
"""Test the test function when everything succeeds"""
+ from datetime import datetime
+
+ mock_datetime.now.return_value = datetime(2023, 2, 1, 0, 0, 0)
+ mock_datetime.side_effect = lambda *args, **kwargs: datetime(*args, **kwargs)
+
mock_installer_instance = mock_installer.return_value
mock_installer_instance.install_dependencies.return_value = True
@@ -416,9 +423,11 @@
mock_sleep_validator_instance.run.assert_called_once_with(
duration=10, wait=5, count=3, rand=False, logind=False
)
+ from datetime import datetime
+
mock_sleep_report.assert_called_once_with(
since="2023-01-01",
- until="2023-02-01",
+ until=datetime(2023, 2, 1, 0, 0, 0),
fname="report.html",
fmt="html",
tool_debug=True,