Skip to content

Commit bf11ceb

Browse files
committed
Skip tests for plugins disabled during compile time
Fixes: #943
1 parent 3bcac3a commit bf11ceb

25 files changed

+145
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ dist/libblockdev.spec
5656
tools/lvm-cache-stats
5757
tools/vfat-resize
5858
misc/.vagrant
59+
tests/config_h.py

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ DISTCHECK_CONFIGURE_FLAGS += --without-s390
6565
endif
6666

6767

68-
SUBDIRS = include src dist scripts data tools
68+
SUBDIRS = include src dist scripts data tools tests
6969
if WITH_GTK_DOC
7070
SUBDIRS += docs
7171
endif

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ AC_CONFIG_FILES([Makefile src/Makefile \
4141
scripts/Makefile \
4242
tools/Makefile \
4343
data/Makefile \
44-
data/conf.d/Makefile])
44+
data/conf.d/Makefile \
45+
tests/Makefile])
4546

4647
m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
4748
[GOBJECT_INTROSPECTION_CHECK([1.3.0])],

tests/Makefile.am

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Generate config.h.py with translated defines for easy use within Python
2+
3+
CONFIG_H_PY = config_h.py
4+
PLUGINS =
5+
6+
if WITH_BTRFS
7+
PLUGINS += btrfs
8+
endif
9+
10+
if WITH_CRYPTO
11+
PLUGINS += crypto
12+
endif
13+
14+
if WITH_DM
15+
PLUGINS += dm
16+
endif
17+
18+
if WITH_LOOP
19+
PLUGINS += loop
20+
endif
21+
22+
if WITH_LVM
23+
PLUGINS += lvm
24+
endif
25+
26+
if WITH_LVM_DBUS
27+
PLUGINS += lvm-dbus
28+
endif
29+
30+
if WITH_MDRAID
31+
PLUGINS += mdraid
32+
endif
33+
34+
if WITH_MPATH
35+
PLUGINS += mpath
36+
endif
37+
38+
if WITH_SWAP
39+
PLUGINS += swap
40+
endif
41+
42+
if WITH_PART
43+
PLUGINS += part
44+
endif
45+
46+
if WITH_FS
47+
PLUGINS += fs
48+
endif
49+
50+
if WITH_NVDIMM
51+
PLUGINS += nvdimm
52+
endif
53+
54+
if WITH_NVME
55+
PLUGINS += nvme
56+
endif
57+
58+
if WITH_SMART
59+
PLUGINS += smart
60+
endif
61+
62+
if WITH_SMARTMONTOOLS
63+
PLUGINS += smartmontools
64+
endif
65+
66+
if WITH_TOOLS
67+
PLUGINS += tools
68+
endif
69+
70+
$(CONFIG_H_PY):
71+
echo -n 'ENABLED_PLUGINS = [ ' > $(CONFIG_H_PY)
72+
for i in $(PLUGINS); do \
73+
echo -n "'$$i', " >> $(CONFIG_H_PY); \
74+
done
75+
echo ']' >> $(CONFIG_H_PY)
76+
77+
all: $(CONFIG_H_PY)
78+
79+
EXTRA_DIST =
80+
81+
clean-local:
82+
rm -f *~ $(CONFIG_H_PY)

tests/btrfs_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from packaging.version import Version
1010

1111
import overrides_hack
12-
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, mount, umount, run_command, TestTags, tag_test
12+
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, mount, umount, run_command, TestTags, tag_test, required_plugins
1313

1414
import gi
1515
gi.require_version('GLib', '2.0')
@@ -21,6 +21,8 @@
2121
def wipefs(device):
2222
os.system("wipefs -a %s > /dev/null" % device)
2323

24+
25+
@required_plugins(("btrfs",))
2426
class BtrfsTest(unittest.TestCase):
2527
requested_plugins = BlockDev.plugin_specs_from_names(("btrfs",))
2628

tests/crypto_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
import tarfile
1111

12-
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, get_avail_locales, requires_locales, run_command, read_file, TestTags, tag_test
12+
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, get_avail_locales, requires_locales, run_command, read_file, TestTags, tag_test, required_plugins
1313

1414
import gi
1515
gi.require_version('GLib', '2.0')
@@ -35,6 +35,7 @@ def check_cryptsetup_version(version):
3535
HAVE_OPAL = check_cryptsetup_version("2.7.0")
3636

3737

38+
@required_plugins(("crypto", "loop"))
3839
class CryptoTestCase(unittest.TestCase):
3940

4041
requested_plugins = BlockDev.plugin_specs_from_names(("crypto", "loop"))

tests/dm_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import os
33
import overrides_hack
44

5-
from utils import run, create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test
5+
from utils import run, create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, required_plugins
66

77
import gi
88
gi.require_version('GLib', '2.0')
99
gi.require_version('BlockDev', '3.0')
1010
from gi.repository import GLib, BlockDev
1111

1212

13+
@required_plugins(("dm",))
1314
class DevMapperTest(unittest.TestCase):
1415

1516
requested_plugins = BlockDev.plugin_specs_from_names(("dm",))

tests/fs_tests/fs_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def check_output(args, ignore_retcode=True):
3333
else:
3434
raise
3535

36-
36+
@utils.required_plugins(("fs", "loop"))
3737
class FSNoDevTestCase(unittest.TestCase):
3838

3939
requested_plugins = BlockDev.plugin_specs_from_names(("fs", "loop"))

tests/fs_tests/generic_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ def ntfs_size(drive):
980980
self.assertEqual(new_size, size)
981981

982982
@tag_test(TestTags.UNSTABLE)
983+
@utils.required_plugins(("tools",))
983984
def test_vfat_generic_resize(self):
984985
"""Test generic resize function with a vfat file system"""
985986
def mkfs_vfat(device, options=None):

tests/fs_tests/vfat_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def setUp(self):
4242

4343
class VfatTestAvailability(VfatNoDevTestCase):
4444

45+
@utils.required_plugins(("tools",))
4546
def test_vfat_available(self):
4647
"""Verify that it is possible to check vfat tech availability"""
4748
available = BlockDev.fs_is_tech_avail(BlockDev.FSTech.VFAT,
@@ -281,6 +282,7 @@ def test_vfat_set_uuid(self):
281282
BlockDev.fs_vfat_check_uuid(10 * "f")
282283

283284

285+
@utils.required_plugins(("tools",))
284286
class VfatResize(VfatTestCase):
285287
def test_vfat_resize(self):
286288
"""Verify that it is possible to resize an vfat file system"""

0 commit comments

Comments
 (0)