[PATCH 4/4] Update tests for lvseg apis.
Dave Wysochanski <[email protected]>
| Newsgroups | dev.linux.lists.lvm-devel |
|---|---|
| Message-ID | <[email protected]> |
Signed-off-by: Dave Wysochanski <[email protected]> --- test/api/test.c | 76 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 39 insertions(+), 37 deletions(-) diff --git a/test/api/test.c b/test/api/test.c index fea3d0d..20f4210 100644 --- a/test/api/test.c +++ b/test/api/test.c @@ -69,6 +69,8 @@ static void _show_help(void) "List the PVs that exist in VG vgname\n"); printf("'vg_list_lvs vgname': " "List the LVs that exist in VG vgname\n"); + printf("'lv_list_lvsegs vgname lvname': " + "List the LV segments that exist in LV vgname/lvname\n"); printf("'vgs_open': " "List the VGs that are currently open\n"); printf("'vgs': " @@ -569,12 +571,15 @@ static void _vg_tag(char **argv, int argc, int add) add ? "adding":"removing", argv[2], argv[1]); } -static void _print_property_value(struct lvm_property_value value) +static void _print_property_value(const char *name, + struct lvm_property_value v) { - if (value.is_string) - printf(", value = %s\n", value.value.string); + if (!v.is_valid) + printf("%s = INVALID\n", name); + else if (v.is_string) + printf("%s = %s\n", name, v.value.string); else - printf(", value = %"PRIu64"\n", value.value.integer); + printf("%s = %"PRIu64"\n", name, v.value.integer); } static void _pv_get_property(char **argv, int argc) @@ -589,17 +594,7 @@ static void _pv_get_property(char **argv, int argc) if (!(pv = _lookup_pv_by_name(argv, argc))) return; v = lvm_pv_get_property(pv, argv[2]); - if (!v.is_valid) - printf("Error "); - else - printf("Success "); - printf("obtaining value of property %s in PV %s", - argv[2], argv[1]); - if (!v.is_valid) { - printf("\n"); - return; - } - _print_property_value(v); + _print_property_value(argv[2], v); } static void _vg_get_property(char **argv, int argc) @@ -614,17 +609,7 @@ static void _vg_get_property(char **argv, int argc) if (!(vg = _lookup_vg_by_name(argv, argc))) return; v = lvm_vg_get_property(vg, argv[2]); - if (!v.is_valid) - printf("Error "); - else - printf("Success "); - printf("obtaining value of property %s in VG %s", - argv[2], argv[1]); - if (!v.is_valid) { - printf("\n"); - return; - } - _print_property_value(v); + _print_property_value(argv[2], v); } static void _lv_get_property(char **argv, int argc) @@ -639,17 +624,7 @@ static void _lv_get_property(char **argv, int argc) if (!(lv = _lookup_lv_by_name(argv[2]))) return; v = lvm_lv_get_property(lv, argv[3]); - if (!v.is_valid) - printf("Error "); - else - printf("Success "); - printf("obtaining value of property %s in LV %s", - argv[3], argv[2]); - if (!v.is_valid) { - printf("\n"); - return; - } - _print_property_value(v); + _print_property_value(argv[3], v); } static void _lv_get_tags(char **argv, int argc) @@ -742,6 +717,31 @@ static void _lvs_in_vg(char **argv, int argc) } } +static void _lvsegs_in_lv(char **argv, int argc) +{ + struct dm_list *lvsegs; + struct lvm_lvseg_list *lvl; + lv_t lv; + + if (!(lv = _lookup_lv_by_name(argv[2]))) + return; + lvsegs = lvm_lv_list_lvsegs(lv); + if (!lvsegs || dm_list_empty(lvsegs)) { + printf("No LV segments in lv %s\n", lvm_lv_get_name(lv)); + return; + } + printf("LV segments in lv %s:\n", lvm_lv_get_name(lv)); + dm_list_iterate_items(lvl, lvsegs) { + struct lvm_property_value v; + v = lvm_lvseg_get_property(lvl->lvseg, "segtype"); + _print_property_value("segtype", v); + v = lvm_lvseg_get_property(lvl->lvseg, "seg_start_pe"); + _print_property_value("seg_start_pe", v); + v = lvm_lvseg_get_property(lvl->lvseg, "seg_size"); + _print_property_value("seg_size", v); + } +} + static void _lv_deactivate(char **argv, int argc) { lv_t lv; @@ -888,6 +888,8 @@ static int lvmapi_test_shell(lvm_t libh) _pvs_in_vg(argv, argc); } else if (!strcmp(argv[0], "vg_list_lvs")) { _lvs_in_vg(argv, argc); + } else if (!strcmp(argv[0], "lv_list_lvsegs")) { + _lvsegs_in_lv(argv, argc); } else if (!strcmp(argv[0], "list_vg_names")) { _list_vg_names(libh); } else if (!strcmp(argv[0], "list_vg_ids")) { -- 1.7.2.2