[lxc-devel] [lxc/master] tests: cleanup source codes.

2xsec on Github lxc-bot at linuxcontainers.org
Tue Jul 3 09:33:06 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 387 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180703/588df7c6/attachment.bin>
-------------- next part --------------
From 2e338007c7801b52385dc4b061fd085199b069f0 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:09:32 +0900
Subject: [PATCH 01/25] tests: cleanup api_reboot.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/api_reboot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/tests/api_reboot.c b/src/tests/api_reboot.c
index d169510b5..730d6a81a 100644
--- a/src/tests/api_reboot.c
+++ b/src/tests/api_reboot.c
@@ -59,6 +59,7 @@ int main(int argc, char *argv[])
 		lxc_error("%s\n", "Container \"reboot\" is not defined");
 		goto on_error_put;
 	}
+
 	c->clear_config(c);
 
 	if (!c->load_config(c, NULL)) {
@@ -118,7 +119,9 @@ int main(int argc, char *argv[])
 
 on_error_put:
 	lxc_container_put(c);
+
 	if (ret == EXIT_SUCCESS)
 		lxc_debug("%s\n", "All reboot tests passed");
+
 	exit(ret);
 }

From 1c95b732d896a40cd8c7af971085637b73bd943a Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:10:55 +0900
Subject: [PATCH 02/25] tests: cleanup clonetest.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/clonetest.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/tests/clonetest.c b/src/tests/clonetest.c
index 814706d27..f3a8e5b0b 100644
--- a/src/tests/clonetest.c
+++ b/src/tests/clonetest.c
@@ -41,6 +41,7 @@ int main(int argc, char *argv[])
 		lxc_container_put(c);
 		c = NULL;
 	}
+
 	if (c2) {
 		c2->destroy(c2);
 		lxc_container_put(c2);
@@ -52,11 +53,14 @@ int main(int argc, char *argv[])
 		ret = 1;
 		goto out;
 	}
+
 	c->save_config(c, NULL);
+
 	if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
 		fprintf(stderr, "%d: failed to create a container\n", __LINE__);
 		goto out;
 	}
+
 	c->load_config(c, NULL);
 
 	if (!c->is_defined(c)) {
@@ -92,12 +96,14 @@ int main(int argc, char *argv[])
 			c2->destroy(c2);
 		lxc_container_put(c2);
 	}
+
 	c2 = lxc_container_new("clonetest-o1", NULL);
 	if (c2) {
 		if (c2->is_defined(c2))
 			c2->destroy(c2);
 		lxc_container_put(c2);
 	}
+
 	c2 = lxc_container_new("clonetest-o2", NULL);
 	if (c2) {
 		if (c2->is_defined(c2))
@@ -112,6 +118,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "failed loading clonetestlvm1\n");
 		goto out;
 	}
+
 	if (!c->is_defined(c)) {
 		fprintf(stderr, "clonetestlvm1 does not exist, skipping lvm tests\n");
 		ret = 0;
@@ -138,6 +145,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "lvm clone failed\n");
 		goto out;
 	}
+
 	lxc_container_put(c2);
 	lxc_container_put(c);
 	c = c2 = NULL;
@@ -166,13 +174,16 @@ int main(int argc, char *argv[])
 	if (c3) {
 		lxc_container_put(c3);
 	}
+
 	if (c2) {
 		c2->destroy(c2);
 		lxc_container_put(c2);
 	}
+
 	if (c) {
 		c->destroy(c);
 		lxc_container_put(c);
 	}
+
 	exit(ret);
 }

From fbeb7a1a24cef6899b6a4f505e81d53c05d405b3 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:11:46 +0900
Subject: [PATCH 03/25] tests: cleanup concurrent.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/concurrent.c | 413 +++++++++++++++++++++++++------------------------
 1 file changed, 213 insertions(+), 200 deletions(-)

