From ad534f790ecb6d527d3d28684542f85ae9759582 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Fri, 24 Jul 2009 12:51:32 +0000 Subject: [PATCH] Add tests for lvm_vg_name_list, lvm_vg_id_list and lvm_scan_vgs. Author: Dave Wysochanski --- test/api/test.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/api/test.c b/test/api/test.c index cd1d2b34d..c9500ffe9 100644 --- a/test/api/test.c +++ b/test/api/test.c @@ -50,6 +50,12 @@ static int lvm_split(char *str, int *argc, char **argv, int max) static void _show_help(void) { + printf("'scan_vgs': " + "Scan the system for LVM metadata\n"); + printf("'vg_list_names': " + "List the names of the VGs that exist in the system\n"); + printf("'vg_list_ids': " + "List the uuids of the VGs that exist in the system\n"); printf("'vg_list_pvs vgname': " "List the PVs that exist in VG vgname\n"); printf("'vg_list_lvs vgname': " @@ -230,6 +236,40 @@ static void _pvs_in_vg(char **argv, int argc) } } +static void _scan_vgs(lvm_t libh) +{ + lvm_scan_vgs(libh); +} + +static void _vg_list_names(lvm_t libh) +{ + struct dm_list *list; + struct lvm_str_list *strl; + const char *tmp; + + list = lvm_list_vg_names(libh); + printf("VG names:\n"); + dm_list_iterate_items(strl, list) { + tmp = strl->str; + printf("%s\n", tmp); + } +} + +static void _vg_list_ids(lvm_t libh) +{ + struct dm_list *list; + struct lvm_str_list *strl; + const char *tmp; + + list = lvm_list_vg_ids(libh); + printf("VG uuids:\n"); + dm_list_iterate_items(strl, list) { + tmp = strl->str; + printf("%s\n", tmp); + } +} + + static void _lvs_in_vg(char **argv, int argc) { struct dm_list *lvs; @@ -301,6 +341,12 @@ 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], "vg_list_names")) { + _vg_list_names(libh); + } else if (!strcmp(argv[0], "vg_list_ids")) { + _vg_list_ids(libh); + } else if (!strcmp(argv[0], "scan_vgs")) { + _scan_vgs(libh); } else { printf ("Unrecognized command %s\n", argv[0]); } -- 2.43.5