public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/test/api vgtest.c
@ 2009-09-04 19:17 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-09-04 19:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-04 19:17:46

Modified files:
	test/api       : vgtest.c 

Log message:
	Update lvm2app unit test vgtest - fix remove bug.
	
	We now must commit to disk after lvm_vg_remove().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13

--- LVM2/test/api/vgtest.c	2009/09/04 12:54:23	1.12
+++ LVM2/test/api/vgtest.c	2009/09/04 19:17:46	1.13
@@ -49,9 +49,8 @@
 	printf("Committing VG %s to disk\n", vg_name); \
 	status = lvm_vg_write(vg); \
 	if (status) { \
-		fprintf(stderr, "Creation of volume group '%s' on " \
-			"device '%s' failed\n", \
-			lvm_vg_get_name(vg), device[0]); \
+		fprintf(stderr, "Commit of volume group '%s' failed\n", \
+			lvm_vg_get_name(vg)); \
 		goto bad; \
 	}
 #define vg_open(vg_name, mode) \
@@ -147,6 +146,7 @@
 
 	vg_open(vg_name, "w");
 	vg_remove(vg);
+	vg_commit(vg);
 	vg_close(vg);
 
 	lvm_quit(handle);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2/test/api vgtest.c
@ 2009-09-03 17:13 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-09-03 17:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-03 17:13:46

Modified files:
	test/api       : vgtest.c 

Log message:
	Update lvm2app vgtest to take vgname and devices as parameters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/test/api/vgtest.c	2009/08/13 12:16:45	1.10
+++ LVM2/test/api/vgtest.c	2009/09/03 17:13:46	1.11
@@ -25,9 +25,9 @@
 
 lvm_t handle;
 vg_t vg;
-const char *vg_name = "my_vg";
-const char *device = "/dev/loop3";
-const char *device2 = "/dev/loop4";
+const char *vg_name;
+#define MAX_DEVICES 16
+const char *device[MAX_DEVICES];
 uint64_t size = 1024;
 
 #define vg_create(vg_name) \
@@ -51,7 +51,7 @@
 	if (status) { \
 		fprintf(stderr, "Creation of volume group '%s' on " \
 			"device '%s' failed\n", \
-			lvm_vg_get_name(vg), device); \
+			lvm_vg_get_name(vg), device[0]); \
 		goto bad; \
 	}
 #define vg_open(vg_name, mode) \
@@ -84,11 +84,29 @@
 		goto bad; \
 	}
 
+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;
 
-	/* FIXME: input vgname, etc from cmdline */
+	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);
@@ -99,7 +117,7 @@
 
 	printf("Library version: %s\n", lvm_library_get_version());
 	vg_create(vg_name);
-	vg_extend(vg, device);
+	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);
@@ -117,13 +135,13 @@
 	vg_close(vg);
 
 	vg_open(vg_name, "w");
-	vg_extend(vg, device2);
-	vg_reduce(vg, device);
+	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);
+	vg_extend(vg, device[0]);
 	vg_commit(vg);
 	vg_close(vg);
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2/test/api vgtest.c
@ 2009-07-27 17:44 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-27 17:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-27 17:44:58

Modified files:
	test/api       : vgtest.c 

Log message:
	Update test/api/vgtest.c to include lvm_vg_reduce.
	
	Signed-off-by: Thomas Woerner <twoerner@redhat.com>
	Acked-by: Dave Wysochanski <dwysocha@redhat.com>
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6

--- LVM2/test/api/vgtest.c	2009/07/26 20:29:56	1.5
+++ LVM2/test/api/vgtest.c	2009/07/27 17:44:58	1.6
@@ -26,8 +26,63 @@
 vg_t *vg;
 const char *vg_name = "my_vg";
 const char *device = "/dev/loop3";
+const char *device2 = "/dev/loop4";
 uint64_t size = 1024;
 
