summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2018-06-08 09:38:05 +0100
committerJoe Thornber <ejt@redhat.com>2018-06-08 09:38:05 +0100
commit0d22b58172808f050abeacdb5d6a7b7132b91a8c (patch)
tree2f27714c5df2865958d2c4dafd124b53152f07ab /test/api
parente6bb780d24246666fa05948ec449a8137280b443 (diff)
downloadlvm2-0d22b58172808f050abeacdb5d6a7b7132b91a8c.tar.gz
liblvm: remove lvmapi
This has been deprecated for a while.
Diffstat (limited to 'test/api')
-rw-r--r--test/api/Makefile.in33
-rw-r--r--test/api/lvtest.c64
-rw-r--r--test/api/pe_start.c47
-rw-r--r--test/api/percent.c63
-rw-r--r--test/api/test.c1110
-rw-r--r--test/api/thin_percent.c78
-rw-r--r--test/api/vglist.c73
-rw-r--r--test/api/vgtest.c164
8 files changed, 0 insertions, 1632 deletions
diff --git a/test/api/Makefile.in b/test/api/Makefile.in
index 687209577..c8d9fc065 100644
--- a/test/api/Makefile.in
+++ b/test/api/Makefile.in
@@ -16,47 +16,14 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
TARGETS =
-ifeq ("@APPLIB@", "yes")
-TARGETS += test
-SOURCES = test.c
-
-TARGETS += \
- lvtest.t \
- vglist.t \
- percent.t \
- pe_start.t \
- thin_percent.t \
- vgtest.t
-
-SOURCES2 = \
- lvtest.c \
- vglist.c \
- percent.c \
- pe_start.c \
- thin_percent.c \
- vgtest.c
-
-endif
-
PYTEST = python_lvm_unit.py
include $(top_builddir)/make.tmpl
DEFS += -D_REENTRANT
-DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so
-LDFLAGS+=\
- -L$(top_builddir)/liblvm \
- -L$(top_builddir)/daemons/dmeventd
-LIBS += @LVM2APP_LIB@ $(DMEVENT_LIBS)
-
-%.t: %.o $(DEPLIBS)
- $(CC) -o $@ $(<) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS)
all:
test -x $(PYTEST) || chmod 755 $(PYTEST)
-test: $(OBJECTS) $(DEPLIBS)
- $(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS) $(READLINE_LIBS)
-
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status test/api/Makefile
diff --git a/test/api/lvtest.c b/test/api/lvtest.c
deleted file mode 100644
index 9a5fc2250..000000000
--- a/test/api/lvtest.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#undef NDEBUG
-
-#include "liblvm/lvm2app.h"
-#include "assert.h"
-
-#define err(args...) \
- do { fprintf(stderr, args); goto bad; } while (0)
-
-int main(int argc, char *argv[])
-{
- lvm_t handle;
- vg_t vg;
- lv_t lv;
- int r = -1;
-
- if (!(handle = lvm_init(NULL)))
- return -1;
-
- if (!(vg = lvm_vg_open(handle, argv[1], "w", 0)))
- err("VG open %s failed.\n", argv[1]);
-
- if (!(lv = lvm_lv_from_name(vg, "test")))
- err("LV test not found.\n");
-
- if (lvm_lv_deactivate(lv))
- err("LV test deactivation failed.\n");
-
- if (lvm_lv_activate(lv))
- err("LV test activation failed.\n");
-
- if (lvm_lv_activate(lv))
- err("LV test repeated activation failed.\n");
-
- if (lvm_lv_rename(lv, "test1"))
- err("LV test rename to test1 failed.\n");
-
- if (lvm_lv_rename(lv, "test2"))
- err("LV test1 rename to test2 failed.\n");
-
- if (lvm_lv_rename(lv, "test"))
- err("LV test2 rename to test failed.\n");
-
- if (lvm_vg_close(vg))
- err("VG close failed.\n");
-
- r = 0;
-bad:
- lvm_quit(handle);
- return r;
-}
diff --git a/test/api/pe_start.c b/test/api/pe_start.c
deleted file mode 100644
index 16b4c0d63..000000000
--- a/test/api/pe_start.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#undef NDEBUG
-
-#include "liblvm/lvm2app.h"
-#include "assert.h"
-
-int main(int argc, char *argv[])
-{
- lvm_t handle;
- vg_t vg = NULL;
- pv_t pv;
- struct lvm_property_value v;
-
- handle = lvm_init(NULL);
- assert(handle);
-
- vg = lvm_vg_create(handle, argv[1]);
- assert(vg);
-
- if (lvm_vg_extend(vg, argv[2]))
- abort();
-
- pv = lvm_pv_from_name(vg, argv[2]);
- assert(pv);
-
- v = lvm_pv_get_property(pv, "pe_start");
- assert(v.is_valid);
- fprintf(stderr, "pe_start = %d\n", (int)v.value.integer);
- assert(v.value.integer == 2048 * 512);
-
- lvm_vg_close(vg);
- lvm_quit(handle);
- return 0;
-}
diff --git a/test/api/percent.c b/test/api/percent.c
deleted file mode 100644
index afc361c96..000000000
--- a/test/api/percent.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#undef NDEBUG
-
-#include "liblvm/lvm2app.h"
-#include "assert.h"
-
-int main(int argc, char *argv[])
-{
- lvm_t handle;
- vg_t vg = NULL;
- lv_t lv;
- struct lvm_property_value v;
- struct lvm_property_value d;
-
- handle = lvm_init(NULL);
- assert(handle);
-
- vg = lvm_vg_open(handle, argv[1], "r", 0);
- assert(vg);
-
- lv = lvm_lv_from_name(vg, "snap");
- assert(lv);
-
- v = lvm_lv_get_property(lv, "snap_percent");
- assert(v.is_valid);
- assert(v.value.integer == PERCENT_0);
-
- lv = lvm_lv_from_name(vg, "mirr");
- assert(lv);
-
- v = lvm_lv_get_property(lv, "copy_percent");
- assert(v.is_valid);
- assert(v.value.integer == PERCENT_100);
-
- lv = lvm_lv_from_name(vg, "snap2");
- assert(lv);
-
- v = lvm_lv_get_property(lv, "snap_percent");
- assert(v.is_valid);
- assert(v.value.integer == 50 * PERCENT_1);
-
- d = lvm_lv_get_property(lv, "data_percent");
- assert(d.is_valid);
- assert(d.value.integer == v.value.integer);
-
- lvm_vg_close(vg);
-
- lvm_quit(handle);
- return 0;
-}
diff --git a/test/api/test.c b/test/api/test.c
deleted file mode 100644
index a4d200bab..000000000
--- a/test/api/test.c
+++ /dev/null
@@ -1,1110 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "configure.h"
-#include "liblvm/lvm2app.h"
-
-#ifdef READLINE_SUPPORT
-#include <readline/readline.h>
-
-#define MAX_ARGS 64
-
-static int lvm_split(char *str, int *argc, char **argv, int max)
-{
- char *b = str, *e;
- *argc = 0;
-
- while (*b) {
- while (*b && isspace(*b))
- b++;
-
- if ((!*b) || ((*argc == 0)&&(*b == '#')))
- break;
-
- e = b;
- while (*e && !isspace(*e))
- e++;
-
- argv[(*argc)++] = b;
- if (!*e)
- break;
- *e++ = '\0';
- b = e;
- if (*argc == max)
- break;
- }
-
- if (*argc < max)
- argv[*argc] = NULL;
-
- return *argc;
-}
-
-static void _show_help(void)
-{
- printf("'lv_activate vgname lvname: "
- "Activate an LV\n");
- printf("'lv_deactivate vgname lvname: "
- "Deactivate an LV\n");
- printf("'vg_remove_lv vgname lvname': "
- "Remove a LV\n");
- printf("'vg_create_lv_linear vgname lvname size_in_bytes': "
- "Create a linear LV\n");
- printf("'scan_vgs': "
- "Scan the system for LVM metadata\n");
- printf("'list_vg_names': "
- "List the names of the VGs that exist in the system\n");
- printf("'list_vg_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("'pv_list_pvsegs pvname': "
- "List the PV segments that exist in PV pvname\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': "
- "List all VGs known to the system\n");
- printf("'vg_extend vgname device: "
- "Issue a lvm_vg_extend() API call on VG 'vgname'\n");
- printf("'vg_reduce vgname device: "
- "Issue a lvm_vg_reduce() API call on VG 'vgname'\n");
- printf("'vg_open vgname ['r' | 'w']': "
- "Issue a lvm_vg_open() API call on VG 'vgname'\n");
- printf("'vg_close vgname': "
- "Issue a lvm_vg_close() API call on VG 'vgname'\n");
- printf("'vg_create vgname: "
- "Issue a lvm_vg_create() to create VG 'vgname'\n");
- printf("'vg_remove vgname: "
- "Issue a lvm_vg_remove() to remove VG 'vgname'\n");
- printf("'config_reload': "
- "Issue a lvm_config_reload() API to reload LVM config\n");
- printf("'config_override' device: "
- "Issue a lvm_config_override() with accept device filter\n");
- printf("'vg_get_tags vgname': "
- "List the tags of a VG\n");
- printf("'lv_get_property vgname lvname property_name': "
- "Display the value of LV property\n");
- printf("'vg_get_property vgname property_name': "
- "Display the value of VG property\n");
- printf("'pv_get_property pvname property_name': "
- "Display the value of PV property\n");
- printf("'vg_set_property vgname property_name': "
- "Set the value of VG property\n");
- printf("'lv_get_tags vgname lvname': "
- "List the tags of a LV\n");
- printf("'vg_{add|remove}_tag vgname tag': "
- "Add/remove a tag from a VG\n");
- printf("'lv_{add|remove}_tag vgname lvname tag': "
- "Add/remove a tag from a LV\n");
- printf("'vgname_from_devname device': "
- "Lookup a vgname from a device name\n");
- printf("'vgname_from_pvid pvid': "
- "Lookup a vgname from a pvid\n");
- printf("'lv_from_uuid vgname lvuuid': "
- "Lookup an LV from an LV uuid\n");
- printf("'lv_from_name vgname lvname': "
- "Lookup an LV from an LV name\n");
- printf("'pv_from_uuid vgname pvuuid': "
- "Lookup an LV from an LV uuid\n");
- printf("'pv_from_name vgname pvname': "
- "Lookup an LV from an LV name\n");
- printf("'quit': exit the program\n");
-}
-
-static struct dm_hash_table *_vgid_hash = NULL;
-static struct dm_hash_table *_vgname_hash = NULL;
-static struct dm_hash_table *_pvname_hash = NULL;
-static struct dm_hash_table *_lvname_hash = NULL;
-
-static void _hash_destroy_single(struct dm_hash_table **htable)
-{
- if (htable && *htable) {
- dm_hash_destroy(*htable);
- *htable = NULL;
- }
-}
-
-static void _hash_destroy(void)
-{
- _hash_destroy_single(&_vgname_hash);
- _hash_destroy_single(&_vgid_hash);
- _hash_destroy_single(&_pvname_hash);
- _hash_destroy_single(&_lvname_hash);
-}
-
-static int _hash_create(void)
-{
- if (!(_vgname_hash = dm_hash_create(128)))
- return 0;
- if (!(_pvname_hash = dm_hash_create(128))) {
- _hash_destroy_single(&_vgname_hash);
- return 0;
- }
- if (!(_lvname_hash = dm_hash_create(128))) {
- _hash_destroy_single(&_vgname_hash);
- _hash_destroy_single(&_pvname_hash);
- return 0;
- }
- if (!(_vgid_hash = dm_hash_create(128))) {
- _hash_destroy_single(&_vgname_hash);
- _hash_destroy_single(&_pvname_hash);
- _hash_destroy_single(&_lvname_hash);
- return 0;
- }
- return 1;
-}
-
-/* FIXME: this should be per vg */
-static lv_t _lookup_lv_by_name(const char *name)
-{
- lv_t lv;
-
- if (!name) {
- printf ("Invalid LV name\n");
- return NULL;
- }
- if (!(lv = dm_hash_lookup(_lvname_hash, name))) {
- printf ("Can't find %s in LVs - run vg_create_lv first\n",
- name);
- return NULL;
- }
- return lv;
-}
-
-static vg_t _lookup_vg_by_name(char **argv, int argc)
-{
- vg_t vg;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return NULL;
- }
- if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
- !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
- printf ("Can't find %s in open VGs - run vg_open first\n",
- argv[1]);
- return NULL;
- }
- return vg;
-}
-
-static pv_t _lookup_pv_by_name(const char *name)
-{
- pv_t pv;
-
- if (!(pv = dm_hash_lookup(_pvname_hash, name))) {
- printf ("Can't find %s in open PVs - run vg_open first\n",
- name);
- return NULL;
- }
- return pv;
-}
-
-static void _add_lvs_to_lvname_hash(struct dm_list *lvs)
-{
- struct lvm_lv_list *lvl;
- dm_list_iterate_items(lvl, lvs) {
- /* Concatenate VG name with LV name */
- dm_hash_insert(_lvname_hash, lvm_lv_get_name(lvl->lv), lvl->lv);
- }
-}
-
-static void _add_pvs_to_pvname_hash(struct dm_list *pvs)
-{
- struct lvm_pv_list *pvl;
- dm_list_iterate_items(pvl, pvs) {
- dm_hash_insert(_pvname_hash, lvm_pv_get_name(pvl->pv), pvl->pv);
- }
-}
-
-static void _remove_device_from_pvname_hash(struct dm_list *pvs, const char *name)
-{
- struct lvm_pv_list *pvl;
- dm_list_iterate_items(pvl, pvs) {
- if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
- dm_hash_remove(_pvname_hash, name);
- }
-}
-static void _add_device_to_pvname_hash(struct dm_list *pvs, const char *name)
-{
- struct lvm_pv_list *pvl;
- dm_list_iterate_items(pvl, pvs) {
- if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
- dm_hash_insert(_pvname_hash, name, pvl->pv);
- }
-}
-
-static void _vg_reduce(char **argv, int argc, lvm_t libh)
-{
- vg_t vg;
- struct dm_list *pvs;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
- !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
- printf ("VG not open\n");
- return;
- }
- if (lvm_vg_reduce(vg, argv[2])) {
- printf("Error reducing %s by %s\n", argv[1], argv[2]);
- return;
- }
-
- printf("Success reducing vg %s by %s\n", argv[1], argv[2]);
-
- /*
- * Add the device into the hashes for lookups
- */
- pvs = lvm_vg_list_pvs(vg);
- if (pvs && !dm_list_empty(pvs))
- _remove_device_from_pvname_hash(pvs, argv[2]);
-}
-
-/* Print "Error" or "Success" depending on lvm status */
-static int _lvm_status_to_pass_fail(int rc)
-{
- if (rc)
- printf("Error ");
- else
- printf("Success ");
- return rc;
-}
-static void _config_override(char **argv, int argc, lvm_t libh)
-{
- int rc;
- char tmp[64];
-
- if (argc < 2) {
- printf ("Please enter device\n");
- return;
- }
- snprintf(tmp, 63, "devices{filter=[\"a|%s|\", \"r|.*|\"]}", argv[1]);
- rc = lvm_config_override(libh, tmp);
- _lvm_status_to_pass_fail(rc);
- printf("overriding LVM configuration\n");
-}
-
-static void _config_reload(char **argv, int argc, lvm_t libh)
-{
- int rc;
- rc = lvm_config_reload(libh);
- _lvm_status_to_pass_fail(rc);
- printf("reloading LVM configuration\n");
-}
-
-static void _vg_extend(char **argv, int argc, lvm_t libh)
-{
- vg_t vg;
- struct dm_list *pvs;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
- !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
- printf ("VG not open\n");
- return;
- }
- if (lvm_vg_extend(vg, argv[2])) {
- printf("Error extending %s with %s\n", argv[1], argv[2]);
- return;
- }
-
- printf("Success extending vg %s with %s\n", argv[1], argv[2]);
-
- /*
- * Add the device into the hashes for lookups
- */
- pvs = lvm_vg_list_pvs(vg);
- if (pvs && !dm_list_empty(pvs))
- _add_device_to_pvname_hash(pvs, argv[2]);
-}
-
-static void _vg_open(char **argv, int argc, lvm_t libh)
-{
- vg_t vg;
- struct dm_list *lvs;
- struct dm_list *pvs;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- if ((vg = dm_hash_lookup(_vgid_hash, argv[1])) ||
- (vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
- printf ("VG already open\n");
- return;
- }
- if (argc < 3)
- vg = lvm_vg_open(libh, argv[1], "r", 0);
- else
- vg = lvm_vg_open(libh, argv[1], argv[2], 0);
- if (!vg || !lvm_vg_get_name(vg)) {
- printf("Error opening %s\n", argv[1]);
- return;
- }
-
- printf("Success opening vg %s\n", argv[1]);
- dm_hash_insert(_vgname_hash, lvm_vg_get_name(vg), vg);
- dm_hash_insert(_vgid_hash, lvm_vg_get_uuid(vg), vg);
-
- /*
- * Add the LVs and PVs into the hashes for lookups
- */
- lvs = lvm_vg_list_lvs(vg);
- if (lvs && !dm_list_empty(lvs))
- _add_lvs_to_lvname_hash(lvs);
- pvs = lvm_vg_list_pvs(vg);
- if (pvs && !dm_list_empty(pvs))
- _add_pvs_to_pvname_hash(pvs);
-}
-/* Lookup the vg and remove it from the vgname and vgid hashes */
-static vg_t _lookup_and_remove_vg(const char *vgname)
-{
- vg_t vg=NULL;
-
- if ((vg = dm_hash_lookup(_vgname_hash, vgname))) {
- dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
- dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
- }
- if (!vg && (vg = dm_hash_lookup(_vgid_hash, vgname))) {
- dm_hash_remove(_vgid_hash, lvm_vg_get_uuid(vg));
- dm_hash_remove(_vgname_hash, lvm_vg_get_name(vg));
- }
- return vg;
-}
-
-static void _vg_write(char **argv, int argc)
-{
- vg_t vg;
- int rc = 0;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- vg = _lookup_vg_by_name(argv, argc);
- if (!vg) {
- printf("Can't find vg_name %s\n", argv[1]);
- return;
- }
- rc = lvm_vg_write(vg);
- _lvm_status_to_pass_fail(rc);
- printf("writing VG %s\n", lvm_vg_get_name(vg));
-}
-
-static void _vg_create(char **argv, int argc, lvm_t libh)
-{
- vg_t vg;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- vg = lvm_vg_create(libh, argv[1]);
- if (!vg || !lvm_vg_get_name(vg)) {
- printf("Error creating %s\n", argv[1]);
- return;
- }
-
- printf("Success creating vg %s\n", argv[1]);
- dm_hash_insert(_vgname_hash, lvm_vg_get_name(vg), vg);
- dm_hash_insert(_vgid_hash, lvm_vg_get_uuid(vg), vg);
-}
-
-static void _vg_remove(char **argv, int argc)
-{
- vg_t vg;
- int rc = 0;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- vg = _lookup_vg_by_name(argv, argc);
- if (!vg) {
- printf("Can't find vg_name %s\n", argv[1]);
- return;
- }
- rc = lvm_vg_remove(vg);
- _lvm_status_to_pass_fail(rc);
- printf("removing VG\n");
-}
-
-static void _vg_close(char **argv, int argc)
-{
- vg_t vg;
- int rc = 0;
-
- if (argc < 2) {
- printf ("Please enter vg_name\n");
- return;
- }
- vg = _lookup_and_remove_vg(argv[1]);
- if (!vg) {
- printf("Can't find vg_name %s\n", argv[1]);
- return;
- }
- rc = lvm_vg_close(vg);
- _lvm_status_to_pass_fail(rc);
- printf("closing VG\n");
-}
-
-static void _show_one_vg(vg_t vg)
-{
- printf("%s (%s): sz=%"PRIu64", free=%"PRIu64", #pv=%"PRIu64
- ", seq#=%"PRIu64"\n",
- lvm_vg_get_name(vg), lvm_vg_get_uuid(vg),
- lvm_vg_get_size(vg), lvm_vg_get_free_size(vg),
- lvm_vg_get_pv_count(vg), lvm_vg_get_seqno(vg));
-}
-
-static void _print_pv(pv_t pv)
-{
- if (!pv)
- return;
- printf("%s (%s): size=%"PRIu64", free=%"PRIu64
- ", dev_size=%"PRIu64", mda_count=%"PRIu64"\n",
- lvm_pv_get_name(pv), lvm_pv_get_uuid(pv),
- lvm_pv_get_size(pv), lvm_pv_get_free(pv),
- lvm_pv_get_dev_size(pv),
- lvm_pv_get_mda_count(pv));
-}
-
-static void _print_lv(vg_t vg, lv_t lv)
-{
- if (!lv)
- return;
- printf("%s/%s (%s): size=%"PRIu64", %sACTIVE / %sSUSPENDED\n",
- lvm_vg_get_name(vg),
- lvm_lv_get_name(lv), lvm_lv_get_uuid(lv),
- lvm_lv_get_size(lv),
- lvm_lv_is_active(lv) ? "" : "IN",
- lvm_lv_is_suspended(lv) ? "" : "NOT ");
-}
-
-static void _list_open_vgs(void)
-{
- dm_hash_iter(_vgid_hash, (dm_hash_iterate_fn) _show_one_vg);
-}
-
-static void _pvs_in_vg(char **argv, int argc)
-{
- struct dm_list *pvs;
- struct lvm_pv_list *pvl;
- vg_t vg;
-
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- pvs = lvm_vg_list_pvs(vg);
- if (!pvs || dm_list_empty(pvs)) {
- printf("No PVs in VG %s\n", lvm_vg_get_name(vg));
- return;
- }
- printf("PVs in VG %s:\n", lvm_vg_get_name(vg));
- dm_list_iterate_items(pvl, pvs) {
- _print_pv(pvl->pv);
- }
-}
-
-static void _print_property_value(const char *name,
- struct lvm_property_value v)
-{
- if (!v.is_valid)
- printf("%s = INVALID\n", name);
- else if (v.is_string)
- printf("%s = %s\n", name, v.value.string);
- else
- printf("%s = %"PRIu64"\n", name, v.value.integer);
-}
-
-static void _pvsegs_in_pv(char **argv, int argc)
-{
- struct dm_list *pvsegs;
- struct lvm_pvseg_list *pvl;
- pv_t pv;
-
- if (!(pv = _lookup_pv_by_name(argv[1])))
- return;
- pvsegs = lvm_pv_list_pvsegs(pv);
- if (!pvsegs || dm_list_empty(pvsegs)) {
- printf("No PV segments in pv %s\n", argv[1]);
- return;
- }
- printf("PV segments in pv %s:\n", argv[1]);
- dm_list_iterate_items(pvl, pvsegs) {
- struct lvm_property_value v;
- v = lvm_pvseg_get_property(pvl->pvseg, "pvseg_start");
- _print_property_value("pvseg_start", v);
- v = lvm_pvseg_get_property(pvl->pvseg, "pvseg_size");
- _print_property_value("pvseg_size", v);
- }
-}
-
-static void _scan_vgs(lvm_t libh)
-{
- lvm_scan(libh);
-}
-
-static void _list_vg_names(lvm_t libh)
-{
- struct dm_list *list;
- struct lvm_str_list *strl;
-
- list = lvm_list_vg_names(libh);
- printf("VG names:\n");
- dm_list_iterate_items(strl, list) {
- printf("%s\n", strl->str);
- }
-}
-
-static void _list_vg_ids(lvm_t libh)
-{
- struct dm_list *list;
- struct lvm_str_list *strl;
-
- list = lvm_list_vg_uuids(libh);
- printf("VG uuids:\n");
- dm_list_iterate_items(strl, list) {
- printf("%s\n", strl->str);
- }
-}
-
-static void _display_tags(struct dm_list *list)
-{
- struct lvm_str_list *strl;
- if (dm_list_empty(list)) {
- printf("No tags exist\n");
- return;
- } else if (!list) {
- printf("Error obtaining tags\n");
- return;
- }
- dm_list_iterate_items(strl, list) {
- printf("%s\n", strl->str);
- }
-}
-
-static void _vg_get_tags(char **argv, int argc)
-{
- vg_t vg;
-
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- printf("VG tags:\n");
- _display_tags(lvm_vg_get_tags(vg));
-}
-
-static void _vg_tag(char **argv, int argc, int add)
-{
- vg_t vg;
-
- if (argc < 3) {
- printf("Please enter vgname, tag\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- if (add && lvm_vg_add_tag(vg, argv[2]))
- printf("Error ");
- else if (!add && lvm_vg_remove_tag(vg, argv[2])){
- printf("Error ");
- } else {
- printf("Success ");
- }
- printf("%s tag %s to VG %s\n",
- add ? "adding":"removing", argv[2], argv[1]);
-}
-
-static void _pv_get_property(char **argv, int argc)
-{
- pv_t pv;
- struct lvm_property_value v;
-
- if (argc < 3) {
- printf("Please enter pvname, field_id\n");
- return;
- }
- if (!(pv = _lookup_pv_by_name(argv[1])))
- return;
- v = lvm_pv_get_property(pv, argv[2]);
- _print_property_value(argv[2], v);
-}
-
-static void _vg_get_property(char **argv, int argc)
-{
- vg_t vg;
- struct lvm_property_value v;
-
- if (argc < 3) {
- printf("Please enter vgname, field_id\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- v = lvm_vg_get_property(vg, argv[2]);
- _print_property_value(argv[2], v);
-}
-
-static void _lv_get_property(char **argv, int argc)
-{
- lv_t lv;
- struct lvm_property_value v;
-
- if (argc < 4) {
- printf("Please enter vgname, lvname, field_id\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- v = lvm_lv_get_property(lv, argv[3]);
- _print_property_value(argv[3], v);
-}
-
-static void _vg_set_property(char **argv, int argc)
-{
- vg_t vg;
- struct lvm_property_value value;
- int rc;
-
- if (argc < 4) {
- printf("Please enter vgname, field_id, value\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- value = lvm_vg_get_property(vg, argv[2]);
- if (!value.is_valid) {
- printf("Error obtaining property value\n");
- return;
- }
- if (value.is_string)
- value.value.string = argv[3];
- else
- value.value.integer = atoi(argv[3]);
- rc = lvm_vg_set_property(vg, argv[2], &value);
- if (rc)
- printf("Error ");
- else
- printf("Success ");
- printf("setting value of property %s in VG %s\n",
- argv[2], argv[1]);
-}
-
-static void _lv_get_tags(char **argv, int argc)
-{
- lv_t lv;
-
- if (argc < 3) {
- printf("Please enter vgname, lvname\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- printf("LV tags:\n");
- _display_tags(lvm_lv_get_tags(lv));
-}
-
-static void _lv_tag(char **argv, int argc, int add)
-{
- lv_t lv;
-
- if (argc < 3) {
- printf("Please enter vgname, lvname\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- if (add && lvm_lv_add_tag(lv, argv[3]))
- printf("Error ");
- else if (!add && lvm_lv_remove_tag(lv, argv[3])){
- printf("Error ");
- } else {
- printf("Success ");
- }
- printf("%s tag %s to LV %s\n",
- add ? "adding":"removing", argv[3], argv[2]);
-}
-
-static void _lv_from_uuid(char **argv, int argc)
-{
- vg_t vg;
-
- if (argc < 3) {
- printf("Please enter vgname, lv_uuid\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- _print_lv(vg, lvm_lv_from_uuid(vg, argv[2]));
-}
-
-static void _lv_from_name(char **argv, int argc)
-{
- vg_t vg;
-
- if (argc < 3) {
- printf("Please enter vgname, lv_uuid\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- _print_lv(vg, lvm_lv_from_name(vg, argv[2]));
-}
-
-static void _pv_from_uuid(char **argv, int argc)
-{
- vg_t vg;
-
- if (argc < 3) {
- printf("Please enter vgname, pv_uuid\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- _print_pv(lvm_pv_from_uuid(vg, argv[2]));
-}
-
-static void _pv_from_name(char **argv, int argc)
-{
- vg_t vg;
-
- if (argc < 3) {
- printf("Please enter vgname, pv_uuid\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- _print_pv(lvm_pv_from_name(vg, argv[2]));
-}
-
-static void _vgname_from_pvid(char **argv, int argc, lvm_t libh)
-{
- const char *vgname;
-
- if (argc < 1) {
- printf("Please enter pvid\n");
- return;
- }
- if (!(vgname = lvm_vgname_from_pvid(libh, argv[1]))) {
- printf("Error ");
- } else {
- printf("Success ");
- }
- printf("looking up vgname=%s from PVID=%s\n",
- vgname, argv[1]);
-}
-static void _vgname_from_devname(char **argv, int argc, lvm_t libh)
-{
- const char *vgname;
-
- if (argc < 1) {
- printf("Please enter device\n");
- return;
- }
- if (!(vgname = lvm_vgname_from_device(libh, argv[1]))) {
- printf("Error ");
- } else {
- printf("Success ");
- }
- printf("looking up vgname=%s from device name=%s\n",
- vgname, argv[1]);
-}
-static void _lvs_in_vg(char **argv, int argc)
-{
- struct dm_list *lvs;
- struct lvm_lv_list *lvl;
- vg_t vg;
-
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- lvs = lvm_vg_list_lvs(vg);
- if (!lvs || dm_list_empty(lvs)) {
- printf("No LVs in VG %s\n", lvm_vg_get_name(vg));
- return;
- }
- printf("LVs in VG %s:\n", lvm_vg_get_name(vg));
- dm_list_iterate_items(lvl, lvs) {
- _print_lv(vg, lvl->lv);
- }
-}
-
-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);
- v = lvm_lvseg_get_property(lvl->lvseg, "devices");
- _print_property_value("devices", v);
- v = lvm_lvseg_get_property(lvl->lvseg, "seg_pe_ranges");
- _print_property_value("seg_pe_ranges", v);
- }
-}
-
-static void _lv_deactivate(char **argv, int argc)
-{
- lv_t lv;
- int rc=0;
-
- if (argc < 3) {
- printf("Please enter vgname, lvname\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- rc = lvm_lv_deactivate(lv);
- _lvm_status_to_pass_fail(rc);
- printf("De-activating LV %s in VG %s\n",
- argv[2], argv[1]);
-}
-static void _lv_activate(char **argv, int argc)
-{
- lv_t lv;
- int rc=0;
-
- if (argc < 3) {
- printf("Please enter vgname, lvname\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- rc = lvm_lv_activate(lv);
- _lvm_status_to_pass_fail(rc);
- printf("activating LV %s in VG %s\n",
- argv[2], argv[1]);
-}
-
-static void _vg_remove_lv(char **argv, int argc)
-{
- lv_t lv;
-
- if (argc < 3) {
- printf("Please enter vgname, lvname\n");
- return;
- }
- if (!(lv = _lookup_lv_by_name(argv[2])))
- return;
- if (lvm_vg_remove_lv(lv))
- printf("Error ");
- else {
- printf("Success ");
- dm_hash_remove(_lvname_hash, argv[2]);
- }
- printf("removing LV %s in VG %s\n",
- argv[2], argv[1]);
-}
-
-static void _vg_create_lv_linear(char **argv, int argc)
-{
- vg_t vg;
- lv_t lv;
-
- if (argc < 4) {
- printf("Please enter vgname, lvname, and size\n");
- return;
- }
- if (!(vg = _lookup_vg_by_name(argv, argc)))
- return;
- lv = lvm_vg_create_lv_linear(vg, argv[2], atol(argv[3]));
- if (!lv)
- printf("Error ");
- else {
- printf("Success ");
- dm_hash_insert(_lvname_hash, argv[2], lv);
- }
- printf("creating LV %s in VG %s\n",
- argv[2], argv[1]);
-}
-
-static int lvmapi_test_shell(lvm_t libh)
-{
- int argc;
- char *input = NULL, *args[MAX_ARGS], **argv;
-
- _hash_create();
- argc=0;
- while (1) {
- free(input);
- input = readline("liblvm> ");
-
- /* EOF */
- if (!input) {
- printf("\n");
- break;
- }
-
- /* empty line */
- if (!*input)
- continue;
-
- argv = args;
-
- if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
- printf("Too many arguments, sorry.");
- continue;
- }
-
- if (!strcmp(argv[0], "lvm")) {
- argv++;
- argc--;
- }
-
- if (!argc)
- continue;
-
- if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit")) {
- printf("Exiting.\n");
- break;
- } else if (!strcmp(argv[0], "?") || !strcmp(argv[0], "help")) {
- _show_help();
- } else if (!strcmp(argv[0], "config_reload")) {
- _config_reload(argv, argc, libh);
- } else if (!strcmp(argv[0], "config_override")) {
- _config_override(argv, argc, libh);
- } else if (!strcmp(argv[0], "vg_extend")) {
- _vg_extend(argv, argc, libh);
- } else if (!strcmp(argv[0], "vg_reduce")) {
- _vg_reduce(argv, argc, libh);
- } else if (!strcmp(argv[0], "vg_write")) {
- _vg_write(argv, argc);
- } else if (!strcmp(argv[0], "vg_open")) {
- _vg_open(argv, argc, libh);
- } else if (!strcmp(argv[0], "vg_close")) {
- _vg_close(argv, argc);
- } else if (!strcmp(argv[0], "vg_create")) {
- _vg_create(argv, argc, libh);
- } else if (!strcmp(argv[0], "vg_remove")) {
- _vg_remove(argv, argc);
- } else if (!strcmp(argv[0], "lv_activate")) {
- _lv_activate(argv, argc);
- } else if (!strcmp(argv[0], "lv_deactivate")) {
- _lv_deactivate(argv, argc);
- } else if (!strcmp(argv[0], "vg_remove_lv")) {
- _vg_remove_lv(argv, argc);
- } else if (!strcmp(argv[0], "vgs_open")) {
- _list_open_vgs();
- } else if (!strcmp(argv[0], "vg_list_pvs")) {
- _pvs_in_vg(argv, argc);
- } else if (!strcmp(argv[0], "pv_list_pvsegs")) {
- _pvsegs_in_pv(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")) {
- _list_vg_ids(libh);
- } else if (!strcmp(argv[0], "scan_vgs")) {
- _scan_vgs(libh);
- } else if (!strcmp(argv[0], "vg_create_lv_linear")) {
- _vg_create_lv_linear(argv, argc);
- } else if (!strcmp(argv[0], "vg_add_tag")) {
- _vg_tag(argv, argc, 1);
- } else if (!strcmp(argv[0], "vg_remove_tag")) {
- _vg_tag(argv, argc, 0);
- } else if (!strcmp(argv[0], "vg_get_tags")) {
- _vg_get_tags(argv, argc);
- } else if (!strcmp(argv[0], "lv_get_property")) {
- _lv_get_property(argv, argc);
- } else if (!strcmp(argv[0], "vg_get_property")) {
- _vg_get_property(argv, argc);
- } else if (!strcmp(argv[0], "pv_get_property")) {
- _pv_get_property(argv, argc);
- } else if (!strcmp(argv[0], "vg_set_property")) {
- _vg_set_property(argv, argc);
- } else if (!strcmp(argv[0], "lv_add_tag")) {
- _lv_tag(argv, argc, 1);
- } else if (!strcmp(argv[0], "lv_remove_tag")) {
- _lv_tag(argv, argc, 0);
- } else if (!strcmp(argv[0], "lv_get_tags")) {
- _lv_get_tags(argv, argc);
- } else if (!strcmp(argv[0], "vgname_from_devname")) {
- _vgname_from_devname(argv, argc, libh);
- } else if (!strcmp(argv[0], "vgname_from_pvid")) {
- _vgname_from_pvid(argv, argc, libh);
- } else if (!strcmp(argv[0], "lv_from_uuid")) {
- _lv_from_uuid(argv, argc);
- } else if (!strcmp(argv[0], "lv_from_name")) {
- _lv_from_name(argv, argc);
- } else if (!strcmp(argv[0], "pv_from_uuid")) {
- _pv_from_uuid(argv, argc);
- } else if (!strcmp(argv[0], "pv_from_name")) {
- _pv_from_name(argv, argc);
- } else {
- printf ("Unrecognized command %s\n", argv[0]);
- }
- }
-
- dm_hash_iter(_vgname_hash, (dm_hash_iterate_fn) lvm_vg_close);
- _hash_destroy();
- free(input);
- return 0;
-}
-#else /* !READLINE_SUPPORT */
-static int lvmapi_test_shell(lvm_t libh)
-{
- printf("Build without readline library, no interactive testing.\n");
- return 1;
-}
-#endif
-
-int main (int argc, char *argv[])
-{
- lvm_t libh;
-
- libh = lvm_init(NULL);
- if (!libh) {
- printf("Unable to open lvm library instance\n");
- return 1;
- }
-
- printf("Library version: %s\n", lvm_library_get_version());
- lvmapi_test_shell(libh);
-
- lvm_quit(libh);
- return 0;
-}
-
diff --git a/test/api/thin_percent.c b/test/api/thin_percent.c
deleted file mode 100644
index 7f99abf77..000000000
--- a/test/api/thin_percent.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#undef NDEBUG
-
-#include "liblvm/lvm2app.h"
-#include "assert.h"
-
-int main(int argc, char *argv[])
-{
- lvm_t handle;
- vg_t vg;
- lv_t lv;
- struct lvm_property_value v;
- struct dm_list *lvsegs;
- struct lvm_lvseg_list *lvl;
-
- handle = lvm_init(NULL);
- assert(handle);
-
- vg = lvm_vg_open(handle, argv[1], "r", 0);
- assert(vg);
-
- lv = lvm_lv_from_name(vg, "pool");
- assert(lv);
-
- lvsegs = lvm_lv_list_lvsegs(lv);
- assert(lvsegs && (dm_list_size(lvsegs) == 1));
- dm_list_iterate_items(lvl, lvsegs) {
- v = lvm_lvseg_get_property(lvl->lvseg, "discards");
- assert(v.is_valid && v.is_string);
- assert(strcmp(v.value.string, "passdown") == 0);
- }
-
- v = lvm_lv_get_property(lv, "data_percent");
- assert(v.is_valid);
- assert(v.value.integer == 25 * PERCENT_1);
-
-
- lv = lvm_lv_from_name(vg, "thin");
- assert(lv);
-
- v = lvm_lv_get_property(lv, "data_percent");
- assert(v.is_valid);
- assert(v.value.integer == 50 * PERCENT_1);
-
-
- lv = lvm_lv_from_name(vg, "snap");
- assert(lv);
-
- v = lvm_lv_get_property(lv, "data_percent");
- assert(v.is_valid);
- assert(v.value.integer == 75 * PERCENT_1);
-
- v = lvm_lv_get_property(lv, "snap_percent");
- assert(v.is_valid);
- assert(v.value.integer == (uint64_t) DM_PERCENT_INVALID);
-
- v = lvm_lv_get_property(lv, "origin");
- assert(v.is_valid);
- assert(strcmp(v.value.string, "thin") == 0);
-
- lvm_vg_close(vg);
- lvm_quit(handle);
-
- return 0;
-}
diff --git a/test/api/vglist.c b/test/api/vglist.c
deleted file mode 100644
index daa21c212..000000000
--- a/test/api/vglist.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <assert.h>
-
-#include "liblvm/lvm2app.h"
-
-lvm_t handle;
-vg_t vg;
-
-static void start(void) {
- handle = lvm_init(NULL);
- if (!handle) {
- fprintf(stderr, "Unable to lvm_init\n");
- abort();
- }
-}
-
-static void done(int ok) {
- if (handle && lvm_errno(handle)) {
- fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
- ok = 0;
- }
- if (handle)
- lvm_quit(handle);
- if (!ok)
- abort();
-}
-
-int main(int argc, char *argv[])
-{
- lvm_str_list_t *str;
- int i = 0;
- struct dm_list *vgnames;
- struct dm_list *vgids;
-
- if (argc != 3)
- abort();
-
- start();
- vgnames = lvm_list_vg_names(handle);
- dm_list_iterate_items(str, vgnames) {
- assert(++i <= 1);
- assert(!strcmp(str->str, argv[1]));
- }
- assert(i == 1);
- done(1);
-
- i = 0;
- start();
- vgids = lvm_list_vg_uuids(handle);
- dm_list_iterate_items(str, vgids) {
- assert(++i <= 1);
- assert(!strcmp(str->str, argv[2]));
- }
- assert(i == 1);
- done(1);
- return 0;
-}
diff --git a/test/api/vgtest.c b/test/api/vgtest.c
deleted file mode 100644
index 6a438d184..000000000
--- a/test/api/vgtest.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-/*
- * Unit test case for vgcreate and related APIs.
- * # gcc -g vgcreate.c -I../../liblvm -I../../include -L../../liblvm \
- * -L../../libdm -ldevmapper -llvm2app
- * # export LD_LIBRARY_PATH=`pwd`/../../libdm:`pwd`/../../liblvm
- */
-#include <stdio.h>
-#include <unistd.h>
-#include <inttypes.h>
-
-#include "liblvm/lvm2app.h"
-
-lvm_t handle;
-vg_t vg;
-const char *vg_name;
-#define MAX_DEVICES 16
-const char *device[MAX_DEVICES];
-uint64_t size = 4096;
-
-#define vg_create(vg_name) \
- printf("Creating VG %s\n", vg_name); \
- vg = lvm_vg_create(handle, vg_name); \
- if (!vg) { \
- fprintf(stderr, "Error creating volume group %s\n", vg_name); \
- goto bad; \
- }
-#define vg_extend(vg, dev) \
- printf("Extending VG %s by %s\n", vg_name, dev); \
- status = lvm_vg_extend(vg, dev); \
- if (status) { \
- fprintf(stderr, "Error extending volume group %s " \
- "with device %s\n", vg_name, dev); \
- goto bad; \
- }
-#define vg_commit(vg) \
- printf("Committing VG %s to disk\n", vg_name); \
- status = lvm_vg_write(vg); \
- if (status) { \
- fprintf(stderr, "Commit of volume group '%s' failed\n", \
- lvm_vg_get_name(vg)); \
- goto bad; \
- }
-#define vg_open(vg_name, mode) \
- printf("Opening VG %s %s\n", vg_name, mode); \
- vg = lvm_vg_open(handle, vg_name, mode, 0); \
- if (!vg) { \
- fprintf(stderr, "Error opening volume group %s\n", vg_name); \
- goto bad; \
- }
-#define vg_close(vg) \
- printf("Closing VG %s\n", vg_name); \
- if (lvm_vg_close(vg)) { \
- fprintf(stderr, "Error closing volume group %s\n", vg_name); \
- goto bad; \
- }
-#define vg_reduce(vg, dev) \
- printf("Reducing VG %s by %s\n", vg_name, dev); \
- status = lvm_vg_reduce(vg, dev); \
- if (status) { \
- fprintf(stderr, "Error reducing volume group %s " \
- "by device %s\n", vg_name, dev); \
- goto bad; \
- }
-#define vg_remove(vg) \
- printf("Removing VG %s from system\n", vg_name); \
- status = lvm_vg_remove(vg); \
- if (status) { \
- fprintf(stderr, "Revmoval of volume group '%s' failed\n", \
- vg_name); \
- goto bad; \
- }
-
-static int init_vgtest(int argc, char *argv[])
-{
- int i;
-
- if (argc < 4) {
- fprintf(stderr, "Usage: %s <vgname> <pv1> <pv2> [... <pvN> ]",
- argv[0]);
- return -1;
- }
- vg_name = argv[1];
- for(i=2; i<MAX_DEVICES && i < argc; i++) {
- device[i-2] = argv[i];
- }
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- int status;
-
- if (init_vgtest(argc, argv) < 0)
- goto bad;
-
- /* FIXME: make the below messages verbose-only and print PASS/FAIL*/
- printf("Opening LVM\n");
- handle = lvm_init(NULL);
- if (!handle) {
- fprintf(stderr, "Unable to lvm_init\n");
- goto bad;
- }
-
- printf("Library version: %s\n", lvm_library_get_version());
- vg_create(vg_name);
- vg_extend(vg, device[0]);
-
- printf("Setting VG %s extent_size to %"PRIu64"\n", vg_name, size);
- status = lvm_vg_set_extent_size(vg, size);
- if (status) {
- fprintf(stderr, "Can not set physical extent "
- "size '%"PRIu64"' for '%s'\n",
- size, vg_name);
- goto bad;
- }
-
- vg_commit(vg);
- vg_close(vg);
-
- vg_open(vg_name, "r");
- vg_close(vg);
-
- vg_open(vg_name, "w");
- vg_extend(vg, device[1]);
- vg_reduce(vg, device[0]);
- vg_commit(vg);
- vg_close(vg);
-
- vg_open(vg_name, "w");
- vg_extend(vg, device[0]);
- vg_commit(vg);
- vg_close(vg);
-
- vg_open(vg_name, "w");
- vg_remove(vg);
- vg_commit(vg);
- vg_close(vg);
-
- lvm_quit(handle);
- printf("liblvm vgcreate unit test PASS\n");
- _exit(0);
-bad:
- printf("liblvm vgcreate unit test FAIL\n");
- if (handle && lvm_errno(handle))
- fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
- if (vg)
- lvm_vg_close(vg);
- if (handle)
- lvm_quit(handle);
- _exit(-1);
-}