xref: /linux/tools/testing/selftests/damon/reclaim.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_reclaim_enabled="/sys/module/damon_reclaim/parameters/enabled"
12if [ ! -f "$damon_reclaim_enabled" ]
13then
14	echo "No 'enabled' file.  Maybe DAMON_RECLAIM 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_reclaim_enabled"
26
27nr_kdamonds=$(pgrep kdamond | wc -l)
28if [ "$nr_kdamonds" -ne 1 ]
29then
30	echo "kdamond is not turned on"
31	exit 1
32fi
33
34echo N > "$damon_reclaim_enabled"
35nr_kdamonds=$(pgrep kdamond | wc -l)
36if [ "$nr_kdamonds" -ne 0 ]
37then
38	echo "kdamond is not turned off"
39	exit 1
40fi
41