示例#1
0
文件: testcase.py 项目: zkrx/tbot
def test_linux(mach: typing.Optional[linux.LinuxShell] = None, ) -> None:
    with mach or tbot.acquire_lab() as lnx:
        p = lnx.workdir / "foobar"

        with tbot.acquire_lab() as lh:
            p2 = lh.workdir / "barfoo"

            # Should fail!
            lnx.exec0("echo", p2)
            lh.exec0("echo", p)

            with tbot.acquire_board(lh) as b:
                with tbot.acquire_linux(b) as lnx2:
                    p3 = lnx2.workdir / "barbarbar"

                    # Should fail!
                    lh.exec0("echo", p3)
                    lnx.exec0("echo", p3)
                    lnx2.exec0("echo", p)
                    lnx2.exec0("echo", p2)

                    # Should pass!
                    lnx.exec0("echo", p)
                    lh.exec0("echo", p2)
                    lnx2.exec0("echo", p3)
示例#2
0
def getcpu(mach: typing.Optional[linux.LinuxMachine] = None, ) -> None:
    with contextlib.ExitStack() as cx:
        if mach is None:
            lh = cx.enter_context(tbot.acquire_lab())
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))
        else:
            lnx = mach

        lnx.exec0("cat", "/proc/cpuinfo")
示例#3
0
def gettarget(mach: typing.Optional[linux.LinuxMachine] = None, ) -> None:
    with contextlib.ExitStack() as cx:
        if mach is None:
            lh = cx.enter_context(tbot.acquire_lab())
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))
        else:
            lnx = mach

        tc.testsuite(getcpu, getlinuxversion, getyoctoversion, mach=lnx)
示例#4
0
def getyoctoversion(
    mach: typing.Optional[linux.LinuxMachine] = None, ) -> None:
    with contextlib.ExitStack() as cx:
        if mach is None:
            lh = cx.enter_context(tbot.acquire_lab())
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))
        else:
            lnx = mach

        lnx.exec0("cat", "/etc/os_release")
示例#5
0
def selftest_board_linux(lab: typing.Optional[tbot.selectable.LabHost] = None) -> None:
    """Test board's linux."""

    with contextlib.ExitStack() as cx:
        lh = cx.enter_context(lab or tbot.acquire_lab())

        try:
            b = cx.enter_context(tbot.acquire_board(lh))
        except NotImplementedError:
            tbot.skip("No board available")

        lnx = cx.enter_context(tbot.acquire_linux(b))

        mach.selftest_machine_shell(lnx)
示例#6
0
def checkswupdate(
    mach: typing.Optional[linux.LinuxMachine] = None,
    **kwargs: typing.Any,
) -> None:
    with contextlib.ExitStack() as cx:
        if mach is None:
            lh = cx.enter_context(tbot.acquire_lab())
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))
        else:
            lnx = mach

        version = lnx.exec("/usr/bin/swupdate", "--version")
        tbot.log.message(f"SWUpdate detected version {version}")
示例#7
0
def selftest_with_linux(lab: typing.Optional[tbot.selectable.LabHost] = None) -> None:
    """Test the tbot.with_linux decorator."""
    with lab or selftest.SelftestHost() as lh:
        with SubstituteBoard():
            # Call without anything
            selftest_decorated_linux()

            # Call with labhost
            selftest_decorated_linux(lh)

            # Call with Linux
            with tbot.acquire_board(lh) as b:
                with tbot.acquire_linux(b) as lnx:
                    selftest_decorated_linux(lnx)
示例#8
0
def selftest_board_linux(lab: typing.Optional[tbot.selectable.LabHost] = None) -> None:
    """Test board's linux."""
    with contextlib.ExitStack() as cx:
        lh = cx.enter_context(lab or tbot.acquire_lab())

        try:
            b = cx.enter_context(tbot.acquire_board(lh))
        except NotImplementedError:
            tbot.log.message(
                tbot.log.c("Skipped").yellow.bold + " because no board available."
            )
            return

        lnx = cx.enter_context(tbot.acquire_linux(b))

        mach.selftest_machine_shell(lnx)
示例#9
0
def qemu_linux_testcases(
    lab: typing.Optional[tbot.selectable.LabHost] = None,
    board_linux: typing.Optional[board.LinuxMachine] = None,
) -> None:
    with contextlib.ExitStack() as cx:
        lh = cx.enter_context(lab or tbot.acquire_lab())
        if board_linux is not None:
            lnx = board_linux
        else:
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))

        tbot.tc.testsuite(
            linux_verify_uname,
            linux_regular_file_operations,
            lnx=lnx,
        )
示例#10
0
def swupdateweb(
    mach: typing.Optional[linux.LinuxMachine] = None,
    ip=None,
    path=None,
) -> None:
    with contextlib.ExitStack() as cx:
        if mach is None:
            lh = cx.enter_context(tbot.acquire_lab())
            b = cx.enter_context(tbot.acquire_board(lh))
            lnx = cx.enter_context(tbot.acquire_linux(b))
        else:
            lnx = mach

        if ip is None:
            raise RuntimeError(f"IP Address is not set")
        if path is None:
            raise RuntimeError(f"Path to SWU is not set")

        return SWUpdater(path, ip).update()
示例#11
0
def wandboard_check_iperf(
    lab: linux.LinuxShell = None,
    board: board.Board = None,
    blx: linux.LinuxShell = None,
    cycles: str = "5",
    minval: str = "70",
    intervall: str = "5",
) -> bool:
    """
    check networkperformance with iperf
    """
    with contextlib.ExitStack() as cx:
        if lab is not None:
            lh = lab
        else:
            lh = cx.enter_context(tbot.acquire_lab())

        if board is not None:
            b = board
        else:
            b = cx.enter_context(tbot.acquire_board(lh))

        if blx is not None:
            lnx = blx
        else:
            lnx = cx.enter_context(tbot.acquire_linux(b))

        ge.lx_check_iperf(lh,
                          lnx,
                          intervall=intervall,
                          cycles=cycles,
                          minval=minval,
                          filename="iperf.dat",
                          showlog=True)

    return True
示例#12
0
def interactive_linux() -> None:
    with tbot.acquire_lab() as lh:
        with tbot.acquire_board(lh) as b:
            with tbot.acquire_linux(b) as lnx:
                lnx.interactive()
示例#13
0
def interactive_linux() -> None:
    """Start an interactive Linux shell on the selected board."""
    with tbot.acquire_lab() as lh:
        with tbot.acquire_board(lh) as b, tbot.acquire_linux(b) as lnx:
            lnx.interactive()