From 3fc28d199f5d2e0b7fa5899ea910d1fe93961bfa Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 23 Aug 2021 13:18:48 +0200 Subject: [PATCH] tests: Add tests for tainting --- tests/integration-test.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/integration-test.py b/tests/integration-test.py index a073e6e..969deab 100755 --- a/tests/integration-test.py +++ b/tests/integration-test.py @@ -778,6 +778,43 @@ class Tests(dbusmock.DBusTestCase): self.stop_daemon() + def test_tainting(self): + '''check that custom fan curves throw a tainting warning''' + + self.create_platform_profile() + fan_curves_dir = os.path.join(self.testbed.get_root_dir(), "sys/devices/platform/asus-nb-wmi/") + os.makedirs(fan_curves_dir) + fan_curves_path = os.path.join(fan_curves_dir, "enabled_fan_curve_profiles") + with open(fan_curves_path, 'w') as curves: + curves.write("profile here\n") + + self.start_daemon() + self.assertEventually(lambda: self.have_text_in_log('Custom fan curves are in use')) + self.stop_daemon() + + os.remove(fan_curves_path) + os.removedirs(fan_curves_dir) + self.remove_platform_profile() + + def test_not_tainting(self): + '''check that fan curves don't throw a tainting warning if unset''' + + self.create_platform_profile() + fan_curves_dir = os.path.join(self.testbed.get_root_dir(), "sys/devices/platform/asus-nb-wmi/") + os.makedirs(fan_curves_dir) + fan_curves_path = os.path.join(fan_curves_dir, "enabled_fan_curve_profiles") + with open(fan_curves_path, 'w') as curves: + curves.write("\n") + + self.start_daemon() + self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced') + self.assertEqual(self.count_text_in_log('Custom fan curves are in use'), 0) + self.stop_daemon() + + os.remove(fan_curves_path) + os.removedirs(fan_curves_dir) + self.remove_platform_profile() + # # Helper methods #