From 81c85c4b88aa83060c66444cd7720965086b8526 Mon Sep 17 00:00:00 2001 From: liudanning Date: Mon, 23 May 2022 21:34:50 +0800 Subject: [PATCH 1/3] kernel_linux_build: modify sched_rtg 03 04 && cpuisolation05 Signed-off-by: liudanning --- .../testcases/bin/cpuisolation05.sh | 5 ++-- .../sched_rtg_t/testcases/bin/sched_rtg03.sh | 18 ++++++------- .../sched_rtg_t/testcases/bin/sched_rtg04.sh | 25 ++++++++++--------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh index 4a73b1f..181e4ed 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation05.sh @@ -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 diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh index 1fef3be..6c53aeb 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh @@ -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 } 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 3d3b60f..cb76fa1 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 @@ -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 } -- Gitee From b4196892b5feddc5a6a709f8c739972ab47c04cd Mon Sep 17 00:00:00 2001 From: liudanning Date: Mon, 23 May 2022 21:46:51 +0800 Subject: [PATCH 2/3] kernel_linux_build: modify format to resolve some static scanning issues Signed-off-by: liudanning --- .../testcases/bin/cpuisolation01.sh | 18 +-- .../testcases/bin/cpuisolation02.sh | 63 ++++----- .../testcases/bin/cpuisolation03.sh | 120 +++++++++--------- .../testcases/bin/cpuisolation04.sh | 41 +++--- .../testcases/bin/enhancedswap04.sh | 10 +- .../testcases/bin/enhancedswap05.sh | 10 +- .../runtest/bin/enhancedswap_t_init.sh | 18 +-- .../runtest/bin/enhancedswap_t_uninit.sh | 2 +- .../sched_rtg_t/testcases/bin/sched_rtg01.sh | 2 +- .../sched_rtg_t/testcases/bin/sched_rtg06.sh | 8 +- test/moduletest/runtest/lib/tst_oh.sh | 16 +-- 11 files changed, 149 insertions(+), 159 deletions(-) diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh index 0f9de2d..9c1963b 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation01.sh @@ -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 } diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh index 45de723..a009e2b 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation02.sh @@ -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 diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh index 34db2c6..f327f9a 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh @@ -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" ) - - 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." + cpu_num1=$(cat active_cpu2.txt | sed -n "1p" ) + + 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 diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh index eb245ad..f234529 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation04.sh @@ -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 diff --git a/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap04.sh b/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap04.sh index 73854a4..b207bfa 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap04.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap04.sh @@ -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" diff --git a/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap05.sh b/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap05.sh index c21199e..76ed507 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap05.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t/testcases/bin/enhancedswap05.sh @@ -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" diff --git a/test/moduletest/runtest/bin/enhancedswap_t_init.sh b/test/moduletest/runtest/bin/enhancedswap_t_init.sh index 8899cf4..4dcadcf 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t_init.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t_init.sh @@ -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 } diff --git a/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh b/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh index fec54b6..e7a5e60 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh @@ -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 } diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh index 94f2772..267a0c8 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh @@ -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() 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 264febc..5066832 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 @@ -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" || diff --git a/test/moduletest/runtest/lib/tst_oh.sh b/test/moduletest/runtest/lib/tst_oh.sh index adc93e3..837bd66 100644 --- a/test/moduletest/runtest/lib/tst_oh.sh +++ b/test/moduletest/runtest/lib/tst_oh.sh @@ -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 -- Gitee From 2fc1d2626b7838794c9434eaae6a9d426b513531 Mon Sep 17 00:00:00 2001 From: Ma Feng Date: Tue, 24 May 2022 12:30:57 +0800 Subject: [PATCH 3/3] test: fix compile specification warnings for enhanced_f2fs_t Signed-off-by: Ma Feng --- .../testcases/bin/enhancedf2fs01.sh | 2 +- .../testcases/bin/enhancedf2fs07.sh | 4 +-- .../testcases/bin/enhancedf2fs08.sh | 16 ++++++------ .../testcases/bin/enhancedf2fs09.sh | 26 ++++++++++++------- .../testcases/bin/enhancedf2fs10.sh | 4 +-- .../testcases/bin/enhancedf2fs11.sh | 4 +-- .../testcases/bin/enhancedf2fs12.sh | 4 +-- .../testcases/bin/equilibrium_init.sh | 20 +++++++------- .../enhancedf2fs_t/testcases/bin/life_init.sh | 14 +++++----- .../testcases/bin/performance_init.sh | 14 +++++----- .../runtest/bin/enhancedf2fs_t_init.sh | 3 ++- .../runtest/bin/enhancedf2fs_t_uninit.sh | 3 ++- 12 files changed, 61 insertions(+), 53 deletions(-) diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs01.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs01.sh index 80256ce..164e7be 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs01.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs01.sh @@ -81,7 +81,7 @@ do_test() do_clean() { - rm -rf log01.txt + rm log01.txt losetup -d /dev/block/loop1 umount /mnt/f2fs_mount } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs07.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs07.sh index 481dfe8..aeb8c7c 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs07.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs07.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh index 9f60215..78b0636 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } @@ -71,10 +71,10 @@ do_test() confirm_value() { local result_out1=$(cat /sys/fs/f2fs/loop1/$1) - if [ $result_out1 == '5242880' ]; then - tst_res TPASS "$1 Value is 5242880 successfully." + if [ "$result_out1" == "5242880" ]; then + tst_res TPASS "$1 is 5242880 expected." else - tst_res TFAIL "$1 Value is 5242880 failed." + tst_res TFAIL "$1 is not 5242880 unexpected!" ret=$(( $ret + 1 )) fi } @@ -82,10 +82,10 @@ confirm_value() confirm_change_value() { local result_out2=$(cat /sys/fs/f2fs/loop1/$1) - if [ $result_out2 == '6000000' ]; then - tst_res TPASS "$1 Value is 6000000 successfully." + if [ "$result_out2" == "6000000" ]; then + tst_res TPASS "$1 is 6000000 expected." else - tst_res TFAIL "$1 Value is 6000000 failed." + tst_res TFAIL "$1 is not 6000000 unexpected!" ret=$(( $ret + 1 )) fi } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh index 273a1c3..86ecb53 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } @@ -46,21 +46,25 @@ do_test() init_value3=$(cat $_ssr_path/hc_hot_node_waterline) init_value4=$(cat $_ssr_path/hc_warm_node_waterline) - confirm_value hc_hot_data_waterline - confirm_value hc_warm_data_waterline - confirm_value hc_hot_node_waterline + confirm_value hc_hot_data_waterline && + confirm_value hc_warm_data_waterline && + confirm_value hc_hot_node_waterline && confirm_value hc_warm_node_waterline + [ $? -ne 0 ] && ret=$(( $ret + 1 )) + echo 85 > $_ssr_path/hc_hot_data_waterline echo 85 > $_ssr_path/hc_warm_data_waterline echo 85 > $_ssr_path/hc_hot_node_waterline echo 85 > $_ssr_path/hc_warm_node_waterline - confirm_change_value hc_hot_data_waterline - confirm_change_value hc_warm_data_waterline - confirm_change_value hc_hot_data_waterline + confirm_change_value hc_hot_data_waterline && + confirm_change_value hc_warm_data_waterline && + confirm_change_value hc_hot_data_waterline && confirm_change_value hc_warm_node_waterline + [ $? -ne 0 ] && ret=$(( $ret + 1 )) + if [ $ret -eq 0 ];then tst_res TPASS "Hierarchical SSR waterline configuration interface pass." else @@ -72,9 +76,10 @@ confirm_value() { if [ $(cat $_ssr_path/$1) == '80' ];then tst_res TPASS "$1 Value is 80 successfully." + return 0 else tst_res TFAIL "$1 Value not is 80 failed." - ret=$(( $ret + 1 )) + return 1 fi } @@ -82,9 +87,10 @@ confirm_change_value() { if [ $(cat $_ssr_path/$1) == '85' ];then tst_res TPASS "$1 Value is 85 successfully." + return 0 else tst_res TFAIL "$1 Value not is 85 failed." - ret=$(( $ret + 1 )) + return 1 fi } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs10.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs10.sh index 89c0378..f0cb3ad 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs10.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs10.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs11.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs11.sh index d6702d3..8675144 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs11.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs11.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs12.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs12.sh index f73a83d..cad1a13 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs12.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs12.sh @@ -29,8 +29,8 @@ source tst_oh.sh do_setup() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/equilibrium_init.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/equilibrium_init.sh index 33b0e9f..78881ce 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/equilibrium_init.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/equilibrium_init.sh @@ -29,8 +29,8 @@ source tst_oh.sh state_init() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } @@ -50,14 +50,14 @@ equilibrium_init() done local b=$(cat $segs_path | grep "valid blocks" | awk -F ' ' '{print$3}' | tr -cd "[0-9]") - local result_left=`echo | awk "{peint $a*512*0.2}"` - local result_might=`echo | awk "{print $a*512-$b}"` - local result_right=`echo | awk "{print $a*512*0.1}"` - local result1=`echo "$result_left $result_might" \ - | awk '{if ($result_left -gt $result_might) print 1; else print 0}'` - local result2=`echo "$result_might $result_right" \ - | awk '{if ($result_might -gt $result_right) print 1; else print 0}'` - if [ $result1 ] && [ $result2 ];then + local result_left=$(echo | awk "{peint $a*512*0.2}") + local result_might=$(echo | awk "{print $a*512-$b}") + local result_right=$(echo | awk "{print $a*512*0.1}") + local result1=$(echo "$result_left $result_might" \ + | awk '{if ($result_left -gt $result_might) print 1; else print 0}') + local result2=$(echo "$result_might $result_right" \ + | awk '{if ($result_might -gt $result_right) print 1; else print 0}') + if [ $result1 -gt 0 ] && [ $result2 -gt 0 ]; then tst_res TPASS "Inequality holds." else tst_res TFAIL "Inequality does not hold." diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/life_init.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/life_init.sh index 1cd2baf..63e48c9 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/life_init.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/life_init.sh @@ -29,8 +29,8 @@ source tst_oh.sh state_init() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } @@ -44,11 +44,11 @@ life_init() local a=$(cat $_segs_path | grep segs | awk -F ' ' '{print$3}') local b=$(cat $_segs_path| grep "valid blocks" | awk -F ' ' '{print$3}' | tr -cd "[0-9]") - local result_left=`echo | awk "{print $a*512-$b}"` - local result_right=`echo | awk "{print $a*512*0.2}"` - local result=`echo "$result_left $result_right" \ - | awk '{if ($result_left -gt $result_right) print 1; else print 0}'` - if [ $result ];then + local result_left=$(echo | awk "{print $a*512-$b}") + local result_right=$(echo | awk "{print $a*512*0.2}") + local result=$(echo "$result_left $result_right" \ + | awk '{if ($result_left -gt $result_right) print 1; else print 0}') + if [ $result -gt 0 ]; then tst_res TPASS "Inequality holds." else tst_res TFAIL "Inequality does not hold." diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/performance_init.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/performance_init.sh index fa6263d..52ff1f5 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/performance_init.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/performance_init.sh @@ -29,8 +29,8 @@ source tst_oh.sh state_init() { - mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs - losetup /dev/block/loop1 /data/image_f2fs + mkfs.f2fs -d1 -t1 -O quota $IMG_FILE + losetup /dev/block/loop1 $IMG_FILE mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ } @@ -50,11 +50,11 @@ performance_init() done echo "end Embedded file system $(date +%Y%m%d%H%M%S)...." >> log06.txt local b=$(cat $segs_path | grep "valid blocks" | awk -F ' ' '{print$3}' | tr -cd "[0-9]") - local result_left=`echo | awk "{print $a*512-$b}"` - local result_right=`echo | awk "{print $a*512*0.1}"` - local result=`echo "$result_left $result_right" \ - | awk '{if ($result_left -lt $result_right) print 1; else print 0}'` - if [ $result ];then + local result_left=$(echo | awk "{print $a*512-$b}") + local result_right=$(echo | awk "{print $a*512*0.1}") + local result=$(echo "$result_left $result_right" \ + | awk '{if ($result_left -lt $result_right) print 1; else print 0}') + if [ $result -gt 0 ];then tst_res TPASS "Inequality holds." else tst_res TFAIL "Inequality does not hold." diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t_init.sh b/test/moduletest/runtest/bin/enhancedf2fs_t_init.sh index 7db45b4..44f4e31 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t_init.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t_init.sh @@ -24,6 +24,7 @@ # History: April 8 2022 - init scripts # ################################################################################ +export IMG_FILE=/data/image_f2fs create_catalogue() { @@ -32,7 +33,7 @@ create_catalogue() enable_init() { - dd if=/dev/zero of=/data/image_f2fs bs=1M count=20480 + dd if=/dev/zero of=$IMG_FILE bs=1M count=20480 } echo "***************************ENHANCED INIT START***************************" diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t_uninit.sh b/test/moduletest/runtest/bin/enhancedf2fs_t_uninit.sh index f5fe902..9e50628 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t_uninit.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t_uninit.sh @@ -27,7 +27,8 @@ delete_catalogue() { - rm -rf /mnt/f2fs_mount/ + rm /mnt/f2fs_mount/* + rmdir /mnt/f2fs_mount } echo "***************************enhanced UNINIT START**************************" -- Gitee