diff options
author | Fabien Lahoudere <fabien.lahoudere@collabora.com> | 2019-11-24 12:07:30 +0100 |
---|---|---|
committer | Enric Balletbo i Serra <enric.balletbo@collabora.com> | 2019-12-06 00:08:35 +0100 |
commit | 6b3273b484669ecc0f0a0c3b12cbd2858b99ecd7 (patch) | |
tree | 0628ae1b36dac65fff39c28099c9c508dc427dcb | |
parent | 87b985129937cce8a759c5267104cd705ec069fc (diff) | |
download | cros-ec-tests-6b3273b484669ecc0f0a0c3b12cbd2858b99ecd7.tar.gz |
test_cros_ec_pwm_backlight: Test backlight brightness behaviour
This patch adds a function to check that the backlight brightness affects
value of duty cycle of the PWM in debugfs.
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
-rwxr-xr-x | test-cros-ec.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test-cros-ec.py b/test-cros-ec.py index bb3734e..8bb9b74 100755 --- a/test-cros-ec.py +++ b/test-cros-ec.py @@ -366,6 +366,47 @@ class TestCrosEC(unittest.TestCase): self.assertEqual(os.path.exists("/sys/class/rtc/" + devname + "/" + filename), 1) self.assertNotEqual(match,0) + def test_cros_ec_pwm_backlight(self): + if not os.path.exists("/sys/class/backlight/backlight/max_brightness"): + self.skipTest("No backlight pwm found, skipping") + is_ec_pwm = False + fd = open("/sys/kernel/debug/pwm", 'r') + line = fd.readline() + while line and not is_ec_pwm: + if line[0] != ' ' and ":ec-pwm" in line: + line = fd.readline() + while line: + if line[0] == '\n': + is_ec_pwm = False + break + if "backlight" in line: + is_ec_pwm = True + break + line = fd.readline() + line = fd.readline() + fd.close() + if not is_ec_pwm: + self.skipTest("No EC backlight pwm found, skipping") + fd = open("/sys/class/backlight/backlight/max_brightness", 'r') + brightness = int(int(fd.read()) / 2) + fd.close() + fd = open("/sys/class/backlight/backlight/brightness", 'w') + fd.write(str(brightness)) + fd.close() + fd = open("/sys/kernel/debug/pwm", 'r') + line = fd.readline() + while line: + if "backlight" in line: + start = line.find("duty") + 6 + self.assertNotEqual(start,5) + end = start + line[start:].find(" ") + self.assertNotEqual(start,end) + duty = int(line[start:end]) + self.assertNotEqual(duty,0) + break + line = fd.readline() + fd.close() + if __name__ == '__main__': unittest.main(testRunner=LavaTestRunner(), # these make sure that some options that are not applicable |