1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00

test: lvm2api thin data_percent

This commit is contained in:
Zdenek Kabelac 2012-10-05 10:33:41 +02:00
parent 39f3c9de0b
commit 7f4f7f70ce
3 changed files with 112 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved.
# Copyright (C) 2009-2012 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@ -20,8 +20,20 @@ ifeq ("@APPLIB@", "yes")
TARGETS += test
SOURCES = test.c
TARGETS += vgtest.t percent.t pe_start.t lvtest.t
SOURCES2 = vgtest.c percent.c pe_start.c lvtest.c
TARGETS += \
lvtest.t \
percent.t \
pe_start.t \
thin_percent.t \
vgtest.t
SOURCES2 = \
lvtest.c \
percent.c \
pe_start.c \
thin_percent.c \
vgtest.c
endif
include $(top_builddir)/make.tmpl

60
test/api/thin_percent.c Normal file
View File

@ -0,0 +1,60 @@
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#undef NDEBUG
#include "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;
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);
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);
lvm_vg_close(vg);
lvm_quit(handle);
return 0;
}

37
test/api/thin_percent.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# 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 General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
. lib/test
aux target_at_least dm-thin-pool 1 0 0 || skip
# disable thin_check if not present in system
which thin_check || aux lvmconf 'global/thin_check_executable = ""'
aux prepare_devs 2
vgcreate -s 64k $vg $(cat DEVICES)
lvcreate -L5M -T $vg/pool
lvcreate -V1M -T $vg/pool -n thin
dd if=/dev/urandom of="$DM_DEV_DIR/$vg/thin" count=2 bs=256K
lvcreate -s $vg/thin -n snap
dd if=/dev/urandom of="$DM_DEV_DIR/$vg/snap" count=3 bs=256K
lvs $vg
aux apitest thin_percent $vg
vgremove -ff $vg