[Libct] [PATCH 6/8] tests: update tests accoding with new changes of API

Andrey Vagin avagin at openvz.org
Wed Nov 5 01:40:23 PST 2014


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/ct_cgroup_basic.c      | 4 +++-
 test/ct_cgroup_sub.c        | 4 +++-
 test/ct_create.c            | 4 +++-
 test/ct_create_exec.c       | 4 +++-
 test/ct_enter.c             | 6 ++++--
 test/ct_ext_mount.c         | 4 +++-
 test/ct_kill_nons.c         | 4 +++-
 test/ct_net_host.c          | 4 +++-
 test/ct_net_veth.c          | 4 +++-
 test/ct_pid_enter.c         | 6 ++++--
 test/ct_private_subdir.c    | 4 +++-
 test/ct_private_subdir_ns.c | 4 +++-
 test/ct_proc.c              | 4 +++-
 test/ct_root.c              | 4 +++-
 test/ct_root_enter.c        | 6 ++++--
 test/ct_service.c           | 4 +++-
 test/ct_userns.c            | 4 +++-
 17 files changed, 54 insertions(+), 20 deletions(-)

diff --git a/test/ct_cgroup_basic.c b/test/ct_cgroup_basic.c
index 34cf929..9cde123 100644
--- a/test/ct_cgroup_basic.c
+++ b/test/ct_cgroup_basic.c
@@ -25,6 +25,7 @@ int main(int argc, char **argv)
 	int *ct_state;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 
 	ct_state = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANON, 0, 0);
@@ -33,8 +34,9 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test-fr");
+	p = libct_process_desc_create(s);
 	libct_controller_add(ct, CTL_FREEZER);
-	libct_container_spawn_cb(ct, check_freezer_cg, ct_state);
+	libct_container_spawn_cb(ct, p, check_freezer_cg, ct_state);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_cgroup_sub.c b/test/ct_cgroup_sub.c
index 497baf2..e3e849d 100644
--- a/test/ct_cgroup_sub.c
+++ b/test/ct_cgroup_sub.c
@@ -40,6 +40,7 @@ int main(int argc, char **argv)
 	int *ct_status;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	int fs_err = 0;
 
 	mkdir(FS_ROOT, 0600);
@@ -53,12 +54,13 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	libct_container_set_nsmask(ct, CLONE_NEWNS);
 	libct_controller_add(ct, CTL_FREEZER);
 	libct_fs_set_root(ct, FS_ROOT);
 	libct_fs_set_private(ct, CT_FS_SUBDIR, FS_PRIVATE);
 	libct_container_set_option(ct, LIBCT_OPT_CGROUP_SUBMOUNT, FS_CG);
-	libct_container_spawn_cb(ct, check_cgroup, ct_status);
+	libct_container_spawn_cb(ct, p, check_cgroup, ct_status);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_create.c b/test/ct_create.c
index 94420e4..1042ded 100644
--- a/test/ct_create.c
+++ b/test/ct_create.c
@@ -17,6 +17,7 @@ int main(int argc, char **argv)
 	int *ct_alive;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 
 	ct_alive = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANON, 0, 0);
