[Piuparts-devel] [Git][debian/piuparts][develop] 5 commits: autopkgtest: add a must-fail test

Holger Levsen gitlab at salsa.debian.org
Mon Jan 18 18:56:42 GMT 2021



Holger Levsen pushed to branch develop at Debian / piuparts


Commits:
9fb9f46a by Nis Martensen at 2021-01-18T19:49:19+01:00
autopkgtest: add a must-fail test

The existing must-succeed test protects against potential bugs that make
piuparts always fail. Other potential bugs might make piuparts always
succeed, so let's add a must-fail test to cover this case, too.

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
0dc80c16 by Nis Martensen at 2021-01-18T19:50:02+01:00
d/p-[ms].lintian-overrides: update to python3

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
3e42799d by Holger Levsen at 2021-01-18T19:51:23+01:00
Bump standards version to 4.5.1, no changes needed.

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
7d99442a by Nis Martensen at 2021-01-18T19:54:21+01:00
piuparts.py: run: do not crash on non-utf-8 command output

This should fix the crash reported in
https://alioth-lists.debian.net/pipermail/piuparts-devel/2020-September/009165.html

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
d7835aeb by Nis Martensen at 2021-01-18T19:56:15+01:00
piuparts.py: Prevent KeyError in diff_meta_data

Since commit c39004577d42c0c6ec63266df3ec2f86b03b8653 different dicts
were used for iterating and modifying, so we never modify the dicts we
are currently iterating over. However, the commit was incomplete because
it was longer guaranteed that each key is still part of the dict we are
trying to modify, but no checks were added.
The result are possible crashes such as the one reported in 968842:

    Traceback (most recent call last):
      File "/usr/sbin/piuparts", line 3267, in <module>
        main()
      File "/usr/sbin/piuparts", line 3252, in main
        process_packages(package_list)
      File "/usr/sbin/piuparts", line 3173, in process_packages
        if not install_purge_test(chroot, chroot_state,
      File "/usr/sbin/piuparts", line 2414, in install_purge_test
        return check_results(chroot, chroot_state, file_owners, deps_info=deps_info)
      File "/usr/sbin/piuparts", line 2235, in check_results
        (new, removed, modified) = diff_meta_data(reference_info, current_info)
      File "/usr/sbin/piuparts", line 2041, in diff_meta_data
        del tree2_c[name]
    KeyError: '/var/spool/news/in.coming/tmp/'

Such KeyErrors can be prevented by checking if a key exists in the dict
before trying to drop it. Adding explicit checks is simpler than
adding a try..except clause here because there are already if clauses
that we can adapt.

Closes: #968842
Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


5 changed files:

- debian/control
- debian/piuparts-master.lintian-overrides
- debian/piuparts-slave.lintian-overrides
- debian/tests/smoke-test
- piuparts.py


Changes:

=====================================
debian/control
=====================================
@@ -3,7 +3,7 @@ Maintainer: piuparts developers team <piuparts-devel at alioth-lists.debian.net>
 Uploaders: Nicolas Dandrimont <olasd at debian.org>
 Section: devel
 Priority: optional
-Standards-Version: 4.4.1
+Standards-Version: 4.5.1
 Rules-Requires-Root: no
 Build-Depends:
  debhelper-compat (= 12),


=====================================
debian/piuparts-master.lintian-overrides
=====================================
@@ -1,5 +1,5 @@
 # It's ok, because it depends on piuparts-common that has the dependency.
-piuparts-master: python-script-but-no-python-dep usr/share/piuparts/master/detect_well_known_errors #!/usr/bin/python3
-piuparts-master: python-script-but-no-python-dep usr/share/piuparts/piuparts-analyze #!/usr/bin/python3
-piuparts-master: python-script-but-no-python-dep usr/share/piuparts/piuparts-master-backend #!/usr/bin/python3
-piuparts-master: python-script-but-no-python-dep usr/share/piuparts/piuparts-report #!/usr/bin/python3
+piuparts-master: python3-script-but-no-python3-dep usr/share/piuparts/master/detect_well_known_errors #!/usr/bin/python3
+piuparts-master: python3-script-but-no-python3-dep usr/share/piuparts/piuparts-analyze #!/usr/bin/python3
+piuparts-master: python3-script-but-no-python3-dep usr/share/piuparts/piuparts-master-backend #!/usr/bin/python3
+piuparts-master: python3-script-but-no-python3-dep usr/share/piuparts/piuparts-report #!/usr/bin/python3


=====================================
debian/piuparts-slave.lintian-overrides
=====================================
@@ -1,2 +1,2 @@
 # It's ok, because it depends on piuparts-common that has the dependency.
-piuparts-slave: python-script-but-no-python-dep usr/share/piuparts/piuparts-slave #!/usr/bin/python3
+piuparts-slave: python3-script-but-no-python3-dep usr/share/piuparts/piuparts-slave #!/usr/bin/python3


=====================================
debian/tests/smoke-test
=====================================
@@ -16,6 +16,9 @@ WORKDIR=$(mktemp -d)
 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
 cd $WORKDIR
 
+
+# set up a very simple test package
+
 mkdir -p t/DEBIAN t/usr t/etc
 cat >t/DEBIAN/control <<EOF
 Package: t
@@ -30,4 +33,35 @@ EOF
 
 dpkg-deb -b t
 
+# this should always succeed
 test_this piuparts t.deb
+
+
+# another simple package, but set up for failure
+
+mkdir -p f/DEBIAN f/usr f/etc
+cat >f/DEBIAN/control <<EOF
+Package: f
+Version: 4
+Maintainer: Piu Parts <piuparts-devel at alioth-lists.debian.net>
+Priority: optional
+Architecture: all
+Installed-Size: 0
+Description: Auto Package Test Fail Dummy
+ Extremely simple binary package for piuparts testing - fail version
+EOF
+
+cat >f/DEBIAN/postinst <<EOF
+#! /bin/sh
+mkdir -p /etc/f/
+touch /etc/f/ailure
+EOF
+
+chmod +x f/DEBIAN/postinst
+
+dpkg-deb -b f
+
+# it is an error if this succeeds
+test_this piuparts f.deb && false
+
+exit 0


=====================================
piuparts.py
=====================================
@@ -559,7 +559,7 @@ def run(command, ignore_errors=False, timeout=0):
     devnull = open('/dev/null', 'r')
     p = subprocess.Popen(command, env=env, stdin=devnull,
                          stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
-                         universal_newlines=True)
+                         universal_newlines=True, errors="backslashreplace")
     output = ""
     excessive_output = False
     if timeout > 0:
