mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-05 02:37:41 +00:00
DAMON debugfs interface selftests use test_write_result() to check if
valid or invalid writes to files of the interface success or fail as
expected. File write error messages from expected failures are only
making the output noisy. Hide such expected error messages.
Link: https://lkml.kernel.org/r/20241028233058.283381-4-sj@kernel.org
Fixes: b348eb7abd ("mm/damon: add user space selftests")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Andrew Paniakin <apanyaki@amazon.com>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
65 lines
1.1 KiB
Bash
65 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
test_write_result() {
|
|
file=$1
|
|
content=$2
|
|
orig_content=$3
|
|
expect_reason=$4
|
|
expected=$5
|
|
|
|
if [ "$expected" = "0" ]
|
|
then
|
|
echo "$content" > "$file"
|
|
else
|
|
echo "$content" > "$file" 2> /dev/null
|
|
fi
|
|
if [ $? -ne "$expected" ]
|
|
then
|
|
echo "writing $content to $file doesn't return $expected"
|
|
echo "expected because: $expect_reason"
|
|
echo "$orig_content" > "$file"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
test_write_succ() {
|
|
test_write_result "$1" "$2" "$3" "$4" 0
|
|
}
|
|
|
|
test_write_fail() {
|
|
test_write_result "$1" "$2" "$3" "$4" 1
|
|
}
|
|
|
|
test_content() {
|
|
file=$1
|
|
orig_content=$2
|
|
expected=$3
|
|
expect_reason=$4
|
|
|
|
content=$(cat "$file")
|
|
if [ "$content" != "$expected" ]
|
|
then
|
|
echo "reading $file expected $expected but $content"
|
|
echo "expected because: $expect_reason"
|
|
echo "$orig_content" > "$file"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
source ./_chk_dependency.sh
|
|
|
|
damon_onoff="$DBGFS/monitor_on"
|
|
if [ -f "$DBGFS/monitor_on_DEPRECATED" ]
|
|
then
|
|
damon_onoff="$DBGFS/monitor_on_DEPRECATED"
|
|
else
|
|
damon_onoff="$DBGFS/monitor_on"
|
|
fi
|
|
|
|
if [ $(cat "$damon_onoff") = "on" ]
|
|
then
|
|
echo "monitoring is on"
|
|
exit $ksft_skip
|
|
fi
|