Commit 6b3273b4 authored by Fabien Lahoudere's avatar Fabien Lahoudere Committed by Enric Balletbo i Serra
Browse files

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: default avatarFabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
parent 87b98512
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment