xref: /linux/tools/testing/selftests/damon/lru_sort.sh (revision 8d2b0853add1d7534dc0794e3c8e0b9e8c4ec640)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4source _common.sh
5
6# Kselftest framework requirement - SKIP code is 4.
7ksft_skip=4
8
9check_dependencies
10
11damon_lru_sort_enabled="/sys/module/damon_lru_sort/parameters/enabled"
12if [ ! -f "$damon_lru_sort_enabled" ]
13then
14	echo "No 'enabled' file.  Maybe DAMON_LRU_SORT not built"
15	exit $ksft_skip
16fi
17
18nr_kdamonds=$(pgrep kdamond | wc -l)
19if [ "$nr_kdamonds" -ne 0 ]
20then
21	echo "Another kdamond is running"
22	exit $ksft_skip
23fi
24
25echo Y > "$damon_lru_sort_enabled"
26nr_kdamonds=$(pgrep kdamond | wc -l)
27if [ "$nr_kdamonds" -ne 1 ]
28then
29	echo "kdamond is not turned on"
30	exit 1
31fi
32
33echo N > "$damon_lru_sort_enabled"
34nr_kdamonds=$(pgrep kdamond | wc -l)
35if [ "$nr_kdamonds" -ne 0 ]
36then
37	echo "kdamond is not turned off"
38	exit 1
39fi
40