]> arthur.barton.de Git - bup.git/commitdiff
tests: metadata: fix failures on systems with selinux enabled
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 2 Jan 2020 20:09:57 +0000 (21:09 +0100)
committerRob Browning <rlb@defaultvalue.org>
Thu, 13 Feb 2020 00:52:47 +0000 (18:52 -0600)
We get a number of failures if selinux is enabled:

! tmetadata.py:298  ['user.foo', 'security.selinux'] == ['user.foo']     FAILED
! tmetadata.py:302  ['user.foo', 'security.selinux'] == ['user.foo']     FAILED
! tmetadata.py:306  ['user.foo', 'security.selinux'] == ['user.foo']     FAILED

Filter out security.selinux to address that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/t/tmetadata.py

index 107ce0e9aef719f97b8bb2e04ada2214486e25b9..3b77af1a9b111b34595b2f983dccd13d2fe117c3 100644 (file)
@@ -279,6 +279,10 @@ if not posix1e:
 
 from bup.metadata import xattr
 if xattr:
+    def remove_selinux(attrs):
+        return list(filter(lambda i: not i in (b'security.selinux', ),
+                           attrs))
+
     @wvtest
     def test_handling_of_incorrect_existing_linux_xattrs():
         if not is_superuser() or detect_fakeroot():
@@ -295,15 +299,15 @@ if xattr:
         m = metadata.from_path(path, archive_path=path, save_symlinks=True)
         xattr.set(path, b'baz', b'bax', namespace=xattr.NS_USER)
         m.apply_to_path(path, restore_numeric_ids=False)
-        WVPASSEQ(xattr.list(path), [b'user.foo'])
+        WVPASSEQ(remove_selinux(xattr.list(path)), [b'user.foo'])
         WVPASSEQ(xattr.get(path, b'user.foo'), b'bar')
         xattr.set(path, b'foo', b'baz', namespace=xattr.NS_USER)
         m.apply_to_path(path, restore_numeric_ids=False)
-        WVPASSEQ(xattr.list(path), [b'user.foo'])
+        WVPASSEQ(remove_selinux(xattr.list(path)), [b'user.foo'])
         WVPASSEQ(xattr.get(path, b'user.foo'), b'bar')
         xattr.remove(path, b'foo', namespace=xattr.NS_USER)
         m.apply_to_path(path, restore_numeric_ids=False)
-        WVPASSEQ(xattr.list(path), [b'user.foo'])
+        WVPASSEQ(remove_selinux(xattr.list(path)), [b'user.foo'])
         WVPASSEQ(xattr.get(path, b'user.foo'), b'bar')
         os.chdir(start_dir)
         cleanup_testfs()