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.
This commit is contained in:
Hans de Goede 2021-03-15 19:27:19 +01:00
parent 86d087fb30
commit 1cbeca326e
2 changed files with 3 additions and 3 deletions

View file

@ -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"))

View file

@ -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.