summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qbutton.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
committerManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
commit9332c933fc05f42882640c9a4e35fab09854af84 (patch)
tree2b9b00b5a411b27f9705603c0d93b8925afd4677 /test-cli/test/tests/qbutton.py
downloadboard-9332c933fc05f42882640c9a4e35fab09854af84.zip
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.gz
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.bz2
Board: Client Test Suite Initial Commit
Diffstat (limited to 'test-cli/test/tests/qbutton.py')
-rw-r--r--test-cli/test/tests/qbutton.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/test-cli/test/tests/qbutton.py b/test-cli/test/tests/qbutton.py
new file mode 100644
index 0000000..1fb204a
--- /dev/null
+++ b/test-cli/test/tests/qbutton.py
@@ -0,0 +1,51 @@
+from test.helpers.syscmd import SysCommand
+import unittest
+import uuid
+import time
+
+class Qbutton(unittest.TestCase):
+
+ def __init__(self, testname, testfunc, gpio):
+ if gpio == "SOPA":
+ super(Qbutton, self).__init__("buttonSopa")
+ else:
+ super(Qbutton, self).__init__("buttonGpio")
+ self._testMethodDoc = testname
+
+ def buttonGpio(self):
+ print("normal-button-test-using-gpio")
+ self.fail("failed: GPIO BUTTON FAIL")
+
+ def buttonSopa(self):
+ str_cmd = "i2cset -f -y 1 0x2d 0x40 0x31"
+ disable_pmic = SysCommand("disable_pmic", str_cmd)
+ disable_pmic.execute()
+ # BUG: REPEAT THIS EXECUTION TWICE BECAUSE FIRST TIME IT RETURNS AN ERROR
+ time.sleep(0.1)
+ disable_pmic.execute()
+ if disable_pmic.execute() == 0:
+ str_cmd = "i2cset -f -y 1 0x2d 0x50 0xff"
+ reset_button = SysCommand("reset_button", str_cmd)
+ if reset_button.execute() == 0:
+ str_cmd = "i2cget -f -y 1 0x2d 0x50"
+ get_button_val = SysCommand("get_button_val", str_cmd)
+ print("\n\t --> PRESS button for 1 sec (TIMEOUT: 10s) \n")
+ timeout = 0
+ while timeout < 20:
+ if get_button_val.execute() == 0:
+ get_button_val.execute()
+ button_value = get_button_val.getOutput()
+ button_value=button_value.decode('ascii').split("x")
+ if int(button_value[1]) == 4:
+ timeout = 20
+ time.sleep(0.5)
+ timeout = timeout + 1
+ if timeout==20 and int(button_value[1]) == 0:
+ self.fail("failed: timeout exceeded")
+ else:
+ timeout = 20
+ self.fail("failed: not button input")
+ else:
+ self.fail("failed: could not complete i2c reset button state")
+ else:
+ self.fail("failed: could not complete i2c disable PMIC")