diff --git a/src/tests/concurrent.c b/src/tests/concurrent.c
index c41e9f48f..87d2ae978 100644
--- a/src/tests/concurrent.c
+++ b/src/tests/concurrent.c
@@ -35,223 +35,236 @@ static int delay = 0;
 static const char *template = "busybox";
 
 static const struct option options[] = {
-    { "threads",     required_argument, NULL, 'j' },
-    { "iterations",  required_argument, NULL, 'i' },
-    { "template",    required_argument, NULL, 't' },
-    { "delay",       required_argument, NULL, 'd' },
-    { "modes",       required_argument, NULL, 'm' },
-    { "quiet",       no_argument,       NULL, 'q' },
-    { "debug",       no_argument,       NULL, 'D' },
-    { "help",        no_argument,       NULL, '?' },
-    { 0, 0, 0, 0 },
+	{ "threads",     required_argument, NULL, 'j' },
+	{ "iterations",  required_argument, NULL, 'i' },
+	{ "template",    required_argument, NULL, 't' },
+	{ "delay",       required_argument, NULL, 'd' },
+	{ "modes",       required_argument, NULL, 'm' },
+	{ "quiet",       no_argument,       NULL, 'q' },
+	{ "debug",       no_argument,       NULL, 'D' },
+	{ "help",        no_argument,       NULL, '?' },
+	{ 0, 0, 0, 0 },
 };
 
 static void usage(void) {
-    fprintf(stderr, "Usage: lxc-test-concurrent [OPTION]...\n\n"
-        "Common options :\n"
-        "  -j, --threads=N              Threads to run concurrently\n"
-        "                               (default: 5, use 1 for no threading)\n"
-        "  -i, --iterations=N           Number times to run the test (default: 1)\n"
-        "  -t, --template=t             Template to use (default: busybox)\n"
-        "  -d, --delay=N                Delay in seconds between start and stop\n"
-        "  -m, --modes=<mode,mode,...>  Modes to run (create, start, stop, destroy)\n"
-        "  -q, --quiet                  Don't produce any output\n"
-        "  -D, --debug                  Create a debug log\n"
-        "  -?, --help                   Give this help list\n"
-        "\n"
-        "Mandatory or optional arguments to long options are also mandatory or optional\n"
-        "for any corresponding short options.\n\n");
+	fprintf(stderr, "Usage: lxc-test-concurrent [OPTION]...\n\n"
+	        "Common options :\n"
+	        "  -j, --threads=N              Threads to run concurrently\n"
+	        "                               (default: 5, use 1 for no threading)\n"
+	        "  -i, --iterations=N           Number times to run the test (default: 1)\n"
+	        "  -t, --template=t             Template to use (default: busybox)\n"
+	        "  -d, --delay=N                Delay in seconds between start and stop\n"
+	        "  -m, --modes=<mode,mode,...>  Modes to run (create, start, stop, destroy)\n"
+	        "  -q, --quiet                  Don't produce any output\n"
+	        "  -D, --debug                  Create a debug log\n"
+	        "  -?, --help                   Give this help list\n"
+	        "\n"
+	        "Mandatory or optional arguments to long options are also mandatory or optional\n"
+	        "for any corresponding short options.\n\n");
 }
 
 struct thread_args {
-    int thread_id;
-    int return_code;
-    const char *mode;
+	int thread_id;
+	int return_code;
+	const char *mode;
 };
 
 static void do_function(void *arguments)
 {
-    char name[NAME_MAX+1];
-    struct thread_args *args = arguments;
-    struct lxc_container *c;
-
-    sprintf(name, "lxc-test-concurrent-%d", args->thread_id);
-
-    args->return_code = 1;
-    c = lxc_container_new(name, NULL);
-    if (!c) {
-        fprintf(stderr, "Unable to instantiate container (%s)\n", name);
-        return;
-    }
-
-    if (debug)
-        c->set_config_item(c, "lxc.log.level", "DEBUG");
-
-    if (strcmp(args->mode, "create") == 0) {
-        if (!c->is_defined(c)) {
-            if (!c->create(c, template, NULL, NULL, 1, NULL)) {
-                fprintf(stderr, "Creating the container (%s) failed...\n", name);
-                goto out;
-            }
-        }
-    } else if(strcmp(args->mode, "start") == 0) {
-        if (c->is_defined(c) && !c->is_running(c)) {
-            c->want_daemonize(c, true);
-            if (!c->start(c, false, NULL)) {
-                fprintf(stderr, "Starting the container (%s) failed...\n", name);
-                goto out;
-            }
-            if (!c->wait(c, "RUNNING", 15)) {
-                fprintf(stderr, "Waiting the container (%s) to start failed...\n", name);
-                goto out;
-            }
-            sleep(delay);
-        }
-    } else if(strcmp(args->mode, "stop") == 0) {
-        if (c->is_defined(c) && c->is_running(c)) {
-            if (!c->stop(c)) {
-                fprintf(stderr, "Stopping the container (%s) failed...\n", name);
-                goto out;
-            }
-            if (!c->wait(c, "STOPPED", 15)) {
-                fprintf(stderr, "Waiting the container (%s) to stop failed...\n", name);
-                goto out;
-            }
-        }
-    } else if(strcmp(args->mode, "destroy") == 0) {
-        if (c->is_defined(c) && !c->is_running(c)) {
-            if (!c->destroy(c)) {
-                fprintf(stderr, "Destroying the container (%s) failed...\n", name);
-                goto out;
-            }
-        }
-    }
-    args->return_code = 0;
+	char name[NAME_MAX + 1];
+	struct thread_args *args = arguments;
+	struct lxc_container *c;
+
+	sprintf(name, "lxc-test-concurrent-%d", args->thread_id);
+
+	args->return_code = 1;
+
+	c = lxc_container_new(name, NULL);
+	if (!c) {
+		fprintf(stderr, "Unable to instantiate container (%s)\n", name);
+		return;
+	}
+
+	if (debug)
+		c->set_config_item(c, "lxc.log.level", "DEBUG");
+
+	if (strcmp(args->mode, "create") == 0) {
+		if (!c->is_defined(c)) {
+			if (!c->create(c, template, NULL, NULL, 1, NULL)) {
+				fprintf(stderr, "Creating the container (%s) failed...\n", name);
+				goto out;
+			}
+		}
+	} else if(strcmp(args->mode, "start") == 0) {
+		if (c->is_defined(c) && !c->is_running(c)) {
+			c->want_daemonize(c, true);
+
+			if (!c->start(c, false, NULL)) {
+				fprintf(stderr, "Starting the container (%s) failed...\n", name);
+				goto out;
+			}
+
+			if (!c->wait(c, "RUNNING", 15)) {
+				fprintf(stderr, "Waiting the container (%s) to start failed...\n", name);
+				goto out;
+			}
+
+			sleep(delay);
+		}
+	} else if(strcmp(args->mode, "stop") == 0) {
+		if (c->is_defined(c) && c->is_running(c)) {
+			if (!c->stop(c)) {
+				fprintf(stderr, "Stopping the container (%s) failed...\n", name);
+				goto out;
+			}
+
+			if (!c->wait(c, "STOPPED", 15)) {
+				fprintf(stderr, "Waiting the container (%s) to stop failed...\n", name);
+				goto out;
+			}
+		}
+	} else if(strcmp(args->mode, "destroy") == 0) {
+		if (c->is_defined(c) && !c->is_running(c)) {
+			if (!c->destroy(c)) {
+				fprintf(stderr, "Destroying the container (%s) failed...\n", name);
+				goto out;
+			}
+		}
+	}
+
+	args->return_code = 0;
+
 out:
-    lxc_container_put(c);
-    if (debug)
-        lxc_log_close();
+	lxc_container_put(c);
+
+	if (debug)
+		lxc_log_close();
 }
 
 static void *concurrent(void *arguments)
 {
-    do_function(arguments);
-    pthread_exit(NULL);
+	do_function(arguments);
+	pthread_exit(NULL);
 
-    return NULL;
+	return NULL;
 }
 
 int main(int argc, char *argv[]) {
-    int i, j, iter, opt;
-    pthread_attr_t attr;
-    pthread_t *threads;
-    struct thread_args *args;
-
-    char *modes_default[] = {"create", "start", "stop", "destroy", NULL};
-    char **modes = modes_default;
-
-    pthread_attr_init(&attr);
-
-    while ((opt = getopt_long(argc, argv, "j:i:t:d:m:qD", options, NULL)) != -1) {
-        switch(opt) {
-        case 'j':
-            nthreads = atoi(optarg);
-            break;
-        case 'i':
-            iterations = atoi(optarg);
-            break;
-        case 't':
-            template = optarg;
-            break;
-        case 'd':
-            delay = atoi(optarg);
-            break;
-        case 'q':
-            quiet = 1;
-            break;
-        case 'D':
-            debug = 1;
-            break;
-        case 'm': {
-            char *mode_tok, *tok, *saveptr = NULL;
-
-	    if (!optarg)
-                continue;
-
-            modes = NULL;
-            for (i = 0, mode_tok = optarg;
-                 (tok = strtok_r(mode_tok, ",", &saveptr));
-                i++, mode_tok = NULL) {
-                modes = realloc(modes, sizeof(*modes) * (i+2));
-                if (!modes) {
-                    perror("realloc");
-                    exit(EXIT_FAILURE);
-                }
-                modes[i] = tok;
-            }
-	    if (modes)
-		    modes[i] = NULL;
-            break;
-        }
-        default: /* '?' */
-            usage();
-            exit(EXIT_FAILURE);
-        }
-    }
-
-    threads = malloc(sizeof(*threads) * nthreads);
-    args = malloc(sizeof(*args) * nthreads);
-    if (threads == NULL || args == NULL) {
-        fprintf(stderr, "Unable malloc enough memory for %d threads\n", nthreads);
-        exit(EXIT_FAILURE);
-    }
-
-    for (iter = 1; iter <= iterations; iter++) {
-        int fd;
-        fd = open("/", O_RDONLY);
-        if (fd < 0) {
-            fprintf(stderr, "Failed to open /\n");
-            continue;
-        }
-
-        if (!quiet)
-            printf("\nIteration %d/%d maxfd:%d\n", iter, iterations, fd);
-        close(fd);
-
-        for (i = 0; modes[i];i++) {
-            if (!quiet)
-                printf("Executing (%s) for %d containers...\n", modes[i], nthreads);
-            for (j = 0; j < nthreads; j++) {
-                args[j].thread_id = j;
-                args[j].mode = modes[i];
-
-                if (nthreads > 1) {
-                    if (pthread_create(&threads[j], &attr, concurrent, (void *) &args[j]) != 0) {
-                        perror("pthread_create() error");
-                        exit(EXIT_FAILURE);
-                    }
-                } else {
-                    do_function(&args[j]);
-                }
-            }
-
-            for (j = 0; j < nthreads; j++) {
-                if (nthreads > 1) {
-                    if (pthread_join(threads[j], NULL) != 0) {
-                        perror("pthread_join() error");
-                        exit(EXIT_FAILURE);
-                    }
-                }
-                if (args[j].return_code) {
-                    fprintf(stderr, "thread returned error %d\n", args[j].return_code);
-                    exit(EXIT_FAILURE);
-                }
-            }
-        }
-    }
-
-    free(args);
-    free(threads);
-    pthread_attr_destroy(&attr);
-    exit(EXIT_SUCCESS);
+	int i, j, iter, opt;
+	pthread_attr_t attr;
+	pthread_t *threads;
+	struct thread_args *args;
+
+	char *modes_default[] = {"create", "start", "stop", "destroy", NULL};
+	char **modes = modes_default;
+
+	pthread_attr_init(&attr);
+
+	while ((opt = getopt_long(argc, argv, "j:i:t:d:m:qD", options, NULL)) != -1) {
+		switch(opt) {
+		case 'j':
+			nthreads = atoi(optarg);
+			break;
+		case 'i':
+			iterations = atoi(optarg);
+			break;
+		case 't':
+			template = optarg;
+			break;
+		case 'd':
+			delay = atoi(optarg);
+			break;
+		case 'q':
+			quiet = 1;
+			break;
+		case 'D':
+			debug = 1;
+			break;
+		case 'm': {
+			char *mode_tok, *tok, *saveptr = NULL;
+
+			if (!optarg)
+				continue;
+
+			modes = NULL;
+			for (i = 0, mode_tok = optarg;
+			     (tok = strtok_r(mode_tok, ",", &saveptr));
+			     i++, mode_tok = NULL) {
+				modes = realloc(modes, sizeof(*modes) * (i+2));
+				if (!modes) {
+					perror("realloc");
+					exit(EXIT_FAILURE);
+				}
+				modes[i] = tok;
+			}
+
+			if (modes)
+				modes[i] = NULL;
+			break;
+		}
+		default: /* '?' */
+			usage();
+			exit(EXIT_FAILURE);
+		}
+	}
+
+	threads = malloc(sizeof(*threads) * nthreads);
+	args = malloc(sizeof(*args) * nthreads);
+	if (threads == NULL || args == NULL) {
+		fprintf(stderr, "Unable malloc enough memory for %d threads\n", nthreads);
+		exit(EXIT_FAILURE);
+	}
+
+	for (iter = 1; iter <= iterations; iter++) {
+		int fd;
+
+		fd = open("/", O_RDONLY);
+		if (fd < 0) {
+			fprintf(stderr, "Failed to open /\n");
+			continue;
+		}
+
+		if (!quiet)
+			printf("\nIteration %d/%d maxfd:%d\n", iter, iterations, fd);
+
+		close(fd);
+
+		for (i = 0; modes[i];i++) {
+			if (!quiet)
+				printf("Executing (%s) for %d containers...\n", modes[i], nthreads);
+
+			for (j = 0; j < nthreads; j++) {
+				args[j].thread_id = j;
+				args[j].mode = modes[i];
+
+				if (nthreads > 1) {
+					if (pthread_create(&threads[j], &attr, concurrent, (void *) &args[j]) != 0) {
+						perror("pthread_create() error");
+						exit(EXIT_FAILURE);
+					}
+				} else {
+					do_function(&args[j]);
+				}
+			}
+
+			for (j = 0; j < nthreads; j++) {
+				if (nthreads > 1) {
+					if (pthread_join(threads[j], NULL) != 0) {
+						perror("pthread_join() error");
+						exit(EXIT_FAILURE);
+					}
+				}
+
+				if (args[j].return_code) {
+					fprintf(stderr, "thread returned error %d\n", args[j].return_code);
+					exit(EXIT_FAILURE);
+				}
+			}
+		}
+	}
+
+	free(args);
+	free(threads);
+	pthread_attr_destroy(&attr);
+	exit(EXIT_SUCCESS);
 }

