| 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 |
nothing calls this directly
no test coverage detected