diff --git a/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg01.sh b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg01.sh new file mode 100644 index 0000000000000000000000000000000000000000..94f2772d93e848638dbb5595c662b03b646c9e9c --- /dev/null +++ b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg01.sh @@ -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 \ No newline at end of file diff --git a/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg02.sh b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg02.sh new file mode 100644 index 0000000000000000000000000000000000000000..ab43580b281e12ac008dd729d36259cf36cc8cd0 --- /dev/null +++ b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg02.sh @@ -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 \ No newline at end of file diff --git a/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg03.sh b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg03.sh new file mode 100644 index 0000000000000000000000000000000000000000..299d43368fe27e1a06a8397991b5cab5a6638564 --- /dev/null +++ b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg03.sh @@ -0,0 +1,109 @@ +#!/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 TINFO "process $_pid rtgid set to $_set_rtgid expected." + if [ $(cat /proc/$_pid/sched_group_id) -eq $_expect_rtgid ]; then + tst_res TINFO "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 _user_rtgid_cnt=$(cat /proc/sched_rtg_debug | grep RTG_ID | grep -v grep | awk '{print $3}') + local _used_rtgpid_cnt=$(cat /proc/sched_rtg_debug | grep ohos.samples.ec | grep -v grep | awk '{print $3}') + if [ $_set_rtgid -ne 0 ]; then + if [ $_user_rtgid_cnt -eq $_expect_rtgid ]; then + tst_res TINFO "RTG_ID $_used_rtgid_cnt equal to expected value." + if [ $_used_rtgpid_cnt -eq $PID ]; then + tst_res TPASS "process $_pid rtgid set to $_set_rtgid expected." + else + tst_res TFAIL "$_used_rtgpid_cnt not equal to expected value!" + fi + else + tst_res TFAIL "RTG_ID $_used_rtgid_cnt 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 \ No newline at end of file diff --git a/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg04.sh b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg04.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6173eaf004981d1e9e2f3f8a5ce725654cf2194 --- /dev/null +++ b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg04.sh @@ -0,0 +1,74 @@ +#!/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() +{ + 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 + 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 + 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 "syncing 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 "tracing test && trace-information is expected." + else + tst_res TFAIL "tracing test failed or trace-information is unexpected!" + fi +} + + + + + +do_clean() +{ + aa force-stop ohos.samples.ecg +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg06.sh b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg06.sh new file mode 100644 index 0000000000000000000000000000000000000000..9a0b47fcac81fec833ea2d9f291a65de645c06a3 --- /dev/null +++ b/test/moduletest/runtest/bin/rtg_t/testcases/bin/sched_rtg06.sh @@ -0,0 +1,192 @@ +#!/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 + +_mode=$1 + +do_setup() +{ + PPID=`ps -ef | grep "sched_rtg06.sh $1" | grep -v grep | awk '{print $3}'` +} + +do_test() +{ + get_task 41 + if [ $_mode -eq 1 ];then + tst_res TINFO "process is executing random-group mode." + random_group + sleep 60 + tst_res TINFO "executing delete mission...." + ps -ef | grep "sched_rtg06.sh 1" | 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 "kernel bug" || + dmesg | grep "panic" || + dmesg | grep "KASAN bug" + if [ $? -eq 0 ]; then + tst_res TFAIL "there are error messages in the dmesg" + else + tst_res TPASS "stability random group testing is successful" + fi + else + tst_res TFAIL "stability testing failed" + fi + fi + + if [ $_mode -eq 2 ];then + tst_res TINFO "process is executing order-by-group mode" + order_by_group + sleep 60 + tst_res TINFO "executing delete mission...." + ps -ef | grep "sched_rtg06.sh 2" | 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 "kernel bug" || + dmesg | grep "panic" || + dmesg | grep "KASAN bug" + if [ $? -eq 0 ]; then + tst_res TFAIL "there are error messages in the dmesg" + else + tst_res TPASS "stability order-by group testing is successful" + fi + else + tst_res TFAIL "stability testing failed" + fi + fi + + if [ $_mode -eq 3 ];then + tst_res TINFO "process is executing same-group mode" + same_group + sleep 60 + tst_res TINFO "executing delete mission...." + ps -ef | grep "sched_rtg06.sh 3" | 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 "kernel bug" || + dmesg | grep "panic" || + dmesg | grep "KASAN bug" + if [ $? -eq 0 ]; then + tst_res TFAIL "there are error messages in the dmesg" + else + tst_res TPASS "stability same group testing is successful" + fi + else + tst_res TFAIL "stability testing failed" + fi + fi +} + + + +get_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_group() +{ + + 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 +} + +order_by_group() +{ + 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 +} + +same_group() +{ + for i in $(seq 1 40); do + { + 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 + }& + done +} + +do_clean() +{ + aa force-stop ohos.samples.ecg +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/conf/OH_RK3568_config b/test/moduletest/runtest/conf/OH_RK3568_config index 16e3c86cd4ed9ceff18f580f10dea696d7bb9496..aa73bdf26ff78eab1fdad063fb6709783ea48c96 100644 --- a/test/moduletest/runtest/conf/OH_RK3568_config +++ b/test/moduletest/runtest/conf/OH_RK3568_config @@ -23,5 +23,6 @@ # History: Mar 15 2022 - init scripts # ################################################################################ +rtg_t cpusetdecouple_cpuhotplug_t enhancedswap_t diff --git a/test/moduletest/runtest/tests/rtg_t b/test/moduletest/runtest/tests/rtg_t new file mode 100644 index 0000000000000000000000000000000000000000..db3b4b66fa2d106f7a194e10965641502200cc03 --- /dev/null +++ b/test/moduletest/runtest/tests/rtg_t @@ -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: rtg_t +# +# Description: sched rtg testcase list +# +# Authors: liudanning - liudanning@huawei.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +sched_rtg06 sched_rtg06.sh 1 +sched_rtg01 sched_rtg01.sh +sched_rtg02 sched_rtg02.sh +sched_rtg03 sched_rtg03.sh +sched_rtg04 sched_rtg04.sh