Skip to content

Commit 771d775

Browse files
sjp38akpm00
authored andcommitted
selftests/damon/sysfs.py: generalize DAMOS schemes commit assertion
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/[email protected] Signed-off-by: SeongJae Park <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 53f8005 commit 771d775

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/testing/selftests/damon/sysfs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ def assert_scheme_committed(scheme, dump):
136136
for idx, f in enumerate(scheme.ops_filters.filters):
137137
assert_filter_committed(f, dump['ops_filters'][idx])
138138

139+
def assert_schemes_committed(schemes, dump):
140+
assert_true(len(schemes) == len(dump), 'len_schemes', dump)
141+
for idx, scheme in enumerate(schemes):
142+
assert_scheme_committed(scheme, dump[idx])
143+
139144
def main():
140145
kdamonds = _damon_sysfs.Kdamonds(
141146
[_damon_sysfs.Kdamond(
@@ -180,10 +185,7 @@ def main():
180185
{ 'pid': 0, 'nr_regions': 0, 'regions_list': []}]:
181186
fail('adaptive targets', status)
182187

183-
if len(ctx['schemes']) != 1:
184-
fail('number of schemes', status)
185-
186-
assert_scheme_committed(_damon_sysfs.Damos(), ctx['schemes'][0])
188+
assert_schemes_committed([_damon_sysfs.Damos()], ctx['schemes'])
187189

188190
kdamonds.stop()
189191

0 commit comments

Comments
 (0)