+#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, "Creation of volume group '%s' on " \
+			"device '%s' failed\n", \
+			lvm_vg_get_name(vg), device); \
+		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; \
+	}
+
 int main(int argc, char *argv[])
 {
 	int status;
@@ -41,20 +96,8 @@
 		goto bad;
 	}
 
-	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;
-	}
-
-	printf("Extending VG %s\n", vg_name);
-	status = lvm_vg_extend(vg, device);
-	if (status) {
-		fprintf(stderr, "Error extending volume group %s "
-			"with device %s\n", vg_name, device);
-		goto bad;
-	}
+	vg_create(vg_name);
+	vg_extend(vg, device);
 
 	printf("Setting VG %s extent_size to %"PRIu64"\n", vg_name, size);
 	status = lvm_vg_set_extent_size(vg, size);
@@ -65,38 +108,27 @@
 		goto bad;
 	}
 
-	printf("Committing VG %s to disk\n", vg_name);
-	status = lvm_vg_write(vg);
-	if (status) {
-		fprintf(stderr, "Creation of volume group '%s' on "
-			"device '%s' failed\n",
-			vg_name, device);
-		goto bad;
-	}
+	vg_commit(vg);
+	vg_close(vg);
 
-	printf("Closing VG %s\n", vg_name);
-	if (lvm_vg_close(vg))
-		goto bad;
-	printf("Re-opening VG %s for reading\n", vg_name);
-	vg = lvm_vg_open(handle, vg_name, "r", 0);
-	if (!vg)
-		goto bad;
-	printf("Closing VG %s\n", vg_name);
-	if (lvm_vg_close(vg))
-		goto bad;
-	printf("Re-opening VG %s for writing\n", vg_name);
-	vg = lvm_vg_open(handle, vg_name, "w", 0);
-	if (!vg)
-		goto bad;
-	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;
-	}
+	vg_open(vg_name, "r");
+	vg_close(vg);
+
+	vg_open(vg_name, "w");
+	vg_extend(vg, device2);
+	vg_reduce(vg, device);
+	vg_commit(vg);
+	vg_close(vg);
+
+	vg_open(vg_name, "w");
+	vg_extend(vg, device);
+	vg_commit(vg);
+	vg_close(vg);
+
+	vg_open(vg_name, "w");
+	vg_remove(vg);
+	vg_close(vg);
 
-	lvm_vg_close(vg);
 	lvm_destroy(handle);
 	printf("liblvm vgcreate unit test PASS\n");
 	_exit(0);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2/test/api vgtest.c
@ 2009-07-22 22:25 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-22 22:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-22 22:25:30

Modified files:
	test/api       : vgtest.c 

Log message:
	Add a couple lvm_vg_open() calls to vgtest.c.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/test/api/vgtest.c	2009/07/22 16:49:54	1.3
+++ LVM2/test/api/vgtest.c	2009/07/22 22:25:30	1.4
@@ -74,6 +74,20 @@
 		goto bad;
 	}
 