From f120a741966670021a25517c5d8de480a52b5649 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:12:31 +0900
Subject: [PATCH 04/25] tests: cleanup config_jump_table.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/config_jump_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tests/config_jump_table.c b/src/tests/config_jump_table.c
index 8e86c48e4..3f08fb942 100644
--- a/src/tests/config_jump_table.c
+++ b/src/tests/config_jump_table.c
@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
 	for (key = strtok_r(keys, "\n", &saveptr); key != NULL;
 	     key = strtok_r(NULL, "\n", &saveptr)) {
 		struct lxc_config_t *config;
+
 		config = lxc_get_config(key);
 		if (!config) {
 			lxc_error("configuration key \"%s\" not implemented in "
@@ -90,5 +91,4 @@ int main(int argc, char *argv[])
 	free(keys);
 
 	exit(ret);
-
 }

From 9ace5308609cdb02a5af2c80ffba076b7f7cdecc Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:13:21 +0900
Subject: [PATCH 05/25] tests: cleanup console.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/console.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/tests/console.c b/src/tests/console.c
index 9c32cf269..c0ad16033 100644
--- a/src/tests/console.c
+++ b/src/tests/console.c
@@ -46,6 +46,7 @@ static void test_console_close_all(int ttyfd[MAXCONSOLES],
 			close(masterfd[i]);
 			masterfd[i] = -1;
 		}
+
 		if (ttyfd[i] != -1) {
 			close(ttyfd[i]);
 			ttyfd[i] = -1;
@@ -64,11 +65,13 @@ static int test_console_running_container(struct lxc_container *c)
 		ttynum[i] = ttyfd[i] = masterfd[i] = -1;
 
 	ttynum[0] = 1;
+
 	ret = c->console_getfd(c, &ttynum[0], &masterfd[0]);
 	if (ret < 0) {
 		TSTERR("console allocate failed");
 		goto err1;
 	}
+
 	ttyfd[0] = ret;
 	if (ttynum[0] != 1) {
 		TSTERR("console allocate got bad ttynum %d", ttynum[0]);
@@ -94,16 +97,20 @@ static int test_console_running_container(struct lxc_container *c)
 				break;
 			ttyfd[nrconsoles] = ret;
 		}
+
 		if (nrconsoles != TTYCNT) {
 			TSTERR("didn't allocate all consoles %d != %d", nrconsoles, TTYCNT);
 			goto err2;
 		}
+
 		test_console_close_all(ttyfd, masterfd);
 	}
+
 	ret = 0;
 
 err2:
 	test_console_close_all(ttyfd, masterfd);
+
 err1:
 	return ret;
 }
@@ -135,20 +142,24 @@ static int test_console(const char *lxcpath,
 		TSTERR("instantiating container %s", name);
 		goto out1;
 	}
+
 	if (c->is_defined(c)) {
 		c->stop(c);
 		c->destroy(c);
 		c = lxc_container_new(name, lxcpath);
 	}
+
 	if (!c->createl(c, template, NULL, NULL, 0, NULL)) {
 		TSTERR("creating container %s", name);
 		goto out2;
 	}
+
 	c->load_config(c, NULL);
 	c->set_config_item(c, "lxc.tty.max", TTYCNT_STR);
 	c->set_config_item(c, "lxc.pty.max", "1024");
 	c->save_config(c, NULL);
 	c->want_daemonize(c, true);
+
 	if (!c->startl(c, 0, NULL)) {
 		TSTERR("starting container %s", name);
 		goto out3;
@@ -157,10 +168,13 @@ static int test_console(const char *lxcpath,
 	ret = test_console_running_container(c);
 
 	c->stop(c);
+
 out3:
 	c->destroy(c);
+
 out2:
 	lxc_container_put(c);
+
 out1:
 	return ret;
 }
@@ -168,6 +182,7 @@ static int test_console(const char *lxcpath,
 int main(int argc, char *argv[])
 {
 	int ret;
+
 	ret = test_console(NULL, NULL, TSTNAME, "busybox");
 	if (ret < 0)
 		goto err1;
@@ -175,7 +190,9 @@ int main(int argc, char *argv[])
 	ret = test_console("/var/lib/lxctest2", NULL, TSTNAME, "busybox");
 	if (ret < 0)
 		goto err1;
+
 	printf("All tests passed\n");
+
 err1:
 	return ret;
 }

From 00e196f27a9d250d7d69fa9d3e5e1f2f30369c9c Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:14:14 +0900
Subject: [PATCH 06/25] tests: cleanup containertests.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/containertests.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/tests/containertests.c b/src/tests/containertests.c
index 256ff60fd..1412b0b84 100644
--- a/src/tests/containertests.c
+++ b/src/tests/containertests.c
@@ -39,10 +39,12 @@ static int destroy_busybox(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-destroy", "lxc-destroy", "-f", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
@@ -51,12 +53,15 @@ static int destroy_busybox(void)
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -69,10 +74,12 @@ static int create_busybox(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
@@ -81,12 +88,15 @@ static int create_busybox(void)
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -99,25 +109,30 @@ int main(int argc, char *argv[])
 	char *str;
 
 	ret = 1;
+
 	/* test refcounting */
 	c = lxc_container_new(MYNAME, NULL);
 	if (!c) {
 		fprintf(stderr, "%d: error creating lxc_container %s\n", __LINE__, MYNAME);
 		goto out;
 	}
+
 	if (!lxc_container_get(c)) {
 		fprintf(stderr, "%d: error getting refcount\n", __LINE__);
 		goto out;
 	}
+
 	/* peek in, inappropriately, make sure refcount is a we'd like */
 	if (c->numthreads != 2) {
 		fprintf(stderr, "%d: refcount is %d, not %d\n", __LINE__, c->numthreads, 2);
 		goto out;
 	}
+
 	if (strcmp(c->name, MYNAME) != 0) {
 		fprintf(stderr, "%d: container has wrong name (%s not %s)\n", __LINE__, c->name, MYNAME);
 		goto out;
 	}
+
 	str = c->config_file_name(c);
 #define CONFIGFNAM LXCPATH "/" MYNAME "/config"
 	if (!str || strcmp(str, CONFIGFNAM)) {
@@ -127,19 +142,23 @@ int main(int argc, char *argv[])
 	free(str);
 	free(c->configfile);
 	c->configfile = NULL;
+
 	str = c->config_file_name(c);
 	if (str) {
 		fprintf(stderr, "%d: config file name was not NULL as it should have been\n", __LINE__);
 		goto out;
 	}
+
 	if (lxc_container_put(c) != 0) {
 		fprintf(stderr, "%d: c was freed on non-final put\n", __LINE__);
 		goto out;
 	}
+
 	if (c->numthreads != 1) {
 		fprintf(stderr, "%d: refcount is %d, not %d\n", __LINE__, c->numthreads, 1);
 		goto out;
 	}
+
 	if (lxc_container_put(c) != 1) {
 		fprintf(stderr, "%d: c was not freed on final put\n", __LINE__);
 		goto out;
@@ -202,9 +221,11 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: lxc_get_wait_states gave %d not %d\n", __LINE__, numstates, MAX_STATE);
 		goto out;
 	}
+
 	const char **sstr = malloc(numstates * sizeof(const char *));
 	numstates = lxc_get_wait_states(sstr);
 	int i;
+
 	for (i=0; i<numstates; i++) {
 		fprintf(stderr, "got state %d %s\n", i, sstr[i]);
 	}
@@ -237,6 +258,7 @@ int main(int argc, char *argv[])
 		c->stop(c);
 		destroy_busybox();
 	}
+
 	lxc_container_put(c);
 	exit(ret);
 }

From 56aff0c442029bd8bf0627ffca1cd31a8ec5fe50 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:14:52 +0900
Subject: [PATCH 07/25] tests: cleanup createtest.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/createtest.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/tests/createtest.c b/src/tests/createtest.c
index 4051f3c2b..53db119be 100644
--- a/src/tests/createtest.c
+++ b/src/tests/createtest.c
@@ -48,8 +48,10 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set network type\n", __LINE__);
 		goto out;
 	}
+
 	c->set_config_item(c, "lxc.net.0.link", "lxcbr0");
 	c->set_config_item(c, "lxc.net.0.flags", "up");
+
 	if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
 		fprintf(stderr, "%d: failed to create a trusty container\n", __LINE__);
 		goto out;
@@ -63,6 +65,7 @@ int main(int argc, char *argv[])
 	c->clear_config(c);
 	c->load_config(c, NULL);
 	c->want_daemonize(c, true);
+
 	if (!c->startl(c, 0, NULL)) {
 		fprintf(stderr, "%d: failed to start %s\n", __LINE__, MYNAME);
 		goto out;
@@ -85,6 +88,7 @@ int main(int argc, char *argv[])
 
 	fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);
 	ret = 0;
+
 out:
 	lxc_container_put(c);
 	exit(ret);

From 17d11ff74423433156be8891f0ac75bf509a5720 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:15:45 +0900
Subject: [PATCH 08/25] tests: cleanup criu_check_feature.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/criu_check_feature.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/tests/criu_check_feature.c b/src/tests/criu_check_feature.c
index a5e0c34eb..8d2003536 100644
--- a/src/tests/criu_check_feature.c
+++ b/src/tests/criu_check_feature.c
@@ -86,5 +86,6 @@ int main(int argc, char *argv[])
 	lxc_container_put(c);
 	if (ret == EXIT_SUCCESS)
 		lxc_debug("%s\n", "All criu feature check tests passed");
+
 	exit(ret);
 }

From 8d72e58a24a94eacaf17e131499bf53e546b4c49 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:16:30 +0900
Subject: [PATCH 09/25] tests: cleanup destroytest.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/destroytest.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/tests/destroytest.c b/src/tests/destroytest.c
index b8ba8055d..79549120e 100644
--- a/src/tests/destroytest.c
+++ b/src/tests/destroytest.c
@@ -37,24 +37,30 @@ static int create_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
 		if (errno == EINTR)
 			goto again;
+
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -96,6 +102,7 @@ int main(int argc, char *argv[])
 
 	fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);
 	ret = 0;
+
 out:
 	lxc_container_put(c);
 	exit(ret);

From e9432dfc50591a4d0048fd70b8e6cec49f57bb30 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:17:03 +0900
Subject: [PATCH 10/25] tests: cleanup device_add_remove.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/device_add_remove.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/tests/device_add_remove.c b/src/tests/device_add_remove.c
index c776729bf..4a2e95138 100644
--- a/src/tests/device_add_remove.c
+++ b/src/tests/device_add_remove.c
@@ -50,6 +50,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "Adding %s to the container (%s) failed...\n", DEVICE, NAME);
 		goto out;
 	}
