提交 bf25901c 编写于 作者: S SeongJae Park 提交者: Zheng Zengkai

selftests/damon: split test cases

mainline inclusion
from mainline-v5.16-rc5
commit 9ab3b0c8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4RTX9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9ab3b0c8ef629f60ef25cb7634ad305315ae94d1

--------------------------------

Currently, the single test program, debugfs.sh, contains all test cases
for DAMON.  When one of the cases fails, finding which case is failed
from the test log is not so easy, and all remaining tests will be
skipped.  To improve the situation, this commit splits the single
program into small test programs having their own names.

Link: https://lkml.kernel.org/r/20211201150440.1088-12-sj@kernel.orgSigned-off-by: NSeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 9ab3b0c8)
Signed-off-by: NYue Zou <zouyue3@huawei.com>
Reviewed-by: Kefeng Wang<wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e0dd2892
......@@ -3,7 +3,8 @@
TEST_GEN_FILES += huge_count_read_write
TEST_FILES = _chk_dependency.sh
TEST_PROGS = debugfs_attrs.sh
TEST_FILES = _chk_dependency.sh _debugfs_common.sh
TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh
TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh
include ../lib.mk
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
test_write_result() {
file=$1
content=$2
orig_content=$3
expect_reason=$4
expected=$5
echo "$content" > "$file"
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 [ $(cat "$damon_onoff") = "on" ]
then
echo "monitoring is on"
exit $ksft_skip
fi
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
test_write_result() {
file=$1
content=$2
orig_content=$3
expect_reason=$4
expected=$5
echo "$content" > "$file"
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
ksft_skip=4
damon_onoff="$DBGFS/monitor_on"
if [ $(cat "$damon_onoff") = "on" ]
then
echo "monitoring is on"
exit $ksft_skip
fi
source _debugfs_common.sh
# Test attrs file
# ===============
......@@ -65,62 +15,3 @@ test_write_fail "$file" "1 2 3 5 4" "$orig_content" \
"min_nr_regions > max_nr_regions"
test_content "$file" "$orig_content" "1 2 3 4 5" "successfully written"
echo "$orig_content" > "$file"
# Test schemes file
# =================
file="$DBGFS/schemes"
orig_content=$(cat "$file")
test_write_succ "$file" "1 2 3 4 5 6 4 0 0 0 1 2 3 1 100 3 2 1" \
"$orig_content" "valid input"
test_write_fail "$file" "1 2
3 4 5 6 3 0 0 0 1 2 3 1 100 3 2 1" "$orig_content" "multi lines"
test_write_succ "$file" "" "$orig_content" "disabling"
test_write_fail "$file" "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" \
"$orig_content" "wrong condition ranges"
echo "$orig_content" > "$file"
# Test target_ids file
# ====================
file="$DBGFS/target_ids"
orig_content=$(cat "$file")
test_write_succ "$file" "1 2 3 4" "$orig_content" "valid input"
test_write_succ "$file" "1 2 abc 4" "$orig_content" "still valid input"
test_content "$file" "$orig_content" "1 2" "non-integer was there"
test_write_succ "$file" "abc 2 3" "$orig_content" "the file allows wrong input"
test_content "$file" "$orig_content" "" "wrong input written"
test_write_succ "$file" "" "$orig_content" "empty input"
test_content "$file" "$orig_content" "" "empty input written"
echo "$orig_content" > "$file"
# Test empty targets case
# =======================
orig_target_ids=$(cat "$DBGFS/target_ids")
echo "" > "$DBGFS/target_ids"
orig_monitor_on=$(cat "$DBGFS/monitor_on")
test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids"
echo "$orig_target_ids" > "$DBGFS/target_ids"
# Test huge count read write
# ==========================
dmesg -C
for file in "$DBGFS/"*
do
./huge_count_read_write "$file"
done
if dmesg | grep -q WARNING
then
dmesg
exit 1
else
exit 0
fi
echo "PASS"
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source _debugfs_common.sh
# Test empty targets case
# =======================
orig_target_ids=$(cat "$DBGFS/target_ids")
echo "" > "$DBGFS/target_ids"
orig_monitor_on=$(cat "$DBGFS/monitor_on")
test_write_fail "$DBGFS/monitor_on" "on" "orig_monitor_on" "empty target ids"
echo "$orig_target_ids" > "$DBGFS/target_ids"
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source _debugfs_common.sh
# Test huge count read write
# ==========================
dmesg -C
for file in "$DBGFS/"*
do
./huge_count_read_write "$file"
done
if dmesg | grep -q WARNING
then
dmesg
exit 1
else
exit 0
fi
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source _debugfs_common.sh
# Test schemes file
# =================
file="$DBGFS/schemes"
orig_content=$(cat "$file")
test_write_succ "$file" "1 2 3 4 5 6 4 0 0 0 1 2 3 1 100 3 2 1" \
"$orig_content" "valid input"
test_write_fail "$file" "1 2
3 4 5 6 3 0 0 0 1 2 3 1 100 3 2 1" "$orig_content" "multi lines"
test_write_succ "$file" "" "$orig_content" "disabling"
test_write_fail "$file" "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" \
"$orig_content" "wrong condition ranges"
echo "$orig_content" > "$file"
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source _debugfs_common.sh
# Test target_ids file
# ====================
file="$DBGFS/target_ids"
orig_content=$(cat "$file")
test_write_succ "$file" "1 2 3 4" "$orig_content" "valid input"
test_write_succ "$file" "1 2 abc 4" "$orig_content" "still valid input"
test_content "$file" "$orig_content" "1 2" "non-integer was there"
test_write_succ "$file" "abc 2 3" "$orig_content" "the file allows wrong input"
test_content "$file" "$orig_content" "" "wrong input written"
test_write_succ "$file" "" "$orig_content" "empty input"
test_content "$file" "$orig_content" "" "empty input written"
echo "$orig_content" > "$file"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部