Lines Matching refs:ctx
95 _cleanup_(oomd_cgroup_context_freep) OomdCGroupContext *ctx = NULL; in test_oomd_cgroup_context_acquire_and_insert()
129 assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0); in test_oomd_cgroup_context_acquire_and_insert()
131 assert_se(streq(ctx->path, cgroup)); in test_oomd_cgroup_context_acquire_and_insert()
132 assert_se(ctx->current_memory_usage > 0); in test_oomd_cgroup_context_acquire_and_insert()
133 assert_se(ctx->memory_min == 0); in test_oomd_cgroup_context_acquire_and_insert()
134 assert_se(ctx->memory_low == 0); in test_oomd_cgroup_context_acquire_and_insert()
135 assert_se(ctx->swap_usage == 0); in test_oomd_cgroup_context_acquire_and_insert()
136 assert_se(ctx->last_pgscan == 0); in test_oomd_cgroup_context_acquire_and_insert()
137 assert_se(ctx->pgscan == 0); in test_oomd_cgroup_context_acquire_and_insert()
140 assert_se(ctx->preference == MANAGED_OOM_PREFERENCE_OMIT); in test_oomd_cgroup_context_acquire_and_insert()
142 assert_se(ctx->preference == MANAGED_OOM_PREFERENCE_NONE); in test_oomd_cgroup_context_acquire_and_insert()
143 ctx = oomd_cgroup_context_free(ctx); in test_oomd_cgroup_context_acquire_and_insert()
150 assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0); in test_oomd_cgroup_context_acquire_and_insert()
152 assert_se(ctx->preference == MANAGED_OOM_PREFERENCE_AVOID); in test_oomd_cgroup_context_acquire_and_insert()
153 ctx = oomd_cgroup_context_free(ctx); in test_oomd_cgroup_context_acquire_and_insert()
162 assert_se(oomd_cgroup_context_acquire("", &ctx) == 0); in test_oomd_cgroup_context_acquire_and_insert()
163 assert_se(streq(ctx->path, "/")); in test_oomd_cgroup_context_acquire_and_insert()
164 assert_se(ctx->current_memory_usage > 0); in test_oomd_cgroup_context_acquire_and_insert()
165 assert_se(ctx->preference == root_pref); in test_oomd_cgroup_context_acquire_and_insert()
193 ctx = oomd_cgroup_context_free(ctx); in test_oomd_cgroup_context_acquire_and_insert()
195 assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0); in test_oomd_cgroup_context_acquire_and_insert()
196 assert_se(ctx->preference == MANAGED_OOM_PREFERENCE_NONE); in test_oomd_cgroup_context_acquire_and_insert()
254 OomdSystemContext ctx; in test_oomd_system_context_acquire() local
261 assert_se(oomd_system_context_acquire("/verylikelynonexistentpath", &ctx) == -ENOENT); in test_oomd_system_context_acquire()
263 assert_se(oomd_system_context_acquire(path, &ctx) == -EINVAL); in test_oomd_system_context_acquire()
266 assert_se(oomd_system_context_acquire(path, &ctx) == -EINVAL); in test_oomd_system_context_acquire()
272 assert_se(oomd_system_context_acquire(path, &ctx) == -EINVAL); in test_oomd_system_context_acquire()
283 assert_se(oomd_system_context_acquire(path, &ctx) == 0); in test_oomd_system_context_acquire()
284 assert_se(ctx.mem_total == 33275142144); in test_oomd_system_context_acquire()
285 assert_se(ctx.mem_used == 10975404032); in test_oomd_system_context_acquire()
286 assert_se(ctx.swap_total == 8589930496); in test_oomd_system_context_acquire()
287 assert_se(ctx.swap_used == 8582144000); in test_oomd_system_context_acquire()
293 OomdCGroupContext ctx[2] = {}, *c; in test_oomd_pressure_above() local
299 assert_se(store_loadavg_fixed_point(99, 99, &(ctx[0].memory_pressure.avg10)) == 0); in test_oomd_pressure_above()
300 assert_se(store_loadavg_fixed_point(99, 99, &(ctx[0].memory_pressure.avg60)) == 0); in test_oomd_pressure_above()
301 assert_se(store_loadavg_fixed_point(99, 99, &(ctx[0].memory_pressure.avg300)) == 0); in test_oomd_pressure_above()
302 ctx[0].mem_pressure_limit = threshold; in test_oomd_pressure_above()
305 assert_se(store_loadavg_fixed_point(1, 11, &(ctx[1].memory_pressure.avg10)) == 0); in test_oomd_pressure_above()
306 assert_se(store_loadavg_fixed_point(1, 11, &(ctx[1].memory_pressure.avg60)) == 0); in test_oomd_pressure_above()
307 assert_se(store_loadavg_fixed_point(1, 11, &(ctx[1].memory_pressure.avg300)) == 0); in test_oomd_pressure_above()
308 ctx[1].mem_pressure_limit = threshold; in test_oomd_pressure_above()
312 assert_se(hashmap_put(h1, "/herp.slice", &ctx[0]) >= 0); in test_oomd_pressure_above()
314 assert_se(set_contains(t1, &ctx[0])); in test_oomd_pressure_above()
320 assert_se(hashmap_put(h2, "/derp.slice", &ctx[1]) >= 0); in test_oomd_pressure_above()
327 assert_se(hashmap_put(h1, "/derp.slice", &ctx[1]) >= 0); in test_oomd_pressure_above()
329 assert_se(set_contains(t3, &ctx[0])); in test_oomd_pressure_above()
338 OomdSystemContext ctx = (OomdSystemContext) { in test_oomd_mem_and_swap_free_below()
344 assert_se(oomd_mem_available_below(&ctx, 2000) == false); in test_oomd_mem_and_swap_free_below()
345 assert_se(oomd_swap_free_below(&ctx, 2000) == true); in test_oomd_mem_and_swap_free_below()
347 ctx = (OomdSystemContext) { in test_oomd_mem_and_swap_free_below()
353 assert_se(oomd_mem_available_below(&ctx, 2000) == true); in test_oomd_mem_and_swap_free_below()
354 assert_se(oomd_swap_free_below(&ctx, 2000) == false); in test_oomd_mem_and_swap_free_below()
356 ctx = (OomdSystemContext) { in test_oomd_mem_and_swap_free_below()
362 assert_se(oomd_mem_available_below(&ctx, 2000) == false); in test_oomd_mem_and_swap_free_below()
363 assert_se(oomd_swap_free_below(&ctx, 2000) == false); in test_oomd_mem_and_swap_free_below()
377 OomdCGroupContext ctx[7] = { in test_oomd_sort_cgroups() local
417 assert_se(hashmap_put(h, "/herp.slice", &ctx[0]) >= 0); in test_oomd_sort_cgroups()
418 assert_se(hashmap_put(h, "/herp.slice/derp.scope", &ctx[1]) >= 0); in test_oomd_sort_cgroups()
419 assert_se(hashmap_put(h, "/herp.slice/derp.scope/sheep.service", &ctx[2]) >= 0); in test_oomd_sort_cgroups()
420 assert_se(hashmap_put(h, "/zupa.slice", &ctx[3]) >= 0); in test_oomd_sort_cgroups()
421 assert_se(hashmap_put(h, "/boop.slice", &ctx[4]) >= 0); in test_oomd_sort_cgroups()
422 assert_se(hashmap_put(h, "/omitted.slice", &ctx[5]) >= 0); in test_oomd_sort_cgroups()
423 assert_se(hashmap_put(h, "/avoid.slice", &ctx[6]) >= 0); in test_oomd_sort_cgroups()
426 assert_se(sorted_cgroups[0] == &ctx[1]); in test_oomd_sort_cgroups()
427 assert_se(sorted_cgroups[1] == &ctx[2]); in test_oomd_sort_cgroups()
428 assert_se(sorted_cgroups[2] == &ctx[0]); in test_oomd_sort_cgroups()
429 assert_se(sorted_cgroups[3] == &ctx[4]); in test_oomd_sort_cgroups()
430 assert_se(sorted_cgroups[4] == &ctx[3]); in test_oomd_sort_cgroups()
431 assert_se(sorted_cgroups[5] == &ctx[6]); in test_oomd_sort_cgroups()
435 assert_se(sorted_cgroups[0] == &ctx[0]); in test_oomd_sort_cgroups()
436 assert_se(sorted_cgroups[1] == &ctx[2]); in test_oomd_sort_cgroups()
437 assert_se(sorted_cgroups[2] == &ctx[3]); in test_oomd_sort_cgroups()
438 assert_se(sorted_cgroups[3] == &ctx[1]); in test_oomd_sort_cgroups()
439 assert_se(sorted_cgroups[4] == &ctx[4]); in test_oomd_sort_cgroups()
440 assert_se(sorted_cgroups[5] == &ctx[6]); in test_oomd_sort_cgroups()
444 assert_se(sorted_cgroups[0] == &ctx[2]); in test_oomd_sort_cgroups()
445 assert_se(sorted_cgroups[1] == &ctx[1]); in test_oomd_sort_cgroups()