]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-cgroup-util.c
systemctl: fix log message when glob patterns passed to disable command and friends
[thirdparty/systemd.git] / src / test / test-cgroup-util.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "alloc-util.h"
4 #include "cgroup-util.h"
5 #include "dirent-util.h"
6 #include "errno-util.h"
7 #include "fd-util.h"
8 #include "format-util.h"
9 #include "parse-util.h"
10 #include "proc-cmdline.h"
11 #include "process-util.h"
12 #include "special.h"
13 #include "stat-util.h"
14 #include "string-util.h"
15 #include "strv.h"
16 #include "tests.h"
17 #include "user-util.h"
18
19 static void check_p_d_u(const char *path, int code, const char *result) {
20 _cleanup_free_ char *unit = NULL;
21 int r;
22
23 r = cg_path_decode_unit(path, &unit);
24 printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, strnull(result), code);
25 assert_se(r == code);
26 ASSERT_STREQ(unit, result);
27 }
28
29 TEST(path_decode_unit) {
30 check_p_d_u("getty@tty2.service", 0, "getty@tty2.service");
31 check_p_d_u("getty@tty2.service/", 0, "getty@tty2.service");
32 check_p_d_u("getty@tty2.service/xxx", 0, "getty@tty2.service");
33 check_p_d_u("getty@.service/", -ENXIO, NULL);
34 check_p_d_u("getty@.service", -ENXIO, NULL);
35 check_p_d_u("getty.service", 0, "getty.service");
36 check_p_d_u("getty", -ENXIO, NULL);
37 check_p_d_u("getty/waldo", -ENXIO, NULL);
38 check_p_d_u("_cpu.service", 0, "cpu.service");
39 }
40
41 static void check_p_g_u(const char *path, int code, const char *result) {
42 _cleanup_free_ char *unit = NULL;
43 int r;
44
45 r = cg_path_get_unit(path, &unit);
46 printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, strnull(result), code);
47 assert_se(r == code);
48 ASSERT_STREQ(unit, result);
49 }
50
51 TEST(path_get_unit) {
52 check_p_g_u("/system.slice/foobar.service/sdfdsaf", 0, "foobar.service");
53 check_p_g_u("/system.slice/getty@tty5.service", 0, "getty@tty5.service");
54 check_p_g_u("/system.slice/getty@tty5.service/aaa/bbb", 0, "getty@tty5.service");
55 check_p_g_u("/system.slice/getty@tty5.service/", 0, "getty@tty5.service");
56 check_p_g_u("/system.slice/getty@tty6.service/tty5", 0, "getty@tty6.service");
57 check_p_g_u("sadfdsafsda", -ENXIO, NULL);
58 check_p_g_u("/system.slice/getty####@tty6.service/xxx", -ENXIO, NULL);
59 check_p_g_u("/system.slice/system-waldo.slice/foobar.service/sdfdsaf", 0, "foobar.service");
60 check_p_g_u("/system.slice/system-waldo.slice/_cpu.service/sdfdsaf", 0, "cpu.service");
61 check_p_g_u("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "user@1000.service");
62 check_p_g_u("/user.slice/user-1000.slice/user@.service/server.service", -ENXIO, NULL);
63 }
64
65 static void check_p_g_u_p(const char *path, int code, const char *result) {
66 _cleanup_free_ char *unit_path = NULL;
67 int r;
68
69 r = cg_path_get_unit_path(path, &unit_path);
70 printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit_path, r, strnull(result), code);
71 assert_se(r == code);
72 ASSERT_STREQ(unit_path, result);
73 }
74
75 TEST(path_get_unit_path) {
76 check_p_g_u_p("/system.slice/foobar.service/sdfdsaf", 0, "/system.slice/foobar.service");
77 check_p_g_u_p("/system.slice/getty@tty5.service", 0, "/system.slice/getty@tty5.service");
78 check_p_g_u_p("/system.slice/getty@tty5.service/aaa/bbb", 0, "/system.slice/getty@tty5.service");
79 check_p_g_u_p("/system.slice/getty@tty5.service/", 0, "/system.slice/getty@tty5.service");
80 check_p_g_u_p("/system.slice/getty@tty6.service/tty5", 0, "/system.slice/getty@tty6.service");
81 check_p_g_u_p("sadfdsafsda", -ENXIO, NULL);
82 check_p_g_u_p("/system.slice/getty####@tty6.service/xxx", -ENXIO, NULL);
83 check_p_g_u_p("/system.slice/system-waldo.slice/foobar.service/sdfdsaf", 0, "/system.slice/system-waldo.slice/foobar.service");
84 check_p_g_u_p("/system.slice/system-waldo.slice/_cpu.service/sdfdsaf", 0, "/system.slice/system-waldo.slice/_cpu.service");
85 check_p_g_u_p("/system.slice/system-waldo.slice/_cpu.service", 0, "/system.slice/system-waldo.slice/_cpu.service");
86 check_p_g_u_p("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "/user.slice/user-1000.slice/user@1000.service");
87 check_p_g_u_p("/user.slice/user-1000.slice/user@.service/server.service", -ENXIO, NULL);
88 check_p_g_u_p("/user.slice/_user-1000.slice/user@1000.service/foobar.slice/foobar@pie.service", 0, "/user.slice/_user-1000.slice/user@1000.service");
89 check_p_g_u_p("/_session-2.scope/_foobar@pie.service/pa/po", 0, "/_session-2.scope");
90 }
91
92 static void check_p_g_u_u(const char *path, int code, const char *result) {
93 _cleanup_free_ char *unit = NULL;
94 int r;
95
96 r = cg_path_get_user_unit(path, &unit);
97 printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit, r, strnull(result), code);
98 assert_se(r == code);
99 ASSERT_STREQ(unit, result);
100 }
101
102 TEST(path_get_user_unit) {
103 check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, "foobar.service");
104 check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo.slice/foobar.service", 0, "foobar.service");
105 check_p_g_u_u("/user.slice/user-1002.slice/session-2.scope/foobar.service/waldo", 0, "foobar.service");
106 check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service/waldo/uuuux", 0, "foobar.service");
107 check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo/waldo/uuuux", -ENXIO, NULL);
108 check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
109 check_p_g_u_u("/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
110 check_p_g_u_u("/xyz.slice/xyz-waldo.slice/session-77.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service");
111 check_p_g_u_u("/meh.service", -ENXIO, NULL);
112 check_p_g_u_u("/session-3.scope/_cpu.service", 0, "cpu.service");
113 check_p_g_u_u("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "server.service");
114 check_p_g_u_u("/user.slice/user-1000.slice/user@1000.service/foobar.slice/foobar@pie.service", 0, "foobar@pie.service");
115 check_p_g_u_u("/user.slice/user-1000.slice/user@.service/server.service", -ENXIO, NULL);
116 }
117
118 static void check_p_g_s(const char *path, int code, const char *result) {
119 _cleanup_free_ char *s = NULL;
120
121 assert_se(cg_path_get_session(path, &s) == code);
122 ASSERT_STREQ(s, result);
123 }
124
125 TEST(path_get_session) {
126 check_p_g_s("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, "2");
127 check_p_g_s("/session-3.scope", 0, "3");
128 check_p_g_s("/session-.scope", -ENXIO, NULL);
129 check_p_g_s("", -ENXIO, NULL);
130 }
131
132 static void check_p_g_o_u(const char *path, int code, uid_t result) {
133 uid_t uid = 0;
134
135 assert_se(cg_path_get_owner_uid(path, &uid) == code);
136 assert_se(uid == result);
137 }
138
139 TEST(path_get_owner_uid) {
140 check_p_g_o_u("/user.slice/user-1000.slice/session-2.scope/foobar.service", 0, 1000);
141 check_p_g_o_u("/user.slice/user-1006.slice", 0, 1006);
142 check_p_g_o_u("", -ENXIO, 0);
143 }
144
145 static void check_p_g_slice(const char *path, int code, const char *result) {
146 _cleanup_free_ char *s = NULL;
147
148 assert_se(cg_path_get_slice(path, &s) == code);
149 ASSERT_STREQ(s, result);
150 }
151
152 TEST(path_get_slice) {
153 check_p_g_slice("/user.slice", 0, "user.slice");
154 check_p_g_slice("/foobar", 0, SPECIAL_ROOT_SLICE);
155 check_p_g_slice("/user.slice/user-waldo.slice", 0, "user-waldo.slice");
156 check_p_g_slice("", 0, SPECIAL_ROOT_SLICE);
157 check_p_g_slice("foobar", 0, SPECIAL_ROOT_SLICE);
158 check_p_g_slice("foobar.slice", 0, "foobar.slice");
159 check_p_g_slice("foo.slice/foo-bar.slice/waldo.service", 0, "foo-bar.slice");
160 }
161
162 static void check_p_g_u_slice(const char *path, int code, const char *result) {
163 _cleanup_free_ char *s = NULL;
164
165 assert_se(cg_path_get_user_slice(path, &s) == code);
166 ASSERT_STREQ(s, result);
167 }
168
169 TEST(path_get_user_slice) {
170 check_p_g_u_slice("/user.slice", -ENXIO, NULL);
171 check_p_g_u_slice("/foobar", -ENXIO, NULL);
172 check_p_g_u_slice("/user.slice/user-waldo.slice", -ENXIO, NULL);
173 check_p_g_u_slice("", -ENXIO, NULL);
174 check_p_g_u_slice("foobar", -ENXIO, NULL);
175 check_p_g_u_slice("foobar.slice", -ENXIO, NULL);
176 check_p_g_u_slice("foo.slice/foo-bar.slice/waldo.service", -ENXIO, NULL);
177
178 check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service", 0, SPECIAL_ROOT_SLICE);
179 check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/", 0, SPECIAL_ROOT_SLICE);
180 check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service///", 0, SPECIAL_ROOT_SLICE);
181 check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/waldo.service", 0, SPECIAL_ROOT_SLICE);
182 check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/piep.slice/foo.service", 0, "piep.slice");
183 check_p_g_u_slice("/foo.slice//foo-bar.slice/user@1000.service/piep.slice//piep-pap.slice//foo.service", 0, "piep-pap.slice");
184 }
185
186 TEST(get_paths, .sd_booted = true) {
187 _cleanup_free_ char *a = NULL;
188
189 assert_se(cg_get_root_path(&a) >= 0);
190 log_info("Root = %s", a);
191 }
192
193 TEST(proc) {
194 _cleanup_closedir_ DIR *d = NULL;
195 int r;
196
197 ASSERT_OK(proc_dir_open(&d));
198
199 for (;;) {
200 _cleanup_free_ char *path = NULL, *path_shifted = NULL, *session = NULL, *unit = NULL, *user_unit = NULL, *machine = NULL, *slice = NULL;
201 _cleanup_(pidref_done) PidRef pid = PIDREF_NULL;
202 uid_t uid = UID_INVALID;
203
204 r = proc_dir_read_pidref(d, &pid);
205 assert_se(r >= 0);
206
207 if (r == 0)
208 break;
209
210 if (pidref_is_kernel_thread(&pid) != 0)
211 continue;
212
213 cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid.pid, &path);
214 cg_pid_get_path_shifted(pid.pid, NULL, &path_shifted);
215 cg_pid_get_owner_uid(pid.pid, &uid);
216 cg_pid_get_session(pid.pid, &session);
217 cg_pid_get_unit(pid.pid, &unit);
218 cg_pid_get_user_unit(pid.pid, &user_unit);
219 cg_pid_get_machine_name(pid.pid, &machine);
220 cg_pid_get_slice(pid.pid, &slice);
221
222 printf(PID_FMT"\t%s\t%s\t"UID_FMT"\t%s\t%s\t%s\t%s\t%s\n",
223 pid.pid,
224 path,
225 path_shifted,
226 uid,
227 session,
228 unit,
229 user_unit,
230 machine,
231 slice);
232 }
233 }
234
235 static void test_escape_one(const char *s, const char *expected) {
236 _cleanup_free_ char *b = NULL;
237
238 assert_se(s);
239 assert_se(expected);
240
241 ASSERT_OK(cg_escape(s, &b));
242 ASSERT_STREQ(b, expected);
243
244 ASSERT_STREQ(cg_unescape(b), s);
245
246 assert_se(filename_is_valid(b));
247 assert_se(!cg_needs_escape(s) || b[0] == '_');
248 }
249
250 TEST(escape, .sd_booted = true) {
251 test_escape_one("foobar", "foobar");
252 test_escape_one(".foobar", "_.foobar");
253 test_escape_one("foobar.service", "foobar.service");
254 test_escape_one("cgroup.service", "_cgroup.service");
255 test_escape_one("tasks", "_tasks");
256 if (access("/sys/fs/cgroup/cpu", F_OK) == 0)
257 test_escape_one("cpu.service", "_cpu.service");
258 test_escape_one("_foobar", "__foobar");
259 test_escape_one("", "_");
260 test_escape_one("_", "__");
261 test_escape_one(".", "_.");
262 }
263
264 TEST(controller_is_valid) {
265 assert_se(cg_controller_is_valid("foobar"));
266 assert_se(cg_controller_is_valid("foo_bar"));
267 assert_se(cg_controller_is_valid("name=foo"));
268 assert_se(!cg_controller_is_valid(""));
269 assert_se(!cg_controller_is_valid("name="));
270 assert_se(!cg_controller_is_valid("="));
271 assert_se(!cg_controller_is_valid("cpu,cpuacct"));
272 assert_se(!cg_controller_is_valid("_"));
273 assert_se(!cg_controller_is_valid("_foobar"));
274 assert_se(!cg_controller_is_valid("tatü"));
275 }
276
277 static void test_slice_to_path_one(const char *unit, const char *path, int error) {
278 _cleanup_free_ char *ret = NULL;
279 int r;
280
281 log_info("unit: %s", unit);
282
283 r = cg_slice_to_path(unit, &ret);
284 log_info("actual: %s / %d", strnull(ret), r);
285 log_info("expect: %s / %d", strnull(path), error);
286 assert_se(r == error);
287 ASSERT_STREQ(ret, path);
288 }
289
290 TEST(slice_to_path) {
291 test_slice_to_path_one("foobar.slice", "foobar.slice", 0);
292 test_slice_to_path_one("foobar-waldo.slice", "foobar.slice/foobar-waldo.slice", 0);
293 test_slice_to_path_one("foobar-waldo.service", NULL, -EINVAL);
294 test_slice_to_path_one(SPECIAL_ROOT_SLICE, "", 0);
295 test_slice_to_path_one("--.slice", NULL, -EINVAL);
296 test_slice_to_path_one("-", NULL, -EINVAL);
297 test_slice_to_path_one("-foo-.slice", NULL, -EINVAL);
298 test_slice_to_path_one("-foo.slice", NULL, -EINVAL);
299 test_slice_to_path_one("foo-.slice", NULL, -EINVAL);
300 test_slice_to_path_one("foo--bar.slice", NULL, -EINVAL);
301 test_slice_to_path_one("foo.slice/foo--bar.slice", NULL, -EINVAL);
302 test_slice_to_path_one("a-b.slice", "a.slice/a-b.slice", 0);
303 test_slice_to_path_one("a-b-c-d-e.slice", "a.slice/a-b.slice/a-b-c.slice/a-b-c-d.slice/a-b-c-d-e.slice", 0);
304
305 test_slice_to_path_one("foobar@.slice", NULL, -EINVAL);
306 test_slice_to_path_one("foobar@waldo.slice", NULL, -EINVAL);
307 test_slice_to_path_one("foobar@waldo.service", NULL, -EINVAL);
308 test_slice_to_path_one("-foo@-.slice", NULL, -EINVAL);
309 test_slice_to_path_one("-foo@.slice", NULL, -EINVAL);
310 test_slice_to_path_one("foo@-.slice", NULL, -EINVAL);
311 test_slice_to_path_one("foo@@bar.slice", NULL, -EINVAL);
312 test_slice_to_path_one("foo.slice/foo@@bar.slice", NULL, -EINVAL);
313 }
314
315 static void test_shift_path_one(const char *raw, const char *root, const char *shifted) {
316 const char *s = NULL;
317
318 ASSERT_OK(cg_shift_path(raw, root, &s));
319 ASSERT_STREQ(s, shifted);
320 }
321
322 TEST(shift_path) {
323 test_shift_path_one("/foobar/waldo", "/", "/foobar/waldo");
324 test_shift_path_one("/foobar/waldo", "", "/foobar/waldo");
325 test_shift_path_one("/foobar/waldo", "/foobar", "/waldo");
326 test_shift_path_one("/foobar/waldo", "/hogehoge", "/foobar/waldo");
327 }
328
329 TEST(mask_supported, .sd_booted = true) {
330 CGroupMask m;
331
332 ASSERT_OK(cg_mask_supported(&m));
333
334 for (CGroupController c = 0; c < _CGROUP_CONTROLLER_MAX; c++)
335 printf("'%s' is supported: %s\n",
336 cgroup_controller_to_string(c),
337 yes_no(m & CGROUP_CONTROLLER_TO_MASK(c)));
338 }
339
340 TEST(is_cgroup_fs, .sd_booted = true) {
341 struct statfs sfs;
342 assert_se(statfs("/sys/fs/cgroup", &sfs) == 0);
343 if (is_temporary_fs(&sfs))
344 assert_se(statfs("/sys/fs/cgroup/systemd", &sfs) == 0);
345 assert_se(is_cgroup_fs(&sfs));
346 }
347
348 TEST(fd_is_cgroup_fs, .sd_booted = true) {
349 int fd;
350
351 fd = open("/sys/fs/cgroup", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
352 assert_se(fd >= 0);
353 if (fd_is_temporary_fs(fd)) {
354 fd = safe_close(fd);
355 fd = open("/sys/fs/cgroup/systemd", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
356 assert_se(fd >= 0);
357 }
358 assert_se(fd_is_cgroup_fs(fd));
359 fd = safe_close(fd);
360 }
361
362 TEST(cg_tests) {
363 int all, hybrid, systemd, r;
364
365 r = cg_unified();
366 if (IN_SET(r, -ENOENT, -ENOMEDIUM)) {
367 log_tests_skipped("cgroup not mounted");
368 return;
369 }
370 assert_se(r >= 0);
371
372 all = cg_all_unified();
373 assert_se(IN_SET(all, 0, 1));
374
375 hybrid = cg_hybrid_unified();
376 assert_se(IN_SET(hybrid, 0, 1));
377
378 systemd = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
379 assert_se(IN_SET(systemd, 0, 1));
380
381 if (all) {
382 assert_se(systemd);
383 assert_se(!hybrid);
384
385 } else if (hybrid) {
386 assert_se(systemd);
387 assert_se(!all);
388
389 } else
390 assert_se(!systemd);
391 }
392
393 TEST(cg_get_keyed_attribute) {
394 _cleanup_free_ char *val = NULL;
395 char *vals3[3] = {}, *vals3a[3] = {};
396 int r;
397
398 r = cg_get_keyed_attribute("cpu", "/init.scope", "no_such_file", STRV_MAKE("no_such_attr"), &val);
399 if (IN_SET(r, -ENOMEDIUM, -ENOENT) || ERRNO_IS_PRIVILEGE(r)) {
400 log_info_errno(r, "Skipping most of %s, /sys/fs/cgroup not accessible: %m", __func__);
401 return;
402 }
403
404 assert_se(r == -ENOENT);
405 ASSERT_NULL(val);
406
407 if (access("/sys/fs/cgroup/init.scope/cpu.stat", R_OK) < 0) {
408 log_info_errno(errno, "Skipping most of %s, /init.scope/cpu.stat not accessible: %m", __func__);
409 return;
410 }
411
412 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("no_such_attr"), &val) == -ENXIO);
413 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("no_such_attr"), &val) == 0);
414 ASSERT_NULL(val);
415
416 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec"), &val) == 0);
417 val = mfree(val);
418
419 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec"), &val) == 1);
420 log_info("cpu /init.scope cpu.stat [usage_usec] → \"%s\"", val);
421
422 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == -ENXIO);
423 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == 1);
424 assert_se(vals3[0] && !vals3[1]);
425 free(vals3[0]);
426
427 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == -ENXIO);
428 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == 1);
429 assert_se(vals3[0] && !vals3[1]);
430 free(vals3[0]);
431
432 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat",
433 STRV_MAKE("usage_usec", "user_usec", "system_usec"), vals3) == 0);
434 for (size_t i = 0; i < 3; i++)
435 free(vals3[i]);
436
437 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat",
438 STRV_MAKE("usage_usec", "user_usec", "system_usec"), vals3) == 3);
439 log_info("cpu /init.scope cpu.stat [usage_usec user_usec system_usec] → \"%s\", \"%s\", \"%s\"",
440 vals3[0], vals3[1], vals3[2]);
441
442 assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat",
443 STRV_MAKE("system_usec", "user_usec", "usage_usec"), vals3a) == 0);
444 for (size_t i = 0; i < 3; i++)
445 free(vals3a[i]);
446
447 assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat",
448 STRV_MAKE("system_usec", "user_usec", "usage_usec"), vals3a) == 3);
449 log_info("cpu /init.scope cpu.stat [system_usec user_usec usage_usec] → \"%s\", \"%s\", \"%s\"",
450 vals3a[0], vals3a[1], vals3a[2]);
451
452 for (size_t i = 0; i < 3; i++) {
453 free(vals3[i]);
454 free(vals3a[i]);
455 }
456 }
457
458 TEST(bfq_weight_conversion) {
459 assert_se(BFQ_WEIGHT(1) == 1);
460 assert_se(BFQ_WEIGHT(50) == 50);
461 assert_se(BFQ_WEIGHT(100) == 100);
462 assert_se(BFQ_WEIGHT(500) == 136);
463 assert_se(BFQ_WEIGHT(5000) == 545);
464 assert_se(BFQ_WEIGHT(10000) == 1000);
465 }
466
467 DEFINE_TEST_MAIN(LOG_DEBUG);