Commit 553b0142 authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

selftests/damon/sysfs: test filters directory

Add simple test cases for scheme filters of DAMON sysfs interface.  The
test cases check if the files are populated as expected, receives some
valid inputs, and refuses some invalid inputs.

Link: https://lkml.kernel.org/r/20221205230830.144349-10-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 29cbb9a1
...@@ -96,6 +96,34 @@ test_stats() ...@@ -96,6 +96,34 @@ test_stats()
done done
} }
test_filter()
{
filter_dir=$1
ensure_file "$filter_dir/type" "exist" "600"
ensure_write_succ "$filter_dir/type" "anon" "valid input"
ensure_write_succ "$filter_dir/type" "memcg" "valid input"
ensure_write_fail "$filter_dir/type" "foo" "invalid input"
ensure_file "$filter_dir/matching" "exist" "600"
ensure_file "$filter_dir/memcg_path" "exist" "600"
}
test_filters()
{
filters_dir=$1
ensure_dir "$filters_dir" "exist"
ensure_file "$filters_dir/nr_filters" "exist" "600"
ensure_write_succ "$filters_dir/nr_filters" "1" "valid input"
test_filter "$filters_dir/0"
ensure_write_succ "$filters_dir/nr_filters" "2" "valid input"
test_filter "$filters_dir/0"
test_filter "$filters_dir/1"
ensure_write_succ "$filters_dir/nr_filters" "0" "valid input"
ensure_dir "$filters_dir/0" "not_exist"
ensure_dir "$filters_dir/1" "not_exist"
}
test_watermarks() test_watermarks()
{ {
watermarks_dir=$1 watermarks_dir=$1
...@@ -143,6 +171,7 @@ test_scheme() ...@@ -143,6 +171,7 @@ test_scheme()
test_access_pattern "$scheme_dir/access_pattern" test_access_pattern "$scheme_dir/access_pattern"
test_quotas "$scheme_dir/quotas" test_quotas "$scheme_dir/quotas"
test_watermarks "$scheme_dir/watermarks" test_watermarks "$scheme_dir/watermarks"
test_filters "$scheme_dir/filters"
test_stats "$scheme_dir/stats" test_stats "$scheme_dir/stats"
test_tried_regions "$scheme_dir/tried_regions" test_tried_regions "$scheme_dir/tried_regions"
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment