diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh new file mode 100644 index 0000000000000000000000000000000000000000..787953999384acac485459da17b9e142c31a2065 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh @@ -0,0 +1,285 @@ +#!/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: cpuisolation01.sh +# +# Description: check rw nodes test about CPU lightweight isolation +# +# Authors: Dang Zhongkai - dangzhongkai@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ + +source tst_oh.sh + +do_setup() +{ + +} + +write_outliers() +{ + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + MIN_CPUS_VALUE_BACKUP=$(cat $MIN_CPUS) + MAX_CPUS_VALUE_BACKUP=$(cat $MAX_CPUS) + + #write negative value to min_cpus + echo -3 > $MIN_CPUS + ret_min=$? + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + if [ $ret_min -eq 1 ]; then + tst_res TINFO "Invalid write min_cpus negative value." + if [ $MIN_CPUS_VALUE -ge 0 ] && [ $MIN_CPUS_VALUE -le $MAX_CPUS_VALUE ]\ + && [ $MAX_CPUS_VALUE -le 4 ]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "valid write min_cpus negative value." + ret=$(( $ret + 1 )) + fi + + #write oversize value to min_cpus + MIN_BEFORE=$MIN_CPUS_VALUE + echo 9999 > $MIN_CPUS + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + if [[ $MIN_BEFORE -eq $MIN_CPUS_VALUE ]] || [[ $MIN_CPUS_VALUE \ + -eq 4 ]]; then + tst_res TINFO "write min_cpus oversize value change to 4." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "write min_cpus_oversize is normal." + else + tst_res TINFO "Write min_cpus_oversize is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "write min_cpus oversize value not change to 4." + ret=$(( $ret + 1 )) + fi + + #write negative value to max_cpus + echo -3 > $MAX_CPUS + ret_max=$? + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + if [ $ret_max -eq 1 ]; then + tst_res TINFO "Invalid write max_cpus negative value." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "valid write max_cpus negative value." + ret=$(( $ret + 1 )) + fi + + #write oversize value to max_cpus + echo 9999 > $MAX_CPUS + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + if [ $MAX_CPUS_VALUE -eq 4 ]; then + tst_res TINFO "write max_cpus oversize value change to 4." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "write min_cpus_oversize is normal." + else + tst_res TINFO "Write min_cpus_oversize is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "write max_cpus oversize value not change to 4." + ret=$(( $ret + 1 )) + fi + + #write negative value to min_cpus and max_cpus + echo -3 > $MIN_CPUS + ret_min=$? + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + echo -3 > $MAX_CPUS + ret_max=$? + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + + if [[ $ret_min -eq 1 ]] && [[ $ret_max -eq 1 ]]; then + tst_res TINFO "Invalid write max_cpus and min_cpus negative value." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "valid write max_cpus and min_cpus negative value." + ret=$(( $ret + 1 )) + fi + + #write negative value to min_cpus/write oversize value to max_cpus + echo 9999 > $MAX_CPUS + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + echo -3 > $MIN_CPUS + ret_min=$? + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + if [[ $ret_min -eq 1 ]] && [[ $MAX_CPUS_VALUE -eq 4 ]]; then + tst_res TINFO "max_cpus change to 4 and min_cpus negative value." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "max_cpus not change to 4 or min_cpus negative value." + ret=$(( $ret + 1 )) + fi + + #write negative value to max_cpus/write oversize value to min_cpus + MIN_BEFORE2=$MIN_CPUS_VALUE + echo 9999 > $MIN_CPUS + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + echo -3 > $MAX_CPUS + ret_min=$? + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + if [[ $MIN_BEFORE2 -eq $MIN_CPUS_VALUE ]] && [[ $ret_min -eq 1 ]] \ + || [[ $MIN_CPUS_VALUE -eq 4 ]] && [[ $ret_min -eq 1 ]]; then + tst_res TINFO "min_cpus change to 4 and max_cpus negative value." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "min_cpus not change to 4 or max_cpus negative value." + ret=$(( $ret + 1 )) + fi + + #write oversize value to min_cpus and max_cpus + MIN_BEFORE3=$MIN_CPUS_VALUE + echo 9999 > $MIN_CPUS + echo 9999 > $MAX_CPUS + MIN_CPUS_VALUE=$(cat $MIN_CPUS) + MAX_CPUS_VALUE=$(cat $MAX_CPUS) + if [[ $MAX_CPUS_VALUE -eq 4 ]] && [[ $MIN_CPUS_VALUE -eq 4 ]] \ + || [[ $MIN_BEFORE3 -eq $MIN_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -eq \ + 4 ]]; then + tst_res TINFO "write min_cpus and max_cpus value all change to 4." + if [[ $MIN_CPUS_VALUE -ge 0 ]] && [[ $MIN_CPUS_VALUE -le \ + $MAX_CPUS_VALUE ]] && [[ $MAX_CPUS_VALUE -le 4 ]]; then + tst_res TINFO "writing value is normal." + else + tst_res TINFO "writing value is abnormal." + ret=$(( $ret + 1 )) + fi + else + tst_res TINFO "write min_cpus or max_cpus value not change to 4." + ret=$(( $ret + 1 )) + fi + + #Restore initial value + echo ${MIN_CPUS_VALUE_BACKUP} > $MIN_CPUS + echo ${MAX_CPUS_VALUE_BACKUP} > $MAX_CPUS +} + +do_test() +{ + local ret=0 + local dir_name=/sys/devices/system/cpu/cpu0/core_ctl + local MIN_CPUS=${dir_name}/min_cpus + local MAX_CPUS=${dir_name}/max_cpus + + active_cpus=${dir_name}/active_cpus + enable=${dir_name}/enable + global_state=${dir_name}/global_state + need_cpus=${dir_name}/need_cpus + + tst_res TINFO "Start test cpulightweightisolate01." + ls /sys/devices/system/cpu/cpu0/core_ctl/ + + if [[ -e "${active_cpus}" && -e "$enable" && -e "${global_state}" \ + && -e "${MAX_CPUS}" && -e "${MIN_CPUS}" && -e "${need_cpus}" ]]; then + tst_res TINFO "/sys/devices/system/cpu/cpu0/core_ctl/ node normal." + else + tst_res TINFO "/sys/devices/system/cpu/cpu0/core_ctl/ node abnormal." + ret=$(( $ret + 1 )) + fi + + write_outliers + + cpu_total=$(cat /proc/cpuinfo | grep "processor"| wc -l) + cpu_total=$(( $cpu_total - 1 )) + for i in $(seq 0 $cpu_total); do + cpu_name=$(cat $global_state | grep "CPU${i}") + echo $cpu_name + if [ "$cpu_name"x = "CPU${i}"x ]; then + tst_res TINFO "cpu$i name correct." + else + tst_res TINFO "cpu$i name incorrect." + ret=$(( $ret + 1 )) + fi + line=$(( $i + 1)) + cpu_online_state=$(cat $global_state | grep 'Online:' | \ + sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_online_state -eq 1 ]; then + tst_res TINFO "cpu$i online." + else + tst_res TINFO "cpu$i offline." + ret=$(( $ret + 1 )) + fi + + cpu_isolated_state=$(cat $global_state | grep 'Isolated:' | \ + sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_isolated_state -eq 0 ]; then + tst_res TINFO "cpu$i isolated : 0." + else + tst_res TINFO "cpu$i isolated : 1." + ret=$(( $ret + 1 )) + fi + + cpu_is_busy_state=$(cat $global_state | grep 'Is busy:' | \ + sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_is_busy_state -eq 1 ]; then + tst_res TINFO "cpu$i is_busy : 1." + else + tst_res TINFO "cpu$i is_busy : 0." + ret=$(( $ret + 1 )) + fi + done + echo $ret + if [ $ret -eq 0 ];then + tst_res TPASS "cpulightweightisolate01 CPU lightweight isolation features." + else + tst_res TFAIL "cpulightweightisolate01 CPU lightweight isolation features!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh new file mode 100644 index 0000000000000000000000000000000000000000..42db7ad1b9b41437463dd68ec33e8db75480cbc5 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh @@ -0,0 +1,172 @@ +#!/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: cpuisolation02.sh +# +# Description: check CPU lightweight isolation basic function +# +# Authors: Dang Zhongkai - dangzhongkai@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + mkdir /data/local/pid_tmp +} + +do_test() +{ + ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + global_state=${dir_name}/global_state + proc_sd=/proc/sched_debug + cpu_log=/data/local/pid_tmp/cpu_log + + # create tmp file + pid_tmp=/data/local/pid_tmp + cpu_total=$(cat /proc/cpuinfo | grep "processor"| wc -l) + cpu_total=$(( $cpu_total - 1 )) + for i in $(seq 0 $cpu_total); do + touch $pid_tmp/cpu${i}_taskpid.txt + local cpu${i}_taskpid=$pid_tmp/cpu${i}_taskpid.txt + done + + tst_res TINFO "Start test cpuisolation02." + sh create_processs 40 > /dev/null 2>&1 & + #sh create_process 40 > $taskpid + sleep 20 + + rm -rf $cpu_log + cat $proc_sd > $cpu_log + res_cpu0=0 + res_cpu1=0 + res_cpu2=0 + res_cpu3=0 + for pid in $(cat taskpid.txt); do + echo $pid + #1 check sh distributed on each CPU + if [ $(sed -n '/^cpu#0/,/cpu#1$/p' $cpu_log | awk -F " " '{print $3}' \ + | awk '!arr[$0]++' | grep -w "$pid") ];then + res_cpu0=$(($res_cpu0 + 1)) + echo $pid >> $cpu0_taskpid + elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' $cpu_log | awk -F " " '{print $3}' \ + | awk '!arr[$0]++' | grep -w "$pid") ];then + res_cpu1=$(($res_cpu1 + 1)) + echo $pid >> $cpu1_taskpid + elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' $cpu_log | awk -F " " '{print $3}' \ + | awk '!arr[$0]++' | grep -w "$pid") ];then + res_cpu2=$(($res_cpu2 + 1)) + echo $pid >> $cpu2_taskpid + elif [ $(sed -n '/^cpu#3/,$p' $cpu_log | awk -F " " '{print $3}' \ + | awk '!arr[$0]++' | grep -w "$pid") ];then + res_cpu3=$(($res_cpu3 + 1)) + echo $pid >> $cpu3_taskpid + fi + done + echo "cpu0: $res_cpu0" + echo "cpu1: $res_cpu1" + echo "cpu2: $res_cpu2" + echo "cpu3: $res_cpu3" + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + sleep 5 + # both CPUs' isolated is set to 1 and NR isolated is set to 2 + count=0 + cpu_total=$(cat /proc/cpuinfo | grep "processor"| wc -l) + cpu_total=$(( $cpu_total -1 )) + res_3_pid=0 + res_012_pid=0 + for i in $(seq 0 $cpu_total); do + line=$(( $i + 1 )) + cpu_isolated=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + Nr_isolated=$(cat $global_state | grep 'Nr isolated CPUs:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + if [[ $cpu_isolated -eq 1 && $Nr_isolated -eq 2 ]]; then + tst_res TINFO "cpu$i Isolated: 1,and Nr isolated CPUs: 2." + count=$(( $count + 1 )) + check_migration + fi + done + + if [ $count -eq 2 ]; then + tst_res TINFO "two Isolated set to 1,and two Nr isolated CPUs set to 2." + else + tst_res TINFO "Isolated not set to 1 ,or Nr isolated CPUs not set to 2." + ret=$(( $ret + 1 )) + fi + echo "ret=$ret" + if [ $ret -eq 0 ]; then + tst_res TPASS "CPU lightweight isolation basic function test success." + else + tst_res TFAIL "CPU lightweight isolation basic function test failed!" + fi + #restore CPU state + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus +} + +check_migration() +{ + #when the isolation CPU is 0/1/2, check the migration + if [[ $i -eq 0 || $i -eq 1 || $i -eq 2 ]];then + cpu_taskpid=$pid_tmp/cpu${i}_taskpid.txt + echo "cputaskpid$i:::::::" + cat $cpu_taskpid + for pid1 in $(cat $cpu_taskpid); do + i_cpu=$(( $i + 1 )) + sed -n '/^cpu#$i/,/cpu#${i_cpu}$/p' $proc_sd \ + | awk -F " " '{print $3}' | grep -w "$pid1" + res_012_pid=$(($res_012_pid + $?)) + done + echo "cpu$i: $res_012_pid" + if [ $res_012_pid -eq $(eval echo '$'res_cpu"$i") ];then + tst_res TINFO "cpu$i process migrated." + else + tst_res TINFO "cpu$i process is not migrated." + ret=$(( $ret + 1 )) + fi + res_012_pid=0 + #when the isolation CPU is 3, check the migration + else + cat $cpu3_taskpid + for pid2 in $(cat $cpu3_taskpid); do + tail -n+$(sed -n -e "/cpu#3/=" $proc_sd) $proc_sd \ + | awk -F " " '{print $3}' | grep -w "$pid2" + res_3_pid=$(($res_3_pid + $?)) + done + if [ $res_3_pid -eq $res_cpu3 ];then + tst_res TINFO "cpu3 process migrated." + else + tst_res TINFO "cpu3 process is not migrated." + ret=$(( $ret + 1 )) + fi + fi +} + +do_clean() +{ + ps -ef | grep "create_processs" | grep -v "grep" | cut -c 9-18 \ + | xargs kill -9 + rm -rf /data/local/pid_tmp +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh new file mode 100644 index 0000000000000000000000000000000000000000..033d0d0ac5f8033a4298b8cf6d376a58955962c0 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh @@ -0,0 +1,244 @@ +#!/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: cpuisolation03.sh +# +# Description: check CPU lightweight isolation Power up and down function +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + mkdir /data/local/cpuisolation + touch /data/local/cpuisolation/isolated_cpu1.txt + touch /data/local/cpuisolation/active_cpu1.txt + touch /data/local/cpuisolation/isolated_cpu2.txt + touch /data/local/cpuisolation/active_cpu2.txt +} + +do_test() +{ + ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + global_state=${dir_name}/global_state + pid_tmp=/data/local/pid_tmp + proc_sd=/proc/sched_debug + isolated_cpu1=/data/local/cpuisolation/isolated_cpu1.txt + active_cpu1=/data/local/cpuisolation/active_cpu1.txt + isolated_cpu2=/data/local/cpuisolation/isolated_cpu2.txt + active_cpu2=/data/local/cpuisolation/active_cpu2.txt + tst_res TINFO "Start test cpuisolation03." + + sh create_processs 40 + sleep 5 + + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + check_isolation + check_movement + isolated_cpu_online + active_cpu_online + echo "ret=$ret" + if [ $ret -eq 0 ]; then + tst_res TPASS "CPU isolation Power up and down function success." + else + tst_res TFAIL "CPU isolation Power up and down function failed!" + fi + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + +} + +check_isolation() +{ + cpu_total=$(cat /proc/cpuinfo | grep "processor" | wc -l) + cpu_total=$(( ${cpu_total} - 1 )) + active_num1=0 + isolated_num1=0 + for i in $(seq 0 ${cpu_total}); do + line=$(( $i + 1)) + cpu_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_isolated_state -eq 0 ]; then + tst_res TINFO "cpu$i is active." + active_num=$(( $active_num + 1 )) + echo $i >> $active_cpu1 + else + tst_res TINFO "cpu$i is isolated." + isolated_num=$(( $isolated_num + 1 )) + echo $i >> $isolated_cpu1 + fi + done + if [[ $active_num -eq 2 ]] && [[ $isolated_num -eq 2 ]];then + tst_res TINFO "two cpus is active,and two cpus is isolated." + else + tst_res TINFO "the cpus state error." + ret=$(( $ret + 1 )) + fi + cpu_num=$(cat $isolated_cpu1 | sed -n "1p" ) + echo 0 > /sys/devices/system/cpu/cpu${cpu_num}/online + cpu_number=$(( $cpu_num + 1 )) + cpu_online_state=$(cat $global_state | grep 'Online:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ ${cpu_online_state} -eq 0 ];then + tst_res TINFO "cpu${cpu_num} is offline." + else + tst_res TINFO "cpu${cpu_num} is online." + ret=$(( $ret + 1 )) + fi + cpu_num_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ $cpu_num_isolated_state -eq 0 ]; then + tst_res TINFO "cpu${cpu_num} isolated state was cleaned." + else + tst_res TINFO "cpu${cpu_num} isolated state was not cleaned." + ret=$(( $ret + 1 )) + fi +} + +check_movement() +{ + res_cpu=0 + for pid in $(cat taskpid.txt); do + if [ $(sed -n '/^cpu#${cpu_num}/,/cpu#${cpu_number}$/p' $proc_sd \ + | awk -F " " '{print $3}' | grep -w "$pid") ];then + res_cpu=$(($res_cpu + 1)) + fi + done + + if [ $res_cpu -eq 0 ]; then + tst_res TINFO "cpu$cpu_num process migrated." + else + tst_res TINFO "cpu$cpu_num process is not migrated." + ret=$(( $ret + 1 )) + fi +} + +isolated_cpu_online() +{ + echo 1 > /sys/devices/system/cpu/cpu${cpu_num}/online + cpu_online_state=$(cat $global_state | grep 'Online:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ ${cpu_online_state} -eq 1 ];then + tst_res TINFO "cpu${cpu_num} is online." + else + tst_res TINFO "cpu${cpu_num} is offline." + ret=$(( $ret + 1 )) + fi + + cpu_num_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ $cpu_num_isolated_state -eq 0 ]; then + tst_res TINFO "cpu${cpu_num} is active." + else + tst_res TINFO "cpu${cpu_num} is isolated." + ret=$(( $ret + 1 )) + fi + + for i in $(cat $active_cpu1); do + line=$(( $i + 1)) + cpu_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_isolated_state -eq 1 ]; then + isolated_num2=$(( $isolated_num2 + 1 )) + fi + done + + if [ ${isolated_num2} -eq 1 ];then + tst_res TINFO "A active cpu is isolated." + else + tst_res TINFO "the cpus state error." + ret=$(( $ret + 1 )) + fi +} + +active_cpu_online() +{ + active_num2=0 + isolated_num2=0 + for i in $(seq 0 3); do + line=$(( $i + 1)) + cpu_isolated_state2=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_isolated_state2 -eq 0 ]; then + tst_res TINFO "cpu$i is active." + active_num2=$(( $active_num2 + 1 )) + echo $active_num2 + echo $i >> $active_cpu2 + fi + + if [ $cpu_isolated_state2 -eq 1 ]; then + tst_res TINFO "cpu$i is isolated." + isolated_num2=$(( $isolated_num2 + 1 )) + echo $isolated_num2 + echo $i >> $isolated_cpu2 + fi + done + if [[ $active_num2 -eq 2 ]] && [[ $isolated_num2 -eq 2 ]];then + tst_res TINFO "two cpus is active,and two cpus is isolated." + else + tst_res TINFO "the cpus state error." + ret=$(( $ret + 1 )) + fi + cpu_num=$(cat $active_cpu2 | sed -n "1p" ) + echo 0 > /sys/devices/system/cpu/cpu${cpu_num}/online + cpu_number=$(( $cpu_num + 1 )) + cpu_online_state=$(cat $global_state | grep 'Online:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ ${cpu_online_state} -eq 0 ];then + tst_res TINFO "cpu${cpu_num} is offline." + else + tst_res TINFO "cpu${cpu_num} is online." + ret=$(( $ret + 1 )) + fi + echo 1 > /sys/devices/system/cpu/cpu${cpu_num}/online + cpu_online_state=$(cat $global_state | grep 'Online:' \ + | sed -n "${cpu_number}p" | awk -F ':' '{print$2}') + if [ ${cpu_online_state} -eq 1 ];then + tst_res TINFO "cpu${cpu_num} is online." + else + tst_res TINFO "cpu${cpu_num} is offline." + ret=$(( $ret + 1 )) + fi + for i in $(cat $isolated_cpu2); do + line=$(( $i + 1 )) + cpu_num_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + isolated_num3=$(( $isolated_num3 + 1 )) + done + if [ $isolated_num3 -eq 2 ]; then + tst_res TINFO "isolated number doesnt change." + else + tst_res TINFO "isolated number had been changed." + fi +} + +do_clean() +{ + ps -ef | grep "create_processs" | grep -v "grep" | cut -c 9-18 \ + | xargs kill -9 + rm -rf /data/local/pid_tmp + rm -rf /data/local/cpuisolation +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh new file mode 100644 index 0000000000000000000000000000000000000000..f53c35ce4447b4b941ed0ed3e344b36f83a73001 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh @@ -0,0 +1,147 @@ +#!/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: cpuisolation04.sh +# +# Description: check CPU lightweight isolation stress test +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + mkdir /data/local/pid_tmp + mkdir /data/local/cpuisolation + PPID=$(ps -ef | grep "/cpuisolation04.sh" | grep -v grep | awk '{print $3}') +} + +do_test() +{ + ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + global_state=${dir_name}/global_state + tst_res TINFO "Start test cpuisolation04." + isolated_cpu1=/data/local/cpuisolation/isolated_cpu1.txt + active_cpu1=/data/local/cpuisolation/active_cpu1.txt + active_num1=0 + isolated_num1=0 + proc_sd=/proc/sched_debug + cpu_log=/data/local/pid_tmp/cpu_log + + sh create_processs 40 + sleep 5 + for i in $(seq 0 5); do + randmom=$((RANDOM %4 + 1)) + echo $randmom > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + do_isolate + if [ $randmom -ne 4 ]; then + do_num + fi + sleep 2 + done + tst_res TINFO "kill 40 task processes...." + ps -ef | grep "create_processs" | grep -v "grep" \ + | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 + echo "check stress test" + echo "ret=$ret" + if [ $ret -eq 0 ]; then + tst_res TPASS "CPU lightweight isolation stress test success." + else + tst_res TFAIL "CPU lightweight isolation stress test failed!" + fi + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus +} + +do_isolate() +{ + touch /data/local/cpuisolation/isolated_cpu1.txt + touch /data/local/cpuisolation/active_cpu1.txt + for i in $(seq 0 3); do + line=$(( $i + 1)) + cpu_isolated_state=$(cat $global_state | grep 'Isolated:' \ + | sed -n "${line}p" | awk -F ':' '{print$2}') + if [ $cpu_isolated_state -eq 0 ]; then + tst_res TINFO "cpu$i is active." + active_num=$(( $active_num + 1 )) + echo $i >> $active_cpu1 + else + tst_res TINFO "cpu$i is isolated." + isolated_num=$(( $isolated_num + 1 )) + echo $i >> $isolated_cpu1 + fi + done + + if [ $active_num -eq $randmom ];then + tst_res TINFO "isolation is right." + else + tst_res TINFO "the cpus state error." + ret=$(( $ret + 1 )) + fi + active_num=0 + isolated_num=0 +} + +do_num() +{ + res_cpu0=0 + res_cpu1=0 + res_cpu2=0 + res_cpu3=0 + rm -rf $cpu_log + cat $proc_sd > $cpu_log + for i in $(cat $isolated_cpu1); do + for pid in $(cat taskpid.txt); do + if [ $(sed -n '/^cpu#0/,/cpu#1$/p' $cpu_log \ + | awk -F " " '{print $3}' | grep -w "$pid") ];then + res_cpu0=$(($res_cpu0 + 1)) + elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' $cpu_log \ + | awk -F " " '{print $3}' | grep -w "$pid") ];then + res_cpu1=$(($res_cpu1 + 1)) + elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' $cpu_log \ + | awk -F " " '{print $3}' | grep -w "$pid") ];then + res_cpu2=$(($res_cpu2 + 1)) + elif [ $(sed -n '/^cpu#3/,$p' $cpu_log \ + | awk -F " " '{print $3}' | grep -w "$pid") ];then + res_cpu3=$(($res_cpu3 + 1)) + fi + done + if [ $(eval echo '$'res_cpu"$i") -eq 0 ]; then + tst_res TINFO "cpu${i} process migrated." + else + tst_res TINFO "cpu${i} process is not migrated." + ret=$(( $ret + 1 )) + fi + done + rm -rf $isolated_cpu1 + rm -rf $active_cpu1 +} + +do_clean() +{ + rm -rf /data/local/pid_tmp + rm -rf /data/local/cpuisolation + rm -rf $cpu_log +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh new file mode 100644 index 0000000000000000000000000000000000000000..520e36bc2498c1802e222b8773fa559894cde0d8 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh @@ -0,0 +1,84 @@ +#!/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: cpuisolation05.sh +# +# Description: check CPU lightweight isolation trace test +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + tracing_on=$(cat /sys/kernel/debug/tracing/tracing_on) + eval_need=$(cat /sys/kernel/debug/tracing/events/sched/core_ctl_eval_need/enable) + set_busy=$(cat /sys/kernel/debug/tracing/events/sched/core_ctl_set_busy/enable) + update_nr_need=$(cat /sys/kernel/debug/tracing/events/sched/core_ctl_update_nr_need/enable) +} + +do_test() +{ + tst_res TINFO "Start test cpuisolation05." + echo 1 > /sys/kernel/debug/tracing/tracing_on + echo 1 > /sys/kernel/debug/tracing/events/sched/core_ctl_eval_need/enable + echo 1 > /sys/kernel/debug/tracing/events/sched/core_ctl_set_busy/enable + echo 1 > /sys/kernel/debug/tracing/events/sched/core_ctl_update_nr_need/enable + tst_res TINFO "Start CPU trace catching test ..." + bytrace -t 10 -b 32000 --overwrite sched ace app disk ohos graphic sync \ + workq ability >/data/mynewtrace.ftrace & + sleep 5 + for i in $(seq 1 8);do + sh create_processs 40 + sleep 2 + ps -ef | grep "create_process" | grep -v "grep" | cut -c 9-18 | xargs kill -9 + done & + for i in $(seq 1 100);do + echo 1 /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo $((RANDOM %4 + 1)) /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + done& + sleep 40 + tst_res TINFO "Checking CPU trace ..." + #cat /data/mynewtrace.ftrace | grep "eval_need" && + cat /data/mynewtrace.ftrace | grep "set_busy" && + cat /data/mynewtrace.ftrace | grep "update_nr_need" + if [ $? -eq 0 ]; then + tst_res TPASS "trace info found." + else + tst_res TFAIL "trace info no found!" + fi +} + +do_clean() +{ + echo $tracing_on > /sys/kernel/debug/tracing/tracing_on + echo $eval_need > /sys/kernel/debug/tracing/events/sched/core_ctl_eval_need/enable + echo $set_busy > /sys/kernel/debug/tracing/events/sched/core_ctl_set_busy/enable + echo $update_nr_need > /sys/kernel/debug/tracing/events/sched/core_ctl_update_nr_need/enable + echo 4 /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo 1 /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + ps -ef | grep "create_processs" | grep -v "grep" | cut -c 9-18 | xargs kill -9 + rm -rf taskpid.txt +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation06.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation06.sh new file mode 100644 index 0000000000000000000000000000000000000000..c01bb18ba7491d95a61f668f9ee471593d6d2e80 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation06.sh @@ -0,0 +1,71 @@ +#!/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: cpuisolation06.sh +# +# Description: check active_cpus node status about CPU isolation +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ + +source tst_oh.sh + +do_setup() +{ + +} + +do_test() +{ + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + active_cpus=${dir_name}/active_cpus + local ret=0 + cat $active_cpus + if [ $? -eq 0 ]; then + tst_res TINFO "Node active_cpus can be read." + else + tst_res TINFO "Node active_cpus status error." + ret=$(( $ret + 1 )) + fi + + echo 1 > $active_cpus + if [ $? -ne 0 ]; then + tst_res TINFO "Node active_cpus can be write." + else + tst_res TINFO "Node active_cpus status error." + ret=$(( $ret + 1 )) + fi + echo ret=$ret + if [ $ret -eq 0 ]; then + tst_res TPASS "active_cpus node status is right." + else + tst_res TFAIL "active_cpus node status is wrong!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation07.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation07.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ee9ade1ea84e32aa8d930d8a938fdfe435b19a8 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation07.sh @@ -0,0 +1,97 @@ +#!/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: cpuisolation07.sh +# +# Description: check enable node status about CPU isolation +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ + +source tst_oh.sh + +do_setup() +{ + +} + +do_test() +{ + local ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + enable=${dir_name}/enable + pre_enable=$(cat $enable) + cat $enable + if [ $? -eq 0 ]; then + tst_res TINFO "Node enable can be read." + else + tst_res TINFO "Node enable status error." + ret=$(( $ret + 1 )) + fi + #open node enable + echo 1 > $enable + if [ $? -eq 0 ]; then + tst_res TINFO "Node enable can be opened." + else + tst_res TINFO "Node enable open error." + ret=$(( $ret + 1 )) + fi + #close node enable + echo 0 > $enable + if [ $? -eq 0 ]; then + tst_res TINFO "Node enable can be closed." + else + tst_res TINFO "Node enable close error." + ret=$(( $ret + 1 )) + fi + #echo 2 > enable + echo 2 > $enable + if [ $(cat $enable) -eq 1 ]; then + tst_res TINFO "Node enable writing 2 is abnormal." + else + tst_res TINFO "Node enable writing 2 is normal." + ret=$(( $ret + 1 )) + fi + #echo -1 > enable + echo -1 > $enable + if [ $(cat $enable) -eq 1 ]; then + tst_res TINFO "Node enable writing -1 is abnormal." + else + tst_res TINFO "Node enable writing -1 is normal." + ret=$(( $ret + 1 )) + fi + + echo ret=$ret + if [ $ret -eq 0 ]; then + tst_res TPASS "enable node status is right." + else + tst_res TFAIL "enable node status is wrong!" + fi +} + +do_clean() +{ + echo $pre_enable > $enable +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation08.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation08.sh new file mode 100644 index 0000000000000000000000000000000000000000..7a71fe0e842914922fbd379b9e0c25446594c316 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation08.sh @@ -0,0 +1,72 @@ +#!/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: cpuisolation08.sh +# +# Description: check global_state node status about CPU isolation +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ + + +source tst_oh.sh + +do_setup() +{ + +} + +do_test() +{ + local ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + global_state=${dir_name}/global_state + cat $global_state + if [ $? -eq 0 ]; then + tst_res TINFO "Node global_state can be read." + else + tst_res TINFO "Node global_state status error." + ret=$(( $ret + 1 )) + fi + + echo 1 > $global_state + if [ $? -ne 0 ]; then + tst_res TINFO "Node global_state can be write." + else + tst_res TINFO "Node global_state status error." + ret=$(( $ret + 1 )) + fi + echo ret=$ret + if [ $ret -eq 0 ]; then + tst_res TPASS "global_state node status is right." + else + tst_res TFAIL "global_state node status is wrong!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation09.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation09.sh new file mode 100644 index 0000000000000000000000000000000000000000..d78cc442ed5fc20bc7c4c894d11758e8d3db34cb --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation09.sh @@ -0,0 +1,72 @@ +#!/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: cpuisolation09.sh +# +# Description: check need_cpus node status about CPU isolation +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ + + +source tst_oh.sh + +do_setup() +{ + +} + +do_test() +{ + local ret=0 + dir_name=/sys/devices/system/cpu/cpu0/core_ctl + need_cpus=${dir_name}/need_cpus + cat $need_cpus + if [ $? -eq 0 ]; then + tst_res TINFO "Node need_cpus can be read." + else + tst_res TINFO "Node need_cpus status error." + ret=$(( $ret + 1 )) + fi + + echo 1 > $need_cpus + if [ $? -ne 0 ]; then + tst_res TINFO "Node need_cpus can be write." + else + tst_res TINFO "Node need_cpus status error." + ret=$(( $ret + 1 )) + fi + echo ret=$ret + if [ $ret -eq 0 ]; then + tst_res TPASS "need_cpus node status is right." + else + tst_res TFAIL "need_cpus node status is wrong!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/create_processs b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/create_processs new file mode 100644 index 0000000000000000000000000000000000000000..5e1a6752e5be5d69ac6e18f65f15e438423b7099 --- /dev/null +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/create_processs @@ -0,0 +1,13 @@ +#!/bin/sh +rm -rf taskpid.txt +num=$1 +for i in $(seq 1 $num); do + #echo "start $i proc ..." + while true; do + ((cnt++)) + sleep 0.1 + done & + local pgid=$! + #echo "pid ${i} $pgid generated" + echo $pgid >> taskpid.txt +done \ No newline at end of file diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh index 061a27e254aaafad60851f6eed48939e870d0b82..6cce5ec2fdc8bd8b9016158ff9fbc8ee63e32f20 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh @@ -52,16 +52,18 @@ do_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 + for i in $(seq 1 20);do + echo 0 > $sched_group_id + echo 2 > $sched_group_id + done + sleep 50 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." + tst_res TPASS "trace info found." else - tst_res TFAIL "trace info had error found!" + tst_res TFAIL "trace info no found!" fi } diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh index 055c5373893c41f3f13d41cdc51aa01492a5de71..cd9e94327747e990add69c4ab5e04a9a6e81cadd 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh @@ -30,7 +30,7 @@ source tst_oh.sh do_setup() { dmesg -c - PPID=`ps -ef | grep "sched_rtg06.sh" | grep -v grep | awk '{print $3}'` + PPID=$(ps -ef | grep "/sched_rtg06.sh" | grep -v grep | awk '{print $3}') } do_test() @@ -44,7 +44,7 @@ do_test() stability_test() { - start_task 41 + sh create_process 40 if [ $1 == 'randmom' ]; then tst_res TINFO "All 40 porcesss join random rtg from 2 to 20" random_rtg @@ -60,8 +60,10 @@ stability_test() all_in_one_rtg fi sleep 60 - tst_res TINFO "kill 40 processes...." + tst_res TINFO "kill 40 loop processes...." ps -ef | grep "sched_rtg06.sh" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 + tst_res TINFO "kill 40 task processes...." + ps -ef | grep "create_process" | 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 && @@ -83,19 +85,7 @@ stability_test() 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() { diff --git a/test/moduletest/runtest/conf/OH_RK3568_config b/test/moduletest/runtest/conf/OH_RK3568_config index 6243fca2b6da955b6776f21cb8f7292d7f2bd16d..140fea789d56f5973f535a2183d2094d955e871d 100644 --- a/test/moduletest/runtest/conf/OH_RK3568_config +++ b/test/moduletest/runtest/conf/OH_RK3568_config @@ -23,6 +23,7 @@ # History: Mar 15 2022 - init scripts # ################################################################################ +cpuisolation_t cpusetdecouple_cpuhotplug_t enhancedswap_t sched_rtg_t diff --git a/test/moduletest/runtest/tests/cpuisolation_t b/test/moduletest/runtest/tests/cpuisolation_t new file mode 100644 index 0000000000000000000000000000000000000000..dc82fa6aaf074b9dedcff93f4a5e09e865903f17 --- /dev/null +++ b/test/moduletest/runtest/tests/cpuisolation_t @@ -0,0 +1,34 @@ +################################################################################ +# +# 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: cpuisolation_t +# +# Description: cpuisolation testcase list +# +# Authors: liudanning - liudanning@h-partners.com +# +# History: Mar 24 2022 - init scripts +# +################################################################################ +cpuisolation01 cpuisolation01.sh +cpuisolation02 cpuisolation02.sh +cpuisolation03 cpuisolation03.sh +cpuisolation04 cpuisolation04.sh +cpuisolation05 cpuisolation05.sh +cpuisolation06 cpuisolation06.sh +cpuisolation07 cpuisolation07.sh +cpuisolation08 cpuisolation08.sh +cpuisolation09 cpuisolation09.sh