+
 	if (!c->remove_device_node(c, DEVICE, DEVICE)) {
 		fprintf(stderr, "Removing %s from the container (%s) failed...\n", DEVICE, NAME);
 		goto out;
@@ -64,6 +65,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "Destroying the container (%s) failed...\n", NAME);
 		goto out;
 	}
+
 	ret = 0;
 
 out:

From b947e65737c934ab2d8f27e6933349040123c815 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:18:17 +0900
Subject: [PATCH 11/25] tests: cleanup get_item.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/get_item.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/src/tests/get_item.c b/src/tests/get_item.c
index a1a6b6705..f4c8d9228 100644
--- a/src/tests/get_item.c
+++ b/src/tests/get_item.c
@@ -49,11 +49,13 @@ int main(int argc, char *argv[])
 		lxc_error("%s\n", "Failed to set lxc.log.syslog.\n");
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.log.syslog", v2, 255);
 	if (ret < 0) {
 		lxc_error("Failed to retrieve lxc.log.syslog: %d.\n", ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "local0") != 0) {
 		lxc_error("Expected: local0 == %s.\n", v2);
 		goto out;
@@ -71,6 +73,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set hook.pre-start\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.hook.pre-start", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.hook.pre-start) returned %d\n", __LINE__, ret);
@@ -89,6 +92,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set tty\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.tty.max", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.tty) returned %d\n", __LINE__, ret);
@@ -100,6 +104,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set arch\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.arch", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.arch) returned %d\n", __LINE__, ret);
@@ -111,6 +116,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set init_uid\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.init.uid", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.init_uid) returned %d\n", __LINE__, ret);
@@ -122,6 +128,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set init_gid\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.init.gid", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.init_gid) returned %d\n", __LINE__, ret);
@@ -132,12 +139,13 @@ int main(int argc, char *argv[])
 #define HNAME "hostname1"
 	// demonstrate proper usage:
 	char *alloced;
+	int len;
+
 	if (!c->set_config_item(c, "lxc.uts.name", HNAME)) {
 		fprintf(stderr, "%d: failed to set utsname\n", __LINE__);
 		goto out;
 	}
 
-	int len;
 	len = c->get_config_item(c, "lxc.uts.name", NULL, 0);  // query the size of the string
 	if (len < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.utsname) returned %d\n", __LINE__, len);
@@ -151,6 +159,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to allocate %d bytes for utsname\n", __LINE__, len);
 		goto out;
 	}
+
 	// now pass in the malloc'd array, and pass in length of string + 1: again
 	// because we need room for the trailing \0
 	ret = c->get_config_item(c, "lxc.uts.name", alloced, len+1);
@@ -158,6 +167,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(lxc.utsname) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(alloced, HNAME) != 0 || ret != len) {
 		fprintf(stderr, "lxc.utsname returned wrong value: %d %s not %d %s\n", ret, alloced, len, HNAME);
 		goto out;
@@ -169,6 +179,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set mount.entry\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.mount.entry", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.mount.entry) returned %d\n", __LINE__, ret);
@@ -186,11 +197,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set limit.nofile\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.prlimit.nofile", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.prlimit.nofile) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "1234:unlimited")) {
 		fprintf(stderr, "%d: lxc.prlimit.nofile returned wrong value: %d %s not 14 1234:unlimited\n", __LINE__, ret, v2);
 		goto out;
@@ -201,11 +214,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set limit.stack\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.prlimit.stack", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.prlimit.stack) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "unlimited")) {
 		fprintf(stderr, "%d: lxc.prlimit.stack returned wrong value: %d %s not 9 unlimited\n", __LINE__, ret, v2);
 		goto out;
