Skip to content

Commit

Permalink
kernfs,memcg: Add test case for memcg helpers.
Browse files Browse the repository at this point in the history
Orabug: 37322867
Signed-off-by: Imran Khan <[email protected]>
  • Loading branch information
imran-kn committed Nov 26, 2024
1 parent 74e25ba commit 026be7e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_kernfs_memcg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2024, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
import drgn

from drgn_tools import kernfs_memcg as kernfs_memcg


def test_dump_page_cache_pages_pinning_cgroups(prog: drgn.Program) -> None:
kernfs_memcg.dump_page_cache_pages_pinning_cgroups(prog, 10)


def test_dump_memcgroup_hierarchy(prog: drgn.Program) -> None:
kernfs_memcg.dump_memcgroup_hierarchy(prog)


def test_kernfs_node_of_memcgroup(prog: drgn.Program) -> None:
count = 0
for kn in kernfs_memcg.for_each_kernfs_node(prog):
if kernfs_memcg.kernfs_node_of_memcgroup(kn):
count = count + 1
if count >= 5:
print("Found 5 memcgroup, kernfs_node objects.")
break


def test_get_num_active_mem_cgroups(prog: drgn.Program) -> None:
count = kernfs_memcg.get_num_active_mem_cgroups(prog)
print(f"number of active memcgroups: {count}\n")


def test_get_num_dying_mem_cgroups(prog: drgn.Program) -> None:
count = kernfs_memcg.get_num_dying_mem_cgroups(prog)
print(f"number of dying memcgroups: {count}\n")

0 comments on commit 026be7e

Please sign in to comment.