@@ -2013,11 +2013,11 @@ def diff_meta_data(tree1, tree2, quiet=False):
             name = name[1:]
         else:
             verbose = False
-        if name in tree1:
+        if name in tree1_c:
             if verbose:
                 logging.info("IGNORED PATH at 1: %s" % name)
             del tree1_c[name]
-        if name in tree2:
+        if name in tree2_c:
             if verbose:
                 logging.info("IGNORED PATH at 2: %s" % name)
             del tree2_c[name]
@@ -2031,20 +2031,20 @@ def diff_meta_data(tree1, tree2, quiet=False):
         pat = re.compile(pattern)
         for name in tree1.keys():
             m = pat.search(name)
-            if m:
+            if m and name in tree1_c:
                 if verbose:
                     logging.info("IGNORED PATH at 1: %s" % name)
                 del tree1_c[name]
         for name in tree2.keys():
             m = pat.search(name)
-            if m:
+            if m and name in tree2_c:
                 if verbose:
                     logging.info("IGNORED PATH at 2: %s" % name)
                 del tree2_c[name]
 
     modified = []
     for name in tree1.keys():
-        if name in tree2_c:
+        if name in tree1_c and name in tree2_c:
             if objects_are_different(tree1[name], tree2[name]):
                 if not quiet:
                     logging.debug("Modified(user, group, mode, size, target): %s expected%s != found%s" %



View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/d715599319fdccfa510ddcc352bc7b0b4c4fc962...d7835aeb05d1e8cc7b9f60eed3c8149094142a3b

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/d715599319fdccfa510ddcc352bc7b0b4c4fc962...d7835aeb05d1e8cc7b9f60eed3c8149094142a3b
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20210118/5bec9e61/attachment-0001.html>


More information about the Piuparts-devel mailing list