aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-08-24 17:00:15 +0200
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-08-24 17:19:07 +0200
commit937467b6a06b72ee44709541f71b614ca28fa870 (patch)
tree05e038c60e212a7ced76aa69c29858b437240e88 /test
parentead57767f78e0fd661d9b54b8320197712f4988b (diff)
Use printcap() to control test execution
That way, we run only tests that are supported by the running kernel.
Diffstat (limited to 'test')
-rw-r--r--test/test_ctests.py13
-rwxr-xr-xtest/test_examples.py26
-rw-r--r--test/util.py30
3 files changed, 54 insertions, 15 deletions
diff --git a/test/test_ctests.py b/test/test_ctests.py
index 469c867..fa21090 100644
--- a/test/test_ctests.py
+++ b/test/test_ctests.py
@@ -11,14 +11,15 @@ import platform
import sys
from distutils.version import LooseVersion
from util import (wait_for_mount, umount, cleanup, base_cmdline,
- safe_sleep, basename, fuse_test_marker)
+ safe_sleep, basename, fuse_test_marker, fuse_caps,
+ fuse_proto)
from os.path import join as pjoin
import os.path
pytestmark = fuse_test_marker()
-@pytest.mark.skipif('bsd' in sys.platform,
- reason='writeback requires Linux')
+@pytest.mark.skipif('FUSE_CAP_WRITEBACK' not in fuse_caps,
+ reason='not supported by running kernel')
@pytest.mark.parametrize("writeback", (False, True))
def test_write_cache(tmpdir, writeback):
if writeback and LooseVersion(platform.release()) < '3.14':
@@ -36,8 +37,10 @@ def test_write_cache(tmpdir, writeback):
names = [ 'notify_inval_inode', 'invalidate_path' ]
-if sys.platform == 'linux':
+if fuse_proto >= (7,15):
names.append('notify_store_retrieve')
+@pytest.mark.skipif(fuse_proto < (7,12),
+ reason='not supported by running kernel')
@pytest.mark.parametrize("name", names)
@pytest.mark.parametrize("notify", (True, False))
def test_notify1(tmpdir, name, notify):
@@ -66,6 +69,8 @@ def test_notify1(tmpdir, name, notify):
else:
umount(mount_process, mnt_dir)
+@pytest.mark.skipif(fuse_proto < (7,12),
+ reason='not supported by running kernel')
@pytest.mark.parametrize("notify", (True, False))
def test_notify_file_size(tmpdir, notify):
mnt_dir = str(tmpdir)
diff --git a/test/test_examples.py b/test/test_examples.py
index 599726b..5c7cddf 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -18,19 +18,14 @@ import sys
from tempfile import NamedTemporaryFile
from contextlib import contextmanager
from util import (wait_for_mount, umount, cleanup, base_cmdline,
- safe_sleep, basename, fuse_test_marker)
+ safe_sleep, basename, fuse_test_marker, test_printcap,
+ fuse_caps, fuse_proto)
from os.path import join as pjoin
-TEST_FILE = __file__
-
pytestmark = fuse_test_marker()
-def test_printcap():
- cmdline = base_cmdline + [ pjoin(basename, 'example', 'printcap') ]
- proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE,
- universal_newlines=True)
- (stdout, _) = proc.communicate(30)
- assert proc.returncode == 0
+TEST_FILE = __file__
+
with open(TEST_FILE, 'rb') as fh:
TEST_DATA = fh.read()
@@ -70,8 +65,10 @@ def test_hello(tmpdir, name, options):
else:
umount(mount_process, mnt_dir)
-@pytest.mark.skipif('bsd' in sys.platform,
- reason='not supported under BSD')
+
+@pytest.mark.skipif(not os.path.exists(
+ pjoin(basename, 'example', 'passthrough_ll')),
+ reason='not built')
@pytest.mark.parametrize("writeback", (False, True))
@pytest.mark.parametrize("debug", (False, True))
def test_passthrough_ll(tmpdir, writeback, debug, capfd):
@@ -233,6 +230,8 @@ def test_null(tmpdir):
umount(mount_process, mnt_file)
+@pytest.mark.skipif(fuse_proto < (7,12),
+ reason='not supported by running kernel')
@pytest.mark.parametrize("notify", (True, False))
def test_notify_inval_entry(tmpdir, notify):
mnt_dir = str(tmpdir)
@@ -615,3 +614,8 @@ def tst_passthrough(src_dir, mnt_dir):
assert name in os.listdir(src_dir)
assert name in os.listdir(mnt_dir)
assert os.stat(src_name) == os.stat(mnt_name)
+
+# avoid warning about unused import
+test_printcap
+
+
diff --git a/test/util.py b/test/util.py
index 1cd09a1..c15476b 100644
--- a/test/util.py
+++ b/test/util.py
@@ -6,9 +6,31 @@ import stat
import time
from os.path import join as pjoin
import sys
+import re
basename = pjoin(os.path.dirname(__file__), '..')
+def test_printcap():
+ cmdline = base_cmdline + [ pjoin(basename, 'example', 'printcap') ]
+ proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE,
+ universal_newlines=True)
+ (stdout, _) = proc.communicate(30)
+ assert proc.returncode == 0
+
+ proto = None
+ caps = set()
+ for line in stdout.split('\n'):
+ if line.startswith('\t'):
+ caps.add(line.strip())
+ continue
+
+ hit = re.match(r'Protocol version: (\d+)\.(\d+)$', line)
+ if hit:
+ proto = (int(hit.group(1)), int(hit.group(2)))
+
+ return (proto, caps)
+
+
def wait_for_mount(mount_process, mnt_dir,
test_fn=os.path.ismount):
elapsed = 0
@@ -125,3 +147,11 @@ else:
# Try to use local fusermount3
os.environ['PATH'] = '%s:%s' % (pjoin(basename, 'util'), os.environ['PATH'])
+
+try:
+ (fuse_proto, fuse_caps) = test_printcap()
+except:
+ # Rely on test to raise error
+ fuse_proto = (0,0)
+ fuse_caps = set()
+