[Libct] [PATCH] test: compile tests with -Werror -Wall

Andrey Vagin avagin at openvz.org
Tue Oct 28 08:42:06 PDT 2014


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/Makefile               |  2 +-
 test/ct_cgroup_sub.c        | 11 +++++++----
 test/ct_create_exec.c       |  2 ++
 test/ct_enter.c             |  2 ++
 test/ct_ext_mount.c         |  8 +++++---
 test/ct_kill_nons.c         |  2 ++
 test/ct_net_host.c          |  2 ++
 test/ct_net_veth.c          |  3 +++
 test/ct_pid_enter.c         |  2 ++
 test/ct_private_subdir.c    |  7 +++++--
 test/ct_private_subdir_ns.c |  7 +++++--
 test/ct_proc.c              |  2 ++
 test/ct_root.c              |  5 ++++-
 test/ct_root_enter.c        |  5 ++++-
 test/ct_service.c           |  5 ++++-
 15 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/test/Makefile b/test/Makefile
index c91bad1..c553b23 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,7 +7,7 @@ TESTS =	ct_create ct_enter ct_proc ct_root ct_root_enter \
 PIGS  = file_piggy
 
 CC = gcc
-CFLAGS = -I../src/include/uapi/ -g
+CFLAGS = -I../src/include/uapi/ -g -Wall -Werror
 LIBNLDIR = ../.shipped/libnl/lib/.libs
 LDFLAGS = -Wl,--no-as-needed \
 	-lct -L../src/ -Wl,-rpath,'$$ORIGIN/../src' \
diff --git a/test/ct_cgroup_sub.c b/test/ct_cgroup_sub.c
index a3e36fd..497baf2 100644
--- a/test/ct_cgroup_sub.c
+++ b/test/ct_cgroup_sub.c
@@ -9,6 +9,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "test.h"
 
 #ifndef CLONE_NEWNS
@@ -24,7 +27,7 @@ static int check_cgroup(void *a)
 	int *s = a;
 
 	s[0] = 1;
-	mkdir("/"FS_CG"/freezer/x");
+	mkdir("/"FS_CG"/freezer/x", 0600);
 	if (access("/"FS_CG"/freezer/x/freezer.state", F_OK) == 0)
 		s[1] = 1;
 	rmdir("/"FS_CG"/freezer/x");
@@ -39,9 +42,9 @@ int main(int argc, char **argv)
 	ct_handler_t ct;
 	int fs_err = 0;
 
-	mkdir(FS_ROOT);
-	mkdir(FS_PRIVATE);
-	mkdir(FS_PRIVATE "/" FS_CG);
+	mkdir(FS_ROOT, 0600);
+	mkdir(FS_PRIVATE, 0600);
+	mkdir(FS_PRIVATE "/" FS_CG, 0600);
 
 	ct_status = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANON, 0, 0);
diff --git a/test/ct_create_exec.c b/test/ct_create_exec.c
index f5ce515..1d2904b 100644
--- a/test/ct_create_exec.c
+++ b/test/ct_create_exec.c
@@ -8,6 +8,8 @@
 #include <fcntl.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "test.h"
 
 #define PIGGY_FILE	"libct_piggy_file"
diff --git a/test/ct_enter.c b/test/ct_enter.c
index 4d65177..8efabb3 100644
--- a/test/ct_enter.c
+++ b/test/ct_enter.c
@@ -5,6 +5,8 @@
 #include <stdio.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include <unistd.h>
