Ejemplo n.º 1
0
    def test_sort_small(self):
        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        (
            tmp,
            series,
        ) = tempfile.mkstemp(dir=self.ks_dir)
        with open(series, mode="w") as f:
            f.write("""########################################################
	# sorted patches
	########################################################
	patches.suse/mainline-0.patch
	patches.suse/net-0.patch
	########################################################
	# end of sorted patches
	########################################################
""")

        subprocess.check_call([ss_path, "-c", series])
        with open(series) as f:
            content1 = f.read()
        subprocess.check_call([ss_path, series])
        with open(series) as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        os.unlink(series)
Ejemplo n.º 2
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature("Alice Author", "*****@*****.**")
        committer = pygit2.Signature("Cecil Committer", "*****@*****.**")
        tree = self.repo.TreeBuilder()

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        self.mainline_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", self.mainline_repo)

        self.commits = {}
        self.commits["mainline 0"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer, "mainline 0\n\nlog",
            tree.write(), [])

        self.commits["mainline 1"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer, "mainline 1\n\nlog",
            tree.write(), [self.commits["mainline 0"]])

        self.commits["mainline 2"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer, "mainline 2\n\nlog",
            tree.write(), [self.commits["mainline 1"]])
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits["mainline 2"])

        self.repo.checkout("refs/heads/mainline")

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        os.chdir(self.ks_dir)

        subprocess.check_call((
            "git",
            "init",
            "./",
        ),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call((
            "git",
            "config",
            "--add",
            "mergetool.git-sort.cmd",
            "%s $LOCAL $BASE $REMOTE $MERGED" %
            (os.path.join(lib.libdir(), "merge_tool.py"), ),
        ))
        subprocess.check_call((
            "git",
            "config",
            "--add",
            "mergetool.git-sort.trustexitcode",
            "true",
        ))

        self.patch_dir = "patches.suse"
        os.mkdir(self.patch_dir)
Ejemplo n.º 3
0
    def test_nofile(self):
        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        try:
            subprocess.check_output([ss_path, "aaa"], stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(
                err.output.decode(),
                "Error: [Errno 2] No such file or directory: 'aaa'\n")
        else:
            self.assertTrue(False)
Ejemplo n.º 4
0
    def test_fixup(self):
        qm_path = os.path.join(lib.libdir(), "quilt-mode.sh")

        # import commits[1]
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[1])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")
        subprocess.check_call(
            """. %s; qcp -f %s""" % (
                qm_path, str(self.commits[1])),
            shell=True, stdout=subprocess.DEVNULL, executable="/bin/bash")

        retval = subprocess.check_output(("quilt", "--quiltrc", "-", "next",))
        name = "patches.suse/Fix-the-very-small-module.patch"
        self.assertEqual(retval.decode().strip(), name)
Ejemplo n.º 5
0
    def test_simple(self):
        si_path = os.path.join(lib.libdir(), "series_insert.py")
        os.chdir(self.ks_dir)

        series = "series.conf"
        series1 = tests.support.format_series(
            ((None, ("patches.suse/mainline-%d.patch" % (i, ) for i in (
                0,
                2,
            ))), ))
        with open(series, mode="w") as f:
            f.write(series1)

        subprocess.check_call([si_path, "patches.suse/mainline-1.patch"])
        with open(series) as f:
            content = f.read()
        self.assertEqual(
            content,
            tests.support.format_series(
                ((None, ("patches.suse/mainline-%d.patch" % (i, )
                         for i in range(3))), )))

        content = []
        with open("patches.suse/mainline-1.patch") as f:
            for line in f:
                if line.startswith("Git-commit: "):
                    line = "Git-commit: invalid\n"
                content.append(line)
        with open("patches.suse/mainline-1.patch", mode="w+") as f:
            f.writelines(content)

        with open(series, mode="w") as f:
            f.write(series1)

        try:
            subprocess.check_output([si_path, "patches.suse/mainline-1.patch"],
                                    stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(
                err.output.decode(),
                "Error: Git-commit tag \"invalid\" in patch "
                "\"patches.suse/mainline-1.patch\" is not a valid revision.\n")
        else:
            self.assertTrue(False)

        os.unlink(series)
Ejemplo n.º 6
0
    def test_sort(self):
        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        (
            tmp,
            series,
        ) = tempfile.mkstemp(dir=self.ks_dir)
        with open(series, mode="w") as f:
            f.write("""
	patches.suse/unsorted-before.patch

	########################################################
	# sorted patches
	########################################################
	patches.suse/mainline-0.patch
	patches.suse/net-0.patch

	# davem/net
	patches.suse/net-1.patch
	patches.suse/net-2.patch

	# out-of-tree patches
	patches.suse/oot-0.patch
	patches.suse/oot-1.patch

	########################################################
	# end of sorted patches
	########################################################

	patches.suse/unsorted-after.patch
""")

        subprocess.check_call([ss_path, "-c", series])
        with open(series) as f:
            content1 = f.read()
        subprocess.check_call([ss_path, series])
        with open(series) as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        os.unlink(series)
Ejemplo n.º 7
0
def format_import(references, tmpdir, dstdir, rev, poi=[]):
    assert len(poi) == 0 # todo
    args = ("git", "format-patch", "--output-directory", tmpdir, "--notes",
            "--max-count=1", "--subject-prefix=", "--no-numbered", rev,)
    src = subprocess.check_output(args).decode().strip()
    # remove number prefix
    name = os.path.basename(src)[5:]
    dst = os.path.join(dstdir, name)
    if os.path.exists(os.path.join("patches", dst)):
        name = "%s-%s.patch" % (name[:-6], rev[:8],)
        dst = os.path.join(dstdir, name)

    subprocess.check_call((os.path.join(lib.libdir(), "clean_header.sh"),
                           "--commit=%s" % rev, "--reference=%s" % references,
                           src,))
    subprocess.check_call(("quilt", "import", "-P", dst, src,))
    # This will remind the user to run refresh_patch.sh
    lib.touch(".pc/%s~refresh" % (dst,))

    return 0
Ejemplo n.º 8
0
def format_import(references, tmpdir, dstdir, rev, poi=[]):
    assert len(poi) == 0  # todo
    args = (
        "git",
        "format-patch",
        "--output-directory",
        tmpdir,
        "--notes",
        "--max-count=1",
        "--subject-prefix=",
        "--no-numbered",
        rev,
    )
    src = subprocess.check_output(args).decode().strip()
    # remove number prefix
    name = os.path.basename(src)[5:]
    dst = os.path.join(dstdir, name)
    if os.path.exists(os.path.join("patches", dst)):
        name = "%s-%s.patch" % (
            name[:-6],
            rev[:8],
        )
        dst = os.path.join(dstdir, name)

    subprocess.check_call((
        os.path.join(lib.libdir(), "clean_header.sh"),
        "--commit=%s" % rev,
        "--reference=%s" % references,
        src,
    ))
    subprocess.check_call((
        "quilt",
        "import",
        "-P",
        dst,
        src,
    ))
    # This will remind the user to run refresh_patch.sh
    lib.touch(".pc/%s~refresh" % (dst, ))

    return 0
Ejemplo n.º 9
0
    def test_errors(self):
        gs_path = os.path.join(lib.libdir(), "git_sort.py")
        os.chdir(self.repo_dir)

        try:
            subprocess.check_output([gs_path, "-d"], stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().strip(),
                             "Error: Not a git repository")
        else:
            self.assertTrue(False)

        try:
            subprocess.check_output([gs_path], stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().strip(),
                             "Error: Not a git repository")
        else:
            self.assertTrue(False)
Ejemplo n.º 10
0
    def test_errors(self):
        gs_path = os.path.join(lib.libdir(), "git_sort.py")
        os.chdir(self.repo_dir)

        try:
            subprocess.check_output([gs_path, "-d"], stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().strip(),
                             "Error: Not a git repository")
        else:
            self.assertTrue(False)

        try:
            subprocess.check_output([gs_path], stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().strip(),
                             "Error: Not a git repository")
        else:
            self.assertTrue(False)
Ejemplo n.º 11
0
    def test_absent(self):
        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        (
            tmp,
            series,
        ) = tempfile.mkstemp(dir=self.ks_dir)
        with open(series, mode="w") as f:
            f.write("""
	patches.suse/unsorted-before.patch
""")

        try:
            subprocess.check_output([ss_path, series],
                                    stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.output.decode(),
                             "Error: Sorted subseries not found.\n")
        else:
            self.assertTrue(False)

        os.unlink(series)
Ejemplo n.º 12
0
    def test_fixup(self):
        qm_path = os.path.join(lib.libdir(), "quilt-mode.sh")

        # import commits[1]
        subprocess.check_call(". %s; qgoto %s" %
                              (qm_path, str(self.commits[1])),
                              shell=True,
                              stdout=subprocess.DEVNULL,
                              executable="/bin/bash")
        subprocess.check_call(""". %s; qcp -f %s""" %
                              (qm_path, str(self.commits[1])),
                              shell=True,
                              stdout=subprocess.DEVNULL,
                              executable="/bin/bash")

        retval = subprocess.check_output((
            "quilt",
            "--quiltrc",
            "-",
            "next",
        ))
        name = "patches.suse/Fix-the-very-small-module.patch"
        self.assertEqual(retval.decode().strip(), name)
Ejemplo n.º 13
0
    def setUp(self):
        self.ss_path = os.path.join(lib.libdir(), "series_sort.py")

        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature('Alice Author', '*****@*****.**')
        committer = pygit2.Signature('Cecil Committer', '*****@*****.**')
        tree = self.repo.TreeBuilder().write()

        m0 = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 0\n\nlog",
            tree,
            []
        )

        n0 = self.repo.create_commit(
            "refs/heads/net",
            author,
            committer,
            "net 0\n\nlog",
            tree,
            [m0]
        )

        self.repo.checkout("refs/heads/mainline")
        m1 = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 1, merge net\n\nlog",
            tree,
            [m0, n0]
        )

        m2 = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 2\n\nlog",
            tree,
            [m1]
        )

        n1 = self.repo.create_commit(
            "refs/heads/net",
            author,
            committer,
            "net 1\n\nlog",
            tree,
            [n0]
        )

        n2 = self.repo.create_commit(
            "refs/heads/net",
            author,
            committer,
            "net 2\n\nlog",
            tree,
            [n1]
        )

        oot0 = self.repo.create_commit(
            "refs/heads/oot",
            author,
            committer,
            "oot 0\n\nlog",
            tree,
            [m0]
        )

        oot1 = self.repo.create_commit(
            "refs/heads/oot",
            author,
            committer,
            "oot 1\n\nlog",
            tree,
            [oot0]
        )

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        origin_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", origin_repo)
        self.repo.references.create("refs/remotes/origin/master", m2)

        net_repo = k_org_canon_prefix + "davem/net.git"
        self.repo.remotes.create("net", net_repo)
        self.repo.references.create("refs/remotes/net/master", n2)

        self.index = git_sort.SortIndex(self.repo)

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        tests.support.format_patch(self.repo.get(m0), mainline="v3.45-rc6")
        tests.support.format_patch(self.repo.get(n0), mainline="v3.45-rc6")
        tests.support.format_patch(self.repo.get(n1), repo=net_repo)
        tests.support.format_patch(self.repo.get(n2), repo=net_repo)
        tests.support.format_patch(self.repo.get(oot0))
        tests.support.format_patch(self.repo.get(oot1))
        os.chdir(self.ks_dir)
