diff options
author | SeongJae Park <sj@kernel.org> | 2024-05-03 20:03:11 +0200 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-05-12 00:41:33 +0200 |
commit | e799fda6926ec01f8488023d4f891289996322aa (patch) | |
tree | 2de651cde2cbf7ab7d60706fd5812d06ca1fa954 /tools | |
parent | selftests/damon/_damon_sysfs: check errors from nr_schemes file reads (diff) | |
download | linux-e799fda6926ec01f8488023d4f891289996322aa.tar.xz linux-e799fda6926ec01f8488023d4f891289996322aa.zip |
selftests/damon/_damon_sysfs: find sysfs mount point from /proc/mounts
_damon_sysfs.py assumes sysfs is mounted at /sys. In some systems, that
might not be true. Find the mount point from /proc/mounts file content.
Link: https://lkml.kernel.org/r/20240503180318.72798-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/damon/_damon_sysfs.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py index 43239e5b38b2..9682e18dd450 100644 --- a/tools/testing/selftests/damon/_damon_sysfs.py +++ b/tools/testing/selftests/damon/_damon_sysfs.py @@ -2,7 +2,18 @@ import os -sysfs_root = '/sys/kernel/mm/damon/admin' +ksft_skip=4 + +sysfs_root = None +with open('/proc/mounts', 'r') as f: + for line in f: + dev_name, mount_point, dev_fs = line.split()[:3] + if dev_fs == 'sysfs': + sysfs_root = '%s/kernel/mm/damon/admin' % mount_point + break +if sysfs_root is None: + print('Seems sysfs not mounted?') + exit(ksft_skip) def write_file(path, string): "Returns error string if failed, or None otherwise" |