From 1a1bf760f9d912f6c19943b58198d947b4e65b84 Mon Sep 17 00:00:00 2001 From: Simo Kuusela Date: Fri, 24 Feb 2017 13:52:32 +0200 Subject: [PATCH 1/2] meta-iotqa: Add mraa GPIO test The test will set a GPIO pin on and off using mraa and check the output to confirm it works. The test requires to use BeagleBone Black as the testing host and setting up it's GPIO pin 20 as input. Also correct cabling is required for checking the clients GPIO pin output. Signed-off-by: Simo Kuusela --- .../lib/oeqa/runtime/sanity/mraa_gpio.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 meta-iotqa/lib/oeqa/runtime/sanity/mraa_gpio.py diff --git a/meta-iotqa/lib/oeqa/runtime/sanity/mraa_gpio.py b/meta-iotqa/lib/oeqa/runtime/sanity/mraa_gpio.py new file mode 100644 index 0000000000..be5a448c50 --- /dev/null +++ b/meta-iotqa/lib/oeqa/runtime/sanity/mraa_gpio.py @@ -0,0 +1,44 @@ +from oeqa.oetest import oeRuntimeTest +import unittest +import subprocess +from time import sleep + +class MraaGpioTest(oeRuntimeTest): + ''' + These tests require to use BeagleBone as testing host + ''' + pin = "" + def setUp(self): + (status, output)= self.target.run("mraa-gpio version") + output = output.lower() + if any(x in output for x in ("broxton", "tuchuck", "joule")): + self.pin = "51" + elif "minnowboard" in output: + self.pin = "25" + else: + raise unittest.SkipTest(output) + + def test_gpio(self): + ''' + Test a GPIO pin on and off and check the pin output with + BeagleBone + ''' + def check_gpio_output(): + cmd = "cat /sys/class/gpio/gpio20/value".split() + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + return int(output) + + self.target.run("mraa-gpio set " + self.pin + " 0") + sleep(1) + output = check_gpio_output() + self.assertEqual(output, 0, msg="GPIO pin output is not 0") + + self.target.run("mraa-gpio set " + self.pin + " 1") + sleep(1) + output = check_gpio_output() + self.assertEqual(output, 1, msg="GPIO pin output is not 1") + + self.target.run("mraa-gpio set " + self.pin + " 0") + sleep(1) + output = check_gpio_output() + self.assertEqual(output, 0, msg="GPIO pin output is not 0") From 00007207f3fe72c85f5b063ca847882edb6c0680 Mon Sep 17 00:00:00 2001 From: Simo Kuusela Date: Fri, 24 Feb 2017 13:58:10 +0200 Subject: [PATCH 2/2] meta-iotqa: Enable mraa GPIO test Signed-off-by: Simo Kuusela --- meta-iotqa/conf/test/refkit-image-common.manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/meta-iotqa/conf/test/refkit-image-common.manifest b/meta-iotqa/conf/test/refkit-image-common.manifest index 52830f11bb..a62ec1062c 100644 --- a/meta-iotqa/conf/test/refkit-image-common.manifest +++ b/meta-iotqa/conf/test/refkit-image-common.manifest @@ -5,6 +5,7 @@ oeqa.runtime.sanity.comm_managerdaemon oeqa.runtime.sanity.comm_btcheck oeqa.runtime.sanity.apprt_python oeqa.runtime.sanity.mraa_hello +oeqa.runtime.sanity.mraa_gpio oeqa.runtime.sanity.iotivity oeqa.runtime.alsa.alsa oeqa.runtime.sanity.upm