diff --git a/tests/integration_test.py b/tests/integration_test.py index 8f842e0..9cf7f4a 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -1292,6 +1292,70 @@ class Tests(dbusmock.DBusTestCase): profiles = self.get_dbus_property("Profiles") self.assertEqual(len(profiles), 2) + def test_amdgpu_bad_kernel_write(self): + amdgpu_panel_power_savings = "amdgpu/panel_power_savings" + edp = self.testbed.add_device( + "drm", + "card1-eDP", + None, + ["status", "connected\n", amdgpu_panel_power_savings, "0"], + ["DEVTYPE", "drm_connector"], + ) + self.spawn_server_template( + "upower", + {"DaemonVersion": "0.99", "OnBattery": True}, + stdout=subprocess.PIPE, + ) + + attr = os.path.join( + self.testbed.get_root_dir(), + f"sys/class/drm/card1-eDP/{amdgpu_panel_power_savings}", + ) + + self.create_amd_apu() + + self.change_immutable(attr, True) + self.start_daemon() + self.assertIn("amdgpu_panel_power", self.get_dbus_property("Actions")) + + # verify balanced couldn't update + self.set_dbus_property("ActiveProfile", GLib.Variant.new_string("balanced")) + self.assert_sysfs_attr_eventually_is(edp, amdgpu_panel_power_savings, "0") + + self.change_immutable(attr, False) + + def test_amdgpu_bad_kernel_cpuinfo(self): + """Verify AMDGPU panel action behavior if kernel provided bad data""" + + proc_dir = os.path.join(self.testbed.get_root_dir(), "proc/") + os.makedirs(proc_dir) + self.write_file_contents(os.path.join(proc_dir, "cpuinfo"), "vendor_id\n") + + self.spawn_server_template( + "upower", + {"DaemonVersion": "0.99", "OnBattery": True}, + stdout=subprocess.PIPE, + ) + + self.start_daemon() + + self.assertNotIn("amdgpu_panel_power", self.get_dbus_property("Actions")) + + def test_amdgpu_cpu(self): + """Verify AMDGPU panel behavior on non SoC without graphics""" + + self.spawn_server_template( + "upower", + {"DaemonVersion": "0.99", "OnBattery": True}, + stdout=subprocess.PIPE, + ) + + self.create_amd_apu() + + self.start_daemon() + + self.assertIn("amdgpu_panel_power", self.get_dbus_property("Actions")) + def test_amdgpu_panel_power(self): """Verify AMDGPU Panel power actions""" amdgpu_panel_power_savings = "amdgpu/panel_power_savings"