@@ -24,7 +25,8 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
-	libct_container_spawn_cb(ct, set_ct_alive, ct_alive);
+	p = libct_process_desc_create(s);
+	libct_container_spawn_cb(ct, p, set_ct_alive, ct_alive);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_create_exec.c b/test/ct_create_exec.c
index 1d2904b..ab57c74 100644
--- a/test/ct_create_exec.c
+++ b/test/ct_create_exec.c
@@ -19,6 +19,7 @@ int main(int argc, char **argv)
 {
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	char *piggy_a[4];
 	int fd, master, slave;
 	char dat[sizeof(PIGGY_DATA)];
@@ -27,6 +28,7 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 
 	piggy_a[0] = "file_piggy";
 	piggy_a[1] = PIGGY_FILE;
@@ -51,7 +53,7 @@ int main(int argc, char **argv)
 		goto err;
 
 	fds[0] = fds[1] = fds[2] = slave;
-	if (libct_container_spawn_execvfds(ct, "./file_piggy", piggy_a, fds) < 0)
+	if (libct_container_spawn_execvfds(ct, p, "./file_piggy", piggy_a, fds) < 0)
 		goto err;
 
 	read(master, dat, 3);
diff --git a/test/ct_enter.c b/test/ct_enter.c
index 8efabb3..e37b0ec 100644
--- a/test/ct_enter.c
+++ b/test/ct_enter.c
@@ -37,6 +37,7 @@ int main(int argc, char **argv)
 	int pid, p[2];
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 
 	pipe(p);
 	cta.mark = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
@@ -47,8 +48,9 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
-	libct_container_spawn_cb(ct, set_ct_alive, &cta);
-	pid = libct_container_enter_cb(ct, set_ct_enter, &cta);
+	pr = libct_process_desc_create(s);
+	libct_container_spawn_cb(ct, pr, set_ct_alive, &cta);
+	pid = libct_container_enter_cb(ct, pr, set_ct_enter, &cta);
 	waitpid(pid, NULL, 0);
 	write(p[1], "a", 1);
 	libct_container_wait(ct);
diff --git a/test/ct_ext_mount.c b/test/ct_ext_mount.c
index f451671..a8b0df1 100644
--- a/test/ct_ext_mount.c
+++ b/test/ct_ext_mount.c
@@ -51,6 +51,7 @@ int main(int argc, char **argv)
 	char *fs_data;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	int fs_err = 0;
 
 	mkdir(FS_EXT, 0600);
@@ -67,13 +68,14 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	printf("Set root\n");
 	libct_fs_set_root(ct, FS_ROOT);
 	printf("Set bind\n");
 	libct_fs_add_bind_mount(ct, FS_EXT, FS_DIR, 0);
 	libct_fs_add_mount(ct, "test_devpts", FS_PTS, 0, "devpts", "newinstance");
 	printf("Spawn\n");
-	libct_container_spawn_cb(ct, check_fs_data, fs_data);
+	libct_container_spawn_cb(ct, p, check_fs_data, fs_data);
 	printf("Done\n");
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
diff --git a/test/ct_kill_nons.c b/test/ct_kill_nons.c
index b21edb9..fd72bdc 100644
--- a/test/ct_kill_nons.c
+++ b/test/ct_kill_nons.c
@@ -48,6 +48,7 @@ int main(int argc, char **argv)
 	int p[2];
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 	char c;
 
 	pipe(p);
@@ -59,10 +60,11 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test-k");
+	pr = libct_process_desc_create(s);
 	if (libct_container_set_option(ct, LIBCT_OPT_KILLABLE, NULL))
 		return err("can't set killable");
 
-	if (libct_container_spawn_cb(ct, loop_in_ct, &cta) < 0)
+	if (libct_container_spawn_cb(ct, pr, loop_in_ct, &cta) < 0)
 		return err("can't start CT");
 
 	close(p[1]);
diff --git a/test/ct_net_host.c b/test/ct_net_host.c
index 7ef6f0b..934f757 100644
--- a/test/ct_net_host.c
+++ b/test/ct_net_host.c
@@ -27,6 +27,7 @@ int main(int argc, char **argv)
 	int *ct_status;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	ct_net_t nd;
 
 	ct_status = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
@@ -40,6 +41,7 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	libct_container_set_nsmask(ct, CLONE_NEWNET);
 
 	nd = libct_net_add(ct, CT_NET_HOSTNIC, "dm0");
@@ -47,7 +49,7 @@ int main(int argc, char **argv)
 		system("ip link del dm0");
 		return err("Can't add hostnic");
 	}
