From 1cbeca326edaf7a5318c805b880fe1517327dda4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 15 Mar 2021 19:27:19 +0100 Subject: [PATCH] platform-profile: Fix the driver to work with real hardware The platform_profile_choices sysfs file contains the available profiles separated by spaces, not newlines, with a newline at the end (as all text based sysfs files have a newline at the end). Replace the g_strsplit(..., "\n", -1) with a g_strsplit_set (..., " \n", -1) so that the choices get split on the spaces, and the trailing "\n" gets discarded. Also update the integration-test to match. --- src/ppd-driver-platform-profile.c | 2 +- tests/integration-test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ppd-driver-platform-profile.c b/src/ppd-driver-platform-profile.c index de3bf40..2f68d67 100644 --- a/src/ppd-driver-platform-profile.c +++ b/src/ppd-driver-platform-profile.c @@ -101,7 +101,7 @@ verify_acpi_platform_profile_choices (void) return PPD_PROBE_RESULT_FAIL; } - choices = g_strsplit (choices_str, "\n", -1); + choices = g_strsplit_set (choices_str, " \n", -1); if (g_strv_contains ((const char * const*) choices, "low-power") && g_strv_contains ((const char * const*) choices, "balanced") && g_strv_contains ((const char * const*) choices, "performance")) diff --git a/tests/integration-test b/tests/integration-test index 79d1528..4dcea3e 100755 --- a/tests/integration-test +++ b/tests/integration-test @@ -222,9 +222,9 @@ class Tests(dbusmock.DBusTestCase): acpi_dir = os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/") os.makedirs(acpi_dir) with open(os.path.join(acpi_dir, "platform_profile") ,'w') as profile: - profile.write("performance") + profile.write("performance\n") with open(os.path.join(acpi_dir, "platform_profile_choices") ,'w') as choices: - choices.write("low-power\nbalanced\nperformance\n") + choices.write("low-power balanced performance\n") def assertEventually(self, condition, message=None, timeout=50): '''Assert that condition function eventually returns True.