mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-18 15:54:30 -04:00
!71 kernel_linux_build: Add cpuisolation_t test suite && modify sched_rtg test suite
Merge pull request !71 from liudanning/master
This commit is contained in:
@@ -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: cpuisolation01.sh
|
||||
#
|
||||
# Description: check rw nodes test about CPU lightweight isolation
|
||||
#
|
||||
# Authors: liudanning - liudanning@h-partners.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus
|
||||
echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus
|
||||
}
|
||||
|
||||
write_invalid()
|
||||
{
|
||||
local max_value=$1
|
||||
local min_value=$2
|
||||
local mode=$3
|
||||
|
||||
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)
|
||||
|
||||
echo $max_value > $max_cpus
|
||||
ret_max=$?
|
||||
echo $min_value > $min_cpus
|
||||
ret_min=$?
|
||||
min_cpus_value=$(cat $min_cpus)
|
||||
max_cpus_value=$(cat $max_cpus)
|
||||
|
||||
# mode 1 is to inject a single invalid value
|
||||
if [ $mode -eq 1 ]; then
|
||||
if [ $ret_min -eq 1 ]; then
|
||||
check_value
|
||||
elif [ $min_cpus_value -eq 4 ]; then
|
||||
check_value
|
||||
elif [ $ret_max -eq 1 ]; then
|
||||
check_value
|
||||
elif [[ $min_cpus_value -eq 0 ]] && [[ $max_cpus_value -eq 4 ]]; then
|
||||
check_value
|
||||
else
|
||||
tst_res TFAIL "writing single MAX VALUE $max_value or \
|
||||
MIN VALUE $min_value failed."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
# mode 2 is to inject both invalid values
|
||||
if [ $mode -eq 2 ]; then
|
||||
if [[ $ret_min -eq 1 ]] && [[ $ret_max -eq 1 ]]; then
|
||||
check_value
|
||||
elif [[ $ret_min -eq 1 ]] && [[ $max_cpus_value -eq 4 ]]; then
|
||||
check_value
|
||||
elif [[ $ret_max -eq 1 ]] && [[ $min_cpus_value -eq 4 ]]; then
|
||||
check_value
|
||||
elif [[ $ret_max -ne 1 ]] && [[ $max_cpus_value -eq 4 ]] && \
|
||||
[[ $min_cpus_value -eq 4 ]]; then
|
||||
check_value
|
||||
else
|
||||
tst_res TFAIL "writing both MAX VALUE $max_value and \
|
||||
MIN VALUE $min_value failed."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ${min_cpus_value_backup} > $min_cpus
|
||||
echo ${max_cpus_value_backup} > $max_cpus
|
||||
}
|
||||
|
||||
check_value()
|
||||
{
|
||||
if [ $min_cpus_value -ge 0 ] && [ $min_cpus_value -le $max_cpus_value ]\
|
||||
&& [ $max_cpus_value -le 4 ]; then
|
||||
tst_res TPASS "writing MAX VALUE $max_value and MIN VALUE $min_value , \
|
||||
value is normal."
|
||||
else
|
||||
tst_res TFAIL "writing MAX VALUE $max_value and MIN VALUE $min_value , \
|
||||
value is abnormal."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
}
|
||||
|
||||
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 to check rw nodes test about CPU lightweight isolation."
|
||||
if [[ -e "${active_cpus}" && -e "${enable}" && -e "${global_state}" \
|
||||
&& -e "${max_cpus}" && -e "${min_cpus}" && -e "${need_cpus}" ]]; then
|
||||
tst_res TPASS "/sys/devices/system/cpu/cpu0/core_ctl/ node normal."
|
||||
else
|
||||
tst_res TFAIL "/sys/devices/system/cpu/cpu0/core_ctl/ node abnormal."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
write_invalid 4 -3 1
|
||||
write_invalid 4 999 1
|
||||
write_invalid -3 0 1
|
||||
write_invalid 999 0 1
|
||||
write_invalid -3 -3 2
|
||||
write_invalid 999 -3 2
|
||||
write_invalid -3 999 2
|
||||
write_invalid 999 999 2
|
||||
|
||||
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 TPASS "cpu$i name correct."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu$i online."
|
||||
else
|
||||
tst_res TFAIL"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 TPASS "cpu$i isolated : 0."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu$i is_busy : 1."
|
||||
else
|
||||
tst_res TFAIL "cpu$i is_busy : 0."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ret -eq 0 ];then
|
||||
tst_res TPASS "check rw nodes test about CPU isolation successfully."
|
||||
else
|
||||
tst_res TFAIL "check rw nodes test about CPU isolation failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,168 @@
|
||||
#!/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: liudanning - liudanning@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
|
||||
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 to check CPU lightweight isolation basic function."
|
||||
sh create_process.sh 40
|
||||
sleep 20
|
||||
|
||||
rm -rf $cpu_log
|
||||
cat $proc_sd > $cpu_log
|
||||
cpu_num0=0
|
||||
cpu_num1=0
|
||||
cpu_num2=0
|
||||
cpu_num3=0
|
||||
# check sh distributed on each CPU
|
||||
for pid in $(cat taskpid.txt); do
|
||||
echo $pid
|
||||
if [ $(sed -n '/^cpu#0/,/cpu#1$/p' $cpu_log | awk -F " " '{print $3}' \
|
||||
| awk '!arr[$0]++' | grep -w "$pid") ];then
|
||||
cpu_num0=$(($cpu_num0 + 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
|
||||
cpu_num1=$(($cpu_num1 + 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
|
||||
cpu_num2=$(($cpu_num2 + 1))
|
||||
echo $pid >> $cpu2_taskpid
|
||||
elif [ $(sed -n '/^cpu#3/,$p' $cpu_log | awk -F " " '{print $3}' \
|
||||
| awk '!arr[$0]++' | grep -w "$pid") ];then
|
||||
cpu_num3=$(($cpu_num3 + 1))
|
||||
echo $pid >> $cpu3_taskpid
|
||||
fi
|
||||
done
|
||||
|
||||
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 TPASS "two Isolated set to 1,and two Nr isolated CPUs set to 2."
|
||||
else
|
||||
tst_res TFAIL "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
|
||||
|
||||
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 '$'cpu_num"$i") ];then
|
||||
tst_res TPASS "cpu$i process migrated."
|
||||
else
|
||||
tst_res TFAIL "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 $cpu_num3 ];then
|
||||
tst_res TPASS "cpu3 process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu3 process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
ps -ef | grep "create_process" | grep -v "grep" | cut -c 9-18 \
|
||||
| xargs kill -9
|
||||
rm -rf /data/local/pid_tmp
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,250 @@
|
||||
#!/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 to check CPU isolation Power up and down function."
|
||||
sh create_process.sh 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 TPASS "two cpus is active,and two cpus is isolated."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} is offline."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} isolated state was cleaned."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} isolated state was not cleaned."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
}
|
||||
|
||||
check_movement()
|
||||
{
|
||||
cpu_pid=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
|
||||
cpu_pid=$(($cpu_pid + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $cpu_pid -eq 0 ]; then
|
||||
tst_res TPASS "cpu$cpu_num process migrated."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} is online."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} is active."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "A active cpu is isolated."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "two cpus is active,and two cpus is isolated."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} is offline."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "cpu${cpu_num} is online."
|
||||
else
|
||||
tst_res TFAIL "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 TPASS "isolated number doesnt change."
|
||||
else
|
||||
tst_res TFAIL "isolated number had been changed."
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
ps -ef | grep "create_process" | 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
|
||||
@@ -0,0 +1,150 @@
|
||||
#!/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 to check CPU lightweight isolation stress test"
|
||||
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_process.sh 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_process" | 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 TPASS "isolation is right."
|
||||
else
|
||||
tst_res TFAIL "the cpus state error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
active_num=0
|
||||
isolated_num=0
|
||||
}
|
||||
|
||||
do_num()
|
||||
{
|
||||
cpu_pid0=0
|
||||
cpu_pid1=0
|
||||
cpu_pid2=0
|
||||
cpu_pid3=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
|
||||
cpu_pid0=$(($cpu_pid0 + 1))
|
||||
elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' $cpu_log \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid1=$(($cpu_pid1 + 1))
|
||||
elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' $cpu_log \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid2=$(($cpu_pid2 + 1))
|
||||
elif [ $(sed -n '/^cpu#3/,$p' $cpu_log \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid3=$(($cpu_pid3 + 1))
|
||||
fi
|
||||
done
|
||||
if [ $(eval echo '$'cpu_pid"$i") -eq 0 ]; then
|
||||
tst_res TPASS "cpu${i} process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu${i} process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf /data/local/cpuisolation/isolated_cpu1.txt
|
||||
rm -rf /data/local/cpuisolation/active_cpu1.txt
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
rm -rf /data/local/pid_tmp
|
||||
rm -rf /data/local/cpuisolation
|
||||
rm -rf /data/local/pid_tmp/cpu_log
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/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 to check CPU lightweight isolation trace test."
|
||||
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_process.sh 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 "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_process" | grep -v "grep" | cut -c 9-18 | xargs kill -9
|
||||
rm -rf taskpid.txt
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/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 TPASS "Node active_cpus can be read."
|
||||
else
|
||||
tst_res TFAIL "Node active_cpus status error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 1 > $active_cpus
|
||||
if [ $? -ne 0 ]; then
|
||||
tst_res TPASS "Node active_cpus can be write."
|
||||
else
|
||||
tst_res TFAIL "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
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/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 TPASS "Node enable can be read."
|
||||
else
|
||||
tst_res TFAIL "Node enable status error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 1 > $enable
|
||||
if [ $? -eq 0 ]; then
|
||||
tst_res TPASS "Node enable can be opened."
|
||||
else
|
||||
tst_res TFAIL "Node enable open error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 0 > $enable
|
||||
if [ $? -eq 0 ]; then
|
||||
tst_res TPASS "Node enable can be closed."
|
||||
else
|
||||
tst_res TFAIL "Node enable close error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 2 > $enable
|
||||
if [ $(cat $enable) -eq 1 ]; then
|
||||
tst_res TPASS "Node enable writing 2 is abnormal."
|
||||
else
|
||||
tst_res TFAIL "Node enable writing 2 is normal."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo -1 > $enable
|
||||
if [ $(cat $enable) -eq 1 ]; then
|
||||
tst_res TPASS "Node enable writing -1 is abnormal."
|
||||
else
|
||||
tst_res TFAIL "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
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/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 TPASS "Node global_state can be read."
|
||||
else
|
||||
tst_res TFAIL "Node global_state status error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 1 > $global_state
|
||||
if [ $? -ne 0 ]; then
|
||||
tst_res TPASS "Node global_state can be write."
|
||||
else
|
||||
tst_res TFAIL "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
|
||||
@@ -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 TPASS "Node need_cpus can be read."
|
||||
else
|
||||
tst_res TFAIL "Node need_cpus status error."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
echo 1 > $need_cpus
|
||||
if [ $? -ne 0 ]; then
|
||||
tst_res TPASS "Node need_cpus can be write."
|
||||
else
|
||||
tst_res TFAIL "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
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/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: create_processs.sh
|
||||
#
|
||||
# Description: create process
|
||||
#
|
||||
# Authors: liudanning - liudanning@h-partners.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
|
||||
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
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/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: create_process.sh
|
||||
#
|
||||
# Description: create process
|
||||
#
|
||||
# Authors: liudanning - liudanning@h-partners.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
|
||||
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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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.sh 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()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
# History: Mar 15 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
cpuisolation_t
|
||||
cpusetdecouple_cpuhotplug_t
|
||||
enhancedswap_t
|
||||
sched_rtg_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
|
||||
Reference in New Issue
Block a user