@@ -22,10 +22,6 @@ def setUpClass(cls):
2222 else :
2323 BlockDev .reinit (cls .requested_plugins , True , None )
2424
25- class DevMapperPluginVersionCase (DevMapperTest ):
26- @tag_test (TestTags .NOSTORAGE )
27- def test_plugin_version (self ):
28- self .assertEqual (BlockDev .get_plugin_soname (BlockDev .Plugin .DM ), "libbd_dm.so.3" )
2925
3026class DevMapperTestCase (DevMapperTest ):
3127
@@ -51,6 +47,7 @@ def _clean_up(self):
5147
5248 os .unlink (self .dev_file )
5349
50+
5451class DevMapperGetSubsystemFromName (DevMapperTestCase ):
5552 def _destroy_lvm (self ):
5653 run ("vgremove --yes libbd_dm_tests --config \" devices {use_devicesfile = 0}\" >/dev/null 2>&1" )
@@ -71,21 +68,51 @@ def test_get_subsystem_from_name_lvm(self):
7168 def test_get_subsystem_from_name_crypt (self ):
7269 """Verify that it is possible to get luks device subsystem from its name"""
7370 self .addCleanup (self ._destroy_crypt )
74- run ("echo \" supersecretkey\" | cryptsetup luksFormat %s -" % self .loop_dev )
71+ run ("echo \" supersecretkey\" | cryptsetup luksFormat --pbkdf=pbkdf2 --pbkdf-force-iterations=1000 %s -" % self .loop_dev )
7572 run ("echo \" supersecretkey\" | cryptsetup open %s libbd_dm_tests-subsystem_crypt --key-file=-" % self .loop_dev )
7673 subsystem = BlockDev .dm_get_subsystem_from_name ("libbd_dm_tests-subsystem_crypt" )
7774 self .assertEqual (subsystem , "CRYPT" )
7875
76+
77+ def test_get_subsystem_from_name_linear (self ):
78+ succ = BlockDev .dm_create_linear ("testMap" , self .loop_dev , 100 , None )
79+ self .assertTrue (succ )
80+
81+ # no UUID -- subsystem should be empty
82+ subsystem = BlockDev .dm_get_subsystem_from_name ("testMap" )
83+ self .assertEqual (subsystem , "" )
84+
85+ succ = BlockDev .dm_remove ("testMap" )
86+ self .assertTrue (succ )
87+
88+ # "UUID" without "prefix" -- subsystem should be empty
89+ succ = BlockDev .dm_create_linear ("testMap" , self .loop_dev , 100 , "TEST" )
90+ self .assertTrue (succ )
91+
92+ subsystem = BlockDev .dm_get_subsystem_from_name ("testMap" )
93+ self .assertEqual (subsystem , "" )
94+
95+ succ = BlockDev .dm_remove ("testMap" )
96+ self .assertTrue (succ )
97+
98+ # non-existing device --> error
99+ with self .assertRaisesRegex (GLib .GError , "does not exist" ):
100+ BlockDev .dm_get_subsystem_from_name ("testMap" )
101+
102+
79103class DevMapperCreateRemoveLinear (DevMapperTestCase ):
80104 @tag_test (TestTags .CORE )
81105 def test_create_remove_linear (self ):
82106 """Verify that it is possible to create new linear mapping and remove it"""
83107
84108 succ = BlockDev .dm_create_linear ("testMap" , self .loop_dev , 100 , None )
85109 self .assertTrue (succ )
110+ self .assertTrue (os .path .exists ("/dev/mapper/testMap" ))
86111
87112 succ = BlockDev .dm_remove ("testMap" )
88113 self .assertTrue (succ )
114+ self .assertFalse (os .path .exists ("/dev/mapper/testMap" ))
115+
89116
90117class DevMapperMapExists (DevMapperTestCase ):
91118 def test_map_exists (self ):
@@ -115,6 +142,7 @@ def test_map_exists(self):
115142 succ = BlockDev .dm_map_exists ("testMap" , False , False )
116143 self .assertFalse (succ )
117144
145+
118146class DevMapperNameNodeBijection (DevMapperTestCase ):
119147 def test_name_node_bijection (self ):
120148 """Verify that the map's node and map name points to each other"""
@@ -125,9 +153,11 @@ def test_name_node_bijection(self):
125153 self .assertEqual (BlockDev .dm_name_from_node (BlockDev .dm_node_from_name ("testMap" )),
126154 "testMap" )
127155
128- self .assertTrue (succ )
129156
130- class DMDepsTest (DevMapperTest ):
157+ class DMNoStorageTest (DevMapperTest ):
158+ @tag_test (TestTags .NOSTORAGE )
159+ def test_plugin_version (self ):
160+ self .assertEqual (BlockDev .get_plugin_soname (BlockDev .Plugin .DM ), "libbd_dm.so.3" )
131161
132162 @tag_test (TestTags .NOSTORAGE )
133163 def test_missing_dependencies (self ):
0 commit comments