Permalink
Browse files

examples/library: add example on how to use labgrid as a library

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information...
jluebbe committed Apr 7, 2017
1 parent 5292d0c commit aacbe33f2cb3fa54bbf5318ae9ef87fd430fa5b3
Showing with 48 additions and 0 deletions.
  1. +15 −0 examples/library/phytec.yaml
  2. +33 −0 examples/library/test.py
@@ -0,0 +1,15 @@
targets:
main:
resources:
RemotePlace:
name: phycore-imx6
drivers:
NetworkPowerDriver: {}
SerialDriver: {}
BareboxDriver:
prompt: 'barebox@[^:]+:[^ ]+ '
ShellDriver:
prompt: 'root@\w+:[^ ]+ '
login_prompt: ' login: '
username: 'root'
BareboxStrategy: {}
View
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""Power-cycle a target until the /dev/nand0 device is missing."""
import sys
from labgrid import Environment, StepReporter
from labgrid.protocol import CommandProtocol
from labgrid.strategy import BareboxStrategy
from labgrid.strategy.bareboxstrategy import Status
# enable debug logging
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(levelname)7s: %(message)s',
stream=sys.stderr,
)
# show labgrid steps on the console
StepReporter()
def run_once(target):
s = target.get_driver(BareboxStrategy)
s.status = Status.unknown # force a power-cycle
s.transition('barebox')
cmd = target.get_active_driver(CommandProtocol)
cmd.run_check('test -e /dev/nand0')
target.deactivate(cmd)
env = Environment(sys.argv[1])
target = env.get_target('main')
while True:
run_once(target)

0 comments on commit aacbe33

Please sign in to comment.