Ejemplo n.º 14
0
    def setUp(self):
        self.maxDiff = None
        self.ss_path = os.path.join(lib.libdir(), "series_sort.py")

        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature("Alice Author", "*****@*****.**", time=0,
                                  offset=0)
        committer = pygit2.Signature("Cecil Committer", "*****@*****.**",
                                    time=0, offset=0)
        tree = self.repo.TreeBuilder()

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        self.mainline_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", self.mainline_repo)
        self.net_next_repo = k_org_canon_prefix + "davem/net-next.git"
        self.repo.remotes.create("net-next", self.net_next_repo)
        self.net_repo = k_org_canon_prefix + "davem/net.git"
        self.rdma_repo = k_org_canon_prefix + "rdma/rdma.git"
        self.repo.remotes.create("rdma", self.rdma_repo)
        self.dledford_repo = k_org_canon_prefix + "dledford/rdma.git"
        self.repo.remotes.create("dledford/rdma", self.dledford_repo)
        self.nf_repo = k_org_canon_prefix + "pablo/nf.git"
        self.repo.remotes.create("pablo/nf", self.nf_repo)

        self.commits = {}
        self.commits["mainline 0"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 0\n\nlog",
            tree.write(),
            []
        )

        self.commits["net-next 0"] = self.repo.create_commit(
            "refs/heads/net-next",
            author,
            committer,
            "net-next 0\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )
        self.repo.references.create("refs/remotes/net-next/master",
                                    self.commits["net-next 0"])

        self.commits["other 0"] = self.repo.create_commit(
            "refs/heads/other",
            author,
            committer,
            "other 0\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )

        self.commits["rdma for-next 0"] = self.repo.create_commit(
            "refs/heads/rdma-next",
            author,
            committer,
            "rdma for-next 0\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )

        self.commits["mainline 1"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 1, merge rdma\n\nlog",
            tree.write(),
            [self.commits["mainline 0"], self.commits["rdma for-next 0"]]
        )

        self.commits["dledford/rdma k.o/for-next 0"] = self.repo.create_commit(
            "refs/heads/dledford-next",
            author,
            committer,
            "dledford/rdma k.o/for-next 0\n\nlog",
            tree.write(),
            [self.commits["rdma for-next 0"]]
        )
        self.repo.references.create(
            "refs/remotes/dledford/rdma/k.o/for-next",
            self.commits["dledford/rdma k.o/for-next 0"])
        self.repo.references.create("refs/remotes/rdma/for-next",
                                    self.commits["dledford/rdma k.o/for-next 0"])
        self.repo.references.create("refs/remotes/rdma/for-rc",
                                    self.commits["dledford/rdma k.o/for-next 0"])

        self.commits["net 0"] = self.repo.create_commit(
            "refs/heads/net",
            author,
            committer,
            "net 0\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )

        self.commits["nf 0"] = self.repo.create_commit(
            "refs/heads/nf",
            author,
            committer,
            "nf 0\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )
        self.repo.references.create("refs/remotes/pablo/nf/master",
                                    self.commits["nf 0"])

        self.commits["mainline 2"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 2, merge net\n\nlog",
            tree.write(),
            [self.commits["mainline 1"], self.commits["net 0"]]
        )

        self.commits["net 1"] = self.repo.create_commit(
            "refs/heads/net",
            author,
            committer,
            "net 1\n\nlog",
            tree.write(),
            [self.commits["net 0"]]
        )

        tree.insert("README", 
                    self.repo.create_blob("NAME = v4.1 release\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits["v4.1"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.1",
            tree.write(),
            [self.commits["mainline 2"]]
        )
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits["v4.1"])
        self.repo.create_tag("v4.1", self.commits["v4.1"], pygit2.GIT_REF_OID,
                             committer, "Linux 4.1")

        self.repo.checkout("refs/heads/mainline")

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        os.chdir(self.ks_dir)
        self.patch_dir = "patches.suse"
        os.mkdir(self.patch_dir)
Ejemplo n.º 15
0
    def test_cache(self):
        gs_path = os.path.join(lib.libdir(), "git_sort.py")
        cache_path = os.path.join(os.environ["XDG_CACHE_HOME"], "git-sort")

        input_text = "\n".join(self.commits)

        os.chdir(self.repo_dir)
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will rebuild history")

        # "-d" should not create a cache
        retval = 0
        try:
            os.stat(cache_path)
        except OSError as e:
            retval = e.errno
        self.assertEqual(retval, 2)

        output_ref = subprocess.check_output(
            gs_path, input=input_text.encode()).decode()
        time1 = os.stat(cache_path).st_mtime

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")

        # "-d" should not modify a cache
        self.assertEqual(os.stat(cache_path).st_mtime, time1)

        # test that git-sort action is the same as "-d" states (no cache
        # rebuild)
        output = subprocess.check_output(
            gs_path, input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)
        self.assertEqual(os.stat(cache_path).st_mtime, time1)

        # test version number change
        shelve.open(cache_path)["version"] = 1
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[1], "Unsupported cache version")
        self.assertEqual(output[-1], "Will rebuild history")

        output = subprocess.check_output(
            gs_path, input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")

        # corrupt the cache structure
        shelve.open(cache_path)["history"] = {
            "linux.git" : ["abc", "abc", "abc"],
            "net" : ["abc", "abc", "abc"],
            "net-next" : ["abc", "abc", "abc"],
        }
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[1], "Inconsistent cache content")
        self.assertEqual(output[-1], "Will rebuild history")

        output = subprocess.check_output(
            gs_path, input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")
 def test_empty_input(self):
     os.chdir(self.repo_dir)
     gs_path = os.path.join(lib.libdir(), "git_sort.py")
     subprocess.check_output(gs_path, input="\n".encode())
Ejemplo n.º 17
0
    def setUp(self):
        self.maxDiff = None
        self.ss_path = os.path.join(lib.libdir(), "series_sort.py")

        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature("Alice Author",
                                  "*****@*****.**",
                                  time=0,
                                  offset=0)
        committer = pygit2.Signature("Cecil Committer",
                                     "*****@*****.**",
                                     time=0,
                                     offset=0)
        tree = self.repo.TreeBuilder()

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        self.mainline_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", self.mainline_repo)
        self.net_next_repo = k_org_canon_prefix + "davem/net-next.git"
        self.repo.remotes.create("net-next", self.net_next_repo)
        self.net_repo = k_org_canon_prefix + "davem/net.git"
        self.rdma_repo = k_org_canon_prefix + "rdma/rdma.git"
        self.repo.remotes.create("rdma", self.rdma_repo)
        self.dledford_repo = k_org_canon_prefix + "dledford/rdma.git"
        self.repo.remotes.create("dledford/rdma", self.dledford_repo)
        self.nf_repo = k_org_canon_prefix + "pablo/nf.git"
        self.repo.remotes.create("pablo/nf", self.nf_repo)

        self.commits = {}
        self.commits["mainline 0"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer, "mainline 0\n\nlog",
            tree.write(), [])

        self.commits["net-next 0"] = self.repo.create_commit(
            "refs/heads/net-next", author, committer, "net-next 0\n\nlog",
            tree.write(), [self.commits["mainline 0"]])
        self.repo.references.create("refs/remotes/net-next/master",
                                    self.commits["net-next 0"])

        self.commits["other 0"] = self.repo.create_commit(
            "refs/heads/other", author, committer, "other 0\n\nlog",
            tree.write(), [self.commits["mainline 0"]])

        self.commits["rdma for-next 0"] = self.repo.create_commit(
            "refs/heads/rdma-next", author, committer,
            "rdma for-next 0\n\nlog", tree.write(),
            [self.commits["mainline 0"]])

        self.commits["mainline 1"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer,
            "mainline 1, merge rdma\n\nlog", tree.write(),
            [self.commits["mainline 0"], self.commits["rdma for-next 0"]])

        self.commits["dledford/rdma k.o/for-next 0"] = self.repo.create_commit(
            "refs/heads/dledford-next",
            author, committer, "dledford/rdma k.o/for-next 0\n\nlog",
            tree.write(), [self.commits["rdma for-next 0"]])
        self.repo.references.create(
            "refs/remotes/dledford/rdma/k.o/for-next",
            self.commits["dledford/rdma k.o/for-next 0"])
        self.repo.references.create(
            "refs/remotes/rdma/for-next",
            self.commits["dledford/rdma k.o/for-next 0"])
        self.repo.references.create(
            "refs/remotes/rdma/for-rc",
            self.commits["dledford/rdma k.o/for-next 0"])

        self.commits["net 0"] = self.repo.create_commit(
            "refs/heads/net", author, committer, "net 0\n\nlog", tree.write(),
            [self.commits["mainline 0"]])

        self.commits["nf 0"] = self.repo.create_commit(
            "refs/heads/nf", author, committer, "nf 0\n\nlog", tree.write(),
            [self.commits["mainline 0"]])
        self.repo.references.create("refs/remotes/pablo/nf/master",
                                    self.commits["nf 0"])

        self.commits["mainline 2"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer,
            "mainline 2, merge net\n\nlog", tree.write(),
            [self.commits["mainline 1"], self.commits["net 0"]])

        self.commits["net 1"] = self.repo.create_commit(
            "refs/heads/net", author, committer, "net 1\n\nlog", tree.write(),
            [self.commits["net 0"]])

        tree.insert("README", self.repo.create_blob("NAME = v4.1 release\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits["v4.1"] = self.repo.create_commit(
            "refs/heads/mainline", author, committer, "Linux 4.1",
            tree.write(), [self.commits["mainline 2"]])
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits["v4.1"])
        self.repo.create_tag("v4.1", self.commits["v4.1"], pygit2.GIT_REF_OID,
                             committer, "Linux 4.1")

        self.repo.checkout("refs/heads/mainline")

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        os.chdir(self.ks_dir)
        self.patch_dir = "patches.suse"
        os.mkdir(self.patch_dir)
Ejemplo n.º 18
0
    def test_cache(self):
        gs_path = os.path.join(lib.libdir(), "git_sort.py")
        cache_path = os.path.join(os.environ["XDG_CACHE_HOME"], "git-sort")

        input_text = "\n".join(self.commits)

        os.chdir(self.repo_dir)
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will rebuild history")

        # "-d" should not create a cache
        retval = 0
        try:
            os.stat(cache_path)
        except OSError as e:
            retval = e.errno
        self.assertEqual(retval, 2)

        output_ref = subprocess.check_output(
            gs_path, input=input_text.encode()).decode()
        time1 = os.stat(cache_path).st_mtime

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")

        # "-d" should not modify a cache
        self.assertEqual(os.stat(cache_path).st_mtime, time1)

        # test that git-sort action is the same as "-d" states (no cache
        # rebuild)
        output = subprocess.check_output(gs_path,
                                         input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)
        self.assertEqual(os.stat(cache_path).st_mtime, time1)

        # test version number change
        shelve.open(cache_path)["version"] = 1
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[1], "Unsupported cache version")
        self.assertEqual(output[-1], "Will rebuild history")

        output = subprocess.check_output(gs_path,
                                         input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")

        # corrupt the cache structure
        shelve.open(cache_path)["history"] = {
            "linux.git": ["abc", "abc", "abc"],
            "net": ["abc", "abc", "abc"],
            "net-next": ["abc", "abc", "abc"],
        }
        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[1], "Inconsistent cache content")
        self.assertEqual(output[-1], "Will rebuild history")

        output = subprocess.check_output(gs_path,
                                         input=input_text.encode()).decode()
        self.assertEqual(output, output_ref)

        output = subprocess.check_output([gs_path, "-d"]).decode().splitlines()
        self.assertEqual(output[-1], "Will not rebuild history")
Ejemplo n.º 19
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])
        self.repo.config["user.email"] = "*****@*****.**"
        self.repo.config["user.name"] = "Author One"

        author = pygit2.Signature("Author One", "*****@*****.**")
        committer = pygit2.Signature("Maintainer One",
                                     "*****@*****.**")
        tree = self.repo.TreeBuilder()

        tree.insert("driver.c", self.repo.create_blob("#include <bad.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits = []
        self.commits.append(
            self.repo.create_commit(
                "refs/heads/mainline", author, committer,
                """Add a very small module

... which was not tested.

Signed-off-by: Author One <*****@*****.**>
Signed-off-by: Maintainer One <*****@*****.**>
""", tree.write(), []))

        tree.insert("driver.c",
                    self.repo.create_blob("#include <linux/module.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(
            self.repo.create_commit(
                "refs/heads/mainline", author, committer,
                """Fix the very small module

syzbot is reporting deadlocks at __blkdev_get() [1].

----------------------------------------
[   92.493919] systemd-udevd   D12696   525      1 0x00000000
[   92.495891] Call Trace:
[   92.501560]  schedule+0x23/0x80
[   92.502923]  schedule_preempt_disabled+0x5/0x10
[   92.504645]  __mutex_lock+0x416/0x9e0
[   92.510760]  __blkdev_get+0x73/0x4f0
[   92.512220]  blkdev_get+0x12e/0x390
[   92.518151]  do_dentry_open+0x1c3/0x2f0
[   92.519815]  path_openat+0x5d9/0xdc0
[   92.521437]  do_filp_open+0x7d/0xf0
[   92.527365]  do_sys_open+0x1b8/0x250
[   92.528831]  do_syscall_64+0x6e/0x270
[   92.530341]  entry_SYSCALL_64_after_hwframe+0x42/0xb7

[   92.931922] 1 lock held by systemd-udevd/525:
[   92.933642]  #0: 00000000a2849e25 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x73/0x4f0
----------------------------------------

The reason of deadlock turned out that wait_event_interruptible() in

Reported-by: Markus Trippelsdorf <*****@*****.**>
Fixes: %s ("Add a very small module")
Signed-off-by: Author One <*****@*****.**>
Signed-off-by: Maintainer One <*****@*****.**>
""" % (str(self.commits[-1], )), tree.write(), [self.commits[-1]]))

        self.repo.create_tag("v4.10-rc6", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc6")

        self.repo.remotes.create(
            "origin",
            "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git")
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits[-1])

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        with open(os.path.join(self.ks_dir, "series.conf"), mode="w") as f:
            f.write("""# Kernel patches configuration file

	########################################################
	# sorted patches
	########################################################
""")
            f.write("\tpatches.suse/%s\n" %
                    (tests.support.format_patch(self.repo.get(self.commits[0]),
                                                mainline="v4.9",
                                                references="bsc#123"), ))
            f.write("""
	########################################################
	# end of sorted patches
	########################################################
""")

        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        # This overlaps what is tested by test_series_sort, hence, not put in a
        # test of its own.
        subprocess.check_call([ss_path, "-c", "series.conf"])
        with open("series.conf") as f:
            content1 = f.read()
        subprocess.check_call([ss_path, "series.conf"])
        with open("series.conf") as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(
            ["quilt", "setup", "--sourcedir", "../../", "../../series.conf"])
Ejemplo n.º 20
0
    def setUp(self):
        self.ss_path = os.path.join(lib.libdir(), "series_sort.py")

        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature('Alice Author', '*****@*****.**')
        committer = pygit2.Signature('Cecil Committer', '*****@*****.**')
        tree = self.repo.TreeBuilder().write()

        m0 = self.repo.create_commit("refs/heads/mainline", author, committer,
                                     "mainline 0\n\nlog", tree, [])

        n0 = self.repo.create_commit("refs/heads/net", author, committer,
                                     "net 0\n\nlog", tree, [m0])

        self.repo.checkout("refs/heads/mainline")
        m1 = self.repo.create_commit("refs/heads/mainline", author, committer,
                                     "mainline 1, merge net\n\nlog", tree,
                                     [m0, n0])

        m2 = self.repo.create_commit("refs/heads/mainline", author, committer,
                                     "mainline 2\n\nlog", tree, [m1])

        n1 = self.repo.create_commit("refs/heads/net", author, committer,
                                     "net 1\n\nlog", tree, [n0])

        n2 = self.repo.create_commit("refs/heads/net", author, committer,
                                     "net 2\n\nlog", tree, [n1])

        oot0 = self.repo.create_commit("refs/heads/oot", author, committer,
                                       "oot 0\n\nlog", tree, [m0])

        oot1 = self.repo.create_commit("refs/heads/oot", author, committer,
                                       "oot 1\n\nlog", tree, [oot0])

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        origin_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", origin_repo)
        self.repo.references.create("refs/remotes/origin/master", m2)

        net_repo = k_org_canon_prefix + "davem/net.git"
        self.repo.remotes.create("net", net_repo)
        self.repo.references.create("refs/remotes/net/master", n2)

        self.index = git_sort.SortIndex(self.repo)

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        tests.support.format_patch(self.repo.get(m0), mainline="v3.45-rc6")
        tests.support.format_patch(self.repo.get(n0), mainline="v3.45-rc6")
        tests.support.format_patch(self.repo.get(n1), repo=net_repo)
        tests.support.format_patch(self.repo.get(n2), repo=net_repo)
        tests.support.format_patch(self.repo.get(oot0))
        tests.support.format_patch(
            self.repo.get(oot1),
            mainline="Submitted http://lore.kernel.org/somelist/somemessage")
        os.chdir(self.ks_dir)
Ejemplo n.º 21
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])
        self.repo.config["user.email"] = "*****@*****.**"
        self.repo.config["user.name"] = "Author One"

        author = pygit2.Signature("Author One", "*****@*****.**")
        committer = pygit2.Signature("Maintainer One", "*****@*****.**")
        tree = self.repo.TreeBuilder()

        tree.insert("driver.c", 
                    self.repo.create_blob("#include <bad.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits = []
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            """Add a very small module

... which was not tested.

Signed-off-by: Author One <*****@*****.**>
Signed-off-by: Maintainer One <*****@*****.**>
""",
            tree.write(),
            []
        ))

        tree.insert("driver.c", 
                    self.repo.create_blob("#include <linux/module.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            """Fix the very small module

syzbot is reporting deadlocks at __blkdev_get() [1].

----------------------------------------
[   92.493919] systemd-udevd   D12696   525      1 0x00000000
[   92.495891] Call Trace:
[   92.501560]  schedule+0x23/0x80
[   92.502923]  schedule_preempt_disabled+0x5/0x10
[   92.504645]  __mutex_lock+0x416/0x9e0
[   92.510760]  __blkdev_get+0x73/0x4f0
[   92.512220]  blkdev_get+0x12e/0x390
[   92.518151]  do_dentry_open+0x1c3/0x2f0
[   92.519815]  path_openat+0x5d9/0xdc0
[   92.521437]  do_filp_open+0x7d/0xf0
[   92.527365]  do_sys_open+0x1b8/0x250
[   92.528831]  do_syscall_64+0x6e/0x270
[   92.530341]  entry_SYSCALL_64_after_hwframe+0x42/0xb7

[   92.931922] 1 lock held by systemd-udevd/525:
[   92.933642]  #0: 00000000a2849e25 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x73/0x4f0
----------------------------------------

The reason of deadlock turned out that wait_event_interruptible() in

Reported-by: Markus Trippelsdorf <*****@*****.**>
Fixes: %s ("Add a very small module")
Signed-off-by: Author One <*****@*****.**>
Signed-off-by: Maintainer One <*****@*****.**>
""" % (str(self.commits[-1],)),
            tree.write(),
            [self.commits[-1]]
        ))

        self.repo.create_tag("v4.10-rc6", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc6")

        self.repo.remotes.create(
            "origin",
            "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git")
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits[-1])

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        with open(os.path.join(self.ks_dir, "series.conf"), mode="w") as f:
            f.write(
"""# Kernel patches configuration file

	########################################################
	# sorted patches
	########################################################
""")
            f.write("\tpatches.suse/%s\n" % (
                tests.support.format_patch(self.repo.get(self.commits[0]),
                                           mainline="v4.9",
                                           references="bsc#123"),))
            f.write(
"""
	########################################################
	# end of sorted patches
	########################################################
""")

        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        # This overlaps what is tested by test_series_sort, hence, not put in a
        # test of its own.
        subprocess.check_call([ss_path, "-c", "series.conf"])
        with open("series.conf") as f:
            content1 = f.read()
        subprocess.check_call([ss_path, "series.conf"])
        with open("series.conf") as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(
            ["quilt", "setup", "--sourcedir", "../../", "../../series.conf"])
Ejemplo n.º 22
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])

        author = pygit2.Signature("Alice Author", "*****@*****.**")
        committer = pygit2.Signature("Cecil Committer", "*****@*****.**")
        tree = self.repo.TreeBuilder()

        k_org_canon_prefix = "git://git.kernel.org/pub/scm/linux/kernel/git/"
        self.mainline_repo = k_org_canon_prefix + "torvalds/linux.git"
        self.repo.remotes.create("origin", self.mainline_repo)

        self.commits = {}
        self.commits["mainline 0"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 0\n\nlog",
            tree.write(),
            []
        )

        self.commits["mainline 1"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 1\n\nlog",
            tree.write(),
            [self.commits["mainline 0"]]
        )

        self.commits["mainline 2"] = self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "mainline 2\n\nlog",
            tree.write(),
            [self.commits["mainline 1"]]
        )
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits["mainline 2"])

        self.repo.checkout("refs/heads/mainline")

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        os.chdir(self.ks_dir)

        subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL)
        subprocess.check_call(
            ("git", "config", "--add", "mergetool.git-sort.cmd",
             "%s $LOCAL $BASE $REMOTE $MERGED" % (
                 os.path.join(lib.libdir(), "merge_tool.py"),),))
        subprocess.check_call(("git", "config", "--add",
                               "mergetool.git-sort.trustexitcode", "true",))

        self.patch_dir = "patches.suse"
        os.mkdir(self.patch_dir)
Ejemplo n.º 23
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp(prefix="ks_linux_git")
     self.lg_path = os.path.join(lib.libdir(), "../linux_git.sh")
Ejemplo n.º 24
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp(prefix="gs_log2")
     os.chdir(self.tmpdir)
     self.log2_path = os.path.join( lib.libdir(), "../log2")
Ejemplo n.º 25
0
    def test_quilt_mode(self):
        qm_path = os.path.join(lib.libdir(), "quilt-mode.sh")

        # test series file replacement
        with open("series") as f:
            entries = ["%s\n" % (l,) for l in
                       [line.strip() for line in f.readlines()]
                       if l and not l.startswith("#")]
        # remove the symlink
        os.unlink("series")
        with open("series", mode="w") as f:
            f.writelines(entries)
        subprocess.check_call(
            (os.path.join(lib.libdir(), "qgoto.py"), str(self.commits[0]),),
            stdout=subprocess.DEVNULL)

        # test qgoto
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[0])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")

        # test qdupcheck
        try:
            subprocess.check_output(
                ". %s; qdupcheck %s" % (qm_path, str(self.commits[1])),
                shell=True, executable="/bin/bash")
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().splitlines()[-1].strip(),
                             "patches.suse/Linux-4.10-rc5.patch")
        else:
            self.assertTrue(False)
        
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[1])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")

        try:
            subprocess.check_output(
                ". %s; qdupcheck %s" % (qm_path, str(self.commits[1])),
                shell=True, executable="/bin/bash")
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().splitlines()[-1].strip(),
                             "This is the top patch.")
        else:
            self.assertTrue(False)

        # import commits[2]
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[2])), shell=True,
            executable="/bin/bash")
        subprocess.check_call(
            """. %s; qcp -r "bsc#1077761" -d patches.suse %s""" % (
                qm_path, str(self.commits[2])),
            shell=True, stdout=subprocess.DEVNULL, executable="/bin/bash")

        retval = subprocess.check_output(("quilt", "--quiltrc", "-", "next",))
        name = "patches.suse/KVM-arm-arm64-vgic-v3-Add-accessors-for-the-ICH_APxR.patch"
        self.assertEqual(retval.decode().strip(), name)

        try:
            with open(os.path.join(self.ks_dir, name)) as f:
                retval = f.readlines().index(
                    "Acked-by: Alexander Graf <*****@*****.**>\n")
        except ValueError:
            retval = -1
        self.assertNotEqual(retval, -1)

        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)

        try:
            subprocess.check_output(("quilt", "--quiltrc", "-", "pop",),
                                    stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().endswith(
                "needs to be refreshed first.\n"))
        else:
            self.assertTrue(False)

        subprocess.check_call(("quilt", "--quiltrc", "-", "refresh",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "pop",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)

        # prepare repository
        os.chdir(self.ks_dir)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                       stdout=subprocess.DEVNULL)
        subprocess.check_call(
            ("git", "commit", "-m",
             "KVM: arm/arm64: vgic-v3: Add accessors for the ICH_APxRn_EL2 registers",),
            stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "checkout", "-q", "-b", "other",
                               "HEAD^",))
        shutil.rmtree("tmp/current")
        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(("quilt", "setup", "--sourcedir", "../../",
                               "../../series.conf",),)

        # import commits[3]
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[3])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")
        subprocess.check_call(
            """. %s; qcp -r "bsc#123" -d patches.suse %s""" % (
                qm_path, str(self.commits[3])),
            shell=True, stdout=subprocess.DEVNULL, executable="/bin/bash")

        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "refresh",),
                              stdout=subprocess.DEVNULL)
        name = subprocess.check_output(
            ("quilt", "--quiltrc", "-", "top",)).decode().strip()

        os.chdir(self.ks_dir)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                              stdout=subprocess.DEVNULL)

        # test pre-commit.sh
        pc_path = os.path.join(lib.libdir(), "pre-commit.sh")

        subprocess.check_call(pc_path, stdout=subprocess.DEVNULL)

        with open("series.conf") as f:
            content = f.readlines()

        content2 = list(content)
        middle = int(len(content2) / 2)
        content2[middle], content2[middle + 1] = \
            content2[middle + 1], content2[middle]

        with open("series.conf", mode="w") as f:
            f.writelines(content2)

        # check should be done against index, not working tree
        subprocess.check_call(pc_path, stdout=subprocess.DEVNULL)

        subprocess.check_call(("git", "add", "series.conf",),
                              stdout=subprocess.DEVNULL)

        # ... test a bad sorted section
        try:
            subprocess.check_output(pc_path, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().startswith(
                "Input is not sorted."))
        else:
            self.assertTrue(False)

        with open("series.conf", mode="w") as f:
            f.writelines(content)

        subprocess.check_call(("git", "add", "series.conf",),
                              stdout=subprocess.DEVNULL)

        subprocess.check_call(("git", "commit", "-m",
                               "sched/debug: Ignore TASK_IDLE for SysRq-W",),
                              stdout=subprocess.DEVNULL)

        # ... test a bad sorted patch
        with open(name) as f:
            content = f.readlines()
        content2 = list(content)
        for i in range(len(content2)):
            if content2[i].startswith("Git-commit: "):
                content2[i] = "Git-commit: cb329c2e40cf6cfc7bcd7c36ce5547f95e972ea5\n"
                break
        with open(name, mode="w") as f:
            f.writelines(content2)
        subprocess.check_call(("git", "add", name,), stdout=subprocess.DEVNULL)

        try:
            subprocess.check_output(pc_path, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().startswith(
                "Error: There is a problem with patch \"%s\"." % (name,)))
        else:
            self.assertTrue(False)

        with open(name, mode="w") as f:
            f.writelines(content)
        subprocess.check_call(("git", "add", name,), stdout=subprocess.DEVNULL)

        # test merge_tool.py
        subprocess.check_call(("git", "checkout", "-q", "master",))
        shutil.rmtree("tmp/current")
        subprocess.check_call(
            ("git", "config", "--add", "mergetool.git-sort.cmd",
             "%s $LOCAL $BASE $REMOTE $MERGED" % (
                 os.path.join(lib.libdir(), "merge_tool.py"),),))
        subprocess.check_call(("git", "config", "--add",
                               "mergetool.git-sort.trustexitcode", "true",))
        retval = subprocess.call(("git", "merge", "other",),
                                       stdout=subprocess.DEVNULL,
                                       stderr=subprocess.DEVNULL)
        self.assertEqual(retval, 1)
        retval = subprocess.check_output(
            ("git", "mergetool", "--tool=git-sort", "series.conf",))
        self.assertEqual(
            retval.decode().splitlines()[-1].strip(),
            "1 commits added, 0 commits removed from base to remote.")
        with open("series.conf") as f:
            entries = series_conf.filter_series(f.readlines())
        self.assertEqual(entries,
                         ["patches.suse/%s.patch" %
                          (tests.support.format_sanitized_subject(
                              self.repo.get(commit).message),)
                          for commit in self.commits[:4]])
        retval = subprocess.check_output(("git", "status", "--porcelain",
                                          "series.conf",))
        self.assertEqual(retval.decode().strip(), "M  series.conf")
Ejemplo n.º 26
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])
        self.repo.config["user.email"] = "*****@*****.**"
        self.repo.config["user.name"] = "Alexander Graf"
        readme_path = os.path.join(os.environ["LINUX_GIT"], "README")

        author = pygit2.Signature("Alice Author", "*****@*****.**")
        committer = pygit2.Signature("Cecil Committer", "*****@*****.**")
        tree = self.repo.TreeBuilder()

        tree.insert("README", 
                    self.repo.create_blob("NAME = Roaring Lionus\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits = []
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.9",
            tree.write(),
            []
        ))
        self.repo.create_tag("v4.9", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.9")

        tree.insert("README", 
                    self.repo.create_blob("NAME = Anniversary Edition\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.10-rc5",
            tree.write(),
            [self.commits[-1]]
        ))
        self.repo.create_tag("v4.10-rc5", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc5")

        tree.insert("driver.c", 
                    self.repo.create_blob("#include <linux/module.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        author2 = pygit2.Signature("Marc Zyngier", "*****@*****.**")
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author2,
            author2,
            """KVM: arm/arm64: vgic-v3: Add accessors for the ICH_APxRn_EL2 registers

As we're about to access the Active Priority registers a lot more,
let's define accessors that take the register number as a parameter.

Tested-by: Alexander Graf <*****@*****.**>
Acked-by: David Daney <*****@*****.**>
Reviewed-by: Eric Auger <*****@*****.**>
Signed-off-by: Marc Zyngier <*****@*****.**>
Signed-off-by: Christoffer Dall <*****@*****.**>
""",
            tree.write(),
            [self.commits[-1]]
        ))

        tree.insert("core.c", 
                    self.repo.create_blob("#include <linux/kernel.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        author3 = pygit2.Signature("Peter Zijlstra", "*****@*****.**")
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author3,
            author3,
            """sched/debug: Ignore TASK_IDLE for SysRq-W

Markus reported that tasks in TASK_IDLE state are reported by SysRq-W,
which results in undesirable clutter.

Reported-by: Markus Trippelsdorf <*****@*****.**>
Signed-off-by: Peter Zijlstra (Intel) <*****@*****.**>
Cc: Linus Torvalds <*****@*****.**>
Cc: Peter Zijlstra <*****@*****.**>
Cc: Thomas Gleixner <*****@*****.**>
Cc: [email protected]
Signed-off-by: Ingo Molnar <*****@*****.**>
""",
            tree.write(),
            [self.commits[-1]]
        ))

        tree.insert("README", 
                    self.repo.create_blob("NAME = Fearless Coyote\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.10-rc6",
            tree.write(),
            [self.commits[-1]]
        ))
        self.repo.create_tag("v4.10-rc6", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc6")

        self.repo.remotes.create(
            "origin",
            "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git")
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits[-1])

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        with open(os.path.join(self.ks_dir, "series.conf"), mode="w") as f:
            f.write(
"""# Kernel patches configuration file

	########################################################
	# sorted patches
	########################################################
""")
            for commit, tag in (
                (self.commits[0], "v4.9",),
                (self.commits[1], "v4.10-rc5",),
            ):
                f.write("\tpatches.suse/%s\n" % (
                    tests.support.format_patch(self.repo.get(commit),
                                               mainline=tag),))
            f.write(
"""
	########################################################
	# end of sorted patches
	########################################################
""")

        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        # This overlaps what is tested by test_series_sort, hence, not put in a
        # test of its own.
        subprocess.check_call([ss_path, "-c", "series.conf"])
        with open("series.conf") as f:
            content1 = f.read()
        subprocess.check_call([ss_path, "series.conf"])
        with open("series.conf") as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "commit", "-m", "import",),
                              stdout=subprocess.DEVNULL)

        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(
            ["quilt", "setup", "--sourcedir", "../../", "../../series.conf"])
Ejemplo n.º 27
0
    def test_quilt_mode(self):
        qm_path = os.path.join(lib.libdir(), "quilt-mode.sh")

        # test series file replacement
        with open("series") as f:
            entries = ["%s\n" % (l,) for l in
                       [line.strip() for line in f.readlines()]
                       if l and not l.startswith("#")]
        # remove the symlink
        os.unlink("series")
        with open("series", mode="w") as f:
            f.writelines(entries)
        subprocess.check_call(
            (os.path.join(lib.libdir(), "qgoto.py"), str(self.commits[0]),),
            stdout=subprocess.DEVNULL)

        # test qgoto
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[0])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")

        # test qdupcheck
        try:
            subprocess.check_output(
                ". %s; qdupcheck %s" % (qm_path, str(self.commits[1])),
                shell=True, executable="/bin/bash")
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().splitlines()[-1].strip(),
                             "patches.suse/Linux-4.10-rc5.patch")
        else:
            self.assertTrue(False)
        
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[1])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")

        try:
            subprocess.check_output(
                ". %s; qdupcheck %s" % (qm_path, str(self.commits[1])),
                shell=True, executable="/bin/bash")
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertEqual(err.output.decode().splitlines()[-1].strip(),
                             "This is the top patch.")
        else:
            self.assertTrue(False)

        # import commits[2]
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[2])), shell=True,
            executable="/bin/bash")
        subprocess.check_call(
            """. %s; qcp -r "bsc#1077761" -d patches.suse %s""" % (
                qm_path, str(self.commits[2])),
            shell=True, stdout=subprocess.DEVNULL, executable="/bin/bash")

        retval = subprocess.check_output(("quilt", "--quiltrc", "-", "next",))
        name = "patches.suse/KVM-arm-arm64-vgic-v3-Add-accessors-for-the-ICH_APxR.patch"
        self.assertEqual(retval.decode().strip(), name)

        try:
            with open(os.path.join(self.ks_dir, name)) as f:
                retval = f.readlines().index(
                    "Acked-by: Alexander Graf <*****@*****.**>\n")
        except ValueError:
            retval = -1
        self.assertNotEqual(retval, -1)

        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)

        try:
            subprocess.check_output(("quilt", "--quiltrc", "-", "pop",),
                                    stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().endswith(
                "needs to be refreshed first.\n"))
        else:
            self.assertTrue(False)

        subprocess.check_call(("quilt", "--quiltrc", "-", "refresh",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "pop",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)

        # prepare repository
        os.chdir(self.ks_dir)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                       stdout=subprocess.DEVNULL)
        subprocess.check_call(
            ("git", "commit", "-m",
             "KVM: arm/arm64: vgic-v3: Add accessors for the ICH_APxRn_EL2 registers",),
            stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "checkout", "-q", "-b", "other",
                               "HEAD^",))
        shutil.rmtree("tmp/current")
        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(("quilt", "setup", "--sourcedir", "../../",
                               "../../series.conf",),)

        # import commits[3]
        subprocess.check_call(
            ". %s; qgoto %s" % (qm_path, str(self.commits[3])), shell=True,
            stdout=subprocess.DEVNULL, executable="/bin/bash")
        subprocess.check_call(
            """. %s; qcp -r "bsc#123" -d patches.suse %s""" % (
                qm_path, str(self.commits[3])),
            shell=True, stdout=subprocess.DEVNULL, executable="/bin/bash")

        subprocess.check_call(("quilt", "--quiltrc", "-", "push",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("quilt", "--quiltrc", "-", "refresh",),
                              stdout=subprocess.DEVNULL)
        name = subprocess.check_output(
            ("quilt", "--quiltrc", "-", "top",)).decode().strip()

        os.chdir(self.ks_dir)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                              stdout=subprocess.DEVNULL)

        # test pre-commit.sh
        pc_path = os.path.join(lib.libdir(), "pre-commit.sh")

        subprocess.check_call(pc_path, stdout=subprocess.DEVNULL)

        with open("series.conf") as f:
            content = f.readlines()

        content2 = list(content)
        middle = int(len(content2) / 2)
        content2[middle], content2[middle + 1] = \
            content2[middle + 1], content2[middle]

        with open("series.conf", mode="w") as f:
            f.writelines(content2)

        # check should be done against index, not working tree
        subprocess.check_call(pc_path, stdout=subprocess.DEVNULL)

        subprocess.check_call(("git", "add", "series.conf",),
                              stdout=subprocess.DEVNULL)

        # ... test a bad sorted section
        try:
            subprocess.check_output(pc_path, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().startswith(
                "Input is not sorted."))
        else:
            self.assertTrue(False)

        with open("series.conf", mode="w") as f:
            f.writelines(content)

        subprocess.check_call(("git", "add", "series.conf",),
                              stdout=subprocess.DEVNULL)

        subprocess.check_call(("git", "commit", "-m",
                               "sched/debug: Ignore TASK_IDLE for SysRq-W",),
                              stdout=subprocess.DEVNULL)

        # ... test a bad sorted patch
        with open(name) as f:
            content = f.readlines()
        content2 = list(content)
        for i in range(len(content2)):
            if content2[i].startswith("Git-commit: "):
                content2[i] = "Git-commit: cb329c2e40cf6cfc7bcd7c36ce5547f95e972ea5\n"
                break
        with open(name, mode="w") as f:
            f.writelines(content2)
        subprocess.check_call(("git", "add", name,), stdout=subprocess.DEVNULL)

        try:
            subprocess.check_output(pc_path, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as err:
            self.assertEqual(err.returncode, 1)
            self.assertTrue(err.output.decode().startswith(
                "Error: There is a problem with patch \"%s\"." % (name,)))
        else:
            self.assertTrue(False)

        with open(name, mode="w") as f:
            f.writelines(content)
        subprocess.check_call(("git", "add", name,), stdout=subprocess.DEVNULL)

        # test merge_tool.py
        subprocess.check_call(("git", "checkout", "-q", "master",))
        shutil.rmtree("tmp/current")
        subprocess.check_call(
            ("git", "config", "--add", "mergetool.git-sort.cmd",
             "%s $LOCAL $BASE $REMOTE $MERGED" % (
                 os.path.join(lib.libdir(), "merge_tool.py"),),))
        subprocess.check_call(("git", "config", "--add",
                               "mergetool.git-sort.trustexitcode", "true",))
        retval = subprocess.call(("git", "merge", "other",),
                                       stdout=subprocess.DEVNULL,
                                       stderr=subprocess.DEVNULL)
        self.assertEqual(retval, 1)
        retval = subprocess.check_output(
            ("git", "mergetool", "--tool=git-sort", "series.conf",))
        self.assertEqual(
            retval.decode().splitlines()[-1].strip(),
            "1 commits added, 0 commits removed from base to remote.")
        with open("series.conf") as f:
            entries = series_conf.filter_series(f.readlines())
        self.assertEqual(entries,
                         ["patches.suse/%s.patch" %
                          (tests.support.format_sanitized_subject(
                              self.repo.get(commit).message),)
                          for commit in self.commits[:4]])
        retval = subprocess.check_output(("git", "status", "--porcelain",
                                          "series.conf",))
        self.assertEqual(retval.decode().strip(), "M  series.conf")
Ejemplo n.º 28
0
    def setUp(self):
        os.environ["XDG_CACHE_HOME"] = tempfile.mkdtemp(prefix="gs_cache")

        # setup stub linux repository
        os.environ["LINUX_GIT"] = tempfile.mkdtemp(prefix="gs_repo")
        self.repo = pygit2.init_repository(os.environ["LINUX_GIT"])
        self.repo.config["user.email"] = "*****@*****.**"
        self.repo.config["user.name"] = "Alexander Graf"

        author = pygit2.Signature("Alice Author", "*****@*****.**")
        committer = pygit2.Signature("Cecil Committer", "*****@*****.**")
        tree = self.repo.TreeBuilder()

        tree.insert("README", 
                    self.repo.create_blob("NAME = Roaring Lionus\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits = []
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.9",
            tree.write(),
            []
        ))
        self.repo.create_tag("v4.9", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.9")

        tree.insert("README", 
                    self.repo.create_blob("NAME = Anniversary Edition\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.10-rc5",
            tree.write(),
            [self.commits[-1]]
        ))
        self.repo.create_tag("v4.10-rc5", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc5")

        tree.insert("driver.c", 
                    self.repo.create_blob("#include <linux/module.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        author2 = pygit2.Signature("Marc Zyngier", "*****@*****.**")
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author2,
            author2,
            """KVM: arm/arm64: vgic-v3: Add accessors for the ICH_APxRn_EL2 registers

As we're about to access the Active Priority registers a lot more,
let's define accessors that take the register number as a parameter.

Tested-by: Alexander Graf <*****@*****.**>
Acked-by: David Daney <*****@*****.**>
Reviewed-by: Eric Auger <*****@*****.**>
Signed-off-by: Marc Zyngier <*****@*****.**>
Signed-off-by: Christoffer Dall <*****@*****.**>
""",
            tree.write(),
            [self.commits[-1]]
        ))

        tree.insert("core.c", 
                    self.repo.create_blob("#include <linux/kernel.h>\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        author3 = pygit2.Signature("Peter Zijlstra", "*****@*****.**")
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author3,
            author3,
            """sched/debug: Ignore TASK_IDLE for SysRq-W

Markus reported that tasks in TASK_IDLE state are reported by SysRq-W,
which results in undesirable clutter.

Reported-by: Markus Trippelsdorf <*****@*****.**>
Signed-off-by: Peter Zijlstra (Intel) <*****@*****.**>
Cc: Linus Torvalds <*****@*****.**>
Cc: Peter Zijlstra <*****@*****.**>
Cc: Thomas Gleixner <*****@*****.**>
Cc: [email protected]
Signed-off-by: Ingo Molnar <*****@*****.**>
""",
            tree.write(),
            [self.commits[-1]]
        ))

        tree.insert("README", 
                    self.repo.create_blob("NAME = Fearless Coyote\n"),
                    pygit2.GIT_FILEMODE_BLOB)
        self.commits.append(self.repo.create_commit(
            "refs/heads/mainline",
            author,
            committer,
            "Linux 4.10-rc6",
            tree.write(),
            [self.commits[-1]]
        ))
        self.repo.create_tag("v4.10-rc6", self.commits[-1], pygit2.GIT_REF_OID,
                             committer, "Linux 4.10-rc6")

        self.repo.remotes.create(
            "origin",
            "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git")
        self.repo.references.create("refs/remotes/origin/master",
                                    self.commits[-1])

        # setup stub kernel-source content
        self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
        patch_dir = os.path.join(self.ks_dir, "patches.suse")
        os.mkdir(patch_dir)
        os.chdir(patch_dir)
        with open(os.path.join(self.ks_dir, "series.conf"), mode="w") as f:
            f.write(
"""# Kernel patches configuration file

	########################################################
	# sorted patches
	########################################################
""")
            for commit, tag in (
                (self.commits[0], "v4.9",),
                (self.commits[1], "v4.10-rc5",),
            ):
                f.write("\tpatches.suse/%s\n" % (
                    tests.support.format_patch(self.repo.get(commit),
                                               mainline=tag),))
            f.write(
"""
	########################################################
	# end of sorted patches
	########################################################
""")

        ss_path = os.path.join(lib.libdir(), "series_sort.py")
        os.chdir(self.ks_dir)

        # This overlaps what is tested by test_series_sort, hence, not put in a
        # test of its own.
        subprocess.check_call([ss_path, "-c", "series.conf"])
        with open("series.conf") as f:
            content1 = f.read()
        subprocess.check_call([ss_path, "series.conf"])
        with open("series.conf") as f:
            content2 = f.read()
        self.assertEqual(content2, content1)

        subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "add", "series.conf", "patches.suse",),
                              stdout=subprocess.DEVNULL)
        subprocess.check_call(("git", "commit", "-m", "import",),
                              stdout=subprocess.DEVNULL)

        os.makedirs("tmp/current")
        os.chdir("tmp/current")
        subprocess.check_call(
            ["quilt", "setup", "--sourcedir", "../../", "../../series.conf"])
Ejemplo n.º 29
0
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp(prefix="ks_linux_git")
     self.lg_path = os.path.join(lib.libdir(), "../linux_git.sh")