-	if (libct_container_spawn_cb(ct, check_ct_net, ct_status) < 0) {
+	if (libct_container_spawn_cb(ct, p, check_ct_net, ct_status) < 0) {
 		system("ip link del dm0");
 		return err("Can't spawn CT");
 	}
diff --git a/test/ct_net_veth.c b/test/ct_net_veth.c
index e52cbbc..dc7be15 100644
--- a/test/ct_net_veth.c
+++ b/test/ct_net_veth.c
@@ -39,6 +39,7 @@ int main(int argc, char **argv)
 	struct ct_arg ca;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 	struct ct_net_veth_arg va;
 	ct_net_t nd;
 
@@ -56,6 +57,7 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	pr = libct_process_desc_create(s);
 	libct_container_set_nsmask(ct, CLONE_NEWNET);
 
 	nd = libct_net_add(ct, CT_NET_VETH, &va);
@@ -65,7 +67,7 @@ int main(int argc, char **argv)
 	if (libct_net_dev_set_mac_addr(nd, "00:11:22:33:44:55"))
 		return err("Can't set mac");
 
-	if (libct_container_spawn_cb(ct, check_ct_net, &ca) < 0)
+	if (libct_container_spawn_cb(ct, pr, check_ct_net, &ca) < 0)
 		return err("Can't spawn CT");
 
 	if (!system("ip link l " VETH_HOST_NAME ""))
diff --git a/test/ct_pid_enter.c b/test/ct_pid_enter.c
index 133e24c..919217a 100644
--- a/test/ct_pid_enter.c
+++ b/test/ct_pid_enter.c
@@ -43,6 +43,7 @@ int main(int argc, char **argv)
 	int pid, p[2];
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 
 	pipe(p);
 	cta.mark = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
@@ -55,9 +56,10 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	pr = libct_process_desc_create(s);
 	libct_container_set_nsmask(ct, CLONE_NEWPID);
-	libct_container_spawn_cb(ct, set_ct_alive, &cta);
-	pid = libct_container_enter_cb(ct, set_ct_enter, &cta);
+	libct_container_spawn_cb(ct, pr, set_ct_alive, &cta);
+	pid = libct_container_enter_cb(ct, pr, set_ct_enter, &cta);
 	if (waitpid(pid, NULL, 0) < 0)
 		perror("Can't wait entered process");
 
diff --git a/test/ct_private_subdir.c b/test/ct_private_subdir.c
index 7c4765b..ff578fa 100644
--- a/test/ct_private_subdir.c
+++ b/test/ct_private_subdir.c
@@ -35,6 +35,7 @@ int main(int argc, char **argv)
 	char *fs_data;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	int fs_err = 0;
 
 	mkdir(FS_ROOT, 0600);
@@ -49,9 +50,10 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	libct_fs_set_root(ct, FS_ROOT);
 	libct_fs_set_private(ct, CT_FS_SUBDIR, FS_PRIVATE);
-	libct_container_spawn_cb(ct, check_fs_data, fs_data);
+	libct_container_spawn_cb(ct, p, check_fs_data, fs_data);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_private_subdir_ns.c b/test/ct_private_subdir_ns.c
index 1d8e63f..63b6abb 100644
--- a/test/ct_private_subdir_ns.c
+++ b/test/ct_private_subdir_ns.c
@@ -39,6 +39,7 @@ int main(int argc, char **argv)
 	char *fs_data;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 	int fs_err = 0;
 
 	mkdir(FS_ROOT, 0600);
@@ -53,10 +54,11 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	libct_container_set_nsmask(ct, CLONE_NEWNS);
 	libct_fs_set_root(ct, FS_ROOT);
 	libct_fs_set_private(ct, CT_FS_SUBDIR, FS_PRIVATE);
-	libct_container_spawn_cb(ct, check_fs_data, fs_data);
+	libct_container_spawn_cb(ct, p, check_fs_data, fs_data);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_proc.c b/test/ct_proc.c
index 8667be7..eb24ba1 100644
--- a/test/ct_proc.c
+++ b/test/ct_proc.c
@@ -37,6 +37,7 @@ int main(int argc, char **argv)
 	int *ct_root_pids;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 
 	ct_root_pids = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANON, 0, 0);
@@ -45,12 +46,13 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	if (libct_container_set_nsmask(ct, CLONE_NEWPID | CLONE_NEWNS))
 		return err("No pid & mount NS");
 
 	libct_container_set_option(ct, LIBCT_OPT_AUTO_PROC_MOUNT, NULL);
 
