Skip to content

Commit f797e70

Browse files
sjp38akpm00
authored andcommitted
selftests/damon/sysfs.py: generalize DamosQuota commit assertion
DamosQuota 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 b50c48d commit f797e70

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

tools/testing/selftests/damon/sysfs.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ def assert_watermarks_committed(watermarks, dump):
4545
assert_true(dump['mid'] == watermarks.mid, 'mid', dump)
4646
assert_true(dump['low'] == watermarks.low, 'low', dump)
4747

48+
def assert_quota_committed(quota, dump):
49+
assert_true(dump['reset_interval'] == quota.reset_interval_ms,
50+
'reset_interval', dump)
51+
assert_true(dump['ms'] == quota.ms, 'ms', dump)
52+
assert_true(dump['sz'] == quota.sz, 'sz', dump)
53+
# TODO: assert goals are committed
54+
assert_true(dump['weight_sz'] == quota.weight_sz_permil, 'weight_sz', dump)
55+
assert_true(dump['weight_nr_accesses'] == quota.weight_nr_accesses_permil,
56+
'weight_nr_accesses', dump)
57+
assert_true(
58+
dump['weight_age'] == quota.weight_age_permil, 'weight_age', dump)
59+
4860
def main():
4961
kdamonds = _damon_sysfs.Kdamonds(
5062
[_damon_sysfs.Kdamond(
@@ -109,18 +121,15 @@ def main():
109121
if scheme['target_nid'] != -1:
110122
fail('damos target nid', status)
111123

112-
if scheme['quota'] != {
113-
'reset_interval': 0,
114-
'ms': 0,
115-
'sz': 0,
116-
'goals': [],
117-
'esz': 0,
118-
'weight_sz': 0,
119-
'weight_nr_accesses': 0,
120-
'weight_age': 0,
121-
}:
122-
fail('damos quota', status)
124+
migrate_dests = scheme['migrate_dests']
125+
if migrate_dests['nr_dests'] != 0:
126+
fail('nr_dests', status)
127+
if migrate_dests['node_id_arr'] != []:
128+
fail('node_id_arr', status)
129+
if migrate_dests['weight_arr'] != []:
130+
fail('weight_arr', status)
123131

132+
assert_quota_committed(_damon_sysfs.DamosQuota(), scheme['quota'])
124133
assert_watermarks_committed(_damon_sysfs.DamosWatermarks(),
125134
scheme['wmarks'])
126135

0 commit comments

Comments
 (0)