+
 #include "test.h"
 
 struct ct_arg {
diff --git a/test/ct_ext_mount.c b/test/ct_ext_mount.c
index 2852ac8..f451671 100644
--- a/test/ct_ext_mount.c
+++ b/test/ct_ext_mount.c
@@ -9,6 +9,8 @@
 #include <fcntl.h>
 #include <sys/vfs.h>
 #include <linux/magic.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "test.h"
 
@@ -51,12 +53,12 @@ int main(int argc, char **argv)
 	ct_handler_t ct;
 	int fs_err = 0;
 
-	mkdir(FS_EXT);
+	mkdir(FS_EXT, 0600);
 	if (creat(FS_EXT "/" FS_FILE, 0600) < 0)
 		return err("Can't create file");
 
-	mkdir(FS_ROOT);
-	mkdir(FS_ROOT "/" FS_DIR);
+	mkdir(FS_ROOT, 0600);
+	mkdir(FS_ROOT "/" FS_DIR, 0600);
 	unlink(FS_ROOT "/" FS_DIR "/" FS_FILE);
 
 	fs_data = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
diff --git a/test/ct_kill_nons.c b/test/ct_kill_nons.c
index 34c3594..b21edb9 100644
--- a/test/ct_kill_nons.c
+++ b/test/ct_kill_nons.c
@@ -7,6 +7,8 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "test.h"
 
 struct ct_arg {
diff --git a/test/ct_net_host.c b/test/ct_net_host.c
index 7bfca16..7ef6f0b 100644
--- a/test/ct_net_host.c
+++ b/test/ct_net_host.c
@@ -7,6 +7,8 @@
 #include <stdio.h>
 #include <sys/mman.h>
 #include <sched.h>
+#include <stdlib.h>
+
 #include "test.h"
 
 static int check_ct_net(void *a)
diff --git a/test/ct_net_veth.c b/test/ct_net_veth.c
index 8d43a7e..e52cbbc 100644
--- a/test/ct_net_veth.c
+++ b/test/ct_net_veth.c
@@ -7,6 +7,9 @@
 #include <stdio.h>
 #include <sys/mman.h>
 #include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+
 #include "test.h"
 
 #define VETH_HOST_NAME	"hveth0"
diff --git a/test/ct_pid_enter.c b/test/ct_pid_enter.c
index 198ca38..133e24c 100644
--- a/test/ct_pid_enter.c
+++ b/test/ct_pid_enter.c
@@ -5,6 +5,8 @@
 #include <stdio.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include <unistd.h>
+
 #include "test.h"
 
 #ifndef CLONE_NEWPID
diff --git a/test/ct_private_subdir.c b/test/ct_private_subdir.c
index 97bba39..7c4765b 100644
--- a/test/ct_private_subdir.c
+++ b/test/ct_private_subdir.c
@@ -7,6 +7,9 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "test.h"
 
 #define FS_ROOT		"libct_test_root"
@@ -34,8 +37,8 @@ int main(int argc, char **argv)
 	ct_handler_t ct;
 	int fs_err = 0;
 
-	mkdir(FS_ROOT);
-	mkdir(FS_PRIVATE);
+	mkdir(FS_ROOT, 0600);
+	mkdir(FS_PRIVATE, 0600);
 	if (creat(FS_PRIVATE "/" FS_FILE, 0600) < 0)
 		return err("Can't create file");
 	unlink(FS_ROOT "/" FS_FILE);
diff --git a/test/ct_private_subdir_ns.c b/test/ct_private_subdir_ns.c
index 431f073..1d8e63f 100644
--- a/test/ct_private_subdir_ns.c
+++ b/test/ct_private_subdir_ns.c
@@ -7,6 +7,9 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "test.h"
 
 #ifndef CLONE_NEWNS
@@ -38,8 +41,8 @@ int main(int argc, char **argv)
 	ct_handler_t ct;
 	int fs_err = 0;
 
-	mkdir(FS_ROOT);
-	mkdir(FS_PRIVATE);
+	mkdir(FS_ROOT, 0600);
+	mkdir(FS_PRIVATE, 0600);
 	if (creat(FS_PRIVATE "/" FS_FILE, 0600) < 0)
 		return err("Can't create file");
 	unlink(FS_ROOT "/" FS_FILE);
diff --git a/test/ct_proc.c b/test/ct_proc.c
index f4ac93c..8667be7 100644
--- a/test/ct_proc.c
+++ b/test/ct_proc.c
@@ -7,6 +7,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <sched.h>
+#include <stdlib.h>
+
 #include "test.h"
 
 #ifndef CLONE_NEWNS
diff --git a/test/ct_root.c b/test/ct_root.c
index 5de9caa..4b61c37 100644
--- a/test/ct_root.c
+++ b/test/ct_root.c
@@ -7,6 +7,9 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "test.h"
 
 #define FS_ROOT	"libct_test_root"
@@ -33,7 +36,7 @@ int main(int argc, char **argv)
 	libct_session_t s;
 	ct_handler_t ct;
 
-	mkdir(FS_ROOT);
+	mkdir(FS_ROOT, 0600);
 	fd = open(FS_ROOT "/" FS_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0600);
 	if (fd < 0)
 		return err("Can't create file");
diff --git a/test/ct_root_enter.c b/test/ct_root_enter.c
index 35fed6e..91fc96d 100644
--- a/test/ct_root_enter.c
+++ b/test/ct_root_enter.c
@@ -8,6 +8,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
 #include "test.h"
 
 #define FS_ROOT	"libct_test_root"
@@ -62,7 +65,7 @@ int main(int argc, char **argv)
 
 	pipe(p);
 
-	mkdir(FS_ROOT);
+	mkdir(FS_ROOT, 0600);
 	fd = open(FS_ROOT "/" FS_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0600);
 	if (fd < 0)
 		return err("Can't create file");
diff --git a/test/ct_service.c b/test/ct_service.c
index ee07c75..4924792 100644
--- a/test/ct_service.c
+++ b/test/ct_service.c
@@ -6,6 +6,9 @@
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+
 #include "test.h"
 
 struct ct_arg {
@@ -50,7 +53,7 @@ static int check_service_cg(int pid)
 int main(int argc, char **argv)
 {
 	struct ct_arg cta;
-	int pid, p[2], p2[2];
+	int p[2], p2[2];
 	libct_session_t s;
 	ct_handler_t ct;
 	int cg_ok = 0;
-- 
1.9.1



More information about the Libct mailing list