Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta-iotqa/conf/test/refkit-image-common.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions meta-iotqa/lib/oeqa/runtime/sanity/mraa_gpio.py
Original file line number Diff line number Diff line change
@@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you do this directly without exporting the GPIO first?

Copy link
Contributor Author

@skuusela skuusela Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mythi No the GPIO pin has to be exported, but it's already exported on the Beaglebones. I added few lines to a boot script on the Beaglebone so it's always exported and ready after booting.

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")