From 999fefdab205c4049ab968609275226f25faa4b7 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 16 Mar 2013 11:00:24 -0500 Subject: [PATCH 1/1] Don't even test for Linux xattrs if platform.system() doesn't include Linux. Signed-off-by: Rob Browning --- lib/bup/metadata.py | 24 +++++++++++++----------- lib/bup/t/tmetadata.py | 10 ++++------ wvtest.py | 4 ++++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py index 58f2989..f25e470 100644 --- a/lib/bup/metadata.py +++ b/lib/bup/metadata.py @@ -4,7 +4,7 @@ # # This code is covered under the terms of the GNU Library General # Public License as described in the bup LICENSE file. -import errno, os, sys, stat, time, pwd, grp +import errno, os, sys, stat, time, platform, pwd, grp from cStringIO import StringIO from bup import vint, xstat from bup.drecurse import recursive_dirlist @@ -12,18 +12,20 @@ from bup.helpers import add_error, mkdirp, log, is_superuser from bup.helpers import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name from bup.xstat import utime, lutime -try: - import xattr -except ImportError: - log('Warning: Linux xattr support missing; install python-pyxattr.\n') - xattr = None -if xattr: +if 'Linux' in platform.system(): try: - xattr.get_all - except AttributeError: - log('Warning: python-xattr module is too old; ' - 'install python-pyxattr instead.\n') + import xattr + except ImportError: + log('Warning: Linux xattr support missing; install python-pyxattr.\n') xattr = None + if xattr: + try: + xattr.get_all + except AttributeError: + log('Warning: python-xattr module is too old; ' + 'install python-pyxattr instead.\n') + xattr = None + try: import posix1e except ImportError: diff --git a/lib/bup/t/tmetadata.py b/lib/bup/t/tmetadata.py index 65c012a..c24ec09 100644 --- a/lib/bup/t/tmetadata.py +++ b/lib/bup/t/tmetadata.py @@ -1,4 +1,4 @@ -import glob, grp, pwd, stat, tempfile, subprocess +import glob, grp, platform, pwd, stat, tempfile, subprocess import bup.helpers as helpers from bup import git, metadata, vfs from bup.helpers import clear_errors, detect_fakeroot, is_superuser @@ -28,6 +28,7 @@ def ex(*cmd): def setup_testfs(): + assert('Linux' in platform.system()) # Set up testfs with user_xattr, etc. subprocess.call(['umount', 'testfs']) ex('dd', 'if=/dev/zero', 'of=testfs.img', 'bs=1M', 'count=32') @@ -238,14 +239,11 @@ if not posix1e: from bup.metadata import xattr -if not xattr: - @wvtest - def LINUX_XATTR_SUPPORT_IS_MISSING(): - pass -else: +if xattr: @wvtest def test_handling_of_incorrect_existing_linux_xattrs(): if not is_superuser(): + WVMSG('skipping test -- not superuser') return setup_testfs() for f in glob.glob('testfs/*'): diff --git a/wvtest.py b/wvtest.py index 833cfc4..4c4b4b9 100755 --- a/wvtest.py +++ b/wvtest.py @@ -73,6 +73,10 @@ if __name__ != '__main__': # we're imported as a module return text + def WVMSG(message): + ''' Issues a notification. ''' + return _result(message, traceback.extract_stack()[-3], 'ok') + def WVPASS(cond = True): ''' Counts a test failure unless cond is true. ''' return _check(cond, _code()) -- 2.39.2