예제 #1
0
 def test_create_named_drivers(self, tmpdir):
     p = tmpdir.join("config.yaml")
     p.write("""
     targets:
       test1:
         resources:
         - AndroidFastboot:
             name: "fastboot"
             match: {}
         - RawSerialPort:
             name: "serial_a"
             port: "/dev/ttyUSB0"
             speed: 115200
         - cls: RawSerialPort
           name: "serial_b"
           port: "/dev/ttyUSB0"
           speed: 115200
         drivers:
         - FakeConsoleDriver:
             name: "serial_a"
         - FakeConsoleDriver:
             name: "serial_b"
     """)
     e = Environment(str(p))
     t = e.get_target("test1")
예제 #2
0
    def test_create_multi_drivers(self, tmpdir):
        p = tmpdir.join("config.yaml")
        p.write("""
        targets:
          test1:
            resources:
            - RawSerialPort:
                name: "serial_a"
                port: "/dev/ttyUSB0"
                speed: 115200
            - RawSerialPort:
                name: "serial_b"
                port: "/dev/ttyUSB0"
                speed: 115200
            drivers:
            - SerialDriver:
                name: "serial_a"
                bindings:
                  port: "serial_a"
            - SerialDriver:
                name: "serial_b"
                bindings:
                  port: "serial_b"
        """)
        e = Environment(str(p))
        t = e.get_target("test1")
        r_a = t.get_resource(RawSerialPort, name="serial_a")
        r_b = t.get_resource(RawSerialPort, name="serial_b")
        assert r_a is not r_b
        d_a = t.get_driver(ConsoleProtocol, name="serial_a", activate=False)
        d_b = t.get_driver(ConsoleProtocol, name="serial_b", activate=False)
        assert d_a is not d_b

        assert d_a.port is r_a
        assert d_b.port is r_b
예제 #3
0
 def test_get_target(self, tmpdir):
     p = tmpdir.join("config.yaml")
     p.write("""
     targets:
       test1:
         drivers: {}
       test2:
         role: foo
         resources: {}
     """)
     e = Environment(str(p))
     assert (e.get_target("test1"))
     assert (e.get_target("test2"))
예제 #4
0
 def test_usbserialport_warning(self, tmpdir):
     p = tmpdir.join("config.yaml")
     p.write("""
     targets:
       test1:
         resources:
         - USBSerialPort:
             port: /dev/ttyS0
         drivers:
         - SerialDriver: {}
     """)
     e = Environment(str(p))
     with pytest.warns(UserWarning):
         t = e.get_target("test1")
예제 #5
0
 def test_create_named_resources(self, tmpdir):
     p = tmpdir.join("config.yaml")
     p.write("""
     targets:
       test1:
         resources:
         - AndroidFastboot:
             name: "fastboot"
             match: {}
         - RawSerialPort:
             port: "/dev/ttyUSB0"
             speed: 115200
     """)
     e = Environment(str(p))
     t = e.get_target("test1")
예제 #6
0
 def test_usbserialport_no_warning(self, tmpdir):
     p = tmpdir.join("config.yaml")
     p.write("""
     targets:
       test1:
         resources:
         - USBSerialPort: {}
         drivers:
         - SerialDriver: {}
     """)
     e = Environment(str(p))
     with pytest.warns(None) as record:
         t = e.get_target("test1")
     for i in record.list:
         assert i.category != 'UserWarning'
예제 #7
0
파일: test.py 프로젝트: prevas-hnje/labgrid
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)