-	libct_container_spawn_cb(ct, set_ct_root_pids, ct_root_pids);
+	libct_container_spawn_cb(ct, p, set_ct_root_pids, ct_root_pids);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_root.c b/test/ct_root.c
index 4b61c37..7da98cc 100644
--- a/test/ct_root.c
+++ b/test/ct_root.c
@@ -35,6 +35,7 @@ int main(int argc, char **argv)
 	char *fs_data;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 
 	mkdir(FS_ROOT, 0600);
 	fd = open(FS_ROOT "/" FS_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0600);
@@ -50,8 +51,9 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	libct_fs_set_root(ct, FS_ROOT);
-	libct_container_spawn_cb(ct, check_fs_data, fs_data);
+	libct_container_spawn_cb(ct, p, check_fs_data, fs_data);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
diff --git a/test/ct_root_enter.c b/test/ct_root_enter.c
index 91fc96d..19d3889 100644
--- a/test/ct_root_enter.c
+++ b/test/ct_root_enter.c
@@ -62,6 +62,7 @@ int main(int argc, char **argv)
 	struct ct_arg cta;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 
 	pipe(p);
 
@@ -81,9 +82,10 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	pr = libct_process_desc_create(s);
 	libct_fs_set_root(ct, FS_ROOT);
-	libct_container_spawn_cb(ct, ct_main_fn, &cta);
-	pid = libct_container_enter_cb(ct, ct_enter_fn, &cta);
+	libct_container_spawn_cb(ct, pr, ct_main_fn, &cta);
+	pid = libct_container_enter_cb(ct, pr, ct_enter_fn, &cta);
 	waitpid(pid, NULL, 0);
 	write(p[1], "a", 1);
 	libct_container_wait(ct);
diff --git a/test/ct_service.c b/test/ct_service.c
index 4924792..29c393a 100644
--- a/test/ct_service.c
+++ b/test/ct_service.c
@@ -56,6 +56,7 @@ int main(int argc, char **argv)
 	int p[2], p2[2];
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t pr;
 	int cg_ok = 0;
 	char c;
 
@@ -69,10 +70,11 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test-s");
+	pr = libct_process_desc_create(s);
 	if (libct_container_set_option(ct, LIBCT_OPT_KILLABLE, NULL))
 		return err("can't set killable");
 
-	if (libct_container_spawn_cb(ct, set_ct_alive, &cta) < 0)
+	if (libct_container_spawn_cb(ct, pr, set_ct_alive, &cta) < 0)
 		return err("can't start CT");
 
 	read(p2[0], &c, 1);
diff --git a/test/ct_userns.c b/test/ct_userns.c
index 3e7d076..d35ade8 100644
--- a/test/ct_userns.c
+++ b/test/ct_userns.c
@@ -40,6 +40,7 @@ int main(int argc, char **argv)
 	int *ct_alive;
 	libct_session_t s;
 	ct_handler_t ct;
+	ct_process_desc_t p;
 
 	ct_alive = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANON, 0, 0);
@@ -47,6 +48,7 @@ int main(int argc, char **argv)
 
 	s = libct_session_open_local();
 	ct = libct_container_create(s, "test");
+	p = libct_process_desc_create(s);
 	if (libct_container_set_nsmask(ct, CLONE_NEWPID | CLONE_NEWUSER | CLONE_NEWNS))
 		return 1;
 
@@ -67,7 +69,7 @@ int main(int argc, char **argv)
 	    libct_userns_add_gid_map(ct, 0, 140000, 1200) ||
 	    libct_userns_add_gid_map(ct, 1200, 150000, 1100))
 		return 1;
-	libct_container_spawn_cb(ct, set_ct_alive, ct_alive);
+	libct_container_spawn_cb(ct, p, set_ct_alive, ct_alive);
 	libct_container_wait(ct);
 	libct_container_destroy(ct);
 	libct_session_close(s);
-- 
1.9.1



More information about the Libct mailing list