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

Method foreach

src/tests/containerizer/cgroups_tests.cpp:135–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 CgroupsTest::SetUp();
134
135 foreach (const string& subsystem, strings::tokenize(subsystems, ",")) {
136 // Establish the base hierarchy if this is the first subsystem checked.
137 if (baseHierarchy.empty()) {
138 Result<string> hierarchy = cgroups::hierarchy(subsystem);
139 ASSERT_FALSE(hierarchy.isError());
140
141 if (hierarchy.isNone()) {
142 baseHierarchy = TEST_CGROUPS_HIERARCHY;
143 } else {
144 // Strip the subsystem to get the base hierarchy.
145 Try<string> baseDirname = Path(hierarchy.get()).dirname();
146 ASSERT_SOME(baseDirname);
147 baseHierarchy = baseDirname.get();
148 }
149 }
150
151 // Mount the subsystem if necessary.
152 string hierarchy = path::join(baseHierarchy, subsystem);
153 Try<bool> mounted = cgroups::mounted(hierarchy, subsystem);
154 ASSERT_SOME(mounted);
155 if (!mounted.get()) {
156 ASSERT_SOME(cgroups::mount(hierarchy, subsystem))
157 << "-------------------------------------------------------------\n"
158 << "We cannot run any cgroups tests that require\n"
159 << "a hierarchy with subsystem '" << subsystem << "'\n"
160 << "because we failed to find an existing hierarchy\n"
161 << "or create a new one (tried '" << hierarchy << "').\n"
162 << "You can either remove all existing\n"
163 << "hierarchies, or disable this test case\n"
164 << "(i.e., --gtest_filter=-"
165 << ::testing::UnitTest::GetInstance()
166 ->current_test_info()
167 ->test_case_name() << ".*).\n"
168 << "-------------------------------------------------------------";
169 }
170
171 Try<vector<string>> cgroups = cgroups::get(hierarchy);
172 ASSERT_SOME(cgroups);
173
174 foreach (const string& cgroup, cgroups.get()) {
175 // Remove any cgroups that start with TEST_CGROUPS_ROOT.
176 if (cgroup == TEST_CGROUPS_ROOT) {
177 AWAIT_READY(cgroups::destroy(hierarchy, cgroup));
178 }
179 }
180 }
181 }
182
183 void TearDown() override

Callers

nothing calls this directly

Calls 13

PathClass · 0.85
mountedFunction · 0.85
destroyFunction · 0.85
dirnameMethod · 0.80
hierarchyFunction · 0.50
joinFunction · 0.50
mountFunction · 0.50
getFunction · 0.50
killFunction · 0.50
emptyMethod · 0.45
isErrorMethod · 0.45
isNoneMethod · 0.45

Tested by

no test coverage detected