[pacman-dev] [PATCH 5/5] Add unit tests for -Qkk with altered files.

Jeremy Heiner scalaprotractor at gmail.com
Mon Nov 11 06:47:47 EST 2013


The first test (007) checks every permutation of file type mismatch
that -Qkk warns about. The second (008) checks for the other types of
mismatch (permissions, modification time, size, and symlink path) that
the test framework can set up without root permission.

Signed-off-by: Jeremy Heiner <ScalaProtractor at gmail.com>
---
 test/pacman/tests/TESTS            |  2 ++
 test/pacman/tests/querycheck007.py | 25 +++++++++++++++++++++++++
 test/pacman/tests/querycheck008.py | 25 +++++++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 test/pacman/tests/querycheck007.py
 create mode 100644 test/pacman/tests/querycheck008.py

diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index c460fe0..abe0558 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -94,6 +94,8 @@ TESTS += test/pacman/tests/querycheck003.py
 TESTS += test/pacman/tests/querycheck004.py
 TESTS += test/pacman/tests/querycheck005.py
 TESTS += test/pacman/tests/querycheck006.py
+TESTS += test/pacman/tests/querycheck007.py
+TESTS += test/pacman/tests/querycheck008.py
 TESTS += test/pacman/tests/reason001.py
 TESTS += test/pacman/tests/remove001.py
 TESTS += test/pacman/tests/remove002.py
diff --git a/test/pacman/tests/querycheck007.py b/test/pacman/tests/querycheck007.py
new file mode 100644
index 0000000..9a2c765
--- /dev/null
+++ b/test/pacman/tests/querycheck007.py
@@ -0,0 +1,25 @@
+self.description = "Query--check mtree, bad types"
+
+pkg = pmpkg("dummy")
+pkg.files = ["dummy/z"]
+pkg.makemtree = True
+script = []
+for file, mangle in [
+        ("dummy/d1/", ["rmdir", "touch"]),
+        ("dummy/d2/", ["rmdir", "ln -s z"]),
+        ("dummy/f1", ["rm", "mkdir"]),
+        ("dummy/f2", ["rm", "ln -s z"]),
+        ("dummy/l1 -> z", ["rm", "mkdir"]),
+        ("dummy/l2 -> z", ["rm", "touch"])]:
+    pkg.files.append(file)
+    parsed = pkg.parse_filename(file).rstrip('/')
+    for cmd in mangle:
+        script.append(cmd +" ../"+parsed)
+    self.addrule("PACMAN_OUTPUT=%s .File type mismatch" % parsed)
+pkg.install['post_install'] = ";".join(script)
+self.addpkg2db("local",pkg)
+
+self.args = "-Qkk"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PACMAN_OUTPUT=, 6 altered files")
diff --git a/test/pacman/tests/querycheck008.py b/test/pacman/tests/querycheck008.py
new file mode 100644
index 0000000..538eb75
--- /dev/null
+++ b/test/pacman/tests/querycheck008.py
@@ -0,0 +1,25 @@
+self.description = "Query--check mtree, bad perms+time+size+link"
+
+pkg = pmpkg("dummy")
+pkg.files = ["dummy/z"]
+pkg.makemtree = True
+script = []
+for file, err, mangle in [
+        #("dummy/uid", "UID", ["chown ?"]),#needs root
+        #("dummy/gid", "GID", ["chgrp ?"]),#needs root
+        ("dummy/mode", "Permissions", ["chmod 600"]),
+        ("dummy/mtime", "Modification time", ["touch"]),
+        ("dummy/size", "Size", ["echo x >"]),
+        ("dummy/link -> size", "Symlink path", ["rm", "ln -s z"])]:
+    pkg.files.append(file)
+    parsed = pkg.parse_filename(file)
+    for cmd in mangle:
+        script.append(cmd +" ../"+parsed)
+    self.addrule("PACMAN_OUTPUT=%s .%s mismatch" % (parsed,err))
+pkg.install['post_install'] = ";".join(script)
+self.addpkg2db("local",pkg)
+
+self.args = "-Qkk"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PACMAN_OUTPUT=, 4 altered files")
-- 
1.8.4.2



More information about the pacman-dev mailing list