[Libct] [PATCH] test: add list of tests, which should be executed for all drivers
Pavel Emelyanov
xemul at parallels.com
Wed Nov 19 03:17:36 PST 2014
$ patch -p1 --dry-run < dif-
checking file test/Makefile
Hunk #1 FAILED at 1.
Hunk #2 succeeded at 5 (offset -2 lines).
Hunk #3 FAILED at 24.
Hunk #4 succeeded at 40 (offset -12 lines).
Hunk #5 succeeded at 55 (offset -12 lines).
2 out of 5 hunks FAILED
Smth is missing.
On 11/19/2014 03:00 PM, Andrey Vagin wrote:
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> test/Makefile | 19 +++++++++++++------
> test/vz_create_exec.c | 2 +-
> test/vz_enter.c | 23 ++++++++++++++++++-----
> test/vz_net_veth.c | 2 +-
> 4 files changed, 33 insertions(+), 13 deletions(-)
>
> diff --git a/test/Makefile b/test/Makefile
> index f199873..435b8c8 100644
> --- a/test/Makefile
> +++ b/test/Makefile
> @@ -1,5 +1,7 @@
> include ../Makefile.config
>
> +COMMON_TESTS = vz_create_exec vz_net_veth vz_enter
> +
> LOCAL_TESTS = ct_create ct_enter ct_proc ct_root ct_root_enter \
> ct_create_exec ct_cgroup_basic ct_net_host \
> ct_net_veth ct_private_subdir \
> @@ -7,10 +9,9 @@ LOCAL_TESTS = ct_create ct_enter ct_proc ct_root ct_root_enter \
> ct_cgroup_sub ct_service ct_kill_nons ct_pid_enter \
> ct_userns ct_caps
>
> -VZ_TESTS = vz_create_exec vz_net_veth vz_enter \
> - vz_cgroup_memory vz_cgroup_cpu vz_cgroup_blkio
> +VZ_TESTS = vz_cgroup_memory vz_cgroup_cpu vz_cgroup_blkio
>
> -TESTS = $(LOCAL_TESTS) $(VZ_TESTS)
> +TESTS = $(LOCAL_TESTS) $(VZ_TESTS) $(COMMON_TESTS)
>
> PIGS = file_piggy
>
> @@ -25,12 +26,13 @@ LDFLAGS = -Wl,--no-as-needed \
> -lct -L../src/ -Wl,-rpath,'$$ORIGIN/../src' \
> -lnl-route-3 -lnl-3 -L$(LIBNLDIR) -Wl,-rpath,'$$ORIGIN/$(LIBNLDIR)'
>
> +COMMON_OUTS = $(COMMON_TESTS:%=%.out)
> LOCAL_OUTS = $(LOCAL_TESTS:%=%.out)
> VZ_OUTS = $(VZ_TESTS:%=%.out)
>
> ifdef CONFIG_APPARMOR
> LDFLAGS += -lapparmor
> -TESTS += ct_apparmor
> +LOCAL_TESTS += ct_apparmor
> endif
>
> ifdef CONFIG_SELINUX
> @@ -53,6 +55,7 @@ clean: cleanouts
> rm -f $(TESTS)
> rm -f $(PIGS)
> rm -f $(OBJS)
> + rm -rf root
>
> %.o: %.c
> $(CC) -c $(CFLAGS) $^ -o $@
> @@ -67,10 +70,14 @@ $(1).out: $(1)
> endef
> $(foreach t, $(TESTS), $(eval $(call gen-out,$(t))))
>
> -run-local: cleanouts $(PIGS) $(LOCAL_OUTS)
> +run-local: cleanouts root $(PIGS) $(LOCAL_OUTS) $(COMMON_OUTS)
>
> -run-vz: cleanouts $(VZ_OUTS)
> +run-vz: cleanouts root $(VZ_OUTS) $(COMMON_TESTS)
>
> run: cleanouts $(PIGS) $(OUTS)
>
> +root:
> + mkdir root
> + curl http://images.linuxcontainers.org/images/ubuntu/utopic/arm64/default/20141008_03:49/rootfs.tar.xz | tar -JxC root
> +
> .PHONY: all local vz clean run run-local run-vz
> diff --git a/test/vz_create_exec.c b/test/vz_create_exec.c
> index cb557bd..4363667 100644
> --- a/test/vz_create_exec.c
> +++ b/test/vz_create_exec.c
> @@ -6,7 +6,7 @@
>
> #include "test.h"
>
> -#define FS_ROOT "/"
> +#define FS_ROOT "root"
> int main(int argc, char *argv[])
> {
> libct_session_t s;
> diff --git a/test/vz_enter.c b/test/vz_enter.c
> index d7e26f9..ab1cc25 100644
> --- a/test/vz_enter.c
> +++ b/test/vz_enter.c
> @@ -3,18 +3,22 @@
> #include <libct.h>
> #include <unistd.h>
> #include <linux/sched.h>
> +#include <sys/types.h>
> +#include <sys/wait.h>
>
> #include "test.h"
>
> -#define FS_ROOT "/"
> +#define FS_ROOT "root"
> int main(int argc, char *argv[])
> {
> libct_session_t s;
> ct_handler_t ct;
> ct_process_desc_t p;
> - char *sleep_a[] = { "sleep", "60", NULL};
> - char *ls_a[] = { "ls", "/root/work/libct/test", NULL};
> + char *sleep_a[] = { "read", NULL};
> + char *ls_a[] = { "sh", "-c", "echo ok > test.file", NULL};
> int fds[] = {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO};
> + int pfd[2], status;
> + pid_t pid;
>
> s = libct_session_open_local();
> ct = libct_container_create(s, "1339");
> @@ -28,11 +32,20 @@ int main(int argc, char *argv[])
> CLONE_NEWNET |
> CLONE_NEWPID);
>
> - if (libct_container_spawn_execvfds(ct, p, "/bin/sleep", sleep_a, fds) <= 0)
> + if (pipe(pfd))
> goto err;
>
> - if (libct_container_enter_execvfds(ct, p, "/bin/ls", ls_a, fds) <= 0)
> + fds[0] = pfd[1];
> + if (libct_container_spawn_execvfds(ct, p, "/bin/read", sleep_a, fds) <= 0)
> goto err;
> + close(pfd[1]);
> +
> + pid = libct_container_enter_execvfds(ct, p, "/bin/sh", ls_a, fds);
> + if (pid < 0)
> + goto err;
> + waitpid(pid, &status, 0);
> +
> + close(pfd[0]);
>
> libct_container_wait(ct);
> libct_container_destroy(ct);
> diff --git a/test/vz_net_veth.c b/test/vz_net_veth.c
> index 89a35bf..ac56347 100644
> --- a/test/vz_net_veth.c
> +++ b/test/vz_net_veth.c
> @@ -9,7 +9,7 @@
> #define VETH_HOST_NAME "hveth0"
> #define VETH_CT_NAME "cveth0"
>
> -#define FS_ROOT "/"
> +#define FS_ROOT "root"
> int main(int argc, char *argv[])
> {
> libct_session_t s;
>
More information about the Libct
mailing list