| 112 | { |
| 113 | public: |
| 114 | CfsFilter() |
| 115 | { |
| 116 | #ifdef __linux__ |
| 117 | Result<string> hierarchy = cgroups::hierarchy("cpu"); |
| 118 | if (hierarchy.isSome()) { |
| 119 | bool cfsQuotaEnabled = |
| 120 | os::exists(path::join(hierarchy.get(), "cpu.cfs_quota_us")); |
| 121 | |
| 122 | if (cfsQuotaEnabled) { |
| 123 | cfsError = None(); |
| 124 | } else { |
| 125 | cfsError = Error("CFS bandwidth control is not available"); |
| 126 | } |
| 127 | } else if (hierarchy.isError()) { |
| 128 | cfsError = Error( |
| 129 | "There was an error finding the 'cpu' cgroup hierarchy:\n" + |
| 130 | hierarchy.error()); |
| 131 | } else { |
| 132 | cfsError = Error( |
| 133 | "The 'cpu' cgroup hierarchy was not found, which means\n" |
| 134 | "that CFS bandwidth control is not available"); |
| 135 | } |
| 136 | |
| 137 | if (cfsError.isSome()) { |
| 138 | std::cerr |
| 139 | << "-------------------------------------------------------------\n" |
| 140 | << "The 'CFS_' tests cannot be run because:\n" |
| 141 | << cfsError->message << "\n" |
| 142 | << "-------------------------------------------------------------" |
| 143 | << std::endl; |
| 144 | } |
| 145 | #else |
| 146 | cfsError = Error( |
| 147 | "These tests require CFS bandwidth control, which is a " |
| 148 | "Linux kernel feature, but Linux has not been detected"); |
| 149 | #endif // __linux__ |
| 150 | } |
| 151 | |
| 152 | bool disable(const ::testing::TestInfo* test) const override |
| 153 | { |