MCPcopy Create free account
hub / github.com/apache/mesos / TEST

Function TEST

src/tests/containerizer/ns_tests.cpp:58–98  ·  view source on GitHub ↗

Test that a child in different namespace(s) can setns back to the root namespace. We must fork a child to test this because setns doesn't support multi-threaded processes (which gtest is).

Source from the content-addressed store, hash-verified

56// root namespace. We must fork a child to test this because setns
57// doesn't support multi-threaded processes (which gtest is).
58TEST(NsTest, ROOT_setns)
59{
60 // Clone then exec the setns-test-helper into a new namespace for
61 // each available namespace.
62 int flags = 0;
63
64 foreach (int nsType, ns::nstypes()) {
65 // Skip 'user' namespace because it causes 'clone' to change us
66 // from being user 'root' to user 'nobody', but these tests
67 // require root. See MESOS-3083.
68 if (nsType == CLONE_NEWUSER) {
69 continue;
70 }
71
72 flags |= nsType;
73 }
74
75 ASSERT_NE(0, flags);
76
77 vector<string> argv;
78 argv.push_back("test-helper");
79 argv.push_back(SetnsTestHelper::NAME);
80
81 Try<Subprocess> s = subprocess(
82 getTestHelperPath("test-helper"),
83 argv,
84 Subprocess::FD(STDIN_FILENO),
85 Subprocess::FD(STDOUT_FILENO),
86 Subprocess::FD(STDERR_FILENO),
87 nullptr,
88 None(),
89 [=](const lambda::function<int()>& child) {
90 return os::clone(child, flags | SIGCHLD);
91 });
92
93 // Continue in parent.
94 ASSERT_SOME(s);
95
96 // The child should exit 0.
97 AWAIT_EXPECT_WEXITSTATUS_EQ(0, s->status());
98}
99
100
101// Test the ns::supported() API.

Callers

nothing calls this directly

Calls 15

getTestHelperPathFunction · 0.85
NoneClass · 0.85
nstypesFunction · 0.85
nsnameFunction · 0.85
getnsFunction · 0.85
nstypeFunction · 0.85
reapFunction · 0.85
triggerMethod · 0.80
failureMethod · 0.80
joinMethod · 0.65
runMethod · 0.65
subprocessFunction · 0.50

Tested by

no test coverage detected