]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/damon/sysfs.py: generalize DAMOS schemes commit assertion
authorSeongJae Park <sj@kernel.org>
Sun, 20 Jul 2025 17:16:48 +0000 (10:16 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 26 Jul 2025 22:08:20 +0000 (15:08 -0700)
DAMOS schemes commitment assertion is hard-coded for a specific test case.
Split it out into a general version that can be reused for different test
cases.

Link: https://lkml.kernel.org/r/20250720171652.92309-19-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/damon/sysfs.py

index 6471cb8c6de2de9bad1940d579f06cfa32e0ea4b..4d13da00733ebdb90424a04b15351c1d2803405e 100755 (executable)
@@ -136,6 +136,11 @@ def assert_scheme_committed(scheme, dump):
     for idx, f in enumerate(scheme.ops_filters.filters):
         assert_filter_committed(f, dump['ops_filters'][idx])
 
+def assert_schemes_committed(schemes, dump):
+    assert_true(len(schemes) == len(dump), 'len_schemes', dump)
+    for idx, scheme in enumerate(schemes):
+        assert_scheme_committed(scheme, dump[idx])
+
 def main():
     kdamonds = _damon_sysfs.Kdamonds(
             [_damon_sysfs.Kdamond(
@@ -180,10 +185,7 @@ def main():
             { 'pid': 0, 'nr_regions': 0, 'regions_list': []}]:
         fail('adaptive targets', status)
 
-    if len(ctx['schemes']) != 1:
-        fail('number of schemes', status)
-
-    assert_scheme_committed(_damon_sysfs.Damos(), ctx['schemes'][0])
+    assert_schemes_committed([_damon_sysfs.Damos()], ctx['schemes'])
 
     kdamonds.stop()