diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/pacman/pmdb.py | 121 | ||||
-rwxr-xr-x | test/pacman/pmpkg.py | 13 | ||||
-rwxr-xr-x | test/pacman/pmrule.py | 13 | ||||
-rwxr-xr-x | test/pacman/pmtest.py | 21 | ||||
-rw-r--r-- | test/pacman/tests/database012.py | 8 | ||||
-rw-r--r-- | test/pacman/tests/ignore001.py | 2 | ||||
-rw-r--r-- | test/pacman/tests/pacman005.py | 8 | ||||
-rw-r--r-- | test/pacman/tests/remove002.py | 12 | ||||
-rw-r--r-- | test/pacman/tests/smoke002.py | 19 | ||||
-rw-r--r-- | test/pacman/tests/sync024.py | 23 | ||||
-rw-r--r-- | test/pacman/tests/sync136.py | 2 | ||||
-rw-r--r-- | test/pacman/tests/sync137.py | 2 | ||||
-rw-r--r-- | test/pacman/tests/sync140.py | 13 | ||||
-rw-r--r-- | test/pacman/tests/sync141.py | 13 | ||||
-rw-r--r-- | test/pacman/tests/sync142.py | 14 | ||||
-rw-r--r-- | test/pacman/tests/sync143.py | 18 | ||||
-rw-r--r-- | test/pacman/tests/upgrade006.py | 18 | ||||
-rwxr-xr-x | test/pacman/util.py | 48 |
18 files changed, 211 insertions, 157 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 218e3b58..b4d0e2d5 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -79,11 +79,15 @@ class pmdb: """Database object """ - def __init__(self, treename, dbdir): + def __init__(self, treename, root): self.treename = treename - self.dbdir = dbdir self.pkgs = [] self.option = {} + if self.treename == "local": + self.dbdir = os.path.join(root, PM_DBPATH, treename) + else: + self.dbdir = os.path.join(root, PM_SYNCDBPATH, treename) + self.dbfile = os.path.join(root, PM_SYNCDBPATH, treename + ".db") def __str__(self): return "%s" % self.treename @@ -99,7 +103,7 @@ class pmdb: """ """ - path = os.path.join(self.dbdir, self.treename) + path = self.dbdir if not os.path.isdir(path): return None @@ -152,9 +156,19 @@ class pmdb: pkg.md5sum = fd.readline().strip("\n") elif line == "%REPLACES%": pkg.replaces = _getsection(fd) + elif line == "%EPOCH%": + pkg.epoch = int(fd.readline().strip("\n")) elif line == "%FORCE%": fd.readline() - pkg.force = 1 + pkg.force = True + elif line == "%DEPENDS%": + pkg.depends = _getsection(fd) + elif line == "%OPTDEPENDS%": + pkg.optdepends = _getsection(fd) + elif line == "%CONFLICTS%": + pkg.conflicts = _getsection(fd) + elif line == "%PROVIDES%": + pkg.provides = _getsection(fd) fd.close() pkg.checksum["desc"] = getmd5sum(filename) pkg.mtime["desc"] = getmtime(filename) @@ -181,35 +195,6 @@ class pmdb: pkg.checksum["files"] = getmd5sum(filename) pkg.mtime["files"] = getmtime(filename) - # depends - filename = os.path.join(path, "depends") - if not os.path.isfile(filename): - print "invalid db entry found (depends missing) for pkg", pkgname - return None - fd = file(filename, "r") - while 1: - line = fd.readline() - if not line: - break - line = line.strip("\n") - if line == "%DEPENDS%": - pkg.depends = _getsection(fd) - elif line == "%OPTDEPENDS%": - pkg.optdepends = _getsection(fd) - elif line == "%CONFLICTS%": - pkg.conflicts = _getsection(fd) - elif line == "%PROVIDES%": - pkg.provides = _getsection(fd) - # TODO this was going to be changed, but isn't anymore - #elif line == "%REPLACES%": - # pkg.replaces = _getsection(fd) - #elif line == "%FORCE%": - # fd.readline() - # pkg.force = 1 - fd.close() - pkg.checksum["depends"] = getmd5sum(filename) - pkg.mtime["depends"] = getmtime(filename) - # install filename = os.path.join(path, "install") if os.path.isfile(filename): @@ -225,18 +210,15 @@ class pmdb: """ """ - if self.treename == "local": - path = os.path.join(self.dbdir, self.treename, pkg.fullname()) - else: - path = os.path.join(self.dbdir, "sync", self.treename, pkg.fullname()) + path = os.path.join(self.dbdir, pkg.fullname()) mkdir(path) # desc # for local db entries: name, version, desc, groups, url, license, # arch, builddate, installdate, packager, - # size, reason + # size, reason, depends, conflicts, provides # for sync entries: name, version, desc, groups, csize, md5sum, - # replaces, force + # replaces, force, depends, conflicts, provides data = [_mksection("NAME", pkg.name)] data.append(_mksection("VERSION", pkg.version)) if pkg.desc: @@ -251,6 +233,14 @@ class pmdb: data.append(_mksection("BUILDDATE", pkg.builddate)) if pkg.packager: data.append(_mksection("PACKAGER", pkg.packager)) + if pkg.depends: + data.append(_mksection("DEPENDS", pkg.depends)) + if pkg.optdepends: + data.append(_mksection("OPTDEPENDS", pkg.optdepends)) + if pkg.conflicts: + data.append(_mksection("CONFLICTS", pkg.conflicts)) + if pkg.provides: + data.append(_mksection("PROVIDES", pkg.provides)) if self.treename == "local": if pkg.url: data.append(_mksection("URL", pkg.url)) @@ -260,10 +250,17 @@ class pmdb: data.append(_mksection("SIZE", pkg.size)) if pkg.reason: data.append(_mksection("REASON", pkg.reason)) + if pkg.epoch: + data.append(_mksection("EPOCH", pkg.epoch)) else: data.append(_mksection("FILENAME", pkg.filename())) if pkg.replaces: data.append(_mksection("REPLACES", pkg.replaces)) + if pkg.epoch: + data.append(_mksection("EPOCH", pkg.epoch)) + # for backward compatibility + if not pkg.force: + data.append(_mksection("FORCE", "")) if pkg.force: data.append(_mksection("FORCE", "")) if pkg.csize: @@ -293,30 +290,6 @@ class pmdb: pkg.checksum["files"] = getmd5sum(filename) pkg.mtime["files"] = getmtime(filename) - # depends - # for local db entries: depends, conflicts, provides - # for sync ones: depends, conflicts, provides - data = [] - if pkg.depends: - data.append(_mksection("DEPENDS", pkg.depends)) - if pkg.optdepends: - data.append(_mksection("OPTDEPENDS", pkg.optdepends)) - if pkg.conflicts: - data.append(_mksection("CONFLICTS", pkg.conflicts)) - if pkg.provides: - data.append(_mksection("PROVIDES", pkg.provides)) - #if self.treename != "local": - # if pkg.replaces: - # data.append(_mksection("REPLACES", pkg.replaces)) - # if pkg.force: - # data.append(_mksection("FORCE", "")) - if data: - data.append("") - filename = os.path.join(path, "depends") - mkfile(filename, "\n".join(data)) - pkg.checksum["depends"] = getmd5sum(filename) - pkg.mtime["depends"] = getmtime(filename) - # install if self.treename == "local": empty = 1 @@ -329,30 +302,22 @@ class pmdb: pkg.checksum["install"] = getmd5sum(filename) pkg.mtime["install"] = getmtime(filename) - def gensync(self, path): + def gensync(self): """ """ + if not self.dbfile: + return curdir = os.getcwd() - tmpdir = tempfile.mkdtemp() - os.chdir(tmpdir) - - for pkg in self.pkgs: - mkdescfile(pkg.fullname(), pkg) + os.chdir(self.dbdir) # Generate database archive - mkdir(path) - archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB)) - tar = tarfile.open(archive, "w:gz") - for root, dirs, files in os.walk('.'): - for d in dirs: - tar.add(os.path.join(root, d), recursive=False) - for f in files: - tar.add(os.path.join(root, f)) + tar = tarfile.open(self.dbfile, "w:gz") + for i in os.listdir("."): + tar.add(i) tar.close() os.chdir(curdir) - shutil.rmtree(tmpdir) def ispkgmodified(self, pkg): """ diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 1d55175e..3aabea49 100755 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -48,9 +48,9 @@ class pmpkg: self.csize = 0 self.reason = 0 self.md5sum = "" # sync only - self.replaces = [] # sync only (will be moved to depends) - self.force = 0 # sync only (will be moved to depends) - # depends + self.replaces = [] + self.force = False + self.epoch = 0 self.depends = [] self.optdepends = [] self.conflicts = [] @@ -69,13 +69,11 @@ class pmpkg: } self.checksum = { "desc": "", - "depends": "", "files": "", "install": "" } self.mtime = { "desc": (0, 0, 0), - "depends": (0, 0, 0), "files": (0, 0, 0), "install": (0, 0, 0) } @@ -84,7 +82,6 @@ class pmpkg: s = ["%s" % self.fullname()] s.append("description: %s" % self.desc) s.append("url: %s" % self.url) - s.append("depends: %s" % " ".join(self.depends)) s.append("files: %s" % " ".join(self.files)) s.append("reason: %d" % self.reason) return "\n".join(s) @@ -135,6 +132,10 @@ class pmpkg: data.append("builddate = %s" % self.builddate) data.append("packager = %s" % self.packager) data.append("size = %s" % self.size) + if self.force: + data.append("force = true") + if self.epoch: + data.append("epoch = %d" % self.epoch) if self.arch: data.append("arch = %s" % self.arch) for i in self.license: diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index e7c9c44f..bea8e4a4 100755 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -29,7 +29,9 @@ class pmrule: self.result = 0 def __str__(self): - return "rule = %s" % self.rule + if len(self.rule) <= 40: + return self.rule + return self.rule[:37] + '...' def check(self, root, retcode, localdb, files): """ @@ -76,6 +78,12 @@ class pmrule: elif case == "VERSION": if value != newpkg.version: success = 0 + elif case == "EPOCH": + if int(value) != newpkg.epoch: + success = 0 + elif case == "DESC": + if value != newpkg.desc: + success = 0 elif case == "GROUPS": if not value in newpkg.groups: success = 0 @@ -153,7 +161,4 @@ class pmrule: self.result = success return success - -if __name__ != "__main__": - rule = pmrule("PKG_EXIST=dummy") # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index f3026f29..c70e41ae 100755 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -47,7 +47,7 @@ class pmtest: """ """ if not treename in self.db: - self.db[treename] = pmdb.pmdb(treename, os.path.join(self.root, PM_DBPATH)) + self.db[treename] = pmdb.pmdb(treename, self.root) self.db[treename].pkgs.append(pkg) def addpkg(self, pkg): @@ -73,7 +73,7 @@ class pmtest: self.args = "" self.retcode = 0 self.db = { - "local": pmdb.pmdb("local", os.path.join(self.root, PM_DBPATH)) + "local": pmdb.pmdb("local", self.root) } self.localpkgs = [] self.filesystem = [] @@ -152,9 +152,11 @@ class pmtest: vprint(" Creating sync database archives") for key, value in self.db.iteritems(): if key == "local": continue - archive = value.treename + PM_EXT_DB - vprint("\t" + os.path.join(SYNCREPO, archive)) - value.gensync(os.path.join(syncdir, value.treename)) + vprint("\t" + value.treename) + value.gensync() + serverpath = os.path.join(syncdir, value.treename) + mkdir(serverpath) + shutil.copy(value.dbfile, serverpath) # Filesystem vprint(" Populating file system") @@ -200,7 +202,7 @@ class pmtest: if pacman["gdb"]: cmd.append("libtool execute gdb --args") if pacman["valgrind"]: - cmd.append("valgrind -q --tool=memcheck --leak-check=full --show-reachable=yes") + cmd.append("valgrind -q --tool=memcheck --leak-check=full --show-reachable=yes --suppressions=%s/valgrind.supp" % os.getcwd()) cmd.append("\"%s\" --config=\"%s\" --root=\"%s\" --dbpath=\"%s\" --cachedir=\"%s\"" \ % (pacman["bin"], os.path.join(self.root, PACCONF), @@ -258,11 +260,6 @@ class pmtest: self.result["fail"] += 1 else: msg = "SKIP" - print "\t[%s] %s" % (msg, i.rule) - i.result = success - - -if __name__ == "__main__": - pass + print "\t[%s] %s" % (msg, i) # vim: set ts=4 sw=4 et: diff --git a/test/pacman/tests/database012.py b/test/pacman/tests/database012.py index a1f86980..52813ec6 100644 --- a/test/pacman/tests/database012.py +++ b/test/pacman/tests/database012.py @@ -21,11 +21,5 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_EXIST=dummy") self.addrule("PKG_VERSION=dummy|2.0-1") for f in lp.files: - self.addrule("!FILE_EXIST=%s" % f) -# TODO: I honestly think the above should NOT delete the original files, it -# should upgrade the DB entry without touching anything on the file system. -# E.g. this test should be the same as: -# pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz -#for f in lp.files: -# self.addrule("FILE_EXIST=%s" % f) + self.addrule("FILE_EXIST=%s" % f) self.addrule("!FILE_EXIST=bin/dummy2") diff --git a/test/pacman/tests/ignore001.py b/test/pacman/tests/ignore001.py index bb3fa59a..e9764bc9 100644 --- a/test/pacman/tests/ignore001.py +++ b/test/pacman/tests/ignore001.py @@ -9,7 +9,7 @@ self.addpkg2db("local", package2) package2up = pmpkg("package2", "2.0-1") self.addpkg2db("sync", package2up) -self.option["IgnorePkg"] = ["irrelavent"] +self.option["IgnorePkg"] = ["irrelevant"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/pacman005.py b/test/pacman/tests/pacman005.py new file mode 100644 index 00000000..bb21ad4f --- /dev/null +++ b/test/pacman/tests/pacman005.py @@ -0,0 +1,8 @@ +self.description = "Test invalid combination of command line options (-Qy)" + +p = pmpkg("foobar") +self.addpkg2db("local", p) + +self.args = "-Qy" + +self.addrule("PACMAN_RETCODE=1") diff --git a/test/pacman/tests/remove002.py b/test/pacman/tests/remove002.py new file mode 100644 index 00000000..1deffb0d --- /dev/null +++ b/test/pacman/tests/remove002.py @@ -0,0 +1,12 @@ +self.description = "Remove a package with several files" + +p = pmpkg("foo") +p.files = ["usr/share/file_%d" % n for n in range(1000)] +self.addpkg2db("local", p) + +self.args = "-R %s" % p.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("!PKG_EXIST=foo") +self.addrule("!FILE_EXIST=usr/share/file_0") +self.addrule("!FILE_EXIST=usr/share/file_999") diff --git a/test/pacman/tests/smoke002.py b/test/pacman/tests/smoke002.py new file mode 100644 index 00000000..44f2d0ec --- /dev/null +++ b/test/pacman/tests/smoke002.py @@ -0,0 +1,19 @@ +self.description = "Install packages with huge descriptions" + +p1 = pmpkg("pkg1") +p1.desc = 'A' * 500 * 1024 +self.addpkg(p1) + +p2 = pmpkg("pkg2") +p2.desc = 'A' * 600 * 1024 +self.addpkg(p2) + +self.args = "-U %s %s" % (p1.filename(), p2.filename()) + +# Note that the current cutoff on line length is 512K, so the first package +# will succeed while the second one will fail to record the description. +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("PKG_DESC=pkg1|%s" % p1.desc) +self.addrule("PKG_EXIST=pkg1") +self.addrule("!PKG_DESC=pkg1|%s" % p2.desc) diff --git a/test/pacman/tests/sync024.py b/test/pacman/tests/sync024.py new file mode 100644 index 00000000..6d1192f0 --- /dev/null +++ b/test/pacman/tests/sync024.py @@ -0,0 +1,23 @@ +self.description = "Install a group from a sync db repo/group syntax" + +sp1 = pmpkg("pkg1") +sp2 = pmpkg("pkg2") +sp3 = pmpkg("pkg3") +newp1 = pmpkg("pkg1", "1.2-1") + +for p in sp1, sp2, sp3, newp1: + setattr(p, "groups", ["grp"]) + +self.addpkg2db("testing", newp1); + +for p in sp1, sp2, sp3: + self.addpkg2db("sync", p); + +self.args = "-S testing/grp" + +self.addrule("PACMAN_RETCODE=0") +for p in sp2, sp3: + self.addrule("!PKG_EXIST=%s" % p.name) +self.addrule("PKG_EXIST=%s" % newp1.name) +# The newer version should still be installed +self.addrule("PKG_VERSION=pkg1|1.2-1") diff --git a/test/pacman/tests/sync136.py b/test/pacman/tests/sync136.py index 58d08eb0..b3a6baf4 100644 --- a/test/pacman/tests/sync136.py +++ b/test/pacman/tests/sync136.py @@ -1,7 +1,7 @@ self.description = "Sysupgrade with a sync package forcing a downgrade" sp = pmpkg("dummy", "1.0-1") -sp.force = 1 +sp.force = True self.addpkg2db("sync", sp) diff --git a/test/pacman/tests/sync137.py b/test/pacman/tests/sync137.py index 94caca70..000855c5 100644 --- a/test/pacman/tests/sync137.py +++ b/test/pacman/tests/sync137.py @@ -5,7 +5,7 @@ lp = pmpkg("dummy", "1.0-1") self.addpkg2db("local", lp) sp = pmpkg("dummy", "1.0-2") -sp.force = 1 +sp.force = True self.addpkg2db("sync", sp) self.args = "-Su --ignore %s" % lp.name diff --git a/test/pacman/tests/sync140.py b/test/pacman/tests/sync140.py new file mode 100644 index 00000000..b7ec9fcf --- /dev/null +++ b/test/pacman/tests/sync140.py @@ -0,0 +1,13 @@ +self.description = "Sysupgrade with a sync package having higher epoch" + +sp = pmpkg("dummy", "1.0-1") +sp.epoch = 1 +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "1.1-1") +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.0-1") diff --git a/test/pacman/tests/sync141.py b/test/pacman/tests/sync141.py new file mode 100644 index 00000000..dac81f76 --- /dev/null +++ b/test/pacman/tests/sync141.py @@ -0,0 +1,13 @@ +self.description = "Sysupgrade with an epoch and ignore on same package" + +lp = pmpkg("dummy", "1.0-1") +self.addpkg2db("local", lp) + +sp = pmpkg("dummy", "1.0-2") +sp.epoch = 1 +self.addpkg2db("sync", sp) + +self.args = "-Su --ignore %s" % lp.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.0-1") diff --git a/test/pacman/tests/sync142.py b/test/pacman/tests/sync142.py new file mode 100644 index 00000000..726ef304 --- /dev/null +++ b/test/pacman/tests/sync142.py @@ -0,0 +1,14 @@ +self.description = "Sysupgrade with an epoch package overriding a force package" + +sp = pmpkg("dummy", "1.4-1") +sp.epoch = 2 +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "2.0-1") +lp.force = True +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.4-1") diff --git a/test/pacman/tests/sync143.py b/test/pacman/tests/sync143.py new file mode 100644 index 00000000..2ee940a9 --- /dev/null +++ b/test/pacman/tests/sync143.py @@ -0,0 +1,18 @@ +self.description = "Sysupgrade with same version, different epochs" + +sp = pmpkg("dummy", "2.0-1") +sp.files = ["bin/dummynew"] +sp.epoch = 2 +self.addpkg2db("sync", sp) + +lp = pmpkg("dummy", "2.0-1") +lp.files = ["bin/dummyold"] +lp.force = True +self.addpkg2db("local", lp) + +self.args = "-Su" + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|2.0-1") +self.addrule("FILE_EXIST=bin/dummynew") +self.addrule("!FILE_EXIST=bin/dummyold") diff --git a/test/pacman/tests/upgrade006.py b/test/pacman/tests/upgrade006.py new file mode 100644 index 00000000..5e5173b5 --- /dev/null +++ b/test/pacman/tests/upgrade006.py @@ -0,0 +1,18 @@ +self.description = "Upgrade a package with several files" + +lp = pmpkg("dummy") +lp.files = ["usr/share/file_%d" % n for n in range(250, 750)] +self.addpkg2db("local", lp) + +p = pmpkg("dummy", "1.1-1") +p.files = ["usr/share/file_%d" % n for n in range(600, 1000)] +self.addpkg(p) + +self.args = "-U %s" % p.filename() + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_VERSION=dummy|1.1-1") +self.addrule("!FILE_EXIST=usr/share/file_250") +self.addrule("!FILE_EXIST=usr/share/file_599") +self.addrule("FILE_EXIST=usr/share/file_600") +self.addrule("FILE_EXIST=usr/share/file_999") diff --git a/test/pacman/util.py b/test/pacman/util.py index e01a3b8f..f77da52b 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -25,10 +25,10 @@ import stat # ALPM PM_ROOT = "/" PM_DBPATH = "var/lib/pacman" +PM_SYNCDBPATH = "var/lib/pacman/sync" PM_LOCK = "var/lib/pacman/db.lck" PM_CACHEDIR = "var/cache/pacman/pkg" PM_EXT_PKG = ".pkg.tar.gz" -PM_EXT_DB = ".db.tar.gz" PM_PACNEW = ".pacnew" PM_PACORIG = ".pacorig" PM_PACSAVE = ".pacsave" @@ -113,52 +113,6 @@ def mkfile(name, data = ""): if setperms: os.chmod(filename, int(perms, 8)) -def mkdescfile(filename, pkg): - """ - """ - - data = [] - - # desc - #data.append("pkgname = %s" % pkg.name) - #data.append("pkgver = %s" % pkg.version) - if pkg.desc: - data.append("pkgdesc = %s" % pkg.desc) - if pkg.url: - data.append("url = %s" % pkg.url) - if pkg.builddate: - data.append("builddate = %s" % pkg.builddate) - if pkg.packager: - data.append("packager = %s" % pkg.packager) - if pkg.size: - data.append("size = %s" % pkg.size) - if pkg.arch: - data.append("arch = %s" % pkg.arch) - for i in pkg.groups: - data.append("group = %s" % i) - for i in pkg.license: - data.append("license = %s" % i) - if pkg.md5sum: - data.append("md5sum = %s" % pkg.md5sum) - - # depends - for i in pkg.replaces: - data.append("replaces = %s" % i) - for i in pkg.depends: - data.append("depend = %s" % i) - for i in pkg.optdepends: - data.append("optdepend = %s" % i) - for i in pkg.conflicts: - data.append("conflict = %s" % i) - for i in pkg.provides: - data.append("provides = %s" % i) - for i in pkg.backup: - data.append("backup = %s" % i) - if pkg.force: - data.append("force = 1") - - mkfile(filename, "\n".join(data)) - def mkinstallfile(filename, install): """ """ |