Skip to content

Commit 4a213b7

Browse files
Merge pull request #1119 from vojtechtrefny/master_libblockdev-test-speedup
Tests speedup
2 parents 3863cdc + 77ec3a1 commit 4a213b7

30 files changed

+1212
-1258
lines changed

src/plugins/crypto.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ gboolean _crypto_luks_format (const gchar *device,
950950
gchar *msg = NULL;
951951
const gchar* crypt_version = NULL;
952952
GError *l_error = NULL;
953+
struct crypt_pbkdf_type *pbkdf = NULL;
953954

954955
#ifdef LIBCRYPTSETUP_27
955956
struct crypt_params_hw_opal opal_params = {
@@ -1068,7 +1069,7 @@ gboolean _crypto_luks_format (const gchar *device,
10681069
if (extra) {
10691070
if (luks_version == BD_CRYPTO_LUKS_VERSION_LUKS1) {
10701071

1071-
if (extra->integrity || extra->sector_size || extra->label || extra->subsystem || extra->pbkdf) {
1072+
if (extra->integrity || extra->sector_size || extra->label || extra->subsystem) {
10721073
g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_INVALID_PARAMS,
10731074
"Invalid extra arguments specified. Only `data_alignment`"
10741075
"and `data_device` are valid for LUKS 1.");
@@ -1079,11 +1080,35 @@ gboolean _crypto_luks_format (const gchar *device,
10791080
return FALSE;
10801081
}
10811082

1083+
if (extra->pbkdf) {
1084+
if (g_strcmp0 (extra->pbkdf->type, "pbkdf2") != 0) {
1085+
g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_INVALID_PARAMS,
1086+
"Invalid pbkdf specified. Only `pbkdf2` is valid for LUKS 1.");
1087+
crypt_free (cd);
1088+
g_strfreev (cipher_specs);
1089+
bd_utils_report_finished (progress_id, l_error->message);
1090+
g_propagate_error (error, l_error);
1091+
return FALSE;
1092+
}
1093+
1094+
pbkdf = get_pbkdf_params (extra->pbkdf, &l_error);
1095+
if (pbkdf == NULL && l_error != NULL) {
1096+
crypt_free (cd);
1097+
g_strfreev (cipher_specs);
1098+
bd_utils_report_finished (progress_id, l_error->message);
1099+
g_propagate_prefixed_error (error, l_error,
1100+
"Failed to get PBKDF parameters for '%s'.", device);
1101+
return FALSE;
1102+
}
1103+
crypt_set_pbkdf_type (cd, pbkdf);
1104+
}
1105+
10821106
struct crypt_params_luks1 params = ZERO_INIT;
10831107
params.data_alignment = extra->data_alignment;
10841108
params.data_device = extra->data_device;
10851109
ret = crypt_format (cd, crypt_version, cipher_specs[0], cipher_specs[1],
10861110
NULL, NULL, key_size, &params);
1111+
g_free (pbkdf);
10871112
}
10881113
else if (luks_version == BD_CRYPTO_LUKS_VERSION_LUKS2) {
10891114
struct crypt_params_luks2 params = ZERO_INIT;

tests/_lvm_cases.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323

2424
def _get_lvm_version():
25-
_ret, out, _err = run_command("lvm version")
26-
m = re.search(r"LVM version:\s+([\d\.]+)", out)
27-
if not m or len(m.groups()) != 1:
28-
raise RuntimeError("Failed to determine LVM version from: %s" % out)
29-
return Version(m.groups()[0])
25+
_ret, out, _err = run_command("lvm version")
26+
m = re.search(r"LVM version:\s+([\d\.]+)", out)
27+
if not m or len(m.groups()) != 1:
28+
raise RuntimeError("Failed to determine LVM version from: %s" % out)
29+
return Version(m.groups()[0])
3030

3131
LVM_VERSION = _get_lvm_version()
3232

@@ -1243,7 +1243,7 @@ def test_cache_get_pool_name(self):
12431243
self.assertEqual(BlockDev.lvm_cache_pool_name("testVG", "testLV"), cpool_name)
12441244

12451245
@tag_test(TestTags.SLOW)
1246-
def test_create_cached_lv(self):
1246+
def test_create_writecached_lv(self):
12471247
"""Verify that it is possible to create a cached LV in a single step"""
12481248

12491249
if LVM_VERSION < Version("2.03.10") and self.test_type == "dbus":
@@ -1299,7 +1299,7 @@ def test_cache_get_stats(self):
12991299
self.assertEqual(stats.mode, BlockDev.LVMCacheMode.WRITETHROUGH)
13001300

13011301
@tag_test(TestTags.SLOW)
1302-
def test_cache_get_stats(self):
1302+
def test_thinpool_cache_get_stats(self):
13031303
"""Verify that it is possible to get stats for a cached thinpool"""
13041304

13051305
succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None)

tests/btrfs_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def setUpClass(cls):
4343
class BtrfsPluginVersionCase(BtrfsTest):
4444
@tag_test(TestTags.NOSTORAGE)
4545
def test_plugin_version(self):
46-
self.assertEqual(BlockDev.get_plugin_soname(BlockDev.Plugin.BTRFS), "libbd_btrfs.so.3")
46+
self.assertEqual(BlockDev.get_plugin_soname(BlockDev.Plugin.BTRFS), "libbd_btrfs.so.3")
4747

4848
class BtrfsTestCase(BtrfsTest):
4949

0 commit comments

Comments
 (0)