File: test.py

package info (click to toggle)
labgrid 0.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,232 kB
  • sloc: python: 17,045; makefile: 30; sh: 12
file content (32 lines) | stat: -rwxr-xr-x 755 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
"""Power-cycle a target until the /dev/nand0 device is missing."""

import sys
import logging

from labgrid import Environment, StepReporter
from labgrid.strategy.bareboxstrategy import Status


# enable debug 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['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)