summaryrefslogtreecommitdiffstats
path: root/test/api/percent.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/api/percent.c')
-rw-r--r--test/api/percent.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/api/percent.c b/test/api/percent.c
new file mode 100644
index 00000000..28d8144b
--- /dev/null
+++ b/test/api/percent.c
@@ -0,0 +1,45 @@
+#include "lvm2app.h"
+
+#define assert(x) do { if (!(x)) goto bad; } while (0)
+
+int main(int argc, char *argv[])
+{
+ lvm_t handle = lvm_init(NULL);
+ assert(handle);
+
+ vg_t vg = lvm_vg_open(handle, argv[1], "r", 0);
+ assert(vg);
+
+ lv_t lv = lvm_lv_from_name(vg, "snap");
+ assert(lv);
+
+ struct lvm_property_value 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);
+
+ lvm_vg_close(vg);
+ return 0;
+
+bad:
+ 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);
+ return 1;
+}