You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/02/27 02:22:23 UTC
git commit: Fixed ROOT_CGROUPS_Write test.
Repository: mesos
Updated Branches:
refs/heads/master f19db574d -> e937ff0c7
Fixed ROOT_CGROUPS_Write test.
Review: https://reviews.apache.org/r/18532
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e937ff0c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e937ff0c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e937ff0c
Branch: refs/heads/master
Commit: e937ff0c7362179fc0eee73a75bc7bdf4a34859f
Parents: f19db57
Author: Ian Downes <ia...@gmail.com>
Authored: Wed Feb 26 17:16:54 2014 -0800
Committer: Vinod Kone <vi...@twitter.com>
Committed: Wed Feb 26 17:16:54 2014 -0800
----------------------------------------------------------------------
src/tests/cgroups_tests.cpp | 47 +++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e937ff0c/src/tests/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cgroups_tests.cpp b/src/tests/cgroups_tests.cpp
index 6a111e5..b9ec276 100644
--- a/src/tests/cgroups_tests.cpp
+++ b/src/tests/cgroups_tests.cpp
@@ -398,37 +398,40 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Write)
EXPECT_ERROR(
cgroups::write(hierarchy, TEST_CGROUPS_ROOT, "invalid", "invalid"));
+ ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
+
pid_t pid = ::fork();
ASSERT_NE(-1, pid);
- ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
+ if (pid == 0) {
+ // In child process, wait for kill signal.
+ while (true) { sleep(1); }
- if (pid > 0) {
- // In parent process.
- ASSERT_SOME(
- cgroups::write(hierarchy, TEST_CGROUPS_ROOT, "tasks", stringify(pid)));
+ // Should not reach here.
+ const char* message = "Error, child should be killed before reaching here";
+ while (write(STDERR_FILENO, message, strlen(message)) == -1 &&
+ errno == EINTR);
- Try<std::set<pid_t> > pids = cgroups::processes(hierarchy, TEST_CGROUPS_ROOT);
- ASSERT_SOME(pids);
+ _exit(1);
+ }
- EXPECT_NE(0u, pids.get().count(pid));
+ // In parent process.
+ ASSERT_SOME(
+ cgroups::write(hierarchy, TEST_CGROUPS_ROOT, "cgroup.procs", stringify(pid)));
- // Kill the child process.
- ASSERT_NE(-1, ::kill(pid, SIGKILL));
+ Try<std::set<pid_t> > pids = cgroups::processes(hierarchy, TEST_CGROUPS_ROOT);
+ ASSERT_SOME(pids);
- // Wait for the child process.
- int status;
- EXPECT_NE(-1, ::waitpid((pid_t) -1, &status, 0));
- ASSERT_TRUE(WIFSIGNALED(status));
- EXPECT_EQ(SIGKILL, WTERMSIG(status));
- } else {
- // In child process, wait for kill signal.
- while (true);
+ EXPECT_NE(0u, pids.get().count(pid));
- // Should not reach here.
- std::cerr << "Reach an unreachable statement!" << std::endl;
- abort();
- }
+ // Kill the child process.
+ ASSERT_NE(-1, ::kill(pid, SIGKILL));
+
+ // Wait for the child process.
+ int status;
+ EXPECT_NE(-1, ::waitpid((pid_t) -1, &status, 0));
+ ASSERT_TRUE(WIFSIGNALED(status));
+ EXPECT_EQ(SIGKILL, WTERMSIG(status));
}