summaryrefslogtreecommitdiff
path: root/test/power_button.py
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-07-01 20:48:48 +0800
committerGerrit <chrome-bot@google.com>2012-07-02 20:36:57 -0700
commited9d6282d46d8216ae6f81477171324fcbdc94aa (patch)
tree1b82197c912cb2577564dc6f170f24d3347701bc /test/power_button.py
parentf44db828733e942efeb61305e24231b88ac500b4 (diff)
downloadchrome-ec-ed9d6282d46d8216ae6f81477171324fcbdc94aa.tar.gz
Add a function to check no specific message comes from EC
This function has been defined and used in several tests. Let's consolidate them into the helper class. BUG=none TEST=The four tests passed Change-Id: I069bec84e0f2ce12ef9e8b7fe610f54bb58af0de Reviewed-on: https://gerrit.chromium.org/gerrit/26534 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'test/power_button.py')
-rw-r--r--test/power_button.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/test/power_button.py b/test/power_button.py
index 7f5c3b9fb0..0f5766ca96 100644
--- a/test/power_button.py
+++ b/test/power_button.py
@@ -15,14 +15,6 @@ SHORTER_THAN_T0 = 0.01
LONGER_THAN_T0 = 0.05
LONGER_THAN_T1 = 5
-def check_no_output(helper, reg_ex):
- success = False
- try:
- helper.wait_output(reg_ex, use_re=True, timeout=1)
- except:
- success = True
- return success
-
def consume_output(helper, reg_ex):
done = False
while not done:
@@ -44,7 +36,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 0")
time.sleep(SHORTER_THAN_T0)
helper.ec_command("gpiomock POWER_BUTTONn 1")
- if not check_no_output(helper, "PB released"):
+ if not helper.check_no_output("PB released"):
return False
helper.trace("Press power button for longer than T0 and check this\n" +
@@ -54,7 +46,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 1")
helper.wait_output("PB released", timeout=1)
# Expect shown only once
- if not check_no_output(helper, "PB released"):
+ if not helper.check_no_output("PB released"):
return False
helper.trace("Press power button for two consecutive SHORTER_THAN_T0\n" +
@@ -66,7 +58,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 0")
time.sleep(SHORTER_THAN_T0)
helper.ec_command("gpiomock POWER_BUTTONn 1")
- if not check_no_output(helper, "PB released"):
+ if not helper.check_no_output("PB released"):
return False
helper.trace("Hold down power button for LONGER_THAN_T0 and check a\n" +
@@ -77,7 +69,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 1")
helper.wait_output("pwrbtn=LOW", timeout=1)
helper.wait_output("pwrbtn=HIGH", timeout=1)
- if not check_no_output(helper, "pwrbtn=LOW"):
+ if not helper.check_no_output("pwrbtn=LOW"):
return False
helper.trace("Press power button for SHORTER_THAN_T0, release for\n" +
@@ -92,7 +84,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 1")
helper.wait_output("pwrbtn=LOW", timeout=1)
helper.wait_output("pwrbtn=HIGH", timeout=1)
- if not check_no_output(helper, "pwrbtn=LOW"):
+ if not helper.check_no_output("pwrbtn=LOW"):
return False
helper.trace("Hold down power button, wait for power button press\n" +
@@ -104,7 +96,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 1")
time.sleep(SHORTER_THAN_T0)
helper.ec_command("gpiomock POWER_BUTTONn 0")
- if not check_no_output(helper, "PB released"):
+ if not helper.check_no_output("PB released"):
return False
helper.ec_command("gpiomock POWER_BUTTONn 1")
helper.wait_output("PB released", timeout=1)
@@ -119,7 +111,7 @@ def test(helper):
use_re=True)["t"]
t_high = helper.wait_output("\[(?P<t>[\d\.]+) PB PCH pwrbtn=HIGH\]",
use_re=True)["t"]
- if not check_no_output(helper, "pwrbtn=LOW"):
+ if not helper.check_no_output("pwrbtn=LOW"):
return False
if float(t_high) - float(t_low) <= LONGER_THAN_T0 - 0.1:
return False
@@ -130,7 +122,7 @@ def test(helper):
helper.ec_command("gpiomock POWER_BUTTONn 0")
time.sleep(LONGER_THAN_T0)
helper.ec_command("gpiomock POWER_BUTTONn 1")
- if not check_no_output(helper, "i8042 SEND"):
+ if not helper.check_no_output("i8042 SEND"):
return False
helper.trace("While powered on, hold down power button for\n" +
@@ -144,7 +136,7 @@ def test(helper):
use_re=True)["t"]
t_high = helper.wait_output("\[(?P<t>[\d\.]+) PB PCH pwrbtn=HIGH\]",
use_re=True)["t"]
- if not check_no_output(helper, "pwrbtn=LOW"):
+ if not helper.check_no_output("pwrbtn=LOW"):
return False
if float(t_high) - float(t_low) >= 0.1:
return False
@@ -168,7 +160,7 @@ def test(helper):
helper.wait_output("pwrbtn=HIGH", timeout=1)
helper.wait_output("pwrbtn=LOW", timeout=1)
helper.wait_output("pwrbtn=HIGH", timeout=1)
- if not check_no_output(helper, "pwrbtn=LOW"):
+ if not helper.check_no_output("pwrbtn=LOW"):
return False
return True # PASS !