mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 16:53:20 -04:00
mm/damon/tests/core-kunit: test damon_mvsum()
Add a simple unit test for damon_nr_accesses_mvsum()'s internal core logic, damon_mvsum(). The test contains cases for just-started windows, partially completed windows, and just-completed windows. Link: https://lore.kernel.org/20260630040812.149729-3-sj@kernel.org Signed-off-by: SJ Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
@@ -682,6 +682,30 @@ static void damon_test_moving_sum(struct kunit *test)
|
||||
}
|
||||
}
|
||||
|
||||
static void damon_test_mvsum(struct kunit *test)
|
||||
{
|
||||
unsigned long input_expects[] = {
|
||||
/* current value, last value, remaining window (bp) */
|
||||
0, 49, 10000, 49, /* 0 + 49 * 1 */
|
||||
3, 10, 7000, 10, /* 3 + 10 * 0.7 */
|
||||
3, 10, 5000, 8, /* 3 + 10 * 0.5 */
|
||||
32, 100, 1000, 42, /* 32 + 100 * 0.1 */
|
||||
42, 49, 0, 42, /* 42 + 49 * 0 */
|
||||
};
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(input_expects); i += 4) {
|
||||
unsigned long current_nr = input_expects[i];
|
||||
unsigned long last_nr = input_expects[i + 1];
|
||||
unsigned long left_window_bp = input_expects[i + 2];
|
||||
unsigned long expect = input_expects[i + 3];
|
||||
|
||||
KUNIT_EXPECT_EQ(test, damon_mvsum(current_nr, last_nr,
|
||||
left_window_bp), expect);
|
||||
}
|
||||
}
|
||||
|
||||
static void damos_test_new_filter(struct kunit *test)
|
||||
{
|
||||
struct damos_filter *filter;
|
||||
@@ -1575,6 +1599,7 @@ static struct kunit_case damon_test_cases[] = {
|
||||
KUNIT_CASE(damon_test_update_monitoring_result),
|
||||
KUNIT_CASE(damon_test_set_attrs),
|
||||
KUNIT_CASE(damon_test_moving_sum),
|
||||
KUNIT_CASE(damon_test_mvsum),
|
||||
KUNIT_CASE(damos_test_new_filter),
|
||||
KUNIT_CASE(damos_test_commit_quota_goal),
|
||||
KUNIT_CASE(damos_test_commit_quota_goals),
|
||||
|
||||
Reference in New Issue
Block a user