Skip to contentSkip to conversation

mm/damon/tests/core-kunit: add damos_commit_filter test

PATCH In review Sang-Heon Jeon 2 participants 2 messages Aug 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon/tests/core-kunit: add damos_commit_filter test

Add unit test to verify that damos_commmit_filter() change dest value well.

---
This test will be succeeded after this patch [1] applied.

[1] https://lore.kernel.org/damon/[email protected]/

---
 mm/damon/tests/core-kunit.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
mm/damon/tests/core-kunit.h +17 -0
index dfedfff19940..5f5dc9db2e90 100644
@@ -419,6 +419,22 @@ static void damos_test_new_filter(struct kunit *test)
 	damos_destroy_filter(filter);
 }
 
+static void damos_test_commit_filter(struct kunit *test)
+{
+	struct damos_filter *src_filter = damos_new_filter(
+		DAMOS_FILTER_TYPE_ANON, true, true);
+	struct damos_filter *dst_filter = damos_new_filter(
+		DAMOS_FILTER_TYPE_ACTIVE, false, false);
+
+	damos_commit_filter(dst_filter, src_filter);
+	KUNIT_EXPECT_EQ(test, dst_filter->type, src_filter->type);
+	KUNIT_EXPECT_EQ(test, dst_filter->matching, src_filter->matching);
+	KUNIT_EXPECT_EQ(test, dst_filter->allow, src_filter->allow);
+
+	damos_destroy_filter(src_filter);
+	damos_destroy_filter(dst_filter);
+}
+
 static void damos_test_filter_out(struct kunit *test)
 {
 	struct damon_target *t;
@@ -594,6 +610,7 @@ static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_set_attrs),
 	KUNIT_CASE(damon_test_moving_sum),
 	KUNIT_CASE(damos_test_new_filter),
+	KUNIT_CASE(damos_test_commit_filter),
 	KUNIT_CASE(damos_test_filter_out),
 	KUNIT_CASE(damon_test_feed_loop_next_input),
 	KUNIT_CASE(damon_test_set_filters_default_reject),
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

+ Andrew

Quoted 3 lines · On Sun, 17 Aug 2025 11:13:48 +0900 Sang-Heon Jeon <[email protected]> wrote:

Add unit test to verify that damos_commmit_filter() change dest value well.

Quoted 4 lines

---
This test will be succeeded after this patch [1] applied.

[1] https://lore.kernel.org/damon/[email protected]/

FWIW, the subject of the patch is "mm/damon/core: fix damos_commit_filter not changing allow". This patch should be applied _after_ the fix, since the new test that this patch is adding will fail and make 'git bisect' complicated, otherwise.

Thanks,
SJ

[...]