Skip to content

Commit

Permalink
tests: cleanup destroytest.c
Browse files Browse the repository at this point in the history
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
  • Loading branch information
2xsec committed Jul 3, 2018
1 parent 17d11ff commit 8d72e58
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tests/destroytest.c
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8d72e58

Please sign in to comment.