@@ -219,6 +234,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(limit) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, ALL_LIMITS)) {
 		fprintf(stderr, "%d: lxc.prlimit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(ALL_LIMITS)-1, ALL_LIMITS);
 		goto out;
@@ -229,11 +245,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed clearing limit.nofile\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.prlimit", v3, 2047);
 	if (ret != sizeof(LIMIT_STACK)-1) {
 		fprintf(stderr, "%d: get_config_item(limit) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, LIMIT_STACK)) {
 		fprintf(stderr, "%d: lxc.prlimit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(LIMIT_STACK)-1, LIMIT_STACK);
 		goto out;
@@ -253,11 +271,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set lxc.sysctl.net.ipv4.ip_forward\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.sysctl.net.ipv4.ip_forward", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.sysctl.net.ipv4.ip_forward) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "1")) {
 		fprintf(stderr, "%d: lxc.sysctl.net.ipv4.ip_forward returned wrong value: %d %s not 1\n", __LINE__, ret, v2);
 		goto out;
@@ -268,11 +288,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set lxc.sysctl.net.core.somaxconn\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.sysctl.net.core.somaxconn", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.sysctl.net.core.somaxconn) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "256")) {
 		fprintf(stderr, "%d: lxc.sysctl.net.core.somaxconn returned wrong value: %d %s not 256\n", __LINE__, ret, v2);
 		goto out;
@@ -284,6 +306,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(sysctl) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, ALL_SYSCTLS)) {
 		fprintf(stderr, "%d: lxc.sysctl returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(ALL_SYSCTLS) - 1, ALL_SYSCTLS);
 		goto out;
@@ -294,11 +317,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed clearing lxc.sysctl.net.ipv4.ip_forward\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.sysctl", v3, 2047);
 	if (ret != sizeof(SYSCTL_SOMAXCONN) - 1) {
 		fprintf(stderr, "%d: get_config_item(sysctl) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, SYSCTL_SOMAXCONN)) {
 		fprintf(stderr, "%d: lxc.sysctl returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(SYSCTL_SOMAXCONN) - 1, SYSCTL_SOMAXCONN);
 		goto out;
@@ -324,6 +349,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(lxc.proc.setgroups) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "allow")) {
 		fprintf(stderr, "%d: lxc.proc.setgroups returned wrong value: %d %s not 10\n", __LINE__, ret, v2);
 		goto out;
@@ -340,6 +366,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(lxc.proc.oom_score_adj) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v2, "10")) {
 		fprintf(stderr, "%d: lxc.proc.oom_score_adj returned wrong value: %d %s not 10\n", __LINE__, ret, v2);
 		goto out;
@@ -351,6 +378,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(proc) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, ALL_PROCS)) {
 		fprintf(stderr, "%d: lxc.proc returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(ALL_PROCS) - 1, ALL_PROCS);
 		goto out;
@@ -361,11 +389,13 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed clearing lxc.proc.setgroups\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.proc", v3, 2047);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(proc) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (strcmp(v3, PROC_OOM_SCORE_ADJ)) {
 		fprintf(stderr, "%d: lxc.proc returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(PROC_OOM_SCORE_ADJ) - 1, PROC_OOM_SCORE_ADJ);
 		goto out;
@@ -376,6 +406,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set aa_profile\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.apparmor.profile", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.aa_profile) returned %d\n", __LINE__, ret);
@@ -397,6 +428,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: error opening lxc_container %s\n", __LINE__, MYNAME);
 		goto out;
 	}
+
 	if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
 		fprintf(stderr, "%d: failed to create a trusty container\n", __LINE__);
 		goto out;
@@ -414,17 +446,20 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: get_config_item(lxc.cap.drop) with NULL returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.cap.drop", v1, 1);
 	if (ret < 5 || ret > 255) {
 		fprintf(stderr, "%d: get_config_item(lxc.cap.drop) returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.cap.drop", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.cap.drop) returned %d %s\n", __LINE__, ret, v2);
 		goto out;
 	}
 	printf("%d: get_config_item(lxc.cap.drop) returned %d %s\n", __LINE__, ret, v2);
+
 	ret = c->get_config_item(c, "lxc.net", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item(lxc.net) returned %d\n", __LINE__, ret);
@@ -436,18 +471,22 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set lxc.net.0.type\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.link", "lxcbr0")) {
 		fprintf(stderr, "%d: failed to set network.link\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.flags", "up")) {
 		fprintf(stderr, "%d: failed to set network.flags\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.hwaddr", "00:16:3e:xx:xx:xx")) {
 		fprintf(stderr, "%d: failed to set network.hwaddr\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.ipv4.address", "10.2.3.4")) {
 		fprintf(stderr, "%d: failed to set ipv4\n", __LINE__);
 		goto out;
@@ -458,10 +497,12 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: lxc.net.0.ipv4 returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (!c->clear_config_item(c, "lxc.net.0.ipv4.address")) {
 		fprintf(stderr, "%d: failed clearing all ipv4 entries\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.net.0.ipv4.address", v2, 255);
 	if (ret != 0) {
 		fprintf(stderr, "%d: after clearing ipv4 entries get_item(lxc.network.0.ipv4 returned %d\n", __LINE__, ret);
@@ -478,10 +519,12 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: lxc.net.0.ipv4.gateway returned %d\n", __LINE__, ret);
 		goto out;
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.ipv4.gateway", "")) {
 		fprintf(stderr, "%d: failed clearing ipv4.gateway\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.net.0.ipv4.gateway", v2, 255);
 	if (ret != 0) {
 		fprintf(stderr, "%d: after clearing ipv4.gateway get_item(lxc.network.0.ipv4.gateway returned %d\n", __LINE__, ret);
@@ -494,6 +537,7 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 	printf("%d: get_config_item (link) returned %d %s\n", __LINE__, ret, v2);
+
 	ret = c->get_config_item(c, "lxc.net.0.name", v2, 255);
 	if (ret < 0) {
 		fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret);
@@ -505,6 +549,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: clear_config_item failed\n", __LINE__);
 		goto out;
 	}
+
 	ret = c->get_config_item(c, "lxc.net", v2, 255);
 	if (ret != 0) {
 		fprintf(stderr, "%d: network was not actually cleared (get_network returned %d)\n", __LINE__, ret);
@@ -529,14 +574,17 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed clearing lxc.cgroup\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->clear_config_item(c, "lxc.cap.drop")) {
 		fprintf(stderr, "%d: failed clearing lxc.cap.drop\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->clear_config_item(c, "lxc.mount.entry")) {
 		fprintf(stderr, "%d: failed clearing lxc.mount.entry\n", __LINE__);
 		goto out;
 	}
+
 	if (!c->clear_config_item(c, "lxc.hook")) {
 		fprintf(stderr, "%d: failed clearing lxc.hook\n", __LINE__);
 		goto out;
@@ -554,6 +602,7 @@ int main(int argc, char *argv[])
 
 	printf("All get_item tests passed\n");
 	fret = EXIT_SUCCESS;
+
 out:
 	if (c) {
 		c->destroy(c);

From af8660599a8fd983c5773dd2cc0574b6ff068d19 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:18:47 +0900
Subject: [PATCH 12/25] tests: cleanup getkeys.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/getkeys.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/tests/getkeys.c b/src/tests/getkeys.c
index a9299de31..c9e240dfd 100644
--- a/src/tests/getkeys.c
+++ b/src/tests/getkeys.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
 		ret = 1;
 		goto out;
 	}
+
 	ret = c->get_keys(c, NULL, v3, len+1);
 	if (ret != len) {
 		fprintf(stderr, "%d: failed to get keys (%d)\n", __LINE__, ret);

From f0353f8b0b30feb52609274865aac658f74e5f28 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:19:50 +0900
Subject: [PATCH 13/25] tests: cleanup list.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/list.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/tests/list.c b/src/tests/list.c
index 9641dccbb..37f910e61 100644
--- a/src/tests/list.c
+++ b/src/tests/list.c
@@ -31,17 +31,21 @@ static void test_list_func(const char *lxcpath, const char *type,
 	char **names;
 
 	printf("%-10s Counting containers\n", type);
+
 	n = func(lxcpath, NULL, NULL);
 	printf("%-10s Counted %d containers\n", type, n);
 	printf("%-10s Get container struct only\n", type);
+
 	n2 = func(lxcpath, NULL, &clist);
 	if (n2 != n)
 		printf("Warning: first call returned %d, second %d\n", n, n2);
+
 	for (i = 0; i < n2; i++) {
 		struct lxc_container *c = clist[i];
 		printf("%-10s  Got container struct %s\n", type, c->name);
 		lxc_container_put(c);
 	}
+
 	if (n2 > 0) {
 		free(clist);
 		clist = NULL;
@@ -51,10 +55,12 @@ static void test_list_func(const char *lxcpath, const char *type,
 	n2 = func(lxcpath, &names, NULL);
 	if (n2 != n)
 		printf("Warning: first call returned %d, second %d\n", n, n2);
+
 	for (i = 0; i < n2; i++) {
 		printf("%-10s  Got container name %s\n", type, names[i]);
 		free(names[i]);
 	}
+
 	if (n2 > 0) {
 		free(names);
 		names = NULL;
@@ -64,14 +70,18 @@ static void test_list_func(const char *lxcpath, const char *type,
 	n2 = func(lxcpath, &names, &clist);
 	if (n2 != n)
 		printf("Warning: first call returned %d, second %d\n", n, n2);
+
 	for (i = 0; i < n2; i++) {
 		struct lxc_container *c = clist[i];
 		printf("%-10s  Got container struct %s, name %s\n", type, c->name, names[i]);
+
 		if (strcmp(c->name, names[i]))
 			fprintf(stderr, "ERROR: name mismatch!\n");
+
 		free(names[i]);
 		lxc_container_put(c);
 	}
+
 	if (n2 > 0) {
 		free(names);
 		free(clist);

From 3cc076dca1e59df26c0832e3970a1fff025257a3 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:20:44 +0900
Subject: [PATCH 14/25] tests: cleanup locktests.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/locktests.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/tests/locktests.c b/src/tests/locktests.c
index e2b8914dc..cfec5f1ba 100644
--- a/src/tests/locktests.c
+++ b/src/tests/locktests.c
@@ -38,39 +38,49 @@ static void test_two_locks(void)
 
 	if (pipe(p) < 0)
 		exit(1);
+
 	if ((pid = fork()) < 0)
 		exit(1);
+
 	if (pid == 0) {
 		if (read(p[0], &c, 1) < 0) {
 			perror("read");
 			exit(1);
 		}
+
 		l = lxc_newlock("/tmp", "lxctest-sem");
 		if (!l) {
 			fprintf(stderr, "%d: child: failed to create lock\n", __LINE__);
 			exit(1);
 		}
+
 		if (lxclock(l, 0) < 0) {
 			fprintf(stderr, "%d: child: failed to grab lock\n", __LINE__);
 			exit(1);
 		}
+
 		fprintf(stderr, "%d: child: grabbed lock\n", __LINE__);
 		exit(0);
 	}
+
 	l = lxc_newlock("/tmp", "lxctest-sem");
 	if (!l) {
 		fprintf(stderr, "%d: failed to create lock\n", __LINE__);
 		exit(1);
 	}
+
 	if (lxclock(l, 0) < 0) {
 		fprintf(stderr, "%d; failed to get lock\n", __LINE__);
 		exit(1);
 	}
+
 	if (write(p[1], "a", 1) < 0) {
 		perror("write");
 		exit(1);
 	}
+
 	sleep(3);
+
 	ret = waitpid(pid, &status, WNOHANG);
 	if (ret == pid) { // task exited
 		if (WIFEXITED(status)) {
@@ -85,6 +95,7 @@ static void test_two_locks(void)
 		perror("waitpid");
 		exit(1);
 	}
+
 	kill(pid, SIGKILL);
 	wait(&status);
 	close(p[1]);
@@ -103,6 +114,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to get unnamed lock\n", __LINE__);
 		exit(1);
 	}
+
 	ret = lxclock(lock, 0);
 	if (ret) {
 		fprintf(stderr, "%d: failed to take unnamed lock (%d)\n", __LINE__, ret);
@@ -121,8 +133,10 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to get lock\n", __LINE__);
 		exit(1);
 	}
+
 	struct stat sb;
 	char *pathname = RUNTIME_PATH "/lxc/lock/var/lib/lxc/";
+
 	ret = stat(pathname, &sb);
 	if (ret != 0) {
 		fprintf(stderr, "%d: filename %s not created\n", __LINE__,

From b477d8303215ee163a3e3c119f4dbe549608cbad Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:21:36 +0900
Subject: [PATCH 15/25] tests: cleanup lxc-test-utils.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/lxc-test-utils.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/tests/lxc-test-utils.c b/src/tests/lxc-test-utils.c
index 4c628b063..8a1ecc1dd 100644
--- a/src/tests/lxc-test-utils.c
+++ b/src/tests/lxc-test-utils.c
@@ -49,6 +49,7 @@ void test_lxc_deslashify(void)
 	t = lxc_deslashify(s);
 	if (!t)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort(strcmp(t, "/A/B/C/D/E") == 0);
 	free(t);
 
@@ -57,6 +58,7 @@ void test_lxc_deslashify(void)
 	t = lxc_deslashify(s);
 	if (!t)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort(strcmp(t, "/A") == 0);
 	free(t);
 
@@ -64,6 +66,7 @@ void test_lxc_deslashify(void)
 	t = lxc_deslashify(s);
 	if (!t)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort(strcmp(t, "") == 0);
 	free(t);
 
@@ -72,6 +75,7 @@ void test_lxc_deslashify(void)
 	t = lxc_deslashify(s);
 	if (!t)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort(strcmp(t, "/") == 0);
 	free(t);
 }
@@ -188,6 +192,7 @@ void test_detect_ramfs_rootfs(void)
 	for (i = 0; i < sizeof(mountinfo) / sizeof(mountinfo[0]); i++) {
 		if (strcmp(mountinfo[i], "24 0 8:2 / / rw - rootfs rootfs rw,size=1004396k,nr_inodes=251099") == 0)
 			continue;
+
 		if (fprintf(fp2, "%s\n", mountinfo[i]) < 0) {
 			lxc_error("Could not write \"%s\" to temporary file.", mountinfo[i]);
 			goto non_test_error;
@@ -217,6 +222,7 @@ void test_detect_ramfs_rootfs(void)
 		fclose(fp1);
 	else if (fd1 > 0)
 		close(fd1);
+
 	if (fp2)
 		fclose(fp2);
 	else if (fd2 > 0)
@@ -229,8 +235,10 @@ void test_detect_ramfs_rootfs(void)
 		}
 		close(init_ns);
 	}
+
 	if (fret == EXIT_SUCCESS)
 		return;
+
 	exit(fret);
 }
 
@@ -246,11 +254,13 @@ void test_lxc_safe_uint(void)
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)UINT_MAX);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((0 == lxc_safe_uint(numstr, &n)) && n == UINT_MAX);
 
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)UINT_MAX + 1);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((-ERANGE == lxc_safe_uint(numstr, &n)));
 
 	lxc_test_assert_abort((0 == lxc_safe_uint("1234345", &n)) && n == 1234345);
@@ -277,21 +287,25 @@ void test_lxc_safe_int(void)
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)INT_MAX);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((0 == lxc_safe_int(numstr, &n)) && n == INT_MAX);
 
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)INT_MAX + 1);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((-ERANGE == lxc_safe_int(numstr, &n)));
 
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRId64, (int64_t)INT_MIN);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((0 == lxc_safe_int(numstr, &n)) && n == INT_MIN);
 
 	ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRId64, (int64_t)INT_MIN - 1);
 	if (ret < 0 || ret >= LXC_NUMSTRLEN64)
 		exit(EXIT_FAILURE);
+
 	lxc_test_assert_abort((-ERANGE == lxc_safe_int(numstr, &n)));
 
 	lxc_test_assert_abort((0 == lxc_safe_int("1234345", &n)) && n == 1234345);
@@ -394,6 +408,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"0\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 0) {
 		lxc_error("%s\n", "Failed to parse \"0\"");
 		exit(EXIT_FAILURE);
@@ -404,6 +419,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1) {
 		lxc_error("%s\n", "Failed to parse \"1\"");
 		exit(EXIT_FAILURE);
@@ -420,6 +436,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1B\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1) {
 		lxc_error("%s\n", "Failed to parse \"1B\"");
 		exit(EXIT_FAILURE);
@@ -430,6 +447,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1kB\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1024) {
 		lxc_error("%s\n", "Failed to parse \"1kB\"");
 		exit(EXIT_FAILURE);
@@ -440,6 +458,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1MB\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1048576) {
 		lxc_error("%s\n", "Failed to parse \"1MB\"");
 		exit(EXIT_FAILURE);
@@ -456,6 +475,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1 B\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1) {
 		lxc_error("%s\n", "Failed to parse \"1 B\"");
 		exit(EXIT_FAILURE);
@@ -466,6 +486,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1 kB\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1024) {
 		lxc_error("%s\n", "Failed to parse \"1 kB\"");
 		exit(EXIT_FAILURE);
@@ -476,6 +497,7 @@ void test_parse_byte_size_string(void)
 		lxc_error("%s\n", "Failed to parse \"1 MB\"");
 		exit(EXIT_FAILURE);
 	}
+
 	if (n != 1048576) {
 		lxc_error("%s\n", "Failed to parse \"1 MB\"");
 		exit(EXIT_FAILURE);
@@ -503,8 +525,10 @@ void test_lxc_config_net_hwaddr(void)
 
 	if (lxc_config_net_hwaddr("lxc.net"))
 		exit(EXIT_FAILURE);
+
 	if (lxc_config_net_hwaddr("lxc.net."))
 		exit(EXIT_FAILURE);
+
 	if (lxc_config_net_hwaddr("lxc.net.0."))
 		exit(EXIT_FAILURE);
 }

From c3c504a8a9ccd0fe12163746d508508d9ebbac6e Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:22:01 +0900
Subject: [PATCH 16/25] tests: cleanup lxc_raw_clone.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/lxc_raw_clone.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/tests/lxc_raw_clone.c b/src/tests/lxc_raw_clone.c
index 779023141..ae38880a4 100644
--- a/src/tests/lxc_raw_clone.c
+++ b/src/tests/lxc_raw_clone.c
@@ -125,6 +125,7 @@ int main(int argc, char *argv[])
 	flags |= CLONE_NEWIPC;
 	flags |= CLONE_NEWPID;
 	flags |= CLONE_NEWUTS;
+
 	pid = lxc_raw_clone(flags);
 	if (pid < 0) {
 		lxc_error("%s\n", "Failed to call lxc_raw_clone(CLONE_NEWUSER "
@@ -172,7 +173,6 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-
 	if (pid == 0) {
 		lxc_error("%s\n", "Child will exit(EXIT_SUCCESS)");
 		exit(EXIT_SUCCESS);
@@ -190,7 +190,6 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-
 	if (pid == 0) {
 		lxc_error("%s\n", "Child will exit(EXIT_FAILURE)");
 		exit(EXIT_FAILURE);
@@ -208,7 +207,6 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-
 	if (pid == 0) {
 		lxc_error("%s\n", "Child will exit(EXIT_SUCCESS)");
 		exit(EXIT_SUCCESS);
@@ -226,7 +224,6 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-
 	if (pid == 0) {
 		lxc_error("%s\n", "Child will exit(EXIT_FAILURE)");
 		exit(EXIT_FAILURE);

From 915af839db145bc0f56e6d0b3bd6da056d56b325 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:22:27 +0900
Subject: [PATCH 17/25] tests: cleanup lxcpath.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/lxcpath.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/tests/lxcpath.c b/src/tests/lxcpath.c
index 60189901c..b5141b464 100644
--- a/src/tests/lxcpath.c
+++ b/src/tests/lxcpath.c
@@ -44,6 +44,7 @@ int main()
 		TSTERR("create using default path");
 		goto err;
 	}
+
 	p1 = c->get_config_path(c);
 	p2 = c->config_file_name(c);
 	if (!p1 || !p2 || strncmp(p1, p2, strlen(p1))) {
@@ -57,6 +58,7 @@ int main()
 		TSTERR("Error setting custom path");
 		goto err;
 	}
+
 	p1 = c->get_config_path(c);
 	p2 = c->config_file_name(c);
 	if (strcmp(p1, CPATH) || strcmp(p2, FPATH)) {

From fe142896b622ceb4e4bdec834cb793e1d1ee07d6 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:22:48 +0900
Subject: [PATCH 18/25] tests: clenaup may_control.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/may_control.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/tests/may_control.c b/src/tests/may_control.c
index bb7000caa..2930deb2a 100644
--- a/src/tests/may_control.c
+++ b/src/tests/may_control.c
@@ -35,12 +35,16 @@ int main(int argc, char *argv[])
 
 	if (argc < 2)
 		usage(argv[0]);
+
 	name = argv[1];
+
 	if (argc == 3)
 		lxcpath = argv[2];
+
 	c = lxc_container_new(name, lxcpath);
 	if (c)
 		may = c->may_control(c);
+
 	printf("You may%s control %s\n", may ? "" : " not", name);
 	exit(may ? 0 : 1);
 }

From 733666f840e8eecc4667db4afb2fa2935844ece7 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:23:12 +0900
Subject: [PATCH 19/25] tests: cleanup reboot.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/reboot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/tests/reboot.c b/src/tests/reboot.c
index 1f059e0d7..9e9db2277 100644
--- a/src/tests/reboot.c
+++ b/src/tests/reboot.c
@@ -41,6 +41,7 @@ static int do_reboot(void *arg)
 
 	if (reboot(*cmd))
 		printf("failed to reboot(%d): %s\n", *cmd, strerror(errno));
+
 	return 0;
 }
 
@@ -65,6 +66,7 @@ static int test_reboot(int cmd, int sig)
 	if (!WIFSIGNALED(status)) {
 		if (sig != -1)
 			printf("child process exited but was not signaled\n");
+
 		return -1;
 	}
 
@@ -89,9 +91,11 @@ static int have_reboot_patch(void)
 	fclose(f);
 	if (ret != 1)
 		return 0;
+
 	ret = reboot(v ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF);
 	if (ret != -1)
 		return 0;
+
 	return 1;
 }
 

From b4edca7c7c98363f56f21acde9024cded99b8914 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:23:48 +0900
Subject: [PATCH 20/25] tests: cleanup saveconfig.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/saveconfig.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/tests/saveconfig.c b/src/tests/saveconfig.c
index 58f4d24b6..c73240223 100644
--- a/src/tests/saveconfig.c
+++ b/src/tests/saveconfig.c
@@ -37,24 +37,30 @@ static int create_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
 		if (errno == EINTR)
 			goto again;
+
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -90,6 +96,7 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed writing config file /tmp/lxctest1\n", __LINE__);
 		goto out;
 	}
+
 	rename(LXCPATH "/" MYNAME "/config", LXCPATH "/" MYNAME "/config.bak");
 	if (!c->save_config(c, NULL)) {
 		fprintf(stderr, "%d: failed writing config file\n", __LINE__);
@@ -108,6 +115,7 @@ int main(int argc, char *argv[])
 
 	fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);
 	ret = 0;
+
 out:
 	lxc_container_put(c);
 	exit(ret);

From 0ce5c91e606070f8d01dbe4e362337708a690290 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:24:26 +0900
Subject: [PATCH 21/25] tests: cleanup shortlived.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/shortlived.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/tests/shortlived.c b/src/tests/shortlived.c
index 2a039a2f3..da2f04f76 100644
--- a/src/tests/shortlived.c
+++ b/src/tests/shortlived.c
@@ -46,10 +46,12 @@ static int destroy_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-destroy", "lxc-destroy", "-f", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
@@ -58,12 +60,15 @@ static int destroy_container(void)
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -76,24 +81,30 @@ static int create_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
 		if (errno == EINTR)
 			goto again;
+
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -124,6 +135,7 @@ int main(int argc, char *argv[])
 	log.prefix = "shortlived";
 	log.quiet = false;
 	log.lxcpath = NULL;
+
 	if (lxc_log_init(&log))
 		exit(EXIT_FAILURE);
 
@@ -256,11 +268,13 @@ int main(int argc, char *argv[])
 		if (fd >= 0) {
 			char buf[4096];
 			ssize_t buflen;
+
 			while ((buflen = read(fd, buf, 1024)) > 0) {
 				buflen = write(STDERR_FILENO, buf, buflen);
 				if (buflen <= 0)
 					break;
 			}
+
 			close(fd);
 		}
 	}

From 70b12b4a839d80d26bc84e9b0e236735c377ed2f Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:25:02 +0900
Subject: [PATCH 22/25] tests: cleanup shutdowntest.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/shutdowntest.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/tests/shutdowntest.c b/src/tests/shutdowntest.c
index 00b18a45f..cec6efc7b 100644
--- a/src/tests/shutdowntest.c
+++ b/src/tests/shutdowntest.c
@@ -49,8 +49,10 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to set network type\n", __LINE__);
 		goto out;
 	}
+
 	c->set_config_item(c, "lxc.net.0.link", "lxcbr0");
 	c->set_config_item(c, "lxc.net.0.flags", "up");
+
 	if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
 		fprintf(stderr, "%d: failed to create a container\n", __LINE__);
 		goto out;
@@ -64,6 +66,7 @@ int main(int argc, char *argv[])
 	c->clear_config(c);
 	c->load_config(c, NULL);
 	c->want_daemonize(c, true);
+
 	if (!c->startl(c, 0, NULL)) {
 		fprintf(stderr, "%d: failed to start %s\n", __LINE__, MYNAME);
 		goto out;
@@ -74,9 +77,9 @@ int main(int argc, char *argv[])
 
 	if (!c->shutdown(c, 120)) {
 		fprintf(stderr, "%d: failed to shut down %s\n", __LINE__, MYNAME);
-		if (!c->stop(c)) {
+		if (!c->stop(c))
 			fprintf(stderr, "%d: failed to kill %s\n", __LINE__, MYNAME);
-		}
+
 		goto out;
 	}
 
@@ -92,10 +95,10 @@ int main(int argc, char *argv[])
 
 	fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);
 	ret = 0;
+
 out:
-	if (c && c->is_defined(c)) {
+	if (c && c->is_defined(c))
 		c->destroy(c);
-	}
 
 	lxc_container_put(c);
 	exit(ret);

From 63f769f9c52d0a094ad1a93c47678c8a68ab4506 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:25:54 +0900
Subject: [PATCH 23/25] tests: cleanup snapshot.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/snapshot.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/tests/snapshot.c b/src/tests/snapshot.c
index ed5643a7a..1b7d7ab44 100644
--- a/src/tests/snapshot.c
+++ b/src/tests/snapshot.c
@@ -32,23 +32,28 @@
 static void try_to_remove(void)
 {
 	struct lxc_container *c;
+
 	c = lxc_container_new(RESTNAME, NULL);
 	if (c) {
 		c->snapshot_destroy_all(c);
 		if (c->is_defined(c))
 			c->destroy(c);
+
 		lxc_container_put(c);
 	}
+
 	c = lxc_container_new(MYNAME2, NULL);
 	if (c) {
 		c->destroy_with_snapshots(c);
 		lxc_container_put(c);
 	}
+
 	c = lxc_container_new(MYNAME, NULL);
 	if (c) {
 		c->snapshot_destroy_all(c);
 		if (c->is_defined(c))
 			c->destroy(c);
+
 		lxc_container_put(c);
 	}
 }
@@ -66,6 +71,7 @@ int main(int argc, char *argv[])
 		template = argv[1];
 
 	try_to_remove();
+
 	c = lxc_container_new(MYNAME, NULL);
 	if (!c) {
 		fprintf(stderr, "%s: %d: failed to load first container\n", __FILE__, __LINE__);
@@ -76,15 +82,19 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
 		(void) c->destroy_with_snapshots(c);
 	}
+
 	if (!c->set_config_item(c, "lxc.net.0.type", "empty")) {
 		fprintf(stderr, "%s: %d: failed to set network type\n", __FILE__, __LINE__);
 		goto err;
 	}
+
 	c->save_config(c, NULL);
+
 	if (!c->createl(c, template, NULL, NULL, 0, NULL)) {
 		fprintf(stderr, "%s: %d: failed to create %s container\n", __FILE__, __LINE__, template);
 		goto err;
 	}
+
 	c->load_config(c, NULL);
 
 	if (c->snapshot(c, NULL) != 0) {
@@ -110,13 +120,14 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%s: %d: failed listing containers\n", __FILE__, __LINE__);
 		goto err;
 	}
+
 	if (strcmp(s->name, "snap0") != 0) {
 		fprintf(stderr, "%s: %d: snapshot had bad name\n", __FILE__, __LINE__);
 		goto err;
 	}
-	for (i=0; i<n; i++) {
+
+	for (i=0; i<n; i++)
 		s[i].free(&s[i]);
-	}
 	free(s);
 
 	if (!c->snapshot_restore(c, "snap0", RESTNAME)) {
@@ -152,13 +163,14 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%s: %d: failed listing containers\n", __FILE__, __LINE__);
 		goto err;
 	}
+
 	if (strcmp(s->name, "snap0") != 0) {
 		fprintf(stderr, "%s: %d: snapshot had bad name\n", __FILE__, __LINE__);
 		goto err;
 	}
-	for (i=0; i<n; i++) {
+
+	for (i=0; i<n; i++)
 		s[i].free(&s[i]);
-	}
 	free(s);
 
 	if (!c2->snapshot_restore(c2, "snap0", NULL)) {
@@ -177,6 +189,7 @@ int main(int argc, char *argv[])
 
 	printf("All tests passed\n");
 	exit(0);
+
 err:
 	lxc_container_put(c);
 	try_to_remove();

From dcfbd1c07b988cfbd690b3bc9491f1bb7ab6fd52 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:26:40 +0900
Subject: [PATCH 24/25] tests: cleanup startone.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/startone.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/tests/startone.c b/src/tests/startone.c
index d8e82be81..86cdf4d58 100644
--- a/src/tests/startone.c
+++ b/src/tests/startone.c
@@ -39,24 +39,30 @@ static int destroy_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-destroy", "lxc-destroy", "-f", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
 		if (errno == EINTR)
 			goto again;
+
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -69,24 +75,30 @@ static int create_container(void)
 		perror("fork");
 		return -1;
 	}
+
 	if (pid == 0) {
 		execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL);
 		exit(EXIT_FAILURE);
 	}
+
 again:
 	ret = waitpid(pid, &status, 0);
 	if (ret == -1) {
 		if (errno == EINTR)
 			goto again;
+
 		perror("waitpid");
 		return -1;
 	}
+
 	if (ret != pid)
 		goto again;
+
 	if (!WIFEXITED(status))  { // did not exit normally
 		fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
 		return -1;
 	}
+
 	return WEXITSTATUS(status);
 }
 
@@ -100,6 +112,7 @@ int main(int argc, char *argv[])
 	int len;
 
 	ret = 1;
+
 	/* test a real container */
 	c = lxc_container_new(MYNAME, NULL);
 	if (!c) {
@@ -167,6 +180,7 @@ int main(int argc, char *argv[])
 	}
 
 	sleep(3);
+
 	s = c->state(c);
 	if (!s || strcmp(s, "RUNNING")) {
 		fprintf(stderr, "%d: %s is in state %s, not in RUNNING.\n", __LINE__, c->name, s ? s : "undefined");
@@ -192,7 +206,7 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-    sprintf(buf, "XXX");
+	sprintf(buf, "XXX");
 	len = c->get_cgroup_item(c, "freezer.state", buf, 200);
 	if (len <= 0 || (strcmp(buf, "FREEZING\n") && strcmp(buf, "FROZEN\n"))) {
 		fprintf(stderr, "%d: not able to get freezer.state (len %d buf %s)\n", __LINE__, len, buf);

From 6ea8a4365bb265264bf2b0218efcd084df79b187 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 3 Jul 2018 18:27:11 +0900
Subject: [PATCH 25/25] tests: cleanup state_server.c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/state_server.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/tests/state_server.c b/src/tests/state_server.c
index c59da12d6..a814227ea 100644
--- a/src/tests/state_server.c
+++ b/src/tests/state_server.c
@@ -149,5 +149,6 @@ int main(int argc, char *argv[])
 	lxc_container_put(c);
 	if (ret == EXIT_SUCCESS)
 		lxc_debug("%s\n", "All state server tests passed");
+
 	exit(ret);
 }


More information about the lxc-devel mailing list