summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/pacman/README1
-rwxr-xr-xtest/pacman/pactest.py2
-rw-r--r--test/pacman/pmdb.py2
-rw-r--r--test/pacman/pmenv.py2
-rw-r--r--test/pacman/pmfile.py2
-rw-r--r--test/pacman/pmpkg.py2
-rw-r--r--test/pacman/pmrule.py9
-rw-r--r--test/pacman/pmtest.py2
-rw-r--r--test/pacman/tests/Makefile.am10
-rw-r--r--test/pacman/tests/fileconflict011.py17
-rw-r--r--test/pacman/tests/fileconflict012.py2
-rw-r--r--test/pacman/tests/fileconflict013.py22
-rw-r--r--test/pacman/tests/fileconflict015.py17
-rw-r--r--test/pacman/tests/fileconflict016.py23
-rw-r--r--test/pacman/tests/ignore008.py29
-rw-r--r--test/pacman/tests/query007.py11
-rw-r--r--test/pacman/tests/remove031.py11
-rw-r--r--test/pacman/tests/sync139.py23
-rw-r--r--test/pacman/tests/sync301.py27
-rw-r--r--test/pacman/tests/sync302.py49
-rw-r--r--test/pacman/tests/sync303.py35
-rw-r--r--test/pacman/tests/sync304.py25
-rw-r--r--test/pacman/tests/sync305.py64
-rw-r--r--test/pacman/tests/sync502.py17
-rw-r--r--test/pacman/tests/sync503.py18
-rw-r--r--test/pacman/tests/sync700.py22
-rw-r--r--test/pacman/tests/sync701.py22
-rw-r--r--test/pacman/tests/sync702.py22
-rw-r--r--test/pacman/tests/upgrade012.py2
-rw-r--r--test/pacman/tests/upgrade014.py2
-rw-r--r--test/pacman/tests/upgrade015.py2
-rw-r--r--test/pacman/tests/upgrade016.py2
-rw-r--r--test/pacman/tests/upgrade046.py2
-rw-r--r--test/pacman/util.py2
-rw-r--r--test/scripts/Makefile.am10
-rw-r--r--test/scripts/human_to_size_test.sh75
-rwxr-xr-xtest/scripts/parseopts_test.sh138
37 files changed, 500 insertions, 223 deletions
diff --git a/test/pacman/README b/test/pacman/README
index a3c36fc9..ae3303a3 100644
--- a/test/pacman/README
+++ b/test/pacman/README
@@ -108,7 +108,6 @@ is not necessarily complete:
- HoldPkg
- IgnorePkg
- IgnoreGroup
- - SyncFirst
- NoExtract
- NoUpgrade
- XferCommand
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py
index bb198eb4..2fb64edc 100755
--- a/test/pacman/pactest.py
+++ b/test/pacman/pactest.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# pactest : run automated testing on the pacman binary
#
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index b94c6cf6..285c3151 100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py
index 04aecd9a..0e455cee 100644
--- a/test/pacman/pmenv.py
+++ b/test/pacman/pmenv.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index cdcc7715..d5aa1a11 100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 00f345c0..bfc93dd6 100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index 70c8838e..778b6aac 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
@@ -87,8 +87,11 @@ class pmrule(object):
if not value in newpkg.depends:
success = 0
elif case == "OPTDEPENDS":
- if not value in newpkg.optdepends:
- success = 0
+ success = 0
+ for optdep in newpkg.optdepends:
+ if value == optdep.split(':', 1)[0]:
+ success = 1
+ break
elif case == "REASON":
if newpkg.reason != int(value):
success = 0
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 4e1ecd0b..1a026864 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/pacman/tests/Makefile.am b/test/pacman/tests/Makefile.am
index 508534ac..9ab0c777 100644
--- a/test/pacman/tests/Makefile.am
+++ b/test/pacman/tests/Makefile.am
@@ -17,11 +17,9 @@ edit = sed \
$(CONFTESTS): Makefile
- @echo ' ' GEN $@;
- @$(RM) $@ $@.tmp
- @test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@.tmp || true
- @test -f $@.tmp || false
- @chmod a-w $@.tmp
- @mv $@.tmp $@
+ $(AM_V_at)$(RM) $@ $@.tmp
+ $(AM_V_GEN)test -f $(srcdir)/$@.in && $(edit) $(srcdir)/$@.in >$@.tmp || true
+ $(AM_V_at)chmod a-w $@.tmp
+ $(AM_V_at)mv $@.tmp $@
# vim:set ts=2 sw=2 noet:
diff --git a/test/pacman/tests/fileconflict011.py b/test/pacman/tests/fileconflict011.py
new file mode 100644
index 00000000..af48a067
--- /dev/null
+++ b/test/pacman/tests/fileconflict011.py
@@ -0,0 +1,17 @@
+self.description = "dir->file change during package upgrade (filesystem directory conflict)"
+
+lp1 = pmpkg("pkg1")
+lp1.files = ["dir/"]
+self.addpkg2db("local", lp1)
+
+self.filesystem = ["dir/conflict/"]
+
+p = pmpkg("pkg1", "1.0-2")
+p.files = ["dir"]
+self.addpkg2db("sync", p)
+
+self.args = "-S pkg1"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg1|1.0-1")
+self.addrule("DIR_EXIST=dir/conflict/")
diff --git a/test/pacman/tests/fileconflict012.py b/test/pacman/tests/fileconflict012.py
index 421b739a..95ab5681 100644
--- a/test/pacman/tests/fileconflict012.py
+++ b/test/pacman/tests/fileconflict012.py
@@ -14,4 +14,4 @@ self.args = "-S pkg1"
self.addrule("PACMAN_RETCODE=1")
self.addrule("PKG_VERSION=pkg1|1.0-1")
-self.addrule("DIR_EXIST=dir/")
+self.addrule("FILE_EXIST=dir/file")
diff --git a/test/pacman/tests/fileconflict013.py b/test/pacman/tests/fileconflict013.py
new file mode 100644
index 00000000..521b62e8
--- /dev/null
+++ b/test/pacman/tests/fileconflict013.py
@@ -0,0 +1,22 @@
+self.description = "file->file path change with same effective path (/lib as symlink)"
+
+lp1 = pmpkg("filesystem", "1.0-1")
+lp1.files = ["usr/",
+ "usr/lib/",
+ "lib -> usr/lib/"]
+self.addpkg2db("local", lp1)
+
+lp2 = pmpkg("pkg1", "1.0-1")
+lp2.files = ["lib/libfoo.so"]
+self.addpkg2db("local", lp2)
+
+sp1 = pmpkg("pkg1", "1.0-2")
+sp1.files = ["usr/lib/libfoo.so"]
+self.addpkg2db("sync", sp1)
+
+self.args = "-Su"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=pkg1|1.0-2")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/fileconflict015.py b/test/pacman/tests/fileconflict015.py
new file mode 100644
index 00000000..78634d7e
--- /dev/null
+++ b/test/pacman/tests/fileconflict015.py
@@ -0,0 +1,17 @@
+self.description = "conflict between a directory and a file"
+
+p1 = pmpkg("pkg1")
+p1.files = ["foo/"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2")
+p2.files = ["foo"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("!PKG_EXIST=pkg2")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/fileconflict016.py b/test/pacman/tests/fileconflict016.py
new file mode 100644
index 00000000..93797f64
--- /dev/null
+++ b/test/pacman/tests/fileconflict016.py
@@ -0,0 +1,23 @@
+self.description = "file conflict with same effective path across packages (directory symlink)"
+
+lp1 = pmpkg("filesystem", "1.0-1")
+lp1.files = ["usr/",
+ "usr/lib/",
+ "lib -> usr/lib/"]
+self.addpkg2db("local", lp1)
+
+p1 = pmpkg("pkg1")
+p1.files = ["lib/foo"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2")
+p2.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("!PKG_EXIST=pkg2")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/ignore008.py b/test/pacman/tests/ignore008.py
new file mode 100644
index 00000000..12416ad9
--- /dev/null
+++ b/test/pacman/tests/ignore008.py
@@ -0,0 +1,29 @@
+self.description = "Sync with relevant ignored fnmatched packages"
+
+package1 = pmpkg("foopkg", "1.0-1")
+self.addpkg2db("local", package1)
+
+package2 = pmpkg("barpkg", "2.0-1")
+self.addpkg2db("local", package2)
+
+package3 = pmpkg("bazpkg", "3.0-1")
+self.addpkg2db("local", package3)
+
+
+package1up = pmpkg("foopkg", "2.0-1")
+self.addpkg2db("sync", package1up)
+
+package2up = pmpkg("barpkg", "3.0-1")
+self.addpkg2db("sync", package2up)
+
+package3up = pmpkg("bazpkg", "4.0-1")
+self.addpkg2db("sync", package3up)
+
+self.option["IgnorePkg"] = ["foo*", "ba?pkg"]
+self.args = "-Su"
+
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=foopkg|1.0-1")
+self.addrule("PKG_VERSION=barpkg|2.0-1")
+self.addrule("PKG_VERSION=bazpkg|3.0-1")
diff --git a/test/pacman/tests/query007.py b/test/pacman/tests/query007.py
new file mode 100644
index 00000000..35bb0ca6
--- /dev/null
+++ b/test/pacman/tests/query007.py
@@ -0,0 +1,11 @@
+self.description = "Query ownership of file in root"
+
+sp = pmpkg("dummy")
+sp.files = ["etc/config"]
+self.addpkg2db("local", sp)
+
+self.filesystem = ["config"]
+
+self.args = "-Qo /config"
+
+self.addrule("PACMAN_RETCODE=1")
diff --git a/test/pacman/tests/remove031.py b/test/pacman/tests/remove031.py
new file mode 100644
index 00000000..0ea09c87
--- /dev/null
+++ b/test/pacman/tests/remove031.py
@@ -0,0 +1,11 @@
+self.description = "Remove a package in HoldPkg"
+
+p1 = pmpkg("foopkg")
+self.addpkg2db("local", p1)
+
+self.option["HoldPkg"] = ["???pkg"]
+
+self.args = "-R %s" % p1.name
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_EXIST=foopkg")
diff --git a/test/pacman/tests/sync139.py b/test/pacman/tests/sync139.py
new file mode 100644
index 00000000..0b0526d8
--- /dev/null
+++ b/test/pacman/tests/sync139.py
@@ -0,0 +1,23 @@
+self.description = "Sysupgrade of packages in fnmatch'd IgnoreGroup"
+
+sp1 = pmpkg("pkg1", "1.0-2")
+sp1.groups = ["grp"]
+sp2 = pmpkg("pkg2", "1.0-2")
+sp2.groups = ["grp2"]
+
+for p in sp1, sp2:
+ self.addpkg2db("sync", p)
+
+lp1 = pmpkg("pkg1", "1.0-1")
+lp2 = pmpkg("pkg2", "1.0-1")
+
+for p in lp1, lp2:
+ self.addpkg2db("local", p)
+
+self.option["IgnoreGroup"] = ["grp"]
+
+self.args = "-Su"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=pkg1|1.0-1")
+self.addrule("PKG_VERSION=pkg2|1.0-2")
diff --git a/test/pacman/tests/sync301.py b/test/pacman/tests/sync301.py
deleted file mode 100644
index 96402fc3..00000000
--- a/test/pacman/tests/sync301.py
+++ /dev/null
@@ -1,27 +0,0 @@
-self.description = "Sysupgrade : pacman needs to be upgraded and has new deps"
-
-sp = pmpkg("pacman", "1.0-2")
-sp.depends = ["dep"]
-self.addpkg2db("sync", sp)
-
-spdep = pmpkg("dep")
-self.addpkg2db("sync", spdep)
-
-sp1 = pmpkg("pkg1", "1.0-2")
-self.addpkg2db("sync", sp1)
-
-lp = pmpkg("pacman", "1.0-1")
-self.addpkg2db("local", lp)
-
-lp1 = pmpkg("pkg1", "1.0-1")
-self.addpkg2db("local", lp1)
-
-self.option["SyncFirst"] = ["pacman"]
-
-self.args = "-Su"
-
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("PKG_EXIST=pacman")
-self.addrule("PKG_VERSION=pacman|1.0-2")
-self.addrule("PKG_VERSION=pkg1|1.0-1")
-self.addrule("PKG_EXIST=dep")
diff --git a/test/pacman/tests/sync302.py b/test/pacman/tests/sync302.py
deleted file mode 100644
index 78e45c33..00000000
--- a/test/pacman/tests/sync302.py
+++ /dev/null
@@ -1,49 +0,0 @@
-self.description = "Sysupgrade : pacman needs to be upgraded and has updated deps"
-
-sp = pmpkg("pacman", "1.0-2")
-sp.depends = ["zlib", "curl", "libarchive"]
-self.addpkg2db("sync", sp)
-
-libcdep = pmpkg("glibc", "2.15-1")
-self.addpkg2db("sync", libcdep)
-
-curldep = pmpkg("curl", "7.22-1")
-self.addpkg2db("sync", curldep)
-
-libadep = pmpkg("libarchive", "2.8.5-1")
-self.addpkg2db("sync", libadep)
-
-zlibdep = pmpkg("zlib", "1.2.5-3")
-zlibdep.depends = ["glibc"]
-self.addpkg2db("sync", zlibdep)
-
-
-lp = pmpkg("pacman", "1.0-1")
-self.addpkg2db("local", lp)
-
-lp1 = pmpkg("curl", "7.21.7-1")
-self.addpkg2db("local", lp1)
-
-lp2 = pmpkg("glibc", "2.13-1")
-self.addpkg2db("local", lp2)
-
-lp3 = pmpkg("libarchive", "2.8.4-1")
-self.addpkg2db("local", lp3)
-
-lp4 = pmpkg("zlib", "1.2.5-3")
-self.addpkg2db("local", lp4)
-
-self.option["SyncFirst"] = ["pacman"]
-
-self.args = "-Su"
-
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("PKG_VERSION=pacman|1.0-2")
-self.addrule("PKG_EXIST=glibc")
-self.addrule("PKG_EXIST=curl")
-self.addrule("PKG_EXIST=libarchive")
-# TODO: when SyncFirst recursive comes back, re-enable these
-#self.addrule("PKG_VERSION=glibc|2.15-1")
-#self.addrule("PKG_VERSION=curl|7.22-1")
-#self.addrule("PKG_VERSION=libarchive|2.8.5-1")
-self.addrule("PKG_EXIST=zlib")
diff --git a/test/pacman/tests/sync303.py b/test/pacman/tests/sync303.py
deleted file mode 100644
index 9d7bab58..00000000
--- a/test/pacman/tests/sync303.py
+++ /dev/null
@@ -1,35 +0,0 @@
-self.description = "Sysupgrade: upgrade pacman with deps as provisions"
-
-sp = pmpkg("pacman", "1.0-2")
-sp.depends = ["zlib"]
-self.addpkg2db("sync", sp)
-
-glibcdep = pmpkg("glibc", "2.13-1")
-self.addpkg2db("sync", glibcdep)
-
-zlibdep = pmpkg("zlib", "1.2.5-3")
-zlibdep.depends = ["glibc"]
-self.addpkg2db("sync", zlibdep)
-
-
-lp = pmpkg("pacman", "1.0-1")
-lp.depends = ["zlib"]
-self.addpkg2db("local", lp)
-
-lp2 = pmpkg("glibc-awesome", "2.13-2")
-lp2.provides = ["glibc=2.13"]
-lp2.conflicts = ["glibc"]
-self.addpkg2db("local", lp2)
-
-lp3 = pmpkg("zlib", "1.2.5-3")
-self.addpkg2db("local", lp3)
-
-self.option["SyncFirst"] = ["pacman"]
-
-self.args = "-Su"
-
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("PKG_VERSION=pacman|1.0-2")
-self.addrule("PKG_EXIST=glibc-awesome")
-self.addrule("PKG_VERSION=glibc-awesome|2.13-2")
-self.addrule("PKG_EXIST=zlib")
diff --git a/test/pacman/tests/sync304.py b/test/pacman/tests/sync304.py
deleted file mode 100644
index 18058c99..00000000
--- a/test/pacman/tests/sync304.py
+++ /dev/null
@@ -1,25 +0,0 @@
-self.description = "Sysupgrade: upgrade pacman being depended on"
-
-sp = pmpkg("pacman", "4.0.1-1")
-self.addpkg2db("sync", sp)
-
-sp2 = pmpkg("pyalpm", "2-1")
-sp2.depends = ["pacman>=4.0", "pacman<4.1"]
-self.addpkg2db("sync", sp2)
-
-lp = pmpkg("pacman", "3.5.4-1")
-self.addpkg2db("local", lp)
-
-lp2 = pmpkg("pyalpm", "1-1")
-lp2.depends = ["pacman>=3.5", "pacman<3.6"]
-self.addpkg2db("local", lp2)
-
-self.option["SyncFirst"] = ["pacman"]
-
-self.args = "-Su"
-
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("PKG_VERSION=pacman|4.0.1-1")
-self.addrule("PKG_VERSION=pyalpm|2-1")
-
-self.expectfailure = True
diff --git a/test/pacman/tests/sync305.py b/test/pacman/tests/sync305.py
deleted file mode 100644
index 62005b58..00000000
--- a/test/pacman/tests/sync305.py
+++ /dev/null
@@ -1,64 +0,0 @@
-self.description = "Sysupgrade: syncfirst with recursive/cascading deps"
-
-sp = pmpkg("pacman", "4.0.1-2")
-sp.depends = ["glibc>=2.15", "curl"]
-self.addpkg2db("sync", sp)
-
-glibcdep = pmpkg("glibc", "2.15-1")
-self.addpkg2db("sync", glibcdep)
-
-gcldep = pmpkg("gcc-libs", "4.6.2-5")
-gcldep.depends = ["glibc>=2.14"]
-self.addpkg2db("sync", gcldep)
-
-curldep = pmpkg("curl", "7.23.1-2")
-curldep.depends = ["openssl"]
-self.addpkg2db("sync", curldep)
-
-openssldep = pmpkg("openssl", "1.0.0.e-1")
-openssldep.depends = ["perl"]
-self.addpkg2db("sync", openssldep)
-
-gccdep = pmpkg("gcc", "4.6.2-5")
-gccdep.depends = ["gcc-libs=4.6.2-5"]
-self.addpkg2db("sync", gccdep)
-
-perldep = pmpkg("perl", "5.14.2-5")
-perldep.depends = ["db"]
-self.addpkg2db("sync", perldep)
-
-dbdep = pmpkg("db", "5.2.36-2")
-dbdep.depends = ["gcc-libs"]
-self.addpkg2db("sync", dbdep)
-
-
-lp = pmpkg("pacman", "4.0.1-1")
-lp.depends = ["glibc>=2.14", "curl"]
-self.addpkg2db("local", lp)
-
-lp2 = pmpkg("glibc", "2.14-2")
-self.addpkg2db("local", lp2)
-
-lp3 = pmpkg("curl", "7.23.1-2")
-self.addpkg2db("local", lp3)
-
-lp4 = pmpkg("gcc-libs", "4.6.2-3")
-self.addpkg2db("local", lp4)
-
-lp5 = pmpkg("gcc", "4.6.2-3")
-lp5.depends = ["gcc-libs=4.6.2-3"]
-self.addpkg2db("local", lp5)
-
-lp6 = pmpkg("perl", "5.14.2-5")
-lp6.depends = ["db"]
-self.addpkg2db("local", lp6)
-
-lp7 = pmpkg("db", "5.2.36-2")
-lp7.depends = ["gcc-libs"]
-self.addpkg2db("local", lp7)
-
-self.option["SyncFirst"] = ["pacman"]
-
-self.args = "-Su"
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("PKG_VERSION=pacman|4.0.1-2")
diff --git a/test/pacman/tests/sync502.py b/test/pacman/tests/sync502.py
new file mode 100644
index 00000000..5cc42c9f
--- /dev/null
+++ b/test/pacman/tests/sync502.py
@@ -0,0 +1,17 @@
+self.description = "Install a package from a sync db with fnmatch'ed NoExtract"
+
+sp = pmpkg("dummy")
+sp.files = ["bin/dummy",
+ "usr/share/man/man8",
+ "usr/share/man/man1/dummy.1"]
+self.addpkg2db("sync", sp)
+
+self.option["NoExtract"] = ["usr/share/man/*"]
+
+self.args = "-S %s" % sp.name
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=dummy")
+self.addrule("FILE_EXIST=bin/dummy")
+self.addrule("!FILE_EXIST=usr/share/man/man8")
+self.addrule("!FILE_EXIST=usr/share/man/man1/dummy.1")
diff --git a/test/pacman/tests/sync503.py b/test/pacman/tests/sync503.py
new file mode 100644
index 00000000..9d24f00d
--- /dev/null
+++ b/test/pacman/tests/sync503.py
@@ -0,0 +1,18 @@
+self.description = "Upgrade a package, with a fnmatch in NoUpgrade"
+
+sp = pmpkg("dummy", "1.0-2")
+sp.files = ["etc/dummy.conf"]
+self.addpkg2db("sync", sp)
+
+lp = pmpkg("dummy")
+lp.files = ["etc/dummy.conf"]
+self.addpkg2db("local", lp)
+
+self.option["NoUpgrade"] = ["etc/dummy.*"]
+
+self.args = "-S %s" % sp.name
+
+self.addrule("PKG_VERSION=dummy|1.0-2")
+self.addrule("!FILE_MODIFIED=etc/dummy.conf")
+self.addrule("FILE_PACNEW=etc/dummy.conf")
+self.addrule("!FILE_PACSAVE=etc/dummy.conf")
diff --git a/test/pacman/tests/sync700.py b/test/pacman/tests/sync700.py
new file mode 100644
index 00000000..0002b643
--- /dev/null
+++ b/test/pacman/tests/sync700.py
@@ -0,0 +1,22 @@
+self.description = "do not remove directory symlink if another package has file in its path"
+
+lp1 = pmpkg("pkg1")
+lp1.files = ["usr/lib/foo",
+ "lib -> usr/lib"]
+self.addpkg2db("local", lp1)
+
+lp2 = pmpkg("pkg2")
+lp2.files = ["lib/bar"]
+self.addpkg2db("local", lp2)
+
+p = pmpkg("pkg1", "1.0-2")
+p.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p)
+
+self.args = "-S pkg1"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg1|1.0-1")
+self.addrule("FILE_EXIST=/lib/bar")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/sync701.py b/test/pacman/tests/sync701.py
new file mode 100644
index 00000000..201f6028
--- /dev/null
+++ b/test/pacman/tests/sync701.py
@@ -0,0 +1,22 @@
+self.description = "do not remove directory symlink if incoming package has file in its path (order 1)"
+
+lp = pmpkg("pkg1")
+lp.files = ["usr/lib/foo",
+ "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1", "1.0-2")
+p1.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2")
+p2.files = ["lib/bar"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg1|1.0-1")
+self.addrule("!PKG_EXIST=pkg2")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/sync702.py b/test/pacman/tests/sync702.py
new file mode 100644
index 00000000..ee4eef95
--- /dev/null
+++ b/test/pacman/tests/sync702.py
@@ -0,0 +1,22 @@
+self.description = "do not remove directory symlink if incoming package has file in its path (order 2)"
+
+lp = pmpkg("pkg2")
+lp.files = ["usr/lib/foo",
+ "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1")
+p1.files = ["lib/bar"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2", "1.0-2")
+p2.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg2|1.0-1")
+self.addrule("!PKG_EXIST=pkg1")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/upgrade012.py b/test/pacman/tests/upgrade012.py
index dba8dc18..4d9f0cd1 100644
--- a/test/pacman/tests/upgrade012.py
+++ b/test/pacman/tests/upgrade012.py
@@ -6,7 +6,7 @@ self.addpkg(p)
self.filesystem = ["bin/dummy"]
-self.args = "-Uf %s" % p.filename()
+self.args = "-U --force %s" % p.filename()
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy")
diff --git a/test/pacman/tests/upgrade014.py b/test/pacman/tests/upgrade014.py
index 1632dd36..93c2fe2b 100644
--- a/test/pacman/tests/upgrade014.py
+++ b/test/pacman/tests/upgrade014.py
@@ -13,7 +13,7 @@ p2.files = ["bin/foobar",
for p in p1, p2:
self.addpkg(p)
-self.args = "-Uf %s" % " ".join([p.filename() for p in p1, p2])
+self.args = "-U --force %s" % " ".join([p.filename() for p in p1, p2])
self.addrule("PACMAN_RETCODE=0")
for p in p1, p2:
diff --git a/test/pacman/tests/upgrade015.py b/test/pacman/tests/upgrade015.py
index 22f7c36b..ea6046cb 100644
--- a/test/pacman/tests/upgrade015.py
+++ b/test/pacman/tests/upgrade015.py
@@ -6,7 +6,7 @@ self.addpkg(p)
self.filesystem = ["etc/dummy.conf"]
-self.args = "-Uf %s" % p.filename()
+self.args = "-U --force %s" % p.filename()
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy")
diff --git a/test/pacman/tests/upgrade016.py b/test/pacman/tests/upgrade016.py
index dd31c9ab..b6b3f3ae 100644
--- a/test/pacman/tests/upgrade016.py
+++ b/test/pacman/tests/upgrade016.py
@@ -7,7 +7,7 @@ self.addpkg(p)
self.filesystem = ["etc/dummy.conf"]
-self.args = "-Uf %s" % p.filename()
+self.args = "-U --force %s" % p.filename()
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy")
diff --git a/test/pacman/tests/upgrade046.py b/test/pacman/tests/upgrade046.py
index 12390647..a02a7132 100644
--- a/test/pacman/tests/upgrade046.py
+++ b/test/pacman/tests/upgrade046.py
@@ -20,7 +20,7 @@ p2.files = ["bin/foobar"]
for p in p1, p2:
self.addpkg(p)
-self.args = "-Uf %s" % " ".join([p.filename() for p in p1, p2])
+self.args = "-U --force %s" % " ".join([p.filename() for p in p1, p2])
self.addrule("PACMAN_RETCODE=0")
for p in p1, p2:
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 81dcc906..d40612dc 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
#
diff --git a/test/scripts/Makefile.am b/test/scripts/Makefile.am
new file mode 100644
index 00000000..d525d894
--- /dev/null
+++ b/test/scripts/Makefile.am
@@ -0,0 +1,10 @@
+check_SCRIPTS = \
+ parseopts_test.sh \
+ human_to_size_test.sh
+
+noinst_SCRIPTS = $(check_SCRIPTS)
+
+EXTRA_DIST = \
+ $(check_SCRIPTS)
+
+# vim:set ts=2 sw=2 noet:
diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh
new file mode 100644
index 00000000..dbf1997a
--- /dev/null
+++ b/test/scripts/human_to_size_test.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# source the library function
+if [[ -z $1 || ! -f $1 ]]; then
+ printf "error: path to human_to_size library not provided or does not exist\n"
+ exit 1
+fi
+. "$1"
+
+if ! type -t human_to_size >/dev/null; then
+ printf 'human_to_size function not found\n'
+ exit 1
+fi
+
+parse_hts() {
+ local input=$1 expected=$2 result
+
+ (( ++testcount ))
+
+ result=$(human_to_size "$1")
+ if [[ $result = "$expected" ]]; then
+ (( ++pass ))
+ else
+ (( ++fail ))
+ printf '[TEST %3s]: FAIL\n' "$testcount"
+ printf ' input: %s\n' "$input"
+ printf ' output: %s\n' "$result"
+ printf ' expected: %s\n' "$expected"
+ fi
+}
+
+summarize() {
+ if (( !fail )); then
+ printf 'All %s tests successful\n\n' "$testcount"
+ exit 0
+ else
+ printf '%s of %s tests failed\n\n' "$fail" "$testcount"
+ exit 1
+ fi
+}
+trap 'summarize' EXIT
+
+printf 'Beginning human_to_size tests\n'
+
+# parse_hts <input> <expected output>
+
+parse_hts '1MiB' 1048576
+
+parse_hts '10XiB' ''
+
+parse_hts '10 MiB' 10485760
+
+parse_hts '10 XiB' ''
+
+parse_hts '.1 TiB' 109951162778
+
+parse_hts ' -3 KiB ' -3072
+
+parse_hts 'foo3KiB' ''
+
+parse_hts '3KiBfoo' ''
+
+parse_hts '3kib' ''
+
+parse_hts '+1KiB' 1024
+
+parse_hts '+1.0 KiB' 1024
+
+parse_hts '1MB' 1000000
+
+parse_hts '1M' 1048576
+
+parse_hts ' 1 G ' 1073741824
+
+parse_hts '1Q' ''
diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh
new file mode 100755
index 00000000..1693b9f9
--- /dev/null
+++ b/test/scripts/parseopts_test.sh
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+declare -i testcount=0 pass=0 fail=0
+
+# source the library function
+if [[ -z $1 || ! -f $1 ]]; then
+ printf "error: path to parseopts library not provided or does not exist\n"
+ exit 1
+fi
+. "$1"
+
+if ! type -t parseopts >/dev/null; then
+ printf 'parseopts function not found\n'
+ exit 1
+fi
+
+# borrow opts from makepkg
+OPT_SHORT="AcdefFghiLmop:rRsV"
+OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean:' 'cleanall' 'nodeps'
+ 'noextract' 'force' 'forcever:' 'geninteg' 'help' 'holdver'
+ 'install' 'key:' 'log' 'nocolor' 'nobuild' 'nocheck' 'nosign' 'pkg:' 'rmdeps'
+ 'repackage' 'skipinteg' 'sign' 'source' 'syncdeps' 'version' 'config:'
+ 'noconfirm' 'noprogressbar')
+
+parse() {
+ local result=$1 tokencount=$2; shift 2
+
+ (( ++testcount ))
+ parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null
+ test_result "$result" "$tokencount" "$*" "${OPTRET[@]}"
+ unset OPTRET
+}
+
+test_result() {
+ local result=$1 tokencount=$2 input=$3; shift 3
+
+ if [[ $result = "$*" ]] && (( tokencount == $# )); then
+ (( ++pass ))
+ else
+ printf '[TEST %3s]: FAIL\n' "$testcount"
+ printf ' input: %s\n' "$input"
+ printf ' output: %s (%s tokens)\n' "$*" "$#"
+ printf ' expected: %s (%s tokens)\n' "$result" "$tokencount"
+ echo
+ (( ++fail ))
+ fi
+}
+
+summarize() {
+ if (( !fail )); then
+ printf 'All %s tests successful\n\n' "$testcount"
+ exit 0
+ else
+ printf '%s of %s tests failed\n\n' "$fail" "$testcount"
+ exit 1
+ fi
+}
+trap 'summarize' EXIT
+
+printf 'Beginning parseopts tests\n'
+
+# usage: parse <expected result> <token count> test-params...
+# a failed parse will match only the end of options marker '--'
+
+# no options
+parse '--' 1
+
+# short options
+parse '-s -r --' 3 -s -r
+
+# short options, no spaces
+parse '-s -r --' 3 -sr
+
+# short opt missing an opt arg
+parse '--' 1 -s -p
+
+# short opt with an opt arg
+parse '-p PKGBUILD -L --' 4 -p PKGBUILD -L
+
+# short opt with an opt arg, no space
+parse '-p PKGBUILD --' 3 -pPKGBUILD
+
+# valid shortopts as a long opt
+parse '--' 1 --sir
+
+# long opt wiht no optarg
+parse '--log --' 2 --log
+
+# long opt with missing optarg
+parse '--' 1 -sr --pkg
+
+# long opt with optarg
+parse '--pkg foo --' 3 --pkg foo
+
+# long opt with optarg with whitespace
+parse '--pkg foo bar -- baz' 4 --pkg "foo bar" baz
+
+# long opt with optarg with =
+parse '--pkg foo=bar -- baz' 4 --pkg foo=bar baz
+
+# long opt with explicit optarg
+parse '--pkg bar -- foo baz' 5 foo --pkg=bar baz
+
+# long opt with explicit optarg, with whitespace
+parse '--pkg foo bar -- baz' 4 baz --pkg="foo bar"
+
+# long opt with explicit optarg that doesn't take optarg
+parse '--' 1 --force=always -s
+
+# long opt with explicit optarg with =
+parse '--pkg foo=bar --' 3 --pkg=foo=bar
+
+# explicit end of options with options after
+parse '-s -r -- foo bar baz' 6 -s -r -- foo bar baz
+
+# non-option parameters mixed in with options
+parse '-s -r -- foo baz' 5 -s foo baz -r
+
+# optarg with whitespace
+parse '-p foo bar -s --' 4 -p'foo bar' -s
+
+# non-option parameter with whitespace
+parse '-i -- foo bar' 3 -i 'foo bar'
+
+# successful stem match (opt has no arg)
+parse '--nocolor --' 2 --nocol
+
+# successful stem match (opt has arg)
+parse '--config foo --' 3 --conf foo
+
+# ambiguous long opt
+parse '--' 1 '--for'
+
+# exact match on a possible stem (--force & --forcever)
+parse '--force --' 2 --force
+
+# exact match on possible stem (opt has optarg)
+parse '--clean foo --' 3 --clean=foo