[lxc-devel] [PATCH 1/2] test/: update API usage

Filippo Giunchedi filippo at esaurito.net
Sun Jun 7 12:20:10 UTC 2009


Hi,
I've been playing with lxc, though with --enable-test the test/ directory
doesn't compile, the following patch ought to fix this.
I've not tested tests throughly but seems straightforward enough.

Update the API usage in test/ as to make tests compile
---
 test/Makefile.am       |    7 +++++--
 test/conf.c            |    4 ++--
 test/confile.c         |    5 +++--
 test/dev.c             |    6 +++---
 test/forward.c         |    4 ++--
 test/ipv4_add.c        |    2 +-
 test/ipv6_add.c        |    2 +-
 test/lxc_low_monitor.c |   10 ++++++----
 test/macvlan.c         |    2 +-
 test/movedev.c         |    2 +-
 test/proxy.c           |    4 ++--
 test/tst_list.c        |    2 +-
 test/veth.c            |    2 +-
 13 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/test/Makefile.am b/test/Makefile.am
index bbc47e9..b916869 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,5 +1,7 @@
 if ENABLE_TEST
 
+AM_LDFLAGS = -lutil
+
 INCLUDES= -I$(top_srcdir)/src
 
 noinst_PROGRAMS = \
@@ -29,7 +31,8 @@ tst_list_LDADD = \
 
 confile_SOURCES = confile.c
 confile_LDADD = \
-	$(top_builddir)/src/lxc/lxc_config.o \
+	$(top_builddir)/src/lxc/conf.o \
+	$(top_builddir)/src/lxc/confile.o \
 	$(top_builddir)/src/lxc/liblxc.la
 
 conf_SOURCES = conf.c
@@ -96,4 +99,4 @@ lxc_state_SOURCES = lxc_state.c
 lxc_state_LDADD = \
 	$(top_builddir)/src/lxc/liblxc.la
 
-endif
\ No newline at end of file
+endif
diff --git a/test/conf.c b/test/conf.c
index 441e341..1ba5003 100644
--- a/test/conf.c
+++ b/test/conf.c
@@ -27,8 +27,8 @@
 #include <netinet/in.h>
 #include <net/if.h>
 
