[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250720171652.92309-13-sj@kernel.org>
Date: Sun, 20 Jul 2025 10:16:42 -0700
From: SeongJae Park <sj@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: SeongJae Park <sj@...nel.org>,
Shuah Khan <shuah@...nel.org>,
damon@...ts.linux.dev,
kernel-team@...a.com,
linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
linux-mm@...ck.org
Subject: [PATCH 12/22] selftests/damon/sysfs.py: generalize DAMOS Watermarks commit assertion
DamosWatermarks 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.
Signed-off-by: SeongJae Park <sj@...nel.org>
---
tools/testing/selftests/damon/sysfs.py | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index e67008fd055d..91a28d97b015 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -25,6 +25,22 @@ def fail(expectation, status):
print(json.dumps(status, indent=4))
exit(1)
+def assert_true(condition, expectation, status):
+ if condition is not True:
+ fail(expectation, status)
+
+def assert_watermarks_committed(watermarks, dump):
+ wmark_metric_val = {
+ 'none': 0,
+ 'free_mem_rate': 1,
+ }
+ assert_true(dump['metric'] == wmark_metric_val[watermarks.metric],
+ 'metric', dump)
+ assert_true(dump['interval'] == watermarks.interval, 'interval', dump)
+ assert_true(dump['high'] == watermarks.high, 'high', dump)
+ assert_true(dump['mid'] == watermarks.mid, 'mid', dump)
+ assert_true(dump['low'] == watermarks.low, 'low', dump)
+
def main():
kdamonds = _damon_sysfs.Kdamonds(
[_damon_sysfs.Kdamond(
@@ -100,14 +116,8 @@ def main():
}:
fail('damos quota', status)
- if scheme['wmarks'] != {
- 'metric': 0,
- 'interval': 0,
- 'high': 0,
- 'mid': 0,
- 'low': 0,
- }:
- fail('damos wmarks', status)
+ assert_watermarks_committed(_damon_sysfs.DamosWatermarks(),
+ scheme['wmarks'])
kdamonds.stop()
--
2.39.5
Powered by blists - more mailing lists