master - python-lvm: Bug fixes from unit tests.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=40feaa7bbeaca9a89f9b8e87b684c457cd10aa57 Commit: 40feaa7bbeaca9a89f9b8e87b684c457cd10aa57 Parent: 8882480083f9b4f769cc8756a2f641ae0452040d Author: Tony Asleson <[email protected]> AuthorDate: Tue Jun 18 15:13:27 2013 -0400 Committer: Tony Asleson <[email protected]> CommitterDate: Tue Jul 2 14:24:34 2013 -0500
python-lvm: Bug fixes from unit tests.
After the last rebase, existing unit test case was run which uncovered a number of errors that required attention.
Uninitialized variables and changes to type of numeric return type were addressed.
Signed-off-by Tony Asleson <[email protected]>
--- liblvm/lvm_lv.c | 7 ++++- liblvm/lvm_vg.c | 11 ++++++++ python/liblvm.c | 56 ++++++++++++++++++++++++++++++------------- test/api/python_lvm_unit.py | 13 ++++----- 4 files changed, 62 insertions(+), 25 deletions(-)
liblvm/lvm_lv.c +6 -1
@@ -611,7 +611,12 @@ lv_t lvm_lv_create(lv_create_params_t params) }if (!lv_create_single (params->vg, ¶ms->lvp)) return_NULL; -if (!(lvl =find_lv_in_vg (params->vg, params->lvp.lv_name))) + +/* In some case we are making a thin pool so lv_name is not valid, but +* pool is. +*/ +if (!(lvl =find_lv_in_vg (params->vg, + (params->lvp.lv_name) ? params->lvp.lv_name : params->lvp.pool))) return_NULL;return (lv_t ) lvl->lv; }
liblvm/lvm_vg.c +11 -0
@@ -345,6 +345,17 @@ struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)int lvm_vg_set_property (const vg_t vg,const char *name,struct lvm_property_value *value) { +/* At this point it is unknown if all property set paths make the +* appropriate copy of the string. We will allocate a copy on the vg so +* that worst case we have two copies which will get freed when the vg gets +* released. +*/ + +if (value->is_valid && value->is_string && value->value.string) { + value->value.string =dm_pool_strndup (vg->vgmem, value->value.string, +strlen (value->value.string) +1 ); + } +return set_property (NULL , vg,NULL ,NULL , name, value); }
python/liblvm.c +39 -17
129 lines not on this page · raw message
test/api/python_lvm_unit.py +6 -7
@@ -76,14 +76,13 @@ class TestLvm(unittest.TestCase): self.assertEqual(type(pv.getUuid()), str) self.assertTrue(len(pv.getUuid()) > 0) - self.assertEqual(type(pv.getMdaCount()), int) - self.assertEqual(type(pv.getMdaCount()), int) + self.assertTrue(type(pv.getMdaCount()) == int or type(pv.getMdaCount()) == long ) - self.assertEqual(type(pv.getSize()), int) + self.assertTrue(type(pv.getSize()) == int or type(pv.getSize()) == long) - self.assertEqual(type(pv.getDevSize()), int) + self.assertTrue(type(pv.getDevSize()) == int or type(pv.getSize()) == long) - self.assertEqual(type(pv.getFree()), int) + self.assertTrue(type(pv.getFree()) == int or type(pv.getFree()) == long) def _test_prop(self, prop_obj, prop, var_type, settable): result = prop_obj.getProperty(prop)
@@ -327,7 +326,7 @@ class TestLvm(unittest.TestCase): for method_name in TestLvm.RETURN_NUMERIC: method = getattr(vg, method_name) result = method() - self.assertTrue(type(result) == int) + self.assertTrue(type(result) == int or type(result)== long) vg.close()
@@ -372,4 +371,4 @@ class TestLvm(unittest.TestCase): vg.close() if __name__ == "__main__": - unittest.main() + unittest.main()