diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/pacman/pactest.py | 34 | ||||
-rwxr-xr-x | test/pacman/pmdb.py | 10 | ||||
-rwxr-xr-x | test/pacman/pmpkg.py | 5 | ||||
-rw-r--r-- | test/pacman/tests/sign001.py | 9 | ||||
-rw-r--r-- | test/pacman/tests/sign002.py | 10 | ||||
-rw-r--r-- | test/pacman/tests/smoke004.py | 11 | ||||
-rwxr-xr-x | test/pacman/util.py | 3 | ||||
-rwxr-xr-x | test/util/vercmptest.sh | 2 |
8 files changed, 70 insertions, 14 deletions
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py index 69e655a0..64d56510 100755 --- a/test/pacman/pactest.py +++ b/test/pacman/pactest.py @@ -17,8 +17,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import os, sys, glob +import glob from optparse import OptionParser +import os +import shutil +import sys +import tempfile import pmenv import util @@ -63,6 +67,9 @@ def createOptParser(): parser.add_option("-t", "--test", action = "callback", callback = globTests, dest = "testcases", help = "specify test case(s)") + parser.add_option("--keep-root", action = "store_true", + dest = "keeproot", default = False, + help = "don't remove the generated pacman root filesystem") parser.add_option("--nolog", action = "store_true", dest = "nolog", default = False, help = "do not log pacman messages") @@ -80,7 +87,8 @@ def createOptParser(): if __name__ == "__main__": # instantiate env and parser objects - env = pmenv.pmenv() + root_path = tempfile.mkdtemp() + env = pmenv.pmenv(root=root_path) opt_parser = createOptParser() (opts, args) = opt_parser.parse_args() @@ -95,16 +103,22 @@ if __name__ == "__main__": if opts.testcases is None or len(opts.testcases) == 0: print "no tests defined, nothing to do" + os.rmdir(root_path) sys.exit(2) - else: - for i in opts.testcases: - env.addtest(i) - # run tests and print overall results - env.run() - env.results() + for i in opts.testcases: + env.addtest(i) + + # run tests and print overall results + env.run() + env.results() - if env.failed > 0: - sys.exit(1) + if env.failed > 0: + sys.exit(1) + + if not opts.keeproot: + shutil.rmtree(root_path) + else: + print "pacman testing root saved: %s" % root_path # vim: set ts=4 sw=4 et: diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index b31498a7..1af24ae9 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -89,6 +89,12 @@ class pmdb(object): def __str__(self): return "%s" % self.treename + def getverify(self): + for value in "Always","Never","Optional": + if value in self.treename: + return value + return "Never" + def getpkg(self, name): """ """ @@ -150,6 +156,8 @@ class pmdb(object): pkg.size = int(fd.readline().strip("\n")) elif line == "%MD5SUM%": pkg.md5sum = fd.readline().strip("\n") + elif line == "%PGPSIG%": + pkg.pgpsig = fd.readline().strip("\n") elif line == "%REPLACES%": pkg.replaces = _getsection(fd) elif line == "%DEPENDS%": @@ -241,6 +249,8 @@ class pmdb(object): data.append(_mksection("CSIZE", pkg.csize)) if pkg.md5sum: data.append(_mksection("MD5SUM", pkg.md5sum)) + if pkg.pgpsig: + data.append(_mksection("PGPSIG", pkg.pgpsig)) if data: data.append("") filename = os.path.join(path, "desc") diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index be177f35..42573428 100755 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -27,7 +27,7 @@ import util class pmpkg(object): """Package object. - Object holding data from an ArchLinux package. + Object holding data from an Arch Linux package. """ def __init__(self, name, version = "1.0-1"): @@ -47,6 +47,7 @@ class pmpkg(object): self.csize = 0 self.reason = 0 self.md5sum = "" # sync only + self.pgpsig = "" # sync only self.replaces = [] self.depends = [] self.optdepends = [] @@ -88,7 +89,7 @@ class pmpkg(object): return "%s%s" % (self.fullname(), util.PM_EXT_PKG) def makepkg(self, path): - """Creates an ArchLinux package archive. + """Creates an Arch Linux package archive. A package archive is generated in the location 'path', based on the data from the object. diff --git a/test/pacman/tests/sign001.py b/test/pacman/tests/sign001.py new file mode 100644 index 00000000..0ae417b7 --- /dev/null +++ b/test/pacman/tests/sign001.py @@ -0,0 +1,9 @@ +self.description = "Add a signature to a package DB" + +sp = pmpkg("pkg1") +sp.pgpsig = "asdfasdfsdfasdfsdafasdfsdfasd" +self.addpkg2db("sync+Always", sp) + +self.args = "-Ss" + +self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/sign002.py b/test/pacman/tests/sign002.py new file mode 100644 index 00000000..b55f331e --- /dev/null +++ b/test/pacman/tests/sign002.py @@ -0,0 +1,10 @@ +self.description = "Verify a signature in a sync DB (failure)" + +sp = pmpkg("pkg1") +sp.pgpsig = "iEYEABECAAYFAkhMOggACgkQXC5GoPU6du2WVQCffVxF8GKXJIY4juJBIw/ljLrQxygAnj2QlvsUd7MdFekLX18+Ov/xzgZ1" +self.addpkg2db("sync+Always", sp) + +self.args = "-S %s" % sp.name + +self.addrule("PACMAN_RETCODE=1") +self.addrule("!PKG_EXIST=pkg1") diff --git a/test/pacman/tests/smoke004.py b/test/pacman/tests/smoke004.py new file mode 100644 index 00000000..1f9b883d --- /dev/null +++ b/test/pacman/tests/smoke004.py @@ -0,0 +1,11 @@ +self.description = "Read a package DB with several PGP signatures" + +for i in range(1000): + sp = pmpkg("pkg%03d" % i) + sp.desc = "test description for package %d" % i + sp.pgpsig = "asdfasdfsdfasdfsdafasdfsdfasd" + self.addpkg2db("sync", sp) + +self.args = "-Ss" + +self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/util.py b/test/pacman/util.py index 47fde310..ddd955a2 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -132,8 +132,9 @@ def mkcfgfile(filename, root, option, db): if key != "local": value = db[key] data.append("[%s]\n" \ + "VerifySig = %s\n" \ "Server = file://%s" \ - % (value.treename, + % (value.treename, value.getverify(), \ os.path.join(root, SYNCREPO, value.treename))) for optkey, optval in value.option.iteritems(): data.extend(["%s = %s" % (optkey, j) for j in optval]) diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh index 6b3869c5..7ebeba53 100755 --- a/test/util/vercmptest.sh +++ b/test/util/vercmptest.sh @@ -62,7 +62,7 @@ runtest() { # use first arg as our binary if specified [ -n "$1" ] && bin="$1" -if [ ! $(type -p "$bin") ]; then +if ! type -p "$bin"; then echo "vercmp binary ($bin) could not be located" exit 1 fi |