Exemple #1
0
def selftest_tc_uboot_build(lab: typing.Optional[linux.Lab] = None) -> None:
    from tbot.tc.selftest.tc import build

    with tbot.acquire_local() as lh:
        builder = _uboot_prepare(lh)

        build.LocalDummyBuildhost.prepare(lh)
        setattr(lh, "build", lambda: build.LocalDummyBuildhost())

        @tbot.testcase
        def build_with_lab() -> None:
            builder.build(lab=lh)

        build_with_lab()

        @tbot.testcase
        def build_with_buildhost() -> None:
            with lh.build() as bh:
                builder.build(host=bh)

        build_with_buildhost()

        @tbot.testcase
        def build_with_path() -> None:
            with lh.build() as bh:
                path = bh.workdir / "selftest-uboot-build"
                builder.build(path=path)

        build_with_path()

        @tbot.testcase
        def build_with_repo(clean: bool) -> None:
            with lh.build() as bh:
                path = bh.workdir / "selftest-uboot-testbuild"
                if path.exists():
                    bh.exec0("touch", path / "dirty")
                    bh.exec0("rm", "-f", path / ".cleaned")
                repo = builder.checkout(path=path, clean=clean)

                builder.build(repo=repo, clean=clean)
                assert (not clean) == (repo /
                                       "dirty").exists(), "Cleaning failed!"
                assert clean == (repo /
                                 ".cleaned").exists(), "Mr Proper failed!"

        build_with_repo(True)
        build_with_repo(False)
Exemple #2
0
def selftest_tc_uboot_patched_bisect(lab: typing.Optional[linux.Lab] = None) -> None:
    from tbot.tc.selftest.tc import build, git as git_tc

    with build.LocalDummyBuildhost() as bh:
        bh.prepare(bh)
        builder = _uboot_prepare(bh)

        repo = builder.checkout(host=bh)
        repo.reset("HEAD~1", git.ResetMode.HARD)

        good = git_tc.git_increment_commits(repo)

        @tbot.testcase
        def check(repo: git.GitRepository) -> bool:
            builder.build(unpatched_repo=repo)
            result = repo.host.exec("cat", repo / "counter.txt")
            return result[0] == 0 and int(result[1].strip()) < 17

        bad = repo.bisect(good=good, test=check)
        tbot.log.message(f"Bad commit is {bad}!")