kernel_linux_build: Add sched_rtg_t test suite

Signed-off-by: liudanning <liudanning@h-partners.com>
This commit is contained in:
liudanning
2022-04-20 10:59:12 +08:00
parent 8fb2ee9d8f
commit ff1e6a2e5f
7 changed files with 577 additions and 0 deletions
@@ -0,0 +1,99 @@
#!/bin/sh
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg01.sh
#
# Description: sched RTG /proc/$PID/sched_group_id basic function test
#
# Authors: Ma Feng - mafeng.ma@huawei.com
#
# History: April 6 2022 - init scripts
#
################################################################################
source tst_oh.sh
do_setup()
{
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
sleep 1
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
}
do_test()
{
local res=0
local sched_group_id=/proc/$PID/sched_group_id
tst_res TINFO "Start process $PID join rtgid 2 test ..."
cur_rtgid=$(cat $sched_group_id)
if [ cur_rtgid -eq 2 ]; then
tst_res TINFO "process $PID already in rtgid 2, remove it firstly..."
echo 0 > $sched_group_id
fi
echo 2 > $sched_group_id
if [ $? -ne 0 ]; then
tst_res TFAIL "echo 2 > $sched_group_id failed!"
res=$(($res + 1))
fi
local rtgid2=$(cat $sched_group_id)
if [ $rtgid2 -ne 2 ]; then
tst_res TFAIL "process $PID join rtgid 2 failed!"
res=$(($res + 1))
fi
tst_res TINFO "Start process $PID switch rtgid 2 to 3 test ..."
echo 3 > $sched_group_id
if [ $? -eq 0 ]; then
tst_res TFAIL "echo 3 > $sched_group_id success unexpected."
res=$(($res + 1))
fi
local rtgid3=$(cat $sched_group_id)
if [ $rtgid3 -eq 3 ]; then
tst_res TFAIL "process $PID switch rtgid 2 to 3 sucess unexpected!"
res=$(($res + 1))
fi
tst_res TINFO "Start process $PID remove rtgid 2 test ..."
echo 0 > $sched_group_id
if [ $? -ne 0 ]; then
tst_res TFAIL "process $PID remove rtgid 2 failed!"
res=$(($res + 1))
fi
local rtgid0=$(cat $sched_group_id)
if [ $rtgid0 -ne 0 ]; then
tst_res TINFO "process $PID remove rtgid 2 failed!"
res=$(($res + 1))
fi
if [ $res -eq 0 ]; then
tst_res TPASS "sched RTG /proc/$PID/sched_group_id basic function pass."
else
tst_res TFAIL "sched RTG /proc/$PID/sched_group_id basic function failed!"
fi
}
do_clean()
{
aa force-stop ohos.samples.ecg
}
do_setup
do_test
do_clean
tst_exit
@@ -0,0 +1,100 @@
#!/bin/sh
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg02.sh
#
# Description: sched RTG /proc/$PID/sched_group_id interface test
# 1: reserved
# 2-20: valid rtgid
#
# Authors: Ma Feng - mafeng.ma@huawei.com
#
# History: April 6 2022 - init scripts
#
################################################################################
source tst_oh.sh
do_setup()
{
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
sleep 1
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
}
do_test()
{
local res=0
local sched_group_id=/proc/$PID/sched_group_id
tst_res TINFO "Start process $PID sched RTG interface test ..."
cur_rtgid=$(cat $sched_group_id)
if [ cur_rtgid -eq 2 ]; then
tst_res TINFO "process $PID already in rtgid 2, remove it firstly..."
echo 0 > $sched_group_id
fi
set_check_rtgid -1 $PID 1 0
set_check_rtgid 21 $PID 1 0
set_check_rtgid 1 $PID 1 0
set_check_rtgid 20 $PID 0 20
set_check_rtgid 0 $PID 0 0
set_check_rtgid 2 $PID 0 2
set_check_rtgid 0 $PID 0 0
set_check_rtgid 10 $PID 0 10
}
set_check_rtgid()
{
local _set_rtgid=$1
local _pid=$2
local _expect_ret=$3
local _expect_rtgid=$4
local _sched_group_id=/proc/$_pid/sched_group_id
echo $_set_rtgid > $_sched_group_id
if [ $? -eq $_expect_ret ]; then
tst_res TPASS "process $_pid rtgid set to $_set_rtgid expected."
else
tst_res TFAIL "process $_pid rtgid set to $_set_rtgid unexpected!"
fi
local _cur_rtgid=$(cat $_sched_group_id)
if [ $_cur_rtgid -eq $_expect_rtgid ]; then
tst_res TPASS "process $_pid rtgid equal to expected value."
else
tst_res TFAIL "process $_pid rtgid not equal to expected value!"
fi
}
do_clean()
{
aa force-stop ohos.samples.ecg
}
do_setup
do_test
do_clean
tst_exit
@@ -0,0 +1,107 @@
#!/bin/sh
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg03.sh
#
# Description: sched RTG /proc/sched_rtg_debug interface test
#
# Authors: liudanning - liudanning@h-partners.com
#
# History: April 6 2022 - init scripts
#
################################################################################
source tst_oh.sh
do_setup()
{
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
sleep 1
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
}
do_test()
{
local res=0
local sched_group_id=/proc/$PID/sched_group_id
tst_res TINFO "Start sched RTG /proc/sched_rtg_debug interface test ..."
cur_rtgid=$(cat $sched_group_id)
if [ cur_rtgid -eq 2 ]; then
tst_res TINFO "process $PID already in rtgid 2, remove it firstly..."
echo 0 > $sched_group_id
fi
set_check_rtgid_debug 2 $PID 0 2
set_check_rtgid_debug 0 $PID 0 0
}
set_check_rtgid_debug()
{
local _set_rtgid=$1
local _pid=$2
local _expect_ret=$3
local _expect_rtgid=$4
local _sched_group_id=/proc/$_pid/sched_group_id
local _sched_rtg_debug=/proc/sched_rtg_debug
echo $_set_rtgid > $_sched_group_id
if [ $? -eq $_expect_ret ]; then
tst_res TPASS "process $_pid rtgid set to $_set_rtgid expected."
if [ $(cat /proc/$_pid/sched_group_id) -eq $_expect_rtgid ]; then
tst_res TPASS "process $_pid rtgid equal to expected value."
else
tst_res TFAIL "process $_pid rtgid not equal to expected value!"
fi
else
tst_res TFAIL "process $_pid rtgid set to $_set_rtgid unexpected!"
fi
local _rtg_id=$(cat /proc/sched_rtg_debug | grep RTG_ID | grep -v grep | awk '{print $3}')
local _rtg_pid=$(cat /proc/sched_rtg_debug | grep ohos.samples.ec | grep -v grep | awk '{print $3}')
if [ $_set_rtgid -ne 0 ]; then
if [ $_rtg_id -eq $_expect_rtgid ]; then
tst_res TPASS "RTG_ID $_rtg_id equal to expected value."
if [ $_rtg_pid -eq $PID ]; then
tst_res TPASS "process $_pid rtgid set to $rtg_pid expected."
else
tst_res TFAIL "$rtg_pid not equal to expected value!"
fi
else
tst_res TFAIL "RTG_ID $_rtg_id not equal to expected value!"
fi
else
cat $_sched_rtg_debug | grep "RTG tasklist empty"
if [ $? -eq 0 ]; then
tst_res TPASS "process $_pid rtgid set to $_set_rtgid expected."
else
tst_res TFAIL "process $_pid rtgid set to $_set_rtgid unexpected!"
fi
fi
}
do_clean()
{
aa force-stop ohos.samples.ecg
}
do_setup
do_test
do_clean
tst_exit
@@ -0,0 +1,80 @@
#!/bin/sh
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg04.sh
#
# Description: sched RTG tracing test
#
# Authors: liudanning - liudanning@h-partners.com
#
# History: April 6 2022 - init scripts
#
################################################################################
source tst_oh.sh
do_setup()
{
Frame_value=$(cat /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable)
Task_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable)
Cpu_value=$(cat /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable)
Normalized_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable)
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
sleep 1
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
echo 1 > /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable
echo 1 > /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable
echo 1 > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable
echo 1 > /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable
}
do_test()
{
local res=0
local sched_group_id=/proc/$PID/sched_group_id
tst_res TINFO "Start sched RTG trace catching test ..."
bytrace -t 10 -b 32000 --overwrite sched ace app disk ohos graphic sync workq ability >/data/mynewtrace.ftrace &
tst_res TINFO "Checking sched RTG trace ..."
sleep 3
echo 0 > $sched_group_id
echo 2 > $sched_group_id
sleep 40
cat /data/mynewtrace.ftrace | grep "sched_rtg_task_each" &&
cat /data/mynewtrace.ftrace | grep "find_rtg_cpu" &&
cat /data/mynewtrace.ftrace | grep "sched_rtg_valid_normalized_util"
if [ $? -eq 0 ]; then
tst_res TPASS "trace info no error found."
else
tst_res TFAIL "trace info had error found!"
fi
}
do_clean()
{
echo $Frame_value > /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable &&
echo $Task_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable &&
echo $Cpu_value > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable &&
echo $Normalized_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable
aa force-stop ohos.samples.ecg
}
do_setup
do_test
do_clean
tst_exit
@@ -0,0 +1,160 @@
#!/bin/sh
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg06.sh
#
# Description: sched RTG Stability test
#
# Authors: liudanning - liudanning@h-partners.com
#
# History: April 6 2022 - init scripts
#
################################################################################
source tst_oh.sh
do_setup()
{
dmesg -c
PPID=`ps -ef | grep "sched_rtg06.sh" | grep -v grep | awk '{print $3}'`
}
do_test()
{
stability_test randmom
stability_test ordered
stability_test all
}
stability_test()
{
start_task 41
if [ $1 == 'randmom' ]; then
tst_res TINFO "All 40 porcesss join random rtg from 2 to 20"
random_rtg
fi
if [ $1 == 'ordered' ]; then
tst_res TINFO "All 40 processes join rtg from 2 to 20 one by one"
ordered_rtg
fi
if [ $1 == 'all' ]; then
tst_res TINFO "All 40 processes join rtg 2"
all_in_one_rtg
fi
sleep 60
tst_res TINFO "kill 40 processes...."
ps -ef | grep "sched_rtg06.sh" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9
sleep 5
tst_res TINFO "kill process successed."
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default &&
sleep 1 &&
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
if [ $? -eq 0 ]; then
dmesg | grep "BUG" ||
dmesg | grep "panic" ||
dmesg | grep "Unable to handle kernel" ||
dmesg | grep "WARNING:"
if [ $? -eq 0 ]; then
tst_res TFAIL "$1 test error messages found!"
else
tst_res TPASS "sched RTG Stability $1 test success."
fi
else
tst_res TFAIL "sched RTG Stability $1 test failed!"
fi
aa force-stop ohos.samples.ecg
}
start_task()
{
local _num=$1
rm -rf taskpid.txt
for i in $(seq 1 $_num); do
while true; do
((cnt++))
sleep 0.1
done &
local pgid=$!
echo $pgid >> taskpid.txt
done
}
random_rtg()
{
for i in $(seq 1 40); do
{
while true; do
echo $((RANDOM % 19 + 2)) > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.1
echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.2
done
}&
done
}
ordered_rtg()
{
for i in $(seq 1 40); do
{
if [ ${i} -le 20 ]; then
while true; do
echo ${i} > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.1
echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.2
done &
else
while true; do
echo 2 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.1
echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.2
done
fi
}&
done
}
all_in_one_rtg()
{
local _rtg_id=$((RANDOM % 19 + 2))
for i in $(seq 1 40); do
{
while true; do
echo $_rtg_id > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.1
echo 0 > /proc/$(sed -n ${i}p taskpid.txt)/sched_group_id
sleep 0.2
done
}&
done
}
do_clean()
{
rm -rf taskpid.txt
}
do_setup
do_test
do_clean
tst_exit
@@ -25,3 +25,4 @@
################################################################################
cpusetdecouple_cpuhotplug_t
enhancedswap_t
sched_rtg_t
+30
View File
@@ -0,0 +1,30 @@
################################################################################
#
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# File: sched_rtg_t
#
# Description: sched rtg testcase list
#
# Authors: liudanning - liudanning@huawei.com
#
# History: Mar 24 2022 - init scripts
#
################################################################################
sched_rtg01 sched_rtg01.sh
sched_rtg02 sched_rtg02.sh
sched_rtg03 sched_rtg03.sh
sched_rtg04 sched_rtg04.sh
sched_rtg06 sched_rtg06.sh