+	printf("Closing VG %s\n", vg_name);
+	if (!lvm_vg_close(vg))
+		goto bad;
+	printf("Re-opening VG %s for reading\n", vg_name);
+	vg = lvm_vg_open(handle, vg_name, "r", 0);
+	if (!vg)
+		goto bad;
+	printf("Closing VG %s\n", vg_name);
+	if (!lvm_vg_close(vg))
+		goto bad;
+	printf("Re-opening VG %s for writing\n", vg_name);
+	vg = lvm_vg_open(handle, vg_name, "w", 0);
+	if (!vg)
+		goto bad;
 	printf("Removing VG %s from system\n", vg_name);
 	status = lvm_vg_remove(vg);
 	if (lvm_errno(handle)) {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2/test/api vgtest.c
@ 2009-07-22 16:49 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-22 16:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-22 16:49:54

Modified files:
	test/api       : vgtest.c 

Log message:
	Update api/test/vgtest.c error handling.
	
	Reverts some of my 'cleanup' from last night.  For now we will use pass/fail
	on API calls (either 'int' return or NULL/non-NULL handle), then use
	lvm_errno() to get more specific errors.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3

--- LVM2/test/api/vgtest.c	2009/07/22 03:13:57	1.2
+++ LVM2/test/api/vgtest.c	2009/07/22 16:49:54	1.3
@@ -43,38 +43,34 @@
 
 	printf("Creating VG %s\n", vg_name);
 	vg = lvm_vg_create(handle, vg_name);
-	if (lvm_errno(handle)) {
+	if (!vg) {
 		fprintf(stderr, "Error creating volume group %s\n", vg_name);
-		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Extending VG %s\n", vg_name);
 	status = lvm_vg_extend(vg, device);
-	if (lvm_errno(handle)) {
+	if (!status) {
 		fprintf(stderr, "Error extending volume group %s "
 			"with device %s\n", vg_name, device);
-		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Setting VG %s extent_size to %"PRIu64"\n", vg_name, size);
 	status = lvm_vg_set_extent_size(vg, size);
-	if (lvm_errno(handle)) {
+	if (!status) {
 		fprintf(stderr, "Can not set physical extent "
 			"size '%"PRIu64"' for '%s'\n",
 			size, vg_name);
-		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Committing VG %s to disk\n", vg_name);
 	status = lvm_vg_write(vg);
-	if (lvm_errno(handle)) {
+	if (!status) {
 		fprintf(stderr, "Creation of volume group '%s' on "
 			"device '%s' failed\n",
 			vg_name, device);
-		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
@@ -83,7 +79,6 @@
 	if (lvm_errno(handle)) {
 		fprintf(stderr, "Revmoval of volume group '%s' failed\n",
 			vg_name);
-		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
@@ -93,6 +88,8 @@
 	_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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2/test/api vgtest.c
@ 2009-07-22  3:13 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-22  3:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-22 03:13:57

Modified files:
	test/api       : vgtest.c 

Log message:
	Update test/api/vgtest.c to use lvm_errno and lvm_errmsg.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/vgtest.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/test/api/vgtest.c	2009/07/21 10:46:45	1.1
+++ LVM2/test/api/vgtest.c	2009/07/22 03:13:57	1.2
@@ -43,42 +43,47 @@
 
 	printf("Creating VG %s\n", vg_name);
 	vg = lvm_vg_create(handle, vg_name);
-	if (!vg) {
+	if (lvm_errno(handle)) {
 		fprintf(stderr, "Error creating volume group %s\n", vg_name);
+		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Extending VG %s\n", vg_name);
 	status = lvm_vg_extend(vg, device);
-	if (!status) {
+	if (lvm_errno(handle)) {
 		fprintf(stderr, "Error extending volume group %s "
 			"with device %s\n", vg_name, device);
+		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Setting VG %s extent_size to %"PRIu64"\n", vg_name, size);
 	status = lvm_vg_set_extent_size(vg, size);
-	if (!status) {
+	if (lvm_errno(handle)) {
 		fprintf(stderr, "Can not set physical extent "
 			"size '%"PRIu64"' for '%s'\n",
 			size, vg_name);
+		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Committing VG %s to disk\n", vg_name);
 	status = lvm_vg_write(vg);
-	if (!status) {
+	if (lvm_errno(handle)) {
 		fprintf(stderr, "Creation of volume group '%s' on "
 			"device '%s' failed\n",
 			vg_name, device);
+		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 
 	printf("Removing VG %s from system\n", vg_name);
 	status = lvm_vg_remove(vg);
-	if (!status) {
+	if (lvm_errno(handle)) {
 		fprintf(stderr, "Revmoval of volume group '%s' failed\n",
 			vg_name);
+		fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
 		goto bad;
 	}
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-04 19:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-04 19:17 LVM2/test/api vgtest.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2009-09-03 17:13 wysochanski
2009-07-27 17:44 wysochanski
2009-07-22 22:25 wysochanski
2009-07-22 16:49 wysochanski
2009-07-22  3:13 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).