-#include <lxc/lxc_list.h>
-#include <lxc/lxc_conf.h>
+#include <lxc/list.h>
+#include <lxc/conf.h>
 
 /*
  * I want to setup a container with a veth attached on a bridge, 
diff --git a/test/confile.c b/test/confile.c
index af82bf9..10bed64 100644
--- a/test/confile.c
+++ b/test/confile.c
@@ -31,7 +31,8 @@
 #include <net/if.h>
 
 #include <lxc/lxc.h>
-#include <lxc/lxc_config.h>
+#include <lxc/conf.h>
+#include <lxc/confile.h>
 
 static void usage(const char *cmd)
 {
@@ -59,7 +60,7 @@ int main(int argc, char *argv[])
 	if (!file || !name)
 		usage(argv[0]);
 
-	if (lxc_config_init(&lxc_conf)) {
+	if (lxc_conf_init(&lxc_conf)) {
 		fprintf(stderr, "failed to initialize configuration structure\n");
 		return 1;
 	}
diff --git a/test/dev.c b/test/dev.c
index 8275236..b19af44 100644
--- a/test/dev.c
+++ b/test/dev.c
@@ -60,11 +60,11 @@ int main(int argc, char *argv[])
 	}
 
 	if (destroy)
-		ret = device_delete(ifname);
+		ret = lxc_device_delete(ifname);
 	else if (!strcmp(flag, "up"))
-		ret = device_up(ifname);
+		ret = lxc_device_up(ifname);
 	else if (!strcmp(flag, "down"))
-		ret = device_down(ifname);
+		ret = lxc_device_down(ifname);
 
 	if (ret) {
 		fprintf(stderr, "failed to set %s: %s\n", 
diff --git a/test/forward.c b/test/forward.c
index 81fead5..1628d1a 100644
--- a/test/forward.c
+++ b/test/forward.c
@@ -59,9 +59,9 @@ int main(int argc, char *argv[])
 	}
 
 	if (!strcmp(flag, "on"))
-		ret = ip_forward_on(ifname, family);
+		ret = lxc_ip_forward_on(ifname, family);
 	else if (!strcmp(flag, "off"))
-		ret = ip_forward_off(ifname, family);
+		ret = lxc_ip_forward_off(ifname, family);
 	else {
 		usage(argv[0]);
 		return 1;
diff --git a/test/ipv4_add.c b/test/ipv4_add.c
index bcd0cf9..84046d2 100644
--- a/test/ipv4_add.c
+++ b/test/ipv4_add.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 	
-	ret = ip_addr_add(ifname, addr, 24, NULL);
+	ret = lxc_ip_addr_add(ifname, addr, 24, NULL);
 	if (ret) {
 		fprintf(stderr, "failed to set %s: %s\n", 
 			ifname, strerror(-ret));
diff --git a/test/ipv6_add.c b/test/ipv6_add.c
index 20fc098..13de06f 100644
--- a/test/ipv6_add.c
+++ b/test/ipv6_add.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 	
-	ret = ip6_addr_add(ifname, addr, 64, NULL);
+	ret = lxc_ip6_addr_add(ifname, addr, 64, NULL);
 	if (ret) {
 		fprintf(stderr, "failed to set %s: %s\n", 
 			ifname, strerror(-ret));
diff --git a/test/lxc_low_monitor.c b/test/lxc_low_monitor.c
index 02267d5..318be25 100644
--- a/test/lxc_low_monitor.c
+++ b/test/lxc_low_monitor.c
@@ -51,15 +51,17 @@ int main(int argc, char *argv[])
 	if (!name)
 		usage(argv[0]);
 
-	fd = lxc_monitor_open(name);
+	fd = lxc_monitor_open();
 	if (fd < 0) {
 		fprintf(stderr, "failed to open monitor\n");
 		return -1;
 	}
 	
 	for (;;) {
-		lxc_state_t state;
-		lxc_monitor_read(fd, &state);
-		printf("received changing state '%s'\n", lxc_state2str(state));
+		struct lxc_msg msg;
+		lxc_monitor_read(fd, &msg);
+		if (msg.type == lxc_msg_state) {
+			printf("received changing state '%s'\n", lxc_state2str(msg.value));
+		}
 	}
 }
diff --git a/test/macvlan.c b/test/macvlan.c
index 4401d4f..aad50d8 100644
--- a/test/macvlan.c
+++ b/test/macvlan.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	ret = macvlan_create(ifname, peer);
+	ret = lxc_macvlan_create(ifname, peer);
 	if (ret) {
 		fprintf(stderr, "failed to set %s/%s: %s\n", 
 			ifname, peer, strerror(-ret));
diff --git a/test/movedev.c b/test/movedev.c
index 592434a..1c4d9c3 100644
--- a/test/movedev.c
+++ b/test/movedev.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	if (device_move(ifname, pid)) {
+	if (lxc_device_move(ifname, pid)) {
 		fprintf(stderr, "failed to move %s\n", ifname);
 		return 1;
 	}
diff --git a/test/proxy.c b/test/proxy.c
index f82f492..97ed886 100644
--- a/test/proxy.c
+++ b/test/proxy.c
@@ -59,9 +59,9 @@ int main(int argc, char *argv[])
 	}
 
 	if (!strcmp(flag, "on"))
-		ret = neigh_proxy_on(ifname, family);
+		ret = lxc_neigh_proxy_on(ifname, family);
 	else if (!strcmp(flag, "off"))
-		ret = neigh_proxy_off(ifname, family);
+		ret = lxc_neigh_proxy_off(ifname, family);
 	else {
 		usage(argv[0]);
 		return 1;
diff --git a/test/tst_list.c b/test/tst_list.c
index 933b692..8b8816b 100644
--- a/test/tst_list.c
+++ b/test/tst_list.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <string.h>
-#include <lxc/lxc_list.h>
+#include <lxc/list.h>
 
 int main(int argc, char *argv[])
 {
diff --git a/test/veth.c b/test/veth.c
index 58a784c..a47c62f 100644
--- a/test/veth.c
+++ b/test/veth.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	ret = veth_create(ifname, peer);
+	ret = lxc_veth_create(ifname, peer);
 	if (ret) {
 		fprintf(stderr, "failed to set %s/%s: %s\n", 
 			ifname, peer, strerror(-ret));
-- 
1.6.3.1




More information about the lxc-devel mailing list