mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-18 07:44:32 -04:00
!79 kernel_linux_build: modify some sched_rtg and cpuisolation testcases && resolve some static scanning issues
Merge pull request !79 from liudanning/master
This commit is contained in:
@@ -64,7 +64,7 @@ write_invalid()
|
||||
else
|
||||
tst_res TFAIL "writing single MAX VALUE $max_value or \
|
||||
MIN VALUE $min_value failed."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -82,7 +82,7 @@ write_invalid()
|
||||
else
|
||||
tst_res TFAIL "writing both MAX VALUE $max_value and \
|
||||
MIN VALUE $min_value failed."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -99,7 +99,7 @@ check_value()
|
||||
else
|
||||
tst_res TFAIL "writing MAX VALUE $max_value and MIN VALUE $min_value , \
|
||||
value is abnormal."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ do_test()
|
||||
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 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
write_invalid 4 -3 1
|
||||
@@ -142,7 +142,7 @@ do_test()
|
||||
tst_res TPASS "cpu$i name correct."
|
||||
else
|
||||
tst_res TFAIL "cpu$i name incorrect."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
line=$(( $i + 1))
|
||||
@@ -152,7 +152,7 @@ do_test()
|
||||
tst_res TPASS "cpu$i online."
|
||||
else
|
||||
tst_res TFAIL"cpu$i offline."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
cpu_isolated_state=$(cat $global_state | grep 'Isolated:' | \
|
||||
@@ -161,7 +161,7 @@ do_test()
|
||||
tst_res TPASS "cpu$i isolated : 0."
|
||||
else
|
||||
tst_res TFAIL "cpu$i isolated : 1."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
cpu_is_busy_state=$(cat $global_state | grep 'Is busy:' | \
|
||||
@@ -170,14 +170,16 @@ do_test()
|
||||
tst_res TPASS "cpu$i is_busy : 1."
|
||||
else
|
||||
tst_res TFAIL "cpu$i is_busy : 0."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ret -eq 0 ];then
|
||||
tst_res TPASS "check rw nodes test about CPU isolation successfully."
|
||||
exit 0
|
||||
else
|
||||
tst_res TFAIL "check rw nodes test about CPU isolation failed!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
mkdir /data/local/pid_tmp
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
@@ -38,22 +38,20 @@ do_test()
|
||||
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
|
||||
touch 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
|
||||
echo "y" | rm cpu_log.txt
|
||||
sleep 1
|
||||
cat $proc_sd > cpu_log.txt
|
||||
cpu_num0=0
|
||||
cpu_num1=0
|
||||
cpu_num2=0
|
||||
@@ -61,22 +59,22 @@ do_test()
|
||||
# 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
|
||||
if [ $(sed -n '/^cpu#0/,/cpu#1$/p' cpu_log.txt | 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
|
||||
echo $pid >> cpu0_taskpid.txt
|
||||
elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' cpu_log.txt | 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
|
||||
echo $pid >> cpu1_taskpid.txt
|
||||
elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' cpu_log.txt | 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
|
||||
echo $pid >> cpu2_taskpid.txt
|
||||
elif [ $(sed -n '/^cpu#3/,$p' cpu_log.txt | awk -F " " '{print $3}' \
|
||||
| awk '!arr[$0]++' | grep -w "$pid") ]; then
|
||||
cpu_num3=$(($cpu_num3 + 1))
|
||||
echo $pid >> $cpu3_taskpid
|
||||
echo $pid >> cpu3_taskpid.txt
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -86,15 +84,13 @@ do_test()
|
||||
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:' \
|
||||
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
|
||||
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
|
||||
@@ -105,7 +101,7 @@ do_test()
|
||||
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 ))
|
||||
((ret++))
|
||||
fi
|
||||
echo "ret=$ret"
|
||||
if [ $ret -eq 0 ]; then
|
||||
@@ -119,11 +115,13 @@ do_test()
|
||||
|
||||
check_migration()
|
||||
{
|
||||
res_3_pid=0
|
||||
res_012_pid=0
|
||||
# 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
|
||||
cpu_taskpid=cpu${i}_taskpid.txt
|
||||
echo "cputaskpid$i:::::::"
|
||||
cat $cpu_taskpid
|
||||
cat cpu${i}_taskpid.txt
|
||||
for pid1 in $(cat $cpu_taskpid); do
|
||||
i_cpu=$(( $i + 1 ))
|
||||
sed -n '/^cpu#$i/,/cpu#${i_cpu}$/p' $proc_sd \
|
||||
@@ -135,13 +133,13 @@ check_migration()
|
||||
tst_res TPASS "cpu$i process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu$i process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
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
|
||||
cat cpu3_taskpid.txt
|
||||
for pid2 in $(cat cpu3_taskpid.txt); 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 + $?))
|
||||
@@ -150,7 +148,7 @@ check_migration()
|
||||
tst_res TPASS "cpu3 process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu3 process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -159,7 +157,10 @@ do_clean()
|
||||
{
|
||||
ps -ef | grep "create_process" | grep -v "grep" | cut -c 9-18 \
|
||||
| xargs kill -9
|
||||
rm -rf /data/local/pid_tmp
|
||||
echo "y" | rm cpu0_taskpid.txt
|
||||
echo "y" | rm cpu1_taskpid.txt
|
||||
echo "y" | rm cpu2_taskpid.txt
|
||||
echo "y" | rm cpu3_taskpid.txt
|
||||
}
|
||||
|
||||
do_setup
|
||||
|
||||
@@ -29,24 +29,18 @@ 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
|
||||
touch isolated_cpu1.txt
|
||||
touch active_cpu1.txt
|
||||
touch isolated_cpu2.txt
|
||||
touch 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
|
||||
global_state=$dir_name/global_state
|
||||
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
|
||||
@@ -71,8 +65,8 @@ check_isolation()
|
||||
{
|
||||
cpu_total=$(cat /proc/cpuinfo | grep "processor" | wc -l)
|
||||
cpu_total=$(( ${cpu_total} - 1 ))
|
||||
active_num1=0
|
||||
isolated_num1=0
|
||||
active_num=0
|
||||
isolated_num=0
|
||||
for i in $(seq 0 ${cpu_total}); do
|
||||
line=$(( $i + 1))
|
||||
cpu_isolated_state=$(cat $global_state | grep 'Isolated:' \
|
||||
@@ -80,21 +74,21 @@ check_isolation()
|
||||
if [ $cpu_isolated_state -eq 0 ]; then
|
||||
tst_res TINFO "cpu$i is active."
|
||||
active_num=$(( $active_num + 1 ))
|
||||
echo $i >> $active_cpu1
|
||||
echo $i >> active_cpu1.txt
|
||||
else
|
||||
tst_res TINFO "cpu$i is isolated."
|
||||
isolated_num=$(( $isolated_num + 1 ))
|
||||
echo $i >> $isolated_cpu1
|
||||
echo $i >> isolated_cpu1.txt
|
||||
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 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
cpu_num=$(cat $isolated_cpu1 | sed -n "1p" )
|
||||
cpu_num=$(cat isolated_cpu1.txt | 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:' \
|
||||
@@ -103,7 +97,7 @@ check_isolation()
|
||||
tst_res TPASS "cpu${cpu_num} is offline."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} is online."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
cpu_num_isolated_state=$(cat $global_state | grep 'Isolated:' \
|
||||
@@ -112,7 +106,7 @@ check_isolation()
|
||||
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 ))
|
||||
((ret++))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -130,45 +124,45 @@ check_movement()
|
||||
tst_res TPASS "cpu$cpu_num process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu$cpu_num process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
}
|
||||
|
||||
isolated_cpu_online()
|
||||
{
|
||||
echo 1 > /sys/devices/system/cpu/cpu${cpu_num}/online
|
||||
cpu_online_state=$(cat $global_state | grep 'Online:' \
|
||||
cpu_online_state1=$(cat $global_state | grep 'Online:' \
|
||||
| sed -n "${cpu_number}p" | awk -F ':' '{print$2}')
|
||||
if [ ${cpu_online_state} -eq 1 ];then
|
||||
if [ ${cpu_online_state1} -eq 1 ];then
|
||||
tst_res TPASS "cpu${cpu_num} is online."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} is offline."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
|
||||
cpu_num_isolated_state=$(cat $global_state | grep 'Isolated:' \
|
||||
cpu_num_isolated_state1=$(cat $global_state | grep 'Isolated:' \
|
||||
| sed -n "${cpu_number}p" | awk -F ':' '{print$2}')
|
||||
if [ $cpu_num_isolated_state -eq 0 ]; then
|
||||
if [ $cpu_num_isolated_state1 -eq 0 ]; then
|
||||
tst_res TPASS "cpu${cpu_num} is active."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} is isolated."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
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 ))
|
||||
for i in $(cat active_cpu1.txt); do
|
||||
line1=$(( $i + 1))
|
||||
cpu_isolated_state1=$(cat $global_state | grep 'Isolated:' \
|
||||
| sed -n "${line1}p" | awk -F ':' '{print$2}')
|
||||
if [ $cpu_isolated_state1 -eq 1 ]; then
|
||||
isolated_num1=$(( $isolated_num1 + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${isolated_num2} -eq 1 ];then
|
||||
if [ ${isolated_num1} -eq 1 ];then
|
||||
tst_res TPASS "A active cpu is isolated."
|
||||
else
|
||||
tst_res TFAIL "the cpus state error."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -177,56 +171,56 @@ active_cpu_online()
|
||||
active_num2=0
|
||||
isolated_num2=0
|
||||
for i in $(seq 0 3); do
|
||||
line=$(( $i + 1))
|
||||
line2=$(( $i + 1))
|
||||
cpu_isolated_state2=$(cat $global_state | grep 'Isolated:' \
|
||||
| sed -n "${line}p" | awk -F ':' '{print$2}')
|
||||
| sed -n "${line2}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
|
||||
echo $i >> active_cpu2.txt
|
||||
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
|
||||
echo $i >> isolated_cpu2.txt
|
||||
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 ))
|
||||
((ret++))
|
||||
fi
|
||||
cpu_num=$(cat $active_cpu2 | sed -n "1p" )
|
||||
cpu_num1=$(cat active_cpu2.txt | 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."
|
||||
echo 0 > /sys/devices/system/cpu/cpu${cpu_num1}/online
|
||||
cpu_number1=$(( $cpu_num1 + 1 ))
|
||||
cpu_online_state2=$(cat $global_state | grep 'Online:' \
|
||||
| sed -n "${cpu_number1}p" | awk -F ':' '{print$2}')
|
||||
if [ ${cpu_online_state2} -eq 0 ];then
|
||||
tst_res TPASS "cpu${cpu_num1} is offline."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} is online."
|
||||
ret=$(( $ret + 1 ))
|
||||
tst_res TFAIL "cpu${cpu_num1} is online."
|
||||
((ret++))
|
||||
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."
|
||||
echo 1 > /sys/devices/system/cpu/cpu${cpu_num1}/online
|
||||
cpu_online_state3=$(cat $global_state | grep 'Online:' \
|
||||
| sed -n "${cpu_number1}p" | awk -F ':' '{print$2}')
|
||||
if [ ${cpu_online_state3} -eq 1 ];then
|
||||
tst_res TPASS "cpu${cpu_num1} is online."
|
||||
else
|
||||
tst_res TFAIL "cpu${cpu_num} is offline."
|
||||
ret=$(( $ret + 1 ))
|
||||
tst_res TFAIL "cpu${cpu_num1} is offline."
|
||||
((ret++))
|
||||
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}')
|
||||
for i in $(cat isolated_cpu2.txt); do
|
||||
line3=$(( $i + 1 ))
|
||||
cpu_num_isolated_state2=$(cat $global_state | grep 'Isolated:' \
|
||||
| sed -n "${line3}p" | awk -F ':' '{print$2}')
|
||||
isolated_num3=$(( $isolated_num3 + 1 ))
|
||||
done
|
||||
if [ $isolated_num3 -eq 2 ]; then
|
||||
@@ -240,8 +234,10 @@ 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
|
||||
echo "y" | rm isolated_cpu1.txt
|
||||
echo "y" | rm active_cpu1.txt
|
||||
echo "y" | rm isolated_cpu2.txt
|
||||
echo "y" | rm active_cpu2.txt
|
||||
}
|
||||
|
||||
do_setup
|
||||
|
||||
@@ -29,8 +29,6 @@ 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}')
|
||||
}
|
||||
|
||||
@@ -40,12 +38,9 @@ do_test()
|
||||
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
|
||||
@@ -74,8 +69,8 @@ do_test()
|
||||
|
||||
do_isolate()
|
||||
{
|
||||
touch /data/local/cpuisolation/isolated_cpu1.txt
|
||||
touch /data/local/cpuisolation/active_cpu1.txt
|
||||
touch isolated_cpu1.txt
|
||||
touch active_cpu1.txt
|
||||
for i in $(seq 0 3); do
|
||||
line=$(( $i + 1))
|
||||
cpu_isolated_state=$(cat $global_state | grep 'Isolated:' \
|
||||
@@ -83,11 +78,11 @@ do_isolate()
|
||||
if [ $cpu_isolated_state -eq 0 ]; then
|
||||
tst_res TINFO "cpu$i is active."
|
||||
active_num=$(( $active_num + 1 ))
|
||||
echo $i >> $active_cpu1
|
||||
echo $i >> active_cpu1.txt
|
||||
else
|
||||
tst_res TINFO "cpu$i is isolated."
|
||||
isolated_num=$(( $isolated_num + 1 ))
|
||||
echo $i >> $isolated_cpu1
|
||||
echo $i >> isolated_cpu1.txt
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -95,7 +90,7 @@ do_isolate()
|
||||
tst_res TPASS "isolation is right."
|
||||
else
|
||||
tst_res TFAIL "the cpus state error."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
active_num=0
|
||||
isolated_num=0
|
||||
@@ -107,20 +102,20 @@ do_num()
|
||||
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
|
||||
echo "y" | rm cpu_log.txt
|
||||
cat $proc_sd > cpu_log.txt
|
||||
for i in $(cat isolated_cpu1.txt); do
|
||||
for pid in $(cat taskpid.txt); do
|
||||
if [ $(sed -n '/^cpu#0/,/cpu#1$/p' $cpu_log \
|
||||
if [ $(sed -n '/^cpu#0/,/cpu#1$/p' cpu_log.txt \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid0=$(($cpu_pid0 + 1))
|
||||
elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' $cpu_log \
|
||||
elif [ $(sed -n '/^cpu#1/,/cpu#2$/p' cpu_log.txt \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid1=$(($cpu_pid1 + 1))
|
||||
elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' $cpu_log \
|
||||
elif [ $(sed -n '/^cpu#2/,/cpu#3$/p' cpu_log.txt \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid2=$(($cpu_pid2 + 1))
|
||||
elif [ $(sed -n '/^cpu#3/,$p' $cpu_log \
|
||||
elif [ $(sed -n '/^cpu#3/,$p' cpu_log.txt \
|
||||
| awk -F " " '{print $3}' | grep -w "$pid") ];then
|
||||
cpu_pid3=$(($cpu_pid3 + 1))
|
||||
fi
|
||||
@@ -129,19 +124,19 @@ do_num()
|
||||
tst_res TPASS "cpu${i} process migrated."
|
||||
else
|
||||
tst_res TFAIL "cpu${i} process is not migrated."
|
||||
ret=$(( $ret + 1 ))
|
||||
((ret++))
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf /data/local/cpuisolation/isolated_cpu1.txt
|
||||
rm -rf /data/local/cpuisolation/active_cpu1.txt
|
||||
echo "y" | rm isolated_cpu1.txt
|
||||
echo "y" | rm active_cpu1.txt
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
rm -rf /data/local/pid_tmp
|
||||
rm -rf /data/local/cpuisolation
|
||||
rm -rf /data/local/pid_tmp/cpu_log
|
||||
echo "y" | rm cpu_log.txt
|
||||
echo "y" | rm isolated_cpu1.txt
|
||||
echo "y" | rm active_cpu1.txt
|
||||
}
|
||||
|
||||
do_setup
|
||||
|
||||
@@ -59,10 +59,11 @@ do_test()
|
||||
sleep 40
|
||||
|
||||
tst_res TINFO "Checking CPU trace ..."
|
||||
cat /data/mynewtrace.ftrace | grep "set_busy" &&
|
||||
cat /data/mynewtrace.ftrace | grep "update_nr_need"
|
||||
cat cputrace.ftrace | grep "set_busy" &&
|
||||
cat cputrace.ftrace | grep "update_nr_need"
|
||||
if [ $? -eq 0 ]; then
|
||||
tst_res TPASS "trace info found."
|
||||
rm -rf cputrace.ftrace
|
||||
else
|
||||
tst_res TFAIL "trace info no found!"
|
||||
fi
|
||||
|
||||
@@ -42,11 +42,11 @@ do_test()
|
||||
tst_res TINFO "Start anon to zram test"
|
||||
|
||||
# get init zram values
|
||||
zram_100_b=`cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_b=`cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_100_b=$(cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}')
|
||||
zram_b=$(cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}')
|
||||
|
||||
# get buffer_size
|
||||
buffer_size=`cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}'`
|
||||
buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}')
|
||||
|
||||
# set avail_buffers > buffer_size to swap out to zram
|
||||
echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers
|
||||
@@ -54,8 +54,8 @@ do_test()
|
||||
sleep 3
|
||||
|
||||
# get new zram values after swap-out to zram
|
||||
zram_100_a=`cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_a=`cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_100_a=$(cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}')
|
||||
zram_a=$(cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}')
|
||||
|
||||
tst_res TINFO "root zram: $zram_b --> $zram_a"
|
||||
tst_res TINFO "100 zram: $zram_100_b --> $zram_100_a"
|
||||
|
||||
@@ -41,14 +41,14 @@ do_test()
|
||||
|
||||
tst_res TINFO "Start zram to Eswap test"
|
||||
# get init Eswap values
|
||||
eswap_100_b=`cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_b=`cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_100_b=$(cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}')
|
||||
eswap_b=$(cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}')
|
||||
|
||||
# turn on enhanced swap out
|
||||
echo 1 > /dev/memcg/memory.zram_wm_ratio
|
||||
|
||||
# get buffer_size
|
||||
buffer_size=`cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}'`
|
||||
buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}')
|
||||
|
||||
# set avail_buffers > buffer_size to swap out to Eswap
|
||||
echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers
|
||||
@@ -56,8 +56,8 @@ do_test()
|
||||
sleep 3
|
||||
|
||||
# get new Eswap values after swap-out to Eswap
|
||||
eswap_100_a=`cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_a=`cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_100_a=$(cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}')
|
||||
eswap_a=$(cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}')
|
||||
|
||||
tst_res TINFO "root Eswap: $eswap_b --> $eswap_a"
|
||||
tst_res TINFO "100 Eswap: $eswap_100_b --> $eswap_100_a"
|
||||
|
||||
@@ -27,31 +27,27 @@
|
||||
|
||||
pre_condition()
|
||||
{
|
||||
TCBIN=$LTPROOT/testcases/bin
|
||||
export PATH=$TCBIN:$PATH
|
||||
export TMPDIR=/data/local/tmp
|
||||
export LD_LIBRARY_PATH=$LTPROOT/lib
|
||||
export BUSYBOX=/system/bin/busybox-armv7l
|
||||
|
||||
}
|
||||
|
||||
hp_init()
|
||||
{
|
||||
dd if=/dev/random of=/data/hpdisk bs=4096 count=131072
|
||||
losetup /dev/block/loop6 /data/hpdisk
|
||||
hyperhold_device=`cat /proc/sys/kernel/hyperhold/device`
|
||||
dd if=/dev/random of=hpdisk bs=4096 count=131072
|
||||
losetup /dev/block/loop6 hpdisk
|
||||
hyperhold_device=$(cat /proc/sys/kernel/hyperhold/device)
|
||||
echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device
|
||||
}
|
||||
|
||||
hp_enable()
|
||||
{
|
||||
hyperhold_enable=`cat /proc/sys/kernel/hyperhold/enable`
|
||||
hyperhold_enable=$(cat /proc/sys/kernel/hyperhold/enable)
|
||||
echo enable > /proc/sys/kernel/hyperhold/enable
|
||||
}
|
||||
|
||||
zram_init()
|
||||
{
|
||||
zram0_group=`cat /sys/block/zram0/group`
|
||||
zram0_disksize=`cat /sys/block/zram0/disksize`
|
||||
zram0_group=$(cat /sys/block/zram0/group)
|
||||
zram0_disksize=$(cat /sys/block/zram0/disksize)
|
||||
echo readwrite > /sys/block/zram0/group
|
||||
echo 512M > /sys/block/zram0/disksize
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ uninit_platform()
|
||||
echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable
|
||||
echo ${zram0_group} > /sys/block/zram0/group
|
||||
echo ${zram0_disksize} > /sys/block/zram0/disksize
|
||||
rm -rf /data/hpdisk
|
||||
rm -rf hpdisk
|
||||
swapoff /dev/block/zram0
|
||||
echo 1 > /sys/block/zram0/reset
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ 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}'`
|
||||
PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}')
|
||||
}
|
||||
|
||||
do_test()
|
||||
|
||||
@@ -31,7 +31,7 @@ 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}'`
|
||||
PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}')
|
||||
}
|
||||
|
||||
do_test()
|
||||
@@ -75,21 +75,21 @@ set_check_rtgid_debug()
|
||||
local _rtg_pid=$(cat /proc/sched_rtg_debug | grep ohos.samples.ec | grep -v grep | awk '{print $3}')
|
||||
if [ $_set_rtgid -ne 0 ]; then
|
||||
if [ $_rtg_id -eq $_expect_rtgid ]; then
|
||||
tst_res TPASS "RTG_ID $_rtg_id equal to expected value."
|
||||
tst_res TPASS "RTG_ID $_rtg_id exists in $_sched_rtg_debug expected."
|
||||
if [ $_rtg_pid -eq $PID ]; then
|
||||
tst_res TPASS "process $_pid rtgid set to $rtg_pid expected."
|
||||
tst_res TPASS "PID $_pid exists in $rtg_pid expected."
|
||||
else
|
||||
tst_res TFAIL "$rtg_pid not equal to expected value!"
|
||||
tst_res TFAIL "PID $_pid not exists in $rtg_pid unexpected!"
|
||||
fi
|
||||
else
|
||||
tst_res TFAIL "RTG_ID $_rtg_id not equal to expected value!"
|
||||
tst_res TFAIL "RTG_ID $_rtg_id not exists in $_sched_rtg_debug unexpected!"
|
||||
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."
|
||||
cat $_sched_rtg_debug | grep ohos.samples.ec
|
||||
if [ $? -ne 0 ]; then
|
||||
tst_res TPASS "process $_pid rtgid set to 0 expected."
|
||||
else
|
||||
tst_res TFAIL "process $_pid rtgid set to $_set_rtgid unexpected!"
|
||||
tst_res TFAIL "process $_pid rtgid set to 0 unexpected!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
Frame_value=$(cat /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable)
|
||||
Task_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable)
|
||||
Cpu_value=$(cat /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable)
|
||||
Normalized_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable)
|
||||
frame_value=$(cat /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable)
|
||||
task_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable)
|
||||
cpu_value=$(cat /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable)
|
||||
normalized_value=$(cat /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable)
|
||||
|
||||
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
|
||||
sleep 1
|
||||
PID=`ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}'`
|
||||
PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}')
|
||||
echo 1 > /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable
|
||||
echo 1 > /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable
|
||||
echo 1 > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable
|
||||
@@ -57,11 +57,12 @@ do_test()
|
||||
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"
|
||||
cat rtgtrace.ftrace | grep "sched_rtg_task_each" &&
|
||||
cat rtgtrace.ftrace | grep "find_rtg_cpu" &&
|
||||
cat rtgtrace.ftrace | grep "sched_rtg_valid_normalized_util"
|
||||
if [ $? -eq 0 ]; then
|
||||
tst_res TPASS "trace info found."
|
||||
rm -rf rtgtrace.ftrace
|
||||
else
|
||||
tst_res TFAIL "trace info no found!"
|
||||
fi
|
||||
@@ -69,10 +70,10 @@ do_test()
|
||||
|
||||
do_clean()
|
||||
{
|
||||
echo $Frame_value > /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable &&
|
||||
echo $Task_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable &&
|
||||
echo $Cpu_value > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable &&
|
||||
echo $Normalized_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable
|
||||
echo $frame_value > /sys/kernel/debug/tracing/events/rtg/rtg_frame_sched/enable &&
|
||||
echo $task_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_task_each/enable &&
|
||||
echo $cpu_value > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable &&
|
||||
echo $normalized_value > /sys/kernel/debug/tracing/events/rtg/sched_rtg_valid_normalized_util/enable
|
||||
aa force-stop ohos.samples.ecg
|
||||
}
|
||||
|
||||
|
||||
@@ -45,17 +45,17 @@ do_test()
|
||||
stability_test()
|
||||
{
|
||||
sh create_process.sh 40
|
||||
if [ $1 == 'randmom' ]; then
|
||||
if [ "$1" == "randmom" ]; then
|
||||
tst_res TINFO "All 40 porcesss join random rtg from 2 to 20"
|
||||
random_rtg
|
||||
fi
|
||||
|
||||
if [ $1 == 'ordered' ]; then
|
||||
if [ "$1" == "ordered" ]; then
|
||||
tst_res TINFO "All 40 processes join rtg from 2 to 20 one by one"
|
||||
ordered_rtg
|
||||
fi
|
||||
|
||||
if [ $1 == 'all' ]; then
|
||||
if [ "$1" == "all" ]; then
|
||||
tst_res TINFO "All 40 processes join rtg 2"
|
||||
all_in_one_rtg
|
||||
fi
|
||||
@@ -68,7 +68,7 @@ stability_test()
|
||||
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}'`
|
||||
PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}')
|
||||
if [ $? -eq 0 ]; then
|
||||
dmesg | grep "BUG" ||
|
||||
dmesg | grep "panic" ||
|
||||
|
||||
@@ -127,7 +127,7 @@ tst_res()
|
||||
TST_COUNT=$(($TST_COUNT+1))
|
||||
|
||||
_tst_inc_ret "$res"
|
||||
printf "$TST_ID $TST_COUNT `date` "
|
||||
printf "$TST_ID $TST_COUNT $(date) "
|
||||
tst_print_colored $res "$res: "
|
||||
echo "$@"
|
||||
}
|
||||
@@ -163,21 +163,21 @@ tst_judged()
|
||||
|
||||
tst_judged_fail()
|
||||
{
|
||||
actual_res=$1
|
||||
actual_res1=$1
|
||||
shift
|
||||
expect_res=$1
|
||||
expect_res1=$1
|
||||
shift
|
||||
comment="$@"
|
||||
if [ "$actual_res" != "$expect_res" ]; then
|
||||
tst_res TPASS "$comment test pass, expect $expect_res return $actual_res"
|
||||
comment_fail="$@"
|
||||
if [ "$actual_res1" != "$expect_res1" ]; then
|
||||
tst_res TPASS "$comment_fail test pass, expect $expect_res1 return $actual_res1"
|
||||
else
|
||||
tst_res TFAIL "$comment test fail, expect $expect_res return $actual_res"
|
||||
tst_res TFAIL "$comment_fail test fail, expect $expect_res1 return $actual_res1"
|
||||
fi
|
||||
}
|
||||
|
||||
get_product()
|
||||
{
|
||||
echo `uname -a | awk '{printf $NF}'`
|
||||
echo $(uname -a | awk '{printf $NF}')
|
||||
}
|
||||
|
||||
if [ -z "$TST_TD" ]; then
|
||||
|
||||
Reference in New Issue
Block a user