From 9dd0ee7a49ac1cfb056aea5a64079d924e811085 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 2 Jan 2020 21:09:57 +0100 Subject: [PATCH] tests: metadata: fix failures on systems with selinux enabled 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 Reviewed-by: Rob Browning --- lib/bup/t/tmetadata.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/bup/t/tmetadata.py b/lib/bup/t/tmetadata.py index 107ce0e..3b77af1 100644 --- a/lib/bup/t/tmetadata.py +++ b/lib/bup/t/tmetadata.py @@ -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() -- 2.39.2