summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/pacman/pactest.py1
-rwxr-xr-xtest/pacman/pmpkg.py6
-rwxr-xr-xtest/pacman/pmrule.py8
-rw-r--r--test/pacman/tests/replace101.py25
-rw-r--r--test/pacman/tests/replace102.py27
-rw-r--r--test/pacman/tests/smoke002.py12
-rw-r--r--test/pacman/tests/symlink002.py43
-rwxr-xr-xtest/pacman/util.py6
8 files changed, 114 insertions, 14 deletions
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py
index 64d56510..77f87da6 100755
--- a/test/pacman/pactest.py
+++ b/test/pacman/pactest.py
@@ -114,6 +114,7 @@ if __name__ == "__main__":
env.results()
if env.failed > 0:
+ print "pacman testing root saved: %s" % root_path
sys.exit(1)
if not opts.keeproot:
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 59204265..4568adb9 100755
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -63,7 +63,7 @@ class pmpkg(object):
"pre_remove": "",
"post_remove": "",
"pre_upgrade": "",
- "post_upgrade": ""
+ "post_upgrade": "",
}
def __str__(self):
@@ -103,7 +103,7 @@ class pmpkg(object):
# Generate package file system
for f in self.files:
util.mkfile(f, f)
- self.size += os.stat(util.getfilename(f))[stat.ST_SIZE]
+ self.size += os.lstat(util.getfilename(f))[stat.ST_SIZE]
# .PKGINFO
data = ["pkgname = %s" % self.name]
@@ -134,7 +134,7 @@ class pmpkg(object):
util.mkfile(".PKGINFO", "\n".join(data))
# .INSTALL
- if len(self.install.values()) > 0:
+ if any(self.install.values()):
util.mkinstallfile(".INSTALL", self.install)
# safely create the dir
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index c68d085e..0f6ae602 100755
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -146,6 +146,14 @@ class pmrule(object):
else:
print "FILE rule '%s' not found" % case
success = -1
+ elif kind == "LINK":
+ filename = os.path.join(test.root, key)
+ if case == "EXIST":
+ if not os.path.islink(filename):
+ success = 0
+ else:
+ print "LINK rule '%s' not found" % case
+ success = -1
elif kind == "CACHE":
cachedir = os.path.join(test.root, util.PM_CACHEDIR)
if case == "EXISTS":
diff --git a/test/pacman/tests/replace101.py b/test/pacman/tests/replace101.py
new file mode 100644
index 00000000..86c40ac6
--- /dev/null
+++ b/test/pacman/tests/replace101.py
@@ -0,0 +1,25 @@
+self.description = "Sysupgrade with a versioned replacement"
+
+sp1 = pmpkg("python2-yaml", "5-1")
+sp1.replaces = ["python-yaml<5"]
+sp1.conflicts = ["python-yaml<5"]
+sp1.files = ["lib/python2/file"]
+self.addpkg2db("sync", sp1)
+
+# the python3 version
+sp2 = pmpkg("python-yaml", "5-1")
+sp2.files = ["lib/python3/file"]
+self.addpkg2db("sync", sp2)
+
+lp1 = pmpkg("python-yaml", "4-1")
+lp1.files = ["lib/python2/file"]
+self.addpkg2db("local", lp1)
+
+self.args = "-Su"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=python-yaml")
+self.addrule("PKG_VERSION=python2-yaml|5-1")
+self.addrule("FILE_EXIST=lib/python2/file")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/replace102.py b/test/pacman/tests/replace102.py
new file mode 100644
index 00000000..c6e2e5f0
--- /dev/null
+++ b/test/pacman/tests/replace102.py
@@ -0,0 +1,27 @@
+self.description = "Replace a package with a file in 'backup' (local modified)"
+# FS#24543
+
+lp = pmpkg("dummy")
+lp.files = ["etc/dummy.conf*", "bin/dummy"]
+lp.backup = ["etc/dummy.conf"]
+self.addpkg2db("local", lp)
+
+sp = pmpkg("replacement")
+sp.replaces = ["dummy"]
+sp.files = ["etc/dummy.conf", "bin/dummy*"]
+sp.backup = ["etc/dummy.conf"]
+self.addpkg2db("sync", sp)
+
+self.args = "-Su"
+
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("PKG_EXIST=replacement")
+
+self.addrule("FILE_EXIST=etc/dummy.conf")
+self.addrule("!FILE_MODIFIED=etc/dummy.conf")
+self.addrule("!FILE_PACNEW=etc/dummy.conf")
+self.addrule("!FILE_PACSAVE=etc/dummy.conf")
+
+self.addrule("FILE_EXIST=bin/dummy")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/smoke002.py b/test/pacman/tests/smoke002.py
index 44f2d0ec..8ff5cab7 100644
--- a/test/pacman/tests/smoke002.py
+++ b/test/pacman/tests/smoke002.py
@@ -10,10 +10,8 @@ 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)
+# We error out when fed a package with an invalid description; the second one
+# fits the bill in this case as the desc is > 512K
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("!PKG_EXIST=pkg1")
diff --git a/test/pacman/tests/symlink002.py b/test/pacman/tests/symlink002.py
new file mode 100644
index 00000000..6b7423d9
--- /dev/null
+++ b/test/pacman/tests/symlink002.py
@@ -0,0 +1,43 @@
+self.description = "Dead backed-up symlink when removing package (FS#24230)"
+
+# symlink file is changed
+lp = pmpkg("dummy")
+lp.files = ["etc/brokenlink -> nonexistent",
+ "etc/exists"]
+lp.backup = ["etc/brokenlink*"]
+self.addpkg2db("local", lp)
+
+# symlink file is not changed
+lp2 = pmpkg("dummy2")
+lp2.files = ["etc/brokenlink2 -> nonexistent2",
+ "etc/exists2"]
+lp2.backup = ["etc/brokenlink2"]
+self.addpkg2db("local", lp2)
+
+# package is left alone, not uninstalled
+lp3 = pmpkg("dummy3")
+lp3.files = ["etc/brokenlink3 -> nonexistent3",
+ "etc/exists3"]
+self.addpkg2db("local", lp3)
+
+self.args = "-R %s %s" % (lp.name, lp2.name)
+#self.args = "-R"
+
+self.addrule("PACMAN_RETCODE=0")
+
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("!LINK_EXIST=etc/brokenlink")
+self.addrule("!FILE_EXIST=etc/nonexistent")
+self.addrule("!FILE_EXIST=etc/exists")
+
+self.addrule("!PKG_EXIST=dummy2")
+self.addrule("!LINK_EXIST=etc/brokenlink2")
+self.addrule("!FILE_EXIST=etc/nonexistent2")
+self.addrule("!FILE_EXIST=etc/exists2")
+
+self.addrule("PKG_EXIST=dummy3")
+self.addrule("LINK_EXIST=etc/brokenlink3")
+self.addrule("!FILE_EXIST=etc/nonexistent")
+self.addrule("FILE_EXIST=etc/exists3")
+self.addrule("FILE_TYPE=etc/brokenlink3|link")
+self.addrule("FILE_TYPE=etc/exists3|file")
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 47255923..ddd955a2 100755
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -150,7 +150,6 @@ def getmd5sum(filename):
"""
"""
if not os.path.isfile(filename):
- print "file %s does not exist!" % filename
return ""
fd = open(filename, "rb")
checksum = hashlib.md5()
@@ -178,9 +177,8 @@ def getmtime(filename):
"""
"""
if not os.path.exists(filename):
- print "path %s does not exist!" % filename
- return 0, 0, 0
- st = os.stat(filename)
+ return None, None, None
+ st = os.